Commit ae118994 by 张成

up[date

parent 4c9ddc05
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
</style>
<script>
export default {
onLaunch: function() {
// uni.showLoading({
// title: '加载中...',
// mask:true
// });
// uni.clearStorageSync();
},
onShow: function() {
},
onHide: function() {
},
methods:{
unilogin(){
}
export default {
onLaunch: function () {
// uni.showLoading({
// title: '加载中...',
// mask:true
// });
// uni.clearStorageSync();
},
onShow: function () {
},
onHide: function () {
},
methods: {
unilogin() {
}
}
}
</script>
<style>
/*每个页面公共css */
/*每个页面公共css */
.pages {
background: #F2F2F2;
min-height: calc(100vh - 100rpx);
}
* {
box-sizing: border-box;
}
image {
width: 100%;
height: auto;
}
</style>
<template>
<view>
<u-popup :show="showShopCar && goods.length" mode="bottom" :round="10" :overlay="true" :closeOnClickOverlay="true" @close="closeT">
<view class="shop-car">
<view class="header">
<text class="left">购物袋</text>
<text class="right" @click="clearCar"><text class="delete-icon"></text>清空购物车</text>
</view>
<view class="container">
<view>
<view class="empty" v-if="show==false">
<image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.51yuansu.com%2Fpic3%2Fcover%2F01%2F82%2F40%2F596fa6dc00bb4_610.jpg&refer=http%3A%2F%2Fpic.51yuansu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633499781&t=d37222e32213957ddbdd01d62e071309" mode="widthFix" style="width: 400rpx;"></image>
<view class="empty-text">空空如也的购物</view>
<view class="empty-button" @click="goshopping">去选购</view>
</view>
<view v-if="show==true">
<view class="goods-detail" v-for="(item,index) in goods" :key="index">
<view class="detail-left">
<view class="goods-left">
<u-checkbox-group @change="selected(item)">
<label>
<u-checkbox shape="circle" class="selected" color="#555555" :checked="item.flag"/><text></text>
</label>
</u-checkbox-group>
<image :src="item.pics.thumbnailApplet || item.pics.thumbnail" style="width: 150rpx;height: 140rpx;"></image>
</view>
<view class="size">
<text style="font-size: 28rpx;color: #000000;">{{item.name}}</text>
<text style="font-size:20rpx;color:#666666"><text v-for="(rl,index) in item.skus[0].rules" :key="rl.ruleName">{{rl.ruleName}}<text v-if="index!=item.skus.rules.length-1">/</text></text></text>
<text><text class="goods-price">{{item.discount}}</text><text class="price-x"></text><text class="price-xx">{{item.price}}</text></text>
</view>
<view>
<u-popup :show="showShopCar && goods.length" mode="bottom" :round="10" :overlay="true"
:closeOnClickOverlay="true" @close="closeT">
<view class="shop-car">
<view class="header">
<text class="left">购物袋</text>
<text class="right" @click="clearCar"><text class="delete-icon"></text>清空购物车</text>
</view>
<view class="detail-right">
<text class="subtract" @click="reduce(item,index)">-</text>
<text class="num">{{item.num}}</text>
<text @click="add(item)" class="add">+</text>
<view class="container">
<view>
<view class="empty" v-if="show == false">
<image :src="imgPath" mode="widthFix" style="width: 400rpx;"></image>
<view class="empty-text">空空如也的购物</view>
<view class="empty-button" @click="goshopping">去选购</view>
</view>
<view v-if="show == true">
<view class="goods-detail" v-for="(item, index) in goods" :key="index">
<view class="detail-left">
<view class="goods-left">
<u-checkbox-group @change="selected(item)">
<label>
<u-checkbox shape="circle" class="selected" color="#555555"
:checked="item.flag" />
</label>
</u-checkbox-group>
<image :src="item.pics.thumbnailApplet || item.pics.thumbnail"
style="width: 150rpx;height: 140rpx;"></image>
</view>
<view class="size">
<text style="font-size: 28rpx;color: #000000;">{{ item.name }}</text>
<text style="font-size:20rpx;color:#666666">
<text v-for="(rl, index) in item.skus[0].rules" :key="rl.ruleName">
{{ rl.ruleName }}
<text v-if="index != item.skus.rules.length - 1">/</text>
</text>
</text>
<text>
<text class="goods-price">{{ item.sku.discount }}</text>
<text class="price-x"></text>
<text class="price-xx">{{ item.sku.price }}</text>
</text>
</view>
</view>
<view class="detail-right">
<text class="subtract" @click="reduce(item, index)">-</text>
<text class="num">{{ item.num }}</text>
<text @click="add(item)" class="add">+</text>
</view>
</view>
</view>
</view>
</view>
<view style="height:200rpx"></view>
</view>
</view>
</view>
</view>
<view style="height:200rpx"></view>
</view>
</u-popup>
<view class="end" v-if="goods.length">
</u-popup>
<view class="end" v-if="goods.length">
<view class="end-left">
<!-- <checkbox-group @change="selectgoods()">
<label>
<checkbox :checked="allchecked" />全选
</label>
</checkbox-group> -->
<view style="display:flex">
<view class="car-img" @click.stop="openShopCar">
<text class="badge" v-if="totalNum">{{totalNum}}</text>
</view>
<text style="color:#000000;font-weight: bold;font-size: 28rpx;display: flex; margin-left: 30rpx; align-items: center;">{{totalPrice.toFixed(2)}}</text>
</view>
</view>
<view class="end-right" @click="saveReserve" v-if="userms">
付款
<!-- ({{totalNum}}) -->
<text class="badge" v-if="totalNum">{{ totalNum }}</text>
</view>
<text class="shopClassStyle">{{ totalPrice.toFixed(2) }}</text>
</view>
<button v-if="!userms" class="end-right" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="saveReserve">
付款
<!-- ({{totalNum}}) -->
</button>
</view>
<view class="end-right" @click="saveReserve" v-if="userms">
付款
</view>
<button v-if="!userms" class="end-right" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="saveReserve">
付款
</button>
</view>
</view>
</view>
</template>
<script>
import { $EventBus } from "../../utils/EventBus";
import Menu from '@/request/menu';
import User from '@/request/user';
export default{
data(){
return{
showShopCar:false,//是否弹出购物车列表
show:true,
allchecked:true,
// checked:true,
goods:[],//购物车商品信息
}
import { $EventBus } from "../../utils/EventBus";
import Menu from '@/request/menu';
import User from '@/request/user';
export default {
data() {
return {
showShopCar: false,//是否弹出购物车列表
show: true,
allchecked: true,
// checked:true,
goods: [],//购物车商品信息
imgPath: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.51yuansu.com%2Fpic3%2Fcover%2F01%2F82%2F40%2F596fa6dc00bb4_610.jpg&refer=http%3A%2F%2Fpic.51yuansu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633499781&t=d37222e32213957ddbdd01d62e071309'
}
},
created() {
$EventBus.$off('updateCar');
},
mounted() {
this.goods = uni.getStorageSync('shopCarInfo') || [];
$EventBus.$on('updateCar', () => {
this.goods = uni.getStorageSync('shopCarInfo') || [];
});
},
methods: {
// 切换购物车列表显示隐藏
openShopCar() {
this.$nextTick(() => {
this.showShopCar = !this.showShopCar;
})
},
created() {
$EventBus.$off('updateCar');
},
mounted() {
this.goods = uni.getStorageSync('shopCarInfo')||[];
$EventBus.$on('updateCar',()=> {
this.goods=uni.getStorageSync('shopCarInfo')||[];
});
},
methods:{
// 切换购物车列表显示隐藏
openShopCar() {
this.$nextTick(()=>{
this.showShopCar = !this.showShopCar;
})
},
closeT(e) {
console.log(e,11111)
this.showShopCar=false;
},
// 清空购物车
clearCar() {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
},
// 购物车为空时点击去购物,收起购物袋
goshopping(){
this.showShopCar=false;
},
//跳转到结算
saveReserve(e) {
let Authorization = uni.getStorageSync('Authorization');
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v=>v.flag==true);
if(shopCarInfo && this.totalPrice>0 && this.totalNum>0){
if(Authorization){
// 从购物车发起:buyType=1;
// 立即购买:buyType=2;
// 扫码进入:buyType=3;
uni.navigateTo({
url:`/menuSubPackage/pages/settlement/settlement?totalPrice=${this.totalPrice}&totalNum=${this.totalNum}&buyType=1`
})
}else{
this.loginByPhoneNumber(e)
}
}
return;
},
// 付款前未登录发起授权
loginByPhoneNumber(e) {
if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'})
}
},
change(e){
console.log(e)
},
selected(item){
item.flag=!item.flag
if(!item.flag){
this.allchecked=false
}else{
const a=this.goods.filter((item)=>{
return item.flag==true
})
if(a){
this.allchecked=true
}else{
this.allchecked=false
}
}
uni.setStorageSync('shopCarInfo',this.goods);
},
selectgoods(){
this.allchecked=!this.allchecked
if(this.allchecked){
this.goods.map(item=>{
item.flag=true
})
}else{
this.goods.map(item=>{
item.flag=false
closeT(e) {
this.showShopCar = false;
},
// 清空购物车
clearCar() {
uni.removeStorageSync('shopCarInfo');
$EventBus.$emit('updateCar');
},
// 购物车为空时点击去购物,收起购物袋
goshopping() {
this.showShopCar = false;
},
//跳转到结算
saveReserve(e) {
let Authorization = uni.getStorageSync('Authorization');
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v => v.flag == true);
if (shopCarInfo && this.totalPrice > 0 && this.totalNum > 0) {
if (Authorization) {
uni.navigateTo({
url: `/orderSubPackage/pages/settlement/index?buyType=1`
})
} else {
this.loginByPhoneNumber(e)
}
uni.setStorageSync('shopCarInfo',this.goods);
},
reduce(item,index){
item.num-=1
if(item.num==0){
this.goods.splice(index,1);
}
uni.setStorageSync('shopCarInfo',this.goods);
},
add(item){
let s = 0;
this.goods.forEach(function(val) {
s += val.num;
}, 0);
if(s>=9){
uni.showToast({
title:'最多可一次购买9杯',
icon:'none'
});
return;
}
return;
},
// 付款前未登录发起授权
loginByPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
change(e) { console.log(e) },
selected(item) {
item.flag = !item.flag
if (!item.flag) {
this.allchecked = false
} else {
const a = this.goods.filter((item) => {
return item.flag == true
})
if (a) {
this.allchecked = true
} else {
this.allchecked = false
}
let num =item.num
item.num=num+1
uni.setStorageSync('shopCarInfo',this.goods);
}
uni.setStorageSync('shopCarInfo', this.goods);
},
computed:{
userms() {
return this.$store.getters.Authorization;
},
totalNum(){
let totalNum = 0;
selectgoods() {
this.allchecked = !this.allchecked
if (this.allchecked) {
this.goods.map(item => {
item.flag = true
})
} else {
this.goods.map(item => {
item.flag ? totalNum += item.num : totalNum += 0
item.flag = false
})
return totalNum
},
totalPrice() {
let totalPrice = 0;
this.goods.map(item => {
item.flag ? totalPrice += item.num * item.discount : totalPrice += 0
})
return totalPrice
}
uni.setStorageSync('shopCarInfo', this.goods);
},
reduce(item, index) {
item.num -= 1
if (item.num == 0) {
this.goods.splice(index, 1);
}
uni.setStorageSync('shopCarInfo', this.goods);
},
add(item) {
let s = 0;
this.goods.forEach(function (val) {
s += val.num;
}, 0);
if (s >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none'
});
return;
}
let num = item.num
item.num = num + 1
uni.setStorageSync('shopCarInfo', this.goods);
}
},
computed: {
userms() {
return this.$store.getters.Authorization;
},
totalNum() {
let totalNum = 0;
this.goods.map(item => {
item.flag ? totalNum += item.num : totalNum += 0
})
return totalNum
},
totalPrice() {
let totalPrice = 0;
this.goods.forEach(item => {
const sku = item.sku;
item.flag ? totalPrice += item.num * sku.discount : totalPrice += 0
})
return totalPrice
}
}
}
</script>
<style lang="scss">
.shop-car {
display: flex;
flex-direction: column;
height: 860rpx;
.header{
height: 88rpx;
display: flex;
border-bottom:1rpx solid rgb(235,235,235);
.left{
flex: 1;
display: flex;
align-items: center;
padding-left: 40rpx;
font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
}
.right{
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
padding-right: 40rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
.delete-icon{
width:18rpx;
height: 18rpx;
background: url(../../static/imgs/icon-delete.png) center center no-repeat;
background-size: cover;
display: inline-block;
margin-right: 8rpx;
}
}
}
.container{
flex: 1;
overflow: auto;
}
}
.goods{
line-height: 80rpx;
background-color: #FFFFFF;
&-detail{
display: flex;
padding: 30rpx 15rpx 30rpx 30rpx;
background-color: #fff;
justify-content: space-between;
align-items: center;
.detail-left{
display: flex;
.goods-left{
display: flex;
align-items: center;
}
}
.size{
display: flex;
justify-content: space-around;
flex-direction: column;
margin-left: 30rpx;
.goods-price{
font-size: 24rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #FF5200;
}
.price-x{
margin-left:6rpx;
font-size:20rpx;
font-family: ArialMT;
line-height: 22rpx;
color: #666666;
}
.price-xx{
font-size:20rpx;
text-decoration:line-through;
}
}
.detail-right{
text{
width: 40rpx;
line-height: 40rpx;
text-align: center;
display: inline-block;
margin-right: 10rpx;
color:#000000;
}
.add {
color: #FFFFFF;
border-radius: 40rpx;
margin-right: 20rpx;
background:#006ECF;
}
.subtract{
border:1rpx solid #006ECF;
border-radius: 40rpx;
color:#006ECF;
}
}
.shopClassStyle {
color: #000000;
font-weight: bold;
font-size: 28rpx;
display: flex;
margin-left: 30rpx;
align-items: center;
}
.shop-car {
display: flex;
flex-direction: column;
height: 860rpx;
.header {
height: 88rpx;
display: flex;
border-bottom: 1rpx solid rgb(235, 235, 235);
.left {
flex: 1;
display: flex;
align-items: center;
padding-left: 40rpx;
font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
}
.right {
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
padding-right: 40rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
.delete-icon {
width: 18rpx;
height: 18rpx;
background: url(../../static/imgs/icon-delete.png) center center no-repeat;
background-size: cover;
display: inline-block;
margin-right: 8rpx;
}
}
}
.empty{
position: relative;
top: 220rpx;
text-align: center;
display: flex;
align-items: center;
flex-direction: column;
&-text{
color: #808080;
margin-bottom: 50rpx;
}
&-button{
width: 300rpx;
height: 90rpx;
color:orange;
border: 1rpx solid orange;
text-align: center;
line-height: 90rpx;
border-radius: 48rpx;
}
.container {
flex: 1;
overflow: auto;
}
.end{
width: 100%;
height: 92rpx;
background-color:rgb(253, 253, 253);
position: fixed;
bottom: 50px;
left: 0;
display: flex;
z-index: 10075;
align-items: center;
&-left{
width: 70%;
display: flex;
justify-content: space-between;
padding: 0 30rpx;
.end-flex{
display: flex;
align-items: center;
}
.car-img{
width:40rpx;
height: 48rpx;
display: inline-block;
background:url('../../static/imgs/icon-shop-package.png') center center no-repeat;
background-size:cover;
position: relative;
.badge{
position: absolute;
height: 24rpx;
background: #006ECF;
right:-16rpx;
top: -4rpx;
min-width: 24rpx;
font-size: 16rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #FFFFFF;
line-height: 18rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
}
}
&-right{
width: 169rpx;
font-size: 32rpx;
line-height: 92rpx;
background-color: #006ECF;
text-align: center;
color: #fff;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
}
}
.goods {
line-height: 80rpx;
background-color: #FFFFFF;
&-detail {
display: flex;
padding: 30rpx 15rpx 30rpx 30rpx;
background-color: #fff;
justify-content: space-between;
align-items: center;
.detail-left {
display: flex;
.goods-left {
display: flex;
align-items: center;
}
}
.size {
display: flex;
justify-content: space-around;
flex-direction: column;
margin-left: 30rpx;
.goods-price {
font-size: 24rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #FF5200;
}
.price-x {
margin-left: 6rpx;
font-size: 20rpx;
font-family: ArialMT;
line-height: 22rpx;
color: #666666;
}
.price-xx {
font-size: 20rpx;
text-decoration: line-through;
}
}
.detail-right {
text {
width: 40rpx;
line-height: 40rpx;
text-align: center;
display: inline-block;
margin-right: 10rpx;
color: #000000;
}
.add {
color: #FFFFFF;
border-radius: 40rpx;
margin-right: 20rpx;
background: #006ECF;
}
.subtract {
border: 1rpx solid #006ECF;
border-radius: 40rpx;
color: #006ECF;
}
}
}
}
.empty {
position: relative;
top: 220rpx;
text-align: center;
display: flex;
align-items: center;
flex-direction: column;
&-text {
color: #808080;
margin-bottom: 50rpx;
}
&-button {
width: 300rpx;
height: 90rpx;
color: orange;
border: 1rpx solid orange;
text-align: center;
line-height: 90rpx;
border-radius: 48rpx;
}
}
.end {
width: 100%;
height: 92rpx;
background-color: rgb(253, 253, 253);
position: fixed;
bottom: 50px;
left: 0;
display: flex;
z-index: 10075;
align-items: center;
&-left {
width: 70%;
display: flex;
justify-content: space-between;
padding: 0 30rpx;
.end-flex {
display: flex;
align-items: center;
}
.car-img {
width: 40rpx;
height: 48rpx;
display: inline-block;
background: url('../../static/imgs/icon-shop-package.png') center center no-repeat;
background-size: cover;
position: relative;
.badge {
position: absolute;
height: 24rpx;
background: #006ECF;
right: -16rpx;
top: -4rpx;
min-width: 24rpx;
font-size: 16rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #FFFFFF;
line-height: 18rpx;
display: flex;
justify-content: center;
align-items: center;
border-radius: 50%;
}
}
}
&-right {
width: 169rpx;
font-size: 32rpx;
line-height: 92rpx;
background-color: #006ECF;
text-align: center;
color: #fff;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
}
}
</style>
<template>
<view class="spec-content">
<view class="uni-margin-wrap">
<swiper class="swiper" circular autoplay>
<swiper-item v-for="item in goodInfo.pics.introImages">
<view class="swiper-item">
<image class="swiper-spec-content-item-img" :src="item" mode="widthFix"></image>
</view>
</swiper-item>
</swiper>
</view>
<!-- <scroll-view scroll-x="true">
<view class="spec-banner-wrap" scroll-x="true">
<view class="spec-banner-wrap-item" v-for="item in goodInfo.pics.introImages">
<image class="spec-banner-wrap-item-img" :src="item" mode="widthFix"></image>
</view>
</view>
</scroll-view> -->
<view class="good spec-info-left">
<text class="good-name">{{goodInfo.name}}</text>
<view v-for="specItem in goodInfo.specs">
<text class="good-spec-name">{{specItem.specName}}</text>
<view class="good-spec-rule">
<view v-for="specItemRule in specItem.rules">
<text class="good-spec-rule-item">{{specItemRule.ruleName}}</text>
<view v-if="goodInfo">
<view class="uni-margin-wrap">
<swiper class="swiper">
<swiper-item v-for="item in goodInfo.pics.introImages" :key="item">
<image :src="item" class="swiper_img" mode="aspectFit"></image>
</swiper-item>
</swiper>
</view>
<view class="good spec-info-left">
<text class="good-name">{{ goodInfo.name }}</text>
<view class="specs">
<view v-for="specItem in goodInfo.specs" :key="specItem.specId">
<view class="good-spec-name">{{ specItem.specName }}</view>
<view class="good-spec-rule">
<view class="good-spec-rule-item" v-for="specItemRule in specItem.rules"
@click="selectRoles(specItemRule, specItem)" :class="{ active: isActvie(specItemRule) }"
:key="specItemRule.ruleId">
<view>{{ specItemRule.ruleName }}</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="spec-detail">
<text class="spec-detail-title spec-info-left">商品详情</text>
<view class="spec-detail-img" v-for="item in goodInfo.pics.detailImages">
<image class=".spec-detail-img-item " :src="item" mode="widthFix"></image>
</view>
<view class="good-select-height">
</view>
</view>
<view class="good-select good-select-height">
<view class="good-select-price">
<text class="good-select-price-normal">¥100</text>
<text class="good-select-price-small">¥10</text>
<view class="spec-detail">
<view class="spec-detail-title spec-info-left">商品详情</view>
<view class="spec-detail-img" v-for="item in goodInfo.pics.detailImages" :key="item">
<image class="spec-detail-img-item" :src="item" mode="scaleToFill"></image>
</view>
<!-- 底部空白 -->
<view class="good-select-height"></view>
</view>
<view class="good-select-cont">
<button class="good-select-btn" type="default" >立即购买</button>
<button class="good-select-btn" type="default" >加入购物袋</button>
<view class="good-select good-select-height">
<view class="good-select-price">
<text class="good-select-price-normal">¥100</text>
<text class="good-select-price-small">¥10</text>
</view>
<view class="good-select-cont">
<span class="good-select-btn1" @click="getallNum('buyNow')" v-if="userms">
立即购买
</span>
<button v-if="!userms" class="good-select-btn1" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="getallNum">
立即购买
</button>
<span class="good-select-btn2" @click="getallNum" type="default">加入购物袋</span>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello1',
imglist:[{img:"/static/logo.png"},{img:"/static/ggxz01.png"}],
goodInfo:{
"goodId": 100,
"name": "冰茶咖啡",
"price": 29.9,
"discount": 19.9,
"pics": {
"thumbnail": "http://baidu.com",
"introImages": [
"https://cdn.uviewui.com/uview/album/1.jpg",
"https://cdn.uviewui.com/uview/album/2.jpg",
"https://cdn.uviewui.com/uview/album/3.jpg"
],
"detailImages": [
"https://cdn.uviewui.com/uview/album/4.jpg",
"https://cdn.uviewui.com/uview/album/5.jpg",
"https://cdn.uviewui.com/uview/album/6.jpg"
]
},
"desc": "",
"remark": "",
"tags": [
"YYDS",
"杨幂同款"
],
"specs": [
{
"rules": [
{
"isDefault": "1",
"isRecommend": "0",
"price": "2",
"ruleId": "51",
"ruleName": "冰"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "1",
"ruleId": "52",
"ruleName": "热"
}
],
"specId": "44",
"specName": "温度"
},
{
"rules": [
{
"isDefault": "1",
"isRecommend": "0",
"price": "0",
"ruleId": "53",
"ruleName": "不加奶"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "1",
"ruleId": "54",
"ruleName": "正常奶"
}
],
"specId": "45",
"specName": "加奶"
},
{
"rules": [
{
"isDefault": "1",
"isRecommend": "0",
"price": "0",
"ruleId": "55",
"ruleName": "不加糖"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "1",
"ruleId": "56",
"ruleName": "半塘"
},
{
"isDefault": "0",
"isRecommend": "0",
"price": "2",
"ruleId": "57",
"ruleName": "标准糖"
}
],
"specId": "46",
"specName": "糖度"
}
],
"skus": [
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 2,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "无糖",
"price": 0.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "常温",
"price": 0.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 2.00
}
]
},
{
"skuId": 1,
"state": 1,
"rules": [
{
"specId": 1,
"specName": "温度",
"ruleId": 1,
"ruleName": "冰",
"price": 2.00
},
{
"specId": 2,
"specName": "糖度",
"ruleId": 3,
"ruleName": "加糖",
"price": 4.00
}
]
}
]
import Utils from '@/utils/utils'
import User from '@/request/user';
export default {
data() {
return {
title: 'Hello1',
imglist: [{ img: "/static/logo.png" }, { img: "/static/ggxz01.png" }],
goodInfo: null,
selected: []
}
},
onLoad(option) {
const goodsInfo = uni.getStorageSync('goodsInfo')
this.goodInfo = JSON.parse(goodsInfo)
},
methods: {
selectRoles(specItemRule, parent) {
const { selected } = this;
selected.forEach((item, index) => {
if (item.specId == parent.specId) {
selected.splice(index, 1)
}
}
});
this.selected.push({ ...specItemRule, specId: parent.specId })
},
onLoad() {
isActvie(data) {
return this.selected.filter(item => item.ruleId == data.ruleId).length > 0
},
getallNum(type) {
let Authorization = uni.getStorageSync('Authorization');
if (!Authorization) {
this.loginByPhoneNumber(e);
return
}
const skusObj = {};
let selectedSku = null
const skus = this.goodInfo.skus;
skus.forEach(item => {
const ruleId = item.rules.map(item => item.ruleId);
skusObj[item.skuId] = ruleId.sort()
});
const selectedrules = this.selected.map(item => item.ruleId).sort()
for (let item in skusObj) {
const selStr = selectedrules.toString()
const itemStr = skusObj[item].toString()
if (selStr === itemStr) {
selectedSku = item
}
}
const [sku] = skus.filter(item => item.skuId == selectedSku);
if (skus.state == 2) {
uni.showToast({ title: '本商品已经售罄', icon: 'none' });
return;
} else {
const { category, ...goods } = this.goodInfo;
goods.skus = [sku];
goods.sku = sku
goods.num = 1;
goods.flag = true;
goods.skuId = selectedSku
goods.categoryId = category.id;
goods.goodsName = category.name;
Utils.getallNum(goods);
if (type == 'buyNow') {
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1` })
} else {
uni.switchTab({ url: '/pages/menu/menu' })
}
}
},
// 付款前未登录发起授权
loginByPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') {
User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
},
computed: {
userms() {
return this.$store.getters.Authorization;
},
methods: {
}
}
},
}
</script>
<style lang="scss">
.uni-margin-wrap {
height: 444rpx;
width: 100%;
background: #ff00f0;
}
.swiper-spec-content {
height: 300rpx;
width: 100%;
}
.swiper-spec-content-item {
display: block;
height: 300rpx;
line-height: 300rpx;
text-align: center;
}
.swiper-spec-content-item-img {
height: 100%;
width: 100%;
}
.spec-content {
}
.spec-info-left{
padding:22rpx 34rpx;
}
.good {
display: block;
width: 100%;
text-align: left;
.good-name {
.uni-margin-wrap {
width: 100%;
}
.swiper {
height: 597rpx;
width: 100%;
}
.swiper_img {
width: 100%;
height: 100% !important;
}
.spec-content {}
.spec-info-left {
padding: 22rpx 34rpx;
}
.specs {
margin-top: 30rpx;
}
.good {
display: block;
width: 100%;
text-align: left;
.good-name {
font-size: 32rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
line-height: 44rpx;
}
.good-spec-name {
margin-top:22rpx;
.good-spec-name {
margin-top: 24rpx;
color: rgba(0, 0, 0, 1);
font-size: 28rpx;
text-align: left;
line-height: 40rpx;
font-weight: bold;
}
.good-spec-rule {
display: flex;
flex-direction: row;
justify-content: flex-start;
margin-left: 8rpx;
}
}
.good-spec-rule-item {
font-size: 24rpx;
margin-right: 10rpx;
}
.spec-detail {
width: 100%;
height: 100%;
}
.spec-detail-title{
line-height: 40rpx;
font-weight: bold;
}
.spec-detail-img {
display: flex;
flex-direction: column;
margin-top: 0rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 0rpx;
padding: 0rpx;
justify-content: center;
align-items: center;
}
.spec-detail-img-item {
width: 100%;
height: 100%;
}
.good-select-height{
height:200rpx;
}
.good-select{
width: 90%;
position: fixed;
bottom: 0rpx;
text-align: center;
}
.good-select-price{
display: flex;
margin-top: 20rpx;
justify-content: flex-start;
align-items: flex-end;
}
.good-select-price-normal{
font-size: 36rpx;
color: rgba(235, 95, 23, 1);
}
.good-select-price-small{
font-size: 20rpx;
text-decoration:line-through;
}
.good-select-cont{
margin-top: 20rpx;
.good-spec-rule {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
justify-content: flex-start;
margin-left: 8rpx;
margin-top: 24rpx;
flex-wrap: wrap;
}
.good-select-btn {
}
.good-spec-rule-item {
width: 120rpx;
height: 48rpx;
border-radius: 6rpx;
font-size: 24rpx;
margin-right: 10rpx;
margin-top: 10rpx;
color: #000;
line-height: 48rpx;
text-align: center;
display: inline-block;
&.active {
background: #006ECF;
color: #fff;
}
}
.spec-detail {
width: 100%;
height: 100%;
}
.spec-detail-title {
font-weight: bold;
margin-bottom: 30rpx;
}
.spec-detail-img {
height: 500rpx;
}
.spec-detail-img-item {
width: 100%;
height: 100%;
}
.good-select-height {
height: 200rpx;
}
.good-select {
width: 100%;
position: fixed;
bottom: 0rpx;
text-align: center;
background-color: #fff;
}
.good-select-price {
display: flex;
align-items: center;
height: 58rpx;
background: #FFFFFF;
}
.good-select-price-normal {
font-size: 36rpx;
color: rgba(235, 95, 23, 1);
margin-right: 10rpx;
font-weight: 600;
}
.good-select-price-small {
font-size: 20rpx;
text-decoration: line-through;
}
.good-select-cont {
margin-top: 20rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
justify-content: space-between;
padding: 0 32rpx;
}
.good-select-btn1 {
width: 328rpx;
height: 76rpx;
border-radius: 10rpx;
border: 2rpx solid #006ECF;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #006ECF;
line-height: 76rpx;
text-align: center;
}
.good-select-btn2 {
width: 328rpx;
height: 76rpx;
background: #006ECF;
border-radius: 10rpx;
line-height: 76rpx;
text-align: center;
color: #fff;
}
</style>
<template>
</template>
<script>
export default {
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<div class="pages">
<div class="order_status">
<view class="status_text" v-if="orderInfo.state == 0">订单状态:创建未校验</view>
<view class="status_text" v-if="orderInfo.state == 1">订单状态:未支付</view>
<view class="status_text" v-if="orderInfo.state == 2">订单状态:排队中</view>
<view class="status_text" v-if="orderInfo.state == 3">订单状态:制作中</view>
<view class="status_text" v-if="orderInfo.state == 4">订单状态:制作完成</view>
<view class="status_text" v-if="orderInfo.state == 5">订单状态:待取超时</view>
<view class="status_text" v-if="orderInfo.state == 6">订单状态:完成</view>
<view class="status_text" v-if="orderInfo.state == 7">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 8">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 9">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 10">订单状态:取消</view>
<view class="status_text" v-if="orderInfo.state == 11">订单状态:已退款</view>
<view class="status_text" v-if="orderInfo.state == 12">订单状态:部分退款</view>
<div>
<a type="primary" @click="toRefund" v-if="orderInfo.state == 1" class="btn">申请退款</a>
<a type="primary" @click="toRefund" v-if="orderInfo.state == 2" class="btn">申请退款</a>
</div>
</div>
<div class="order_flow">
<div class="code">取单码 Mon999</div>
<image mode="aspectFit" :src="orderInfo.pickCode" class="qr_code"></image>
<div class="flow_describe">
<h3>扫码流程 </h3>
<image :mode="'aspectFit'" width="600px" class="flow_img" src="../../../static/imgs/order_flow.png">
</image>
</div>
<div class="shop_info">
<div class="address">
<div class="address_1">北京朝阳建外SOHO东区A座店</div>
<div class="address_2">距您132m,请确定门店后下单</div>
</div>
<div v-for="item in orderInfo.orderDetails" :key="item.id">
<div class="goods">
<div class="goods_item">
<image mode="aspectFit" :src="jsonParse(item.goods.pics).thumbnail" class="goods_img">
</image>
<div class="goods_text">
<div class="goods_name">
<div class="name">{{ item.goodsName }}</div>
<div class="price">¥{{ item.realAmount }}</div>
</div>
<div class="goods_psce">
<div class="psce_name">
<span v-for="rule in jsonParse(item.specRuleDetail)" :key="rule.specId">
{{ rule.ruleName }}/
</span>
</div>
<div class="size">*{{ item.num }}</div>
</div>
</div>
</div>
</div>
<div class="discount">
<div class="discount_1">
<div class="name">优惠免减</div>
<div class="price">- ¥5</div>
</div>
<div class="concessional_rate">
<div class="name">优惠免减</div>
<div class="price">- ¥5</div>
</div>
</div>
</div>
<div class="total">
<div class="size">共一件商品</div>
<div>
<span class="paid_in">实付</span>
<span class="money">¥10</span>
</div>
</div>
</div>
</div>
<div class="order_describe">
<h3>订单信息</h3>
<div class="item">
<span class="label">下单时间:</span>
<span class="value">2022-11-12 10:20:20</span>
</div>
<div class="item">
<span class="label">取单码号:</span>
<span class="value">2022-11-12 10:20:20</span>
</div>
<div class="item">
<span class="label">订单编号:</span>
<span class="value">2022-11-12 10:20:20</span>
</div>
</div>
<div class="customer_service">
<span>有疑问,联系客服</span>
<u-icon name="arrow-right" color="#000" size="20"></u-icon>
</div>
</div>
</template>
<script>
import Order from '@/request/order'
export default {
onLoad() {
this.orderInfo = uni.getStorageSync('orderInfo');
},
data() {
return {
orderInfo: {}
}
},
methods: {
toRefund() {
Order.orderRefund({ orderId: this.orderInfo.id, refundAmount: this.orderInfo.amount }).then(res => {
console.log(res);
uni.switchTab({ url: '/pages/menu/menu' })
})
},
jsonParse(json) {
return JSON.parse(json)
}
}
}
</script>
<style lang="scss" scoped>
.pages {
padding-top: 1rpx;
padding-bottom: 30rpx;
}
.order_status {
width: 686rpx;
height: 174rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 32rpx auto 0;
padding: 14px;
.status_text {
font-size: 32rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
text-align: center;
}
.btn {
width: 160rpx;
height: 52rpx;
background: #006ECF;
border-radius: 6rpx;
display: block;
margin: 20rpx auto;
padding: 0;
line-height: 52rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
font-size: 20rpx;
text-align: center;
}
}
.order_flow {
background: #FFFFFF;
border-radius: 10rpx;
margin-top: 32rpx;
padding-top: 65rpx;
.code {
font-size: 36rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
text-align: center;
}
.qr_code {
width: 508rpx;
height: 510rpx;
display: block;
margin: 25rpx auto;
background-color: #ccc;
}
.flow_describe {
width: 686rpx;
height: 340rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(166, 166, 166, 0.5);
border-radius: 10rpx;
margin: 0 auto;
padding: 30rpx;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #000000;
}
.flow_img {
width: 600rpx;
height: 214rpx;
display: block;
margin: 24rpx auto;
}
}
}
.shop_info {
width: 686rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
margin-top: 32rpx;
padding: 24rpx 32rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.address {
margin-top: 16rpx;
.address_1 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
}
.address_2 {
margin-top: 5rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
.goods {
margin-top: 35rpx;
padding-top: 35rpx;
.goods_item {
display: flex;
align-items: center;
margin-top: 20rpx;
}
.goods_img {
height: 80rpx;
width: 80rpx;
background-color: #eee;
margin-right: 50rpx;
}
.goods_text {
flex: 1;
.goods_psce,
.goods_name {
display: flex;
justify-content: space-between;
align-items: center;
.name {
font-size: 24rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #333333;
}
.price {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #000000;
}
.psce_name {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.size {
font-size: 24rpx;
font-family: ArialMT;
color: #666666;
}
}
.goods_psce {
margin-top: 10rpx;
}
}
}
.discount {
margin-top: 24rpx;
padding-bottom: 24rpx;
border-bottom: 1rpx solid #666;
.discount_1 {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #333333;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #EB5F17;
}
}
.concessional_rate {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 18rpx;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: 700;
color: #000;
}
}
}
.total {
display: flex;
align-items: center;
display: flex;
justify-content: space-between;
margin-top: 52rpx;
.size {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.paid_in {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 600;
color: #000000;
}
.money {
font-weight: 600;
font-size: 32rpx;
color: #000000;
vertical-align: middle;
}
}
}
.order_describe {
background: #fff;
border-radius: 10rpx;
padding: 0 62rpx 24rpx;
margin-top: 32rpx;
h3 {
padding: 24rpx 0;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
border-bottom: 1rpx solid #666;
}
.item {
margin-top: 20rpx;
.label {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.value {
font-size: 24rpx;
font-family: ArialMT;
color: #333333;
}
}
}
.customer_service {
height: 90rpx;
line-height: 90rpx;
background: #FFFFFF;
border-radius: 10rpx;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
padding: 0 64rpx;
margin: 32rpx 0;
display: flex;
justify-content: space-between;
}
</style>
\ No newline at end of file
<template>
<view class="pages">
<div class="shop_info">
<h3>门店确认</h3>
<div class="address">
<div class="address_1">北京朝阳建外SOHO东区A座店</div>
<div class="address_2">距您132m,请确定门店后下单</div>
</div>
<div class="take_order">
<div class="title">取单时间</div>
<div class="time">现在下单,预计 <span class="min">5</span> 分钟后取餐</div>
</div>
</div>
<div class="goods_info">
<h3>商品详情</h3>
<div class="goods" v-for="item in goods" :key="item.goodsId">
<div class="goods_item">
<image mode="aspectFit" class="goods_img" src=""></image>
<div class="goods_text">
<div class="goods_name">
<div class="name">{{ item.name }}</div>
<div class="price">¥{{ item.sku.price }}</div>
</div>
<div class="goods_psce">
<div class="psce_name">/</div>
<div class="size">x {{ item.num }}</div>
</div>
</div>
</div>
<div class="discount">
<div class="discount_1">
<div class="name">优惠免减</div>
<div class="price">- ¥{{ itemReduction(item.sku.discount, item.sku.price) }}</div>
</div>
<div class="concessional_rate">
<div class="name">特惠价</div>
<div class="price">¥{{ item.sku.discount }}</div>
</div>
</div>
</div>
<div class="total">
<div class="size">{{ totalNum }}件商品</div>
<div>
<span class="paid_in">实付</span>
<span class="money">{{ totalPrice }}</span>
</div>
</div>
</div>
<div class="Payment_method">
<div>支付方式</div>
<div class="type">
<image mode="aspectFit" src="../../../static/imgs/weixin-3.png" class="icon"></image>
<span>微信支付</span>
</div>
</div>
<div class="footer">
<div class="total">
<div class="the_sum">
<span class="name">合计</span>
<span class="price">{{ totalPrice }}</span>
</div>
<div class="sun">
<div class="price">总优惠¥{{ reduction }}</div>
</div>
</div>
<view class="payment" @click="saveReserve" v-if="userms">
付款
</view>
<button v-if="!userms" class="payment" style="border-radius: 0;" open-type="getPhoneNumber"
@getphonenumber="saveReserve">
付款
</button>
</div>
</view>
</template>
<script>
import { $EventBus } from "../../../utils/EventBus";
import Utils from '@/utils/utils'
import Menu from '@/request/menu'
export default {
onLoad(option) {
this.buyType = option.buyType;
console.log(uni.getStorageSync('shopCarInfo'));
this.goods = uni.getStorageSync('shopCarInfo') || [];
$EventBus.$on('updateCar', () => {
this.goods = uni.getStorageSync('shopCarInfo') || [];
});
},
data() {
return {
goods: [],
buyType: ''
}
},
computed: {
userms() {
return this.$store.getters.Authorization;
},
totalNum() {
let totalNum = 0;
this.goods.map(item => {
item.flag ? totalNum += item.num : totalNum += 0
})
return totalNum
},
reduction() {
let price = 0;
let discountNum = 0;
this.goods.forEach(item => {
const sku = item.sku;
if (item.flag) {
discountNum += item.num * sku.discount
price += item.num * sku.price
} else {
totalPrice += 0
price += 0
}
})
return (price - discountNum).toFixed(2)
},
totalPrice() {
let totalPrice = 0;
this.goods.forEach(item => {
const sku = item.sku;
item.flag ? totalPrice += item.num * sku.discount : totalPrice += 0
})
return totalPrice
}
},
methods: {
itemReduction(discount, price) {
return (price - discount).toFixed(2)
},
//结算组装数据发起订单
async saveReserve() {
// 组装购物车数据或者立即支付数据
let res = await Utils.AssemblyOrder(this.totalPrice, this.totalNum, this.buyType);
if (res) {
// 发起订单
let orderInfo = await Menu.saveReserve(res);
if (orderInfo && orderInfo.data.code == 200) {
let payMent = await Menu.requestPayment(orderInfo.data.data, res, this.buyType);
}
}
}
}
}
</script>
<style lang="scss" scoped>
.pages {
padding-top: 1rpx;
}
.shop_info {
width: 686rpx;
height: 306rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
margin-top: 32rpx;
padding: 24rpx 32rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.address {
margin-top: 16rpx;
.address_1 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #333333;
}
.address_2 {
margin-top: 5rpx;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
.take_order {
margin-top: 28rpx;
padding-top: 28rpx;
border-top: 1rpx solid #666;
.title {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.time {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
.min {
color: #006ECF;
font-size: 28rpx;
font-weight: 700;
margin: 0 5rpx;
display: inline-block;
}
}
}
}
.goods_info {
width: 686rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
margin-top: 32rpx;
padding: 24rpx 32rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.goods {
margin-top: 42rpx;
border-bottom: 1rpx solid #666;
padding-bottom: 20rpx;
.goods_item {
display: flex;
align-items: center;
}
.goods_img {
height: 80rpx;
width: 80rpx;
background-color: #eee;
margin-right: 50rpx;
}
.goods_text {
flex: 1;
.goods_psce,
.goods_name {
display: flex;
justify-content: space-between;
align-items: center;
.name {
font-size: 24rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #333333;
}
.price {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #000000;
}
.psce_name {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.size {
font-size: 24rpx;
font-family: ArialMT;
color: #666666;
}
}
.goods_psce {
margin-top: 10rpx;
}
}
}
.discount {
margin-top: 15rpx;
padding-top: 15rpx;
.discount_1 {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #333333;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #EB5F17;
}
}
.concessional_rate {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 18rpx;
.price {
font-family: Arial-BoldMT, Arial;
font-weight: 700;
color: #000;
}
}
}
.total {
display: flex;
align-items: center;
display: flex;
justify-content: space-between;
margin-top: 52rpx;
.size {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
.paid_in {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 600;
color: #000000;
}
.money {
font-weight: 600;
font-size: 32rpx;
color: #000000;
vertical-align: middle;
}
}
}
.Payment_method {
width: 686rpx;
height: 86rpx;
margin: 32rpx auto 0;
padding: 0 32rpx;
background: #FFFFFF;
border-radius: 10rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #333333;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
.type {
display: flex;
align-items: center;
font-weight: 600;
.icon {
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
}
}
}
.footer {
height: 92rpx;
background: #fff;
position: fixed;
bottom: 0;
display: flex;
width: 100%;
.total {
flex: 1;
padding-left: 32rpx;
.the_sum {
.name {
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.price {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
color: #000000;
}
}
.sun {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FF0E00;
margin-top: 10rpx;
}
}
.payment {
width: 170rpx;
height: 100%;
background: #006ECF;
text-align: center;
line-height: 92rpx;
font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
}
}
</style>
\ No newline at end of file
{ "easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": ""
}
}
,{
"path" : "pages/menu/menu",
"style" :
{
"navigationBarTitleText": "菜单",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
},{
"path" : "pages/order/order",
"style" :
{
"navigationBarTitleText": "订单",
"enablePullDownRefresh": false
}
{
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": ""
}
},
{
"path": "pages/menu/menu",
"style": {
"navigationBarTitleText": "菜单",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/order/order",
"style": {
"navigationBarTitleText": "订单",
"enablePullDownRefresh": false
}
},
{
"path": "pages/mine/mine",
"style": {
"navigationBarTitleText": "我的",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
}
],
"subPackages": [
{
"root": "menuSubPackage",
"pages": [
{
"path": "pages/goodsDetail/goodsDetail",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"enablePullDownRefresh": false
}
},
{
"path": "pages/areaSelect/areaSelect",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/mine/mine",
"style" :
{
"navigationBarTitleText": "我的",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
]
},
{
"root": "orderSubPackage",
"pages": [
{
"path": "pages/settlement/index",
"style": {
"navigationBarTitleText": "订单结算",
"enablePullDownRefresh": false
}
},
{
"path": "pages/orderInfo/index",
"style": {
"navigationBarTitleText": "订单详情",
"enablePullDownRefresh": false
}
}
],
"subPackages": [
{
"root": "menuSubPackage",
"pages": [
{
"path" : "pages/goodsDetail/goodsDetail",
"style" :
{
"navigationBarTitleText": "",
"navigationStyle":"custom",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/areaSelect/areaSelect",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
,{
"path" : "pages/settlement/settlement",
"style" :
{
"navigationBarTitleText": "订单结算",
"enablePullDownRefresh": false
}
}
]
},
{
"root": "orderSubPackage",
"pages": [
{
"path": "pages/demo/demo",
"style": {
// "navigationBarBackgroundColor": "",
// "navigationBarTitleText": "",
"enablePullDownRefresh": false
// "navigationStyle":"custom"
}
}
]
},
{
"root": "mineSubPackage",
"pages": [
{
"path": "pages/demo/demo",
"style": {
// "navigationBarBackgroundColor": "",
// "navigationBarTitleText": "",
"enablePullDownRefresh": false
// "navigationStyle":"custom"
}
}
]
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "HOOLOO",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#ffffff"
},
"tabBar": {
"custom":true,
"list": [
{
"pagePath": "pages/menu/menu"
},{
"pagePath": "pages/order/order"
}, {
"pagePath": "pages/mine/mine"
}
]
}
]
},
{
"root": "mineSubPackage",
"pages": []
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "HOOLOO",
"navigationBarBackgroundColor": "#ffffff",
"backgroundColor": "#ffffff"
},
"tabBar": {
"custom": true,
"list": [
{
"pagePath": "pages/menu/menu"
},
{
"pagePath": "pages/order/order"
},
{
"pagePath": "pages/mine/mine"
}
]
}
}
......@@ -4,99 +4,99 @@
</template>
<script>
import config from '../../static/config/index.js'
import Order from '../../request/order/index'
import User from '@/request/user'
import Menu from '@/request/menu'
export default {
data() {
return {
id:''
}
},
onLoad(options) {
this.id='';
this.$store.commit('setOrderId','');
if(options.q){
let url=decodeURIComponent(options.q);
this.id=url.split('/')[url.split('/').length-1];
this.$store.commit('setOrderId',this.id);
}
import config from '../../static/config/index.js'
import Order from '../../request/order/index'
import User from '@/request/user'
import Menu from '@/request/menu'
export default {
data() {
return {
id: ''
}
},
onLoad(options) {
this.id = '';
this.$store.commit('setOrderId', '');
if (options.q) {
let url = decodeURIComponent(options.q);
this.id = url.split('/')[url.split('/').length - 1];
this.$store.commit('setOrderId', this.id);
}
// this.id=1;
},
async onShow() {
// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
// let curRoute = routes[routes.length - 1].route //获取当前页面路由
//   let curParam = routes[routes.length - 1].options;
//  console.log(curParam)
let Authorization=uni.getStorageSync(`Authorization`);
let userPhoneInfo=uni.getStorageSync(`userPhoneInfo`);
if(Authorization && userPhoneInfo){ //
this.$store.commit('setUserPhoneInfo',userPhoneInfo);
this.$store.commit('setAuthorization',Authorization);
if(this.id!=''){
uni.navigateTo({
url:`/menuSubPackage/pages/settlement/settlement?orderId=${this.id}&buyType=3`
})
}else{
uni.reLaunch({
url:'/pages/menu/menu'
})
}
}else{
uni.removeStorageSync('Authorization');
uni.removeStorageSync('userPhoneInfo');
if(this.id!=''){
let _this = this;
uni.showToast({
title:'请授权登录',
icon:'error',
},
async onShow() {
// let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
// let curRoute = routes[routes.length - 1].route //获取当前页面路由
//   let curParam = routes[routes.length - 1].options;
//  console.log(curParam)
let Authorization = uni.getStorageSync(`Authorization`);
let userPhoneInfo = uni.getStorageSync(`userPhoneInfo`);
if (Authorization && userPhoneInfo) {
this.$store.commit('setUserPhoneInfo', userPhoneInfo);
this.$store.commit('setAuthorization', Authorization);
if (this.id != '') {
uni.navigateTo({
url: `/menuSubPackage/pages/settlement/settlement?orderId=${this.id}&buyType=3`
})
} else {
uni.reLaunch({
url: '/pages/menu/menu'
})
}
} else {
uni.removeStorageSync('Authorization');
uni.removeStorageSync('userPhoneInfo');
if (this.id != '') {
let _this = this;
uni.showToast({
title: '请授权登录',
icon: 'error',
success() {
setTimeout(()=>{
setTimeout(() => {
uni.reLaunch({
url:'/pages/menu/menu?orderId='+_this.id
url: '/pages/menu/menu?orderId=' + _this.id
})
},1500)
}, 1500)
}
})
}else{
uni.reLaunch({
url:'/pages/menu/menu'
})
}
})
} else {
uni.reLaunch({
url: '/pages/menu/menu'
})
}
},
methods: {
}
},
methods: {
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>
<template>
<view class="menu-box" :style="{height:`${height}px`}">
<view class="menu-box" :style="{ height: `${height}px` }">
<view class="menu-banner">
<image src="../../static/imgs/banner.png"></image>
<view class="shop-info" :style="{top: `${menuINfo.top}px`}">
<view class="shop-box" :style="{height: `${menuINfo.height}px`,'line-height': `${menuINfo.height}px`}" @click="changeLocaltion">
<text class="shop-name">{{shopInfo.name}}</text>
<u-icon name="arrow-right" class="arrow-right-select" color="#FFFFFF"></u-icon>
<view class="shop-info" :style="{ top: `${menuINfo.top}px` }">
<view class="shop-box"
:style="{ height: `${menuINfo.height}px`, 'line-height': `${menuINfo.height}px` }"
@click="changeLocaltion">
<text class="shop-name">{{ shopInfo.name }}</text>
<u-icon name="arrow-right" class="arrow-right-select" color="#FFFFFF"></u-icon>
</view>
<view class="distance">距您130m</view>
</view>
<view class="login-area">
<view class="avatar"><image :src="'../../static/logo.png'"></image></view>
<view class="user-info">
<view class="user-name" v-if="userms">HI!{{'我是谁'}}</view>
<view class="user-name" v-else>未登录</view>
<view class="dialog">
<view class="content" v-if="userms">希望你今天,明天,天天都开心~</view>
<view class="content" v-if="!userms">请您尽快登录</view>
</view>
</view>
<!-- <view class="login-btn" v-if="!userms" @click="uniGetUserInfo">立刻登录</view> -->
<button class="login-btn" v-if="!userms" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">立刻登录</button>
</view>
</view>
<view class="order-banner" v-if="buied">
<view class="info">
<view class="first">取单码:Mon999</view>
<view class="second">请您耐心等候,剩余等候时间<text class="time">3</text>分钟</view>
<view class="avatar">
<image :src="'../../static/logo.png'"></image>
</view>
<view class="line"></view>
<view class="barCode-box">
<view class="barCode"><image :src="'../../static/logo.png'"></image></view>
<view class="barCode-dis">点击二维码取单</view>
<view class="user-info">
<view class="user-name" v-if="userms">HI!{{ '我是谁' }}</view>
<view class="user-name" v-else>未登录</view>
<view class="dialog">
<view class="content" v-if="userms">希望你今天,明天,天天都开心~</view>
<view class="content" v-if="!userms">请您尽快登录</view>
</view>
</view>
<button class="login-btn" v-if="!userms" open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber">立刻登录</button>
</view>
<view class="page-body" >
<scroll-view class="nav-left" scroll-y :style="{height:`${height-bannerh}px`}" :scroll-top="scrollLeftTop" scroll-with-animation>
<view class="nav-left-item" @click="categoryClickMain(index)" :key="index" :class="index == categoryActive ? 'active' : ''" v-for="(item, index) in classifyData">
{{ item.name }}
<view :class="index == categoryActive ? 'active-line' : ''"></view>
</view>
<view class="order-banner" v-if="buied">
<view class="info">
<view class="first">取单码:Mon999</view>
<view class="second">请您耐心等候,剩余等候时间<text class="time">3</text>分钟</view>
</view>
</scroll-view>
<scroll-view
class="nav-right"
scroll-y
:scroll-top="scrollTop"
@scroll="scroll"
:style="{height:`${height-bannerh}px`}"
scroll-with-animation
>
<view v-for="(category, index) in classifyData" :key="index" class="box">
<view class="right-title">{{category.name}}</view>
<view class="nav-right-item" v-for="(item, i) in category.goods" :key="item.goodsId" @click="cart(item)">
<image class="thumbnail" :src="item.pics.thumbnail" />
<view class="info">
<view class="goods-name">{{ item.name }}</view>
<view class="tags">
<view class="tag-item" v-for="tag in item.tags" :key="tag">{{tag}}</view>
</view>
<view class="dis-box">
<view class="dis">{{item.desc}}</view>
<view class="add-btn" @click.stop="getallNum(item,category)">+</view>
</view>
<view class="mon">
<view class="discount">{{item.discount}}</view>
<view class="price"><text class="num">{{item.price}}</text></view>
<view class="line"></view>
<view class="barCode-box">
<view class="barCode">
<image :src="'../../static/logo.png'"></image>
</view>
<view class="barCode-dis">点击二维码取单</view>
</view>
</view>
<view class="page-body">
<scroll-view class="nav-left" scroll-y :style="{ height: `${height - bannerh}px` }"
:scroll-top="scrollLeftTop" scroll-with-animation>
<view class="nav-left-item" @click="categoryClickMain(index)" :key="index"
:class="index == categoryActive ? 'active' : ''" v-for="(item, index) in classifyData">
{{ item.name }}
<view :class="index == categoryActive ? 'active-line' : ''"></view>
</view>
</scroll-view>
<scroll-view class="nav-right" scroll-y :scroll-top="scrollTop" @scroll="scroll"
:style="{ height: `${height - bannerh}px` }" scroll-with-animation>
<view v-for="category in classifyData" :key="category.id" class="box">
<view class="right-title">{{ category.name }}</view>
<view class="nav-right-item" v-for="item in category.goods" :key="item.goodsId"
@click="cart(item, category)">
<image class="thumbnail" :src="item.pics.thumbnail" />
<view class="info">
<view class="goods-name">{{ item.name }}</view>
<view class="tags">
<view class="tag-item" v-for="tag in item.tags" :key="tag">{{ tag }}</view>
</view>
<view class="dis-box">
<view class="dis">{{ item.desc }}</view>
<view class="add-btn" @click.stop="getallNum(item, category)">+</view>
</view>
<view class="mon">
<view class="discount">{{ item.discount }}</view>
<view class="price"><text class="num">{{ item.price }}</text></view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<shopCar ref="shopbar"></shopCar>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</scroll-view>
<shopCar ref="shopbar"></shopCar>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</view>
</view>
</template>
<script>
import User from '@/request/user'
import ShopCar from '../../components/shopCar/shopCar.vue'
import Utils from '@/utils/utils'
import Menu from '@/request/menu'
import { $EventBus } from '@/utils/EventBus';
export default {
data() {
return {
orderId:null,// 如果有扫码进来的支付orderId则存入
shopInfo:{name:'请选择'},// 店铺信息
menuINfo:{},
buied: false,//控制首页取单码区域显隐
orderBannerh: 0,
bannerh: 0,
name: "wkiwi",
height: 0,
categoryActive: 0,
scrollTop: 0,
scrollLeftTop: 0,
// scrollHeight: 0,
classifyData: [],
arr: [0, 584, 1168, 1752, 2336, 2805, 3274, 3858, 4442, 4911, 5380, 5734, 6203, 6672, 7017],
leftItemHeight: 51,
navLeftHeight: 0,
diff: 0,
tabBarHeight: 50,
selectedTabbar: 0, //选中的tab
};
},
computed: {
userms() {
let res = this.$store.getters.Authorization;
return res;
}
},
created() {
export default {
components: { ShopCar },
data() {
return {
orderId: null,// 如果有扫码进来的支付orderId则存入
shopInfo: { name: '请选择' },// 店铺信息
menuINfo: {},
buied: false,//控制首页取单码区域显隐
orderBannerh: 0,
bannerh: 0,
name: "wkiwi",
height: 0,
categoryActive: 0,
scrollTop: 0,
scrollLeftTop: 0,
// scrollHeight: 0,
classifyData: [],
arr: [0, 584, 1168, 1752, 2336, 2805, 3274, 3858, 4442, 4911, 5380, 5734, 6203, 6672, 7017],
leftItemHeight: 51,
navLeftHeight: 0,
diff: 0,
tabBarHeight: 50,
selectedTabbar: 0, //选中的tab
};
},
computed: {
userms() {
let res = this.$store.getters.Authorization;
return res;
}
},
created() {
this.getLocation();
this.menuINfo = uni.getMenuButtonBoundingClientRect();
console.log(this.menuINfo,77766)
//如果你的分类数据为后台异步获取请 将下方代码放置你的数据回调中
// this.$nextTick(()=>{
// this.getHeightList();
// })
},
//如果你的分类数据为后台异步获取请 将下方代码放置你的数据回调中
// this.$nextTick(()=>{
// this.getHeightList();
// })
},
async onShow() {
console.log(1243)
// 获取首页菜单数据
let shopInfo = this.$store.getters.shopInfo;
if(shopInfo && shopInfo[0].id){
await this.getMenuList(shopInfo[0].id);
}else{
await this.getMenuList(6);
}
let _this = this;
uni.createSelectorQuery()
.select(".menu-banner")
.boundingClientRect(data => {
_this.bannerh = data.height;
}).exec();
if (this.buied) {
uni.createSelectorQuery()
.select(".order-banner")
.boundingClientRect(data => {
_this.orderBannerh = data.height;
_this.height = uni.getSystemInfoSync().windowHeight - _this.tabBarHeight - _this.orderBannerh;
}).exec();
}
else {
this.height = uni.getSystemInfoSync().windowHeight - this.tabBarHeight;
}
// 获取首页菜单数据
let shopInfo = this.$store.getters.shopInfo;
if (shopInfo && shopInfo[0]?.id) {
await this.getMenuList(shopInfo[0].id);
} else {
await this.getMenuList(12);
}
uni.createSelectorQuery().select(".menu-banner").boundingClientRect(data => {
_this.bannerh = data.height;
}).exec();
if (this.buied) {
uni.createSelectorQuery().select(".order-banner").boundingClientRect(data => {
_this.orderBannerh = data.height;
_this.height = uni.getSystemInfoSync().windowHeight - _this.tabBarHeight - _this.orderBannerh;
}).exec();
}
else {
this.height = uni.getSystemInfoSync().windowHeight - this.tabBarHeight;
}
this.getHeightList();
},
onHide() {
this.$refs.shopbar.showShopCar=false;
this.$refs.shopbar.showShopCar = false;
},
onLoad: async function (options) {
if(options.orderId){
this.orderId=options.orderId;
}
onLoad: async function (options) {
if (options.orderId) { this.orderId = options.orderId; }
$EventBus.$off('getMenuList')
$EventBus.$on('getMenuList',(data)=>{
this.shopInfo=data;
console.log(data,554433)
$EventBus.$on('getMenuList', (data) => {
this.shopInfo = data;
this.getMenuList(data.id)
})
},
onReady() {
},
methods: {
},
onReady() { },
methods: {
// 获取用户授权登录
uniGetUserInfo() {
User.uniGetUserInfo();
},
uniGetUserInfo() { User.uniGetUserInfo(); },
// 手机号授权登录
getPhoneNumber(e) {
if(e.detail.errMsg=='getPhoneNumber:ok'){
User.getPhoneNumber(e,this.orderId);
}else if( e.detail.errMsg=="getPhoneNumber:fail user deny"){
uni.showToast({title:'已拒绝手机号授权',icon:'error'})
if (e.detail.errMsg == 'getPhoneNumber:ok') {
User.getPhoneNumber(e, this.orderId);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' })
}
},
changeLocaltion() {
console.log(22345)
uni.navigateTo({
url:'/menuSubPackage/pages/areaSelect/areaSelect'
})
uni.navigateTo({ url: '/menuSubPackage/pages/areaSelect/areaSelect' })
},
// 获取定位授权
getLocation() {
......@@ -198,28 +182,21 @@ import { $EventBus } from '@/utils/EventBus';
uni.authorize({
scope: 'scope.userLocation',
success: (e) => { //1.1 允许授权
console.log(e,11111)
User.getLocation();
User.getLocation();
},
fail:(err)=> { //1.2 拒绝授权
console.log(err,'拒绝')
fail: (err) => { //1.2 拒绝授权
uni.showModal({
title:'提示',
content:'您已拒绝授权定位,请重新开启',
confirmText:'去开启',
title: '提示',
content: '您已拒绝授权定位,请重新开启',
confirmText: '去开启',
success() {
uni.openSetting({
success(res) {
console.log(res,8877)
if(res.authSetting['scope.userLocation']==true){
User.getLocation();
}
// 如果不设置,res结果:
// {errMsg: "openSetting:ok", authSetting: {scope.userLocation: false}}
// 如果设置, res结果:
// {errMsg: "openSetting:ok", authSetting: {scope.userLocation: true}}
// console.log('小程序设置界面:', res)
}})
uni.openSetting({
success(res) {
if (res.authSetting['scope.userLocation'] == true) {
User.getLocation();
}
}
})
}
})
}
......@@ -231,264 +208,246 @@ import { $EventBus } from '@/utils/EventBus';
})
},
async getMenuList(id) {
let res = await Menu.getMenuList(id);
if(res.data.code ==200){
res.data.data.categorys.forEach(y=>{
y.goods.forEach(v=>{
v.specs=JSON.parse(v.specs);
v.skus.forEach(u=>{u.rules=JSON.parse(u.rules)})
})
})
res.data.data = res.data.data;
console.log(res.data.data,87654567)
this.$store.commit('setMenuAllInfo',res.data.data);
this.classifyData = res.data.data.categorys;
}
let { data } = await Menu.getMenuList(id);
if (data.code == 200) {
data.data = data.data;
this.$store.commit('setMenuAllInfo', data.data);
this.classifyData = data.data.categorys;
}
},
// 加入购物车数据
getallNum(item,category) {
getallNum(item, category) {
let itemCopy = JSON.parse(JSON.stringify(item));
itemCopy.skus = itemCopy.skus.find(v=>v.isDefault==1&&v.state!=2) || itemCopy.skus.find(v=>v.isDefault==0&&v.state!=2);
if(!itemCopy.skus){
uni.showToast({title:'本商品已经售罄',icon:'none'});
return;
}else{
console.log(category,'77777777777777yyyyyyyyyyyyy')
itemCopy.skus=[itemCopy.skus];
itemCopy.num=1;
itemCopy.flag=true;
itemCopy.categoryId=category.id;
itemCopy.goodsName=category.name;
console.log(itemCopy,'mmmmmmm')
Utils.getallNum(itemCopy);
}
// let reItem =[
// {
// goodsId: item.goodsId,
// name: item.name,
// price: item.price,
// discount: item.discount,
// flag:true,
// thumbnail:'https://img2.baidu.com/it/u=1001625387,3275765924&fm=26&fmt=auto&gp=0.jpg',
// num:1,
// rules:JSON.parse(item.skus[0].rules)//这里还要查看是否售罄,如果售罄则取下一个临近的sku
// }
// ]
const sku = itemCopy.skus.find(v => v.isDefault == 1 && v.state != 2) || itemCopy.skus.find(v => v.isDefault == 0 && v.state != 2);
if (!itemCopy.skus) {
uni.showToast({ title: '本商品已经售罄', icon: 'none' });
return;
} else {
itemCopy.skus = [sku];
itemCopy.sku = sku
itemCopy.skuId = sku?.skuId
itemCopy.num = 1;
itemCopy.flag = true;
itemCopy.categoryId = category.id;
itemCopy.goodsName = category.name;
Utils.getallNum(itemCopy);
}
},
getHeightList() {
let _this = this;
let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll(".nav-left-item").boundingClientRect(function (rects) {
_this.leftItemHeight = rects[0].height;
_this.navLeftHeight = _this.leftItemHeight * _this.classifyData.length;
_this.diff = _this.navLeftHeight; //- _this.height
});
selectorQuery.selectAll(".box").boundingClientRect(function (rects) {
let arr = [0], top = 0;
rects.forEach(function (rect) {
top += rect.height;
arr.push(top);
});
_this.arr = arr;
}).exec();
},
scroll(e) {
let _this = this;
if (this.timeoutId) { clearTimeout(this.timeoutId) }
this.timeoutId = setTimeout(function () {//节流
_this.scrollHeight = e.detail.scrollTop + 1 + _this.height / 2;
//+1不要删除,解决最后一项某种情况下翻到底部,左边按钮并不会切换至最后一个
//若想使切换参考线为屏幕顶部请删除 _this.height/2
for (let i = 0; i < _this.arr.length; i++) {
let height1 = _this.arr[i];
let height2 = _this.arr[i + 1];
if (!height2 || (_this.scrollHeight >= height1 && _this.scrollHeight < height2)) {
_this.categoryActive = i;
_this.diff > 0 && (_this.scrollLeftTop = Math.round((_this.categoryActive * _this.diff) / (_this.classifyData.length)));
return false;
}
}
_this.categoryActive = 0;
_this.timeoutId = undefined;
}, 0);
},
getHeightList() {
let _this = this;
let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll(".nav-left-item").boundingClientRect(function (rects) {
_this.leftItemHeight = rects[0].height;
_this.navLeftHeight = _this.leftItemHeight * _this.classifyData.length;
_this.diff = _this.navLeftHeight; //- _this.height
});
selectorQuery
.selectAll(".box")
.boundingClientRect(function (rects) {
let arr = [0];
let top = 0;
rects.forEach(function (rect) {
// rect.id // 节点的ID
// rect.dataset // 节点的dataset
// rect.left // 节点的左边界坐标
// rect.right // 节点的右边界坐标
// rect.top // 节点的上边界坐标
// rect.bottom // 节点的下边界坐标
// rect.width // 节点的宽度
// rect.height // 节点的高度
top += rect.height;
arr.push(top);
});
console.log(arr);
_this.arr = arr;
})
.exec();
},
scroll(e) {
let _this = this;
if (this.timeoutId) {
clearTimeout(this.timeoutId);
}
this.timeoutId = setTimeout(function () {
//节流
_this.scrollHeight = e.detail.scrollTop + 1 + _this.height / 2;
//+1不要删除,解决最后一项某种情况下翻到底部,左边按钮并不会切换至最后一个
//若想使切换参考线为屏幕顶部请删除 _this.height/2
for (let i = 0; i < _this.arr.length; i++) {
let height1 = _this.arr[i];
let height2 = _this.arr[i + 1];
if (!height2 || (_this.scrollHeight >= height1 && _this.scrollHeight < height2)) {
_this.categoryActive = i;
_this.diff > 0 && (_this.scrollLeftTop = Math.round((_this.categoryActive * _this.diff) / (_this.classifyData.length)));
return false;
}
}
_this.categoryActive = 0;
_this.timeoutId = undefined;
}, 0);
},
categoryClickMain(index) {
this.categoryActive = index;
this.scrollTop == this.arr[index] ? (this.scrollTop = this.scrollTop + 1) : (this.scrollTop = this.arr[index]); //防止两次相等造成点击不触发滚动时间
},
cart: function (text) {
uni.navigateTo({url:'/menuSubPackage/pages/goodsDetail/goodsDetail'})
// uni.showToast({
// title: text,
// icon: "none"
// });
}
},
components: { ShopCar }
categoryClickMain(index) {
this.categoryActive = index;
this.scrollTop == this.arr[index] ? (this.scrollTop = this.scrollTop + 1) : (this.scrollTop = this.arr[index]); //防止两次相等造成点击不触发滚动时间
},
cart: (item, category) => {
uni.setStorageSync('goodsInfo', JSON.stringify({ ...item, category }));
uni.navigateTo({ url: '/menuSubPackage/pages/goodsDetail/goodsDetail' })
}
},
}
</script>
<style lang="scss">
.menu-box{
.shop-info{
.menu-box {
.shop-info {
position: absolute;
left: 32rpx;
color: #FFFFFF;
.shop-box{
min-width:300rpx;
font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
display: flex;
.shop-name{
flex: 1;
.shop-box {
min-width: 300rpx;
font-size: 28rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
display: flex;
.shop-name {
flex: 1;
}
.arrow-right-select {
width: 9rpx;
}
}
.arrow-right-select{
width:9rpx;
.distance {
height: 46rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
line-height: 42rpx;
}
}
.distance{
height: 46rpx;
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
line-height: 42rpx;
}
}
}
.menu-banner{
.menu-banner {
height: 376rpx;
position:relative;
image{
position: relative;
image {
width: 100%;
height: 376rpx;
}
.login-area{
display: flex;
width:624rpx;
height: 88rpx;
padding: 20rpx 22rpx;
background: rgba(255, 255, 255, 0.2);
box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(0,0,0,0.1);
border-radius: 10rpx;
backdrop-filter: blur(10rpx);
position: absolute;
z-index: 1;
bottom: 0;
left: 64rpx;
box-sizing: border-box;
.avatar{
display: flex;
.login-area {
display: flex;
width: 624rpx;
height: 88rpx;
padding: 20rpx 22rpx;
background: rgba(255, 255, 255, 0.2);
box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(0, 0, 0, 0.1);
border-radius: 10rpx;
backdrop-filter: blur(10rpx);
position: absolute;
z-index: 1;
bottom: 0;
left: 64rpx;
box-sizing: border-box;
.avatar {
display: flex;
justify-items: center;
align-items: center;
background: red;
width: 50rpx;
width: 50rpx;
height: 48rpx;
margin-right: 22rpx;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(50,50,50,0.25);
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(50, 50, 50, 0.25);
border-radius: 4rpx;
image{
width:100%;
image {
width: 100%;
height: 100%;
};
}
.user-info{
flex: 1;
.user-name{
height: 28rpx;
}
;
}
.user-info {
flex: 1;
.user-name {
height: 28rpx;
font-size: 20rpx;
font-family: ArialMT;
color: #FFFFFF;
line-height: 22rpx;
}
.dialog{
display: flex;
height: 22rpx;
}
.dialog {
display: flex;
height: 22rpx;
font-size: 16rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #FFFFFF;
line-height: 22rpx;
.content{
flex: 1;
.content {
flex: 1;
}
.arrow{
width:10rpx;
.arrow {
width: 10rpx;
height: 12px;
display: flex;
display: flex;
font-size: 20rpx;
justify-content: center;
align-items: center;
}
}
}
.login-btn{
// width: 114rpx;
height: 48rpx;
background: #006ECF;
border-radius: 4rpx;
font-size: 20rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
line-height: 48rpx;
text-align: center;
}
}
}
.login-btn {
// width: 114rpx;
height: 48rpx;
background: #006ECF;
border-radius: 4rpx;
font-size: 20rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFFFFF;
line-height: 48rpx;
text-align: center;
}
}
}
}
.order-banner{
.order-banner {
width: 686rpx;
height: 179rpx;
background: #FFFFFF;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(166,166,166,0.5);
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(166, 166, 166, 0.5);
border-radius: 10rpx;
box-sizing: border-box;
position: relative;
left:32rpx;
top:-8rpx;
left: 32rpx;
top: -8rpx;
z-index: 1;
display: flex;
.info{
.info {
padding-left: 32rpx;
flex: 1;
.first{
height: 44rpx;
.first {
height: 44rpx;
font-size: 32rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #323232;
line-height: 44rpx;
margin-top:40rpx;
line-height: 44rpx;
margin-top: 40rpx;
}
.second{
margin-top:20rpx;
.second {
margin-top: 20rpx;
height: 34rpx;
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #323232;
line-height: 34rpx;
.time{
.time {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
......@@ -497,33 +456,38 @@ import { $EventBus } from '@/utils/EventBus';
}
}
}
.line{
width:0;
.line {
width: 0;
height: 104rpx;
border-right: 4rpx solid #006ECF;
position: absolute;
right:188rpx;
right: 188rpx;
top: 36rpx;
}
.barCode-box{
.barCode-box {
margin-top: 30rpx;
width:150rpx;
width: 150rpx;
height: 122rpx;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
flex-direction: column;
.barCode{
width:86rpx;
.barCode {
width: 86rpx;
height: 86rpx;
background:#006ECF;
image{
width:100%;
background: #006ECF;
image {
width: 100%;
height: 100%;
}
}
.barCode-dis{
.barCode-dis {
text-align: center;
margin-top: 14rpx;
font-size: 16rpx;
......@@ -534,11 +498,13 @@ import { $EventBus } from '@/utils/EventBus';
}
}
}
.page-body {
display: flex;
background: #fff;
overflow: hidden;
}
.nav {
display: flex;
width: 100%;
......@@ -547,7 +513,7 @@ import { $EventBus } from '@/utils/EventBus';
.nav-left {
width: 152rpx;
background: #fff;
border-right:2rpx solid #D5D5D5;
border-right: 2rpx solid #D5D5D5;
}
.nav-left-item {
......@@ -562,25 +528,30 @@ import { $EventBus } from '@/utils/EventBus';
align-items: center;
justify-content: center;
}
.nav-left-item:last-child {
border-bottom: none;
}
.nav-right {
width: 596rpx;
}
.box {
display: block;
overflow: hidden;
/* min-height: 100vh; */
/*若您的子分类过少想使得每个子分类占满屏请放开上边注视 */
}
.box:last-child {
border: none;
// min-height: 100vh;
}
.right-title{
.right-title {
padding-left: 28rpx;
margin-bottom:40rpx;
margin-bottom: 40rpx;
height: 44rpx;
font-size: 32rpx;
font-family: PingFangSC-Semibold, PingFang SC;
......@@ -588,22 +559,27 @@ import { $EventBus } from '@/utils/EventBus';
color: #000000;
line-height: 44rpx;
}
.nav-right-item {
display: flex;
padding: 0rpx 36rpx 0rpx 42rpx;
margin-bottom:50rpx;
margin-bottom: 50rpx;
height: 162rpx;
background: #fff;
.thumbnail{//缩略图
.thumbnail {
//缩略图
display: flex;
align-items: center;
width:140rpx;
width: 140rpx;
height: 140rpx;
margin-right:34rpx;
margin-right: 34rpx;
}
.info{
.info {
flex: 1;
.goods-name{
.goods-name {
height: 40rpx;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
......@@ -611,12 +587,13 @@ import { $EventBus } from '@/utils/EventBus';
color: #000000;
line-height: 40rpx;
}
.tags{
.tag-item{
height: 24rpx;
.tags {
.tag-item {
height: 24rpx;
border-radius: 4rpx;
border: 2rpx solid #006ECF;
margin-right:10rpx;
margin-right: 10rpx;
padding: 4rpx 6rpx;
font-size: 16rpx;
font-family: ArialMT;
......@@ -625,32 +602,36 @@ import { $EventBus } from '@/utils/EventBus';
display: inline-block;
}
}
.dis-box{
.dis-box {
display: flex;
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
line-height: 40rpx;
.dis{
flex: 1;
.dis {
flex: 1;
}
.add-btn {
width:40rpx;
height: 40rpx;
border-radius: 50%;
background: #006ECF;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 36rpx;
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background: #006ECF;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 36rpx;
}
}
.mon{
.discount{
.mon {
.discount {
display: inline-block;
height: 32rpx;
height: 32rpx;
font-size: 24rpx;
font-family: Arial-BoldMT, Arial;
font-weight: normal;
......@@ -658,19 +639,21 @@ import { $EventBus } from '@/utils/EventBus';
line-height: 32rpx;
margin-right: 6rpx;
}
.price{
.price {
display: inline-block;
height: 22rpx;
height: 22rpx;
font-size: 20rpx;
font-family: ArialMT;
color: #666666;
line-height: 22rpx;
.num{
text-decoration:line-through;
.num {
text-decoration: line-through;
}
}
}
}
}
......@@ -685,15 +668,18 @@ import { $EventBus } from '@/utils/EventBus';
color: #000000;
background: #fff;
}
.active-line{
.active-line {
height: 170rpx;
width:2rpx;
width: 2rpx;
position: absolute;
right:-2rpx;
right: -2rpx;
top: 0;
z-index: 1;
border-right:4rpx solid #006ECF;;
border-right: 4rpx solid #006ECF;
;
}
::-webkit-scrollbar {
/*取消小程序的默认导航条样式*/
width: 0;
......
<template>
<view>
<view class="pages">
<view class="menu-banner">
<view class="log">
<image class="logImg" src="/static/imgs/hooloo.png"></image>
<view class="logText">未 来 咖 啡</view>
</view>
<image src="../../static/imgs/banner.png"></image>
</view>
<view class="mod11 flex-col">
<view class="box16 flex-col"></view>
<text class="txt6">小黑山羊</text>
<view class="right_arrow">
<u-icon name="arrow-right" color="#fff" size="14"></u-icon>
</view>
</view>
<view class="contents">
<view class="myOrder">
<view class="order1">我的订单</view>
<view class="order2">点击查看订单</view>
<view>
<image class="orderImg" src="../../static/imgs/myOrder.png">
</image>
</view>
</view>
<view class="right_box">
<view class="box">
<view class="left">
<h3>HOOLOO券</h3>
<view class="dec">优惠多多不要错过</view>
</view>
<view class="right">
<image class="right_img" src="../../static/imgs/my3.png"></image>
</view>
</view>
<view class="box two">
<view class="left">
<h3>我的消息</h3>
<view class="dec">点击查看我的消息</view>
</view>
<view class="right">
<image class="right_img" src="../../static/imgs/myMail.png"></image>
</view>
</view>
</view>
</view>
<view class="function">
<h3>常用功能</h3>
<view class="function_item">
<u-icon name="server-fill" color="#000000" size="16"></u-icon>
<text class="function_item_text">联系客服</text>
<u-icon name="arrow-right" class="function_item_icon" color="#000000" size="16"></u-icon>
</view>
</view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</template>
......@@ -36,7 +81,7 @@ export default {
.log {
position: absolute;
z-index: 99;
top: 100rpx;
left: 30rpx;
......@@ -62,4 +107,158 @@ export default {
}
}
.mod11 {
margin: 0 auto;
width: 692rpx;
height: 144rpx;
background: rgba(255, 255, 255, 0.2);
border-radius: 10rpx;
backdrop-filter: blur(10rpx);
display: flex;
align-items: center;
margin-top: -72rpx;
padding: 0 30rpx;
box-sizing: border-box;
color: #fff;
.right_arrow {
margin-left: auto;
}
.txt6 {
margin-left: 20rpx;
}
.box16 {
width: 80rpx;
height: 80rpx;
background: #FF72C1;
box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(50, 50, 50, 0.25);
border-radius: 4rpx;
}
}
.contents {
display: flex;
align-items: center;
margin: 34rpx auto;
width: 692rpx;
.myOrder {
width: 270rpx;
height: 272rpx;
background: #FFFFFF;
border-radius: 10rpx;
text-align: center;
.order1 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
margin-top: 25rpx;
}
.order2 {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #323232;
margin-top: 10rpx;
}
.orderImg {
width: 70rpx;
height: 80rpx;
margin: 0 auto;
margin-top: 50rpx;
}
}
.right_box {
margin-left: 20rpx;
}
.box {
width: 396rpx;
height: 128rpx;
background: #FFFFFF;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 36rpx;
&.two {
margin-top: 15rpx;
}
.left {
text-align: center;
}
h3 {
font-size: 28rpx;
font-family: Arial-BoldMT, Arial;
font-weight: 700;
color: #000000;
}
.dec {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #323232;
margin-top: 10rpx
}
.right_img {
width: 80rpx;
height: 55rpx;
}
}
}
.function {
width: 692rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 0 auto;
padding: 25rpx;
box-sizing: border-box;
h3 {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.function_item {
font-size: 24rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
line-height: 34rpx;
display: flex;
align-items: center;
margin-top: 20rpx;
.function_item_text {
margin-left: 10rpx;
}
.function_item_icon {
margin-left: auto;
}
}
}
</style>
\ No newline at end of file
<template>
<view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
<view class="pages">
<view class="orders">
<view class="order_item" v-for="item in list" :key="item.id" @click="openInfo(item)">
<view class="order_header">
<view>
<h3 class="order_adrass">{{ item.shop.name }}</h3>
<text class="order_time">{{ item.shop.payTime }}</text>
</view>
<view class="order_status" v-if="item.state == 0">创建未校验</view>
<view class="order_status" v-if="item.state == 1">未支付</view>
<view class="order_status" v-if="item.state == 2">排队中</view>
<view class="order_status" v-if="item.state == 3">制作中</view>
<view class="order_status" v-if="item.state == 4">制作完成</view>
<view class="order_status" v-if="item.state == 5">待取超时</view>
<view class="order_status" v-if="item.state == 6">完成</view>
<view class="order_status" v-if="item.state == 7">取消</view>
<view class="order_status" v-if="item.state == 8">取消</view>
<view class="order_status" v-if="item.state == 9">取消</view>
<view class="order_status" v-if="item.state == 10">取消</view>
<view class="order_status" v-if="item.state == 11">已退款</view>
<view class="order_status" v-if="item.state == 12">部分退款</view>
</view>
<view class="order_content">
<view class="goods_item" v-for="good in item.orderDetails" :key="good.id">
<image class="goods_img" :src="jsonParse(good.goods.pics).thumbnail"></image>
<view class="goods_text">
<view class="goods_title">{{ good.goodsName }}×{{ good.num }}</view>
<view class="goods_spce">
<span v-for="rule in jsonParse(good.specRuleDetail)" :key="rule.specId">
{{ rule.ruleName }}/
</span>
</view>
</view>
</view>
</view>
<view class="order_footer">
<view class="total">
共1件商品 合计: <text class="price">¥10.00</text>
</view>
<!-- <a class="btn" type="primary">再来一单</a> -->
</view>
</view>
</view>
<tabBar :selectedTabbar="selectedTabbar"></tabBar>
</view>
</template>
<script>
export default {
name:'order',
data() {
return {
selectedTabbar:1,//选中的tab
}
},
computed:{
import order from '@/request/order'
export default {
name: 'order',
data() {
return {
selectedTabbar: 1,//选中的tab
list: []
}
},
async onLoad() {
const { data } = await order.getMyOrder();
this.list = data.rows
},
async onShow() {
const { data } = await order.getMyOrder();
this.list = data.rows
},
methods: {
openInfo(data) {
uni.setStorageSync('orderInfo', data);
let url = '/orderSubPackage/pages/orderInfo/index'
// : '/orderSubPackage/pages/settlement/index'
uni.navigateTo({ url })
},
methods: {
jsonParse(json) {
return JSON.parse(json)
}
}
}
</script>
<style>
<style lang="scss" scoped>
.orders {
padding: 1rpx;
.order_item {
width: 686rpx;
min-height: 370rpx;
background: #FFFFFF;
border-radius: 10rpx;
margin: 15rpx auto 0;
box-sizing: border-box;
padding: 28rpx 32rpx;
.order_header {
display: flex;
justify-content: space-between;
.order_adrass {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
}
.order_time {
font-size: 20rpx;
font-family: ArialMT;
color: #666666;
}
.order_status {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 500;
color: #000000;
margin-top: 10rpx;
}
}
.order_content {
margin-top: 38rpx;
.goods_item {
display: flex;
align-items: center;
margin-top: 10rpx;
.goods_img {
height: 80rpx;
width: 80rpx;
background-color: #eee;
}
.goods_text {
margin-left: 38rpx;
.goods_title {
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600;
color: #000000;
}
.goods_spce {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
margin-top: 6rpx;
}
}
}
}
.order_footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 50rpx;
.total {
font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
.price {
color: #FF5200;
font-weight: 700
}
}
.btn {
width: 144rpx;
height: 48rpx;
line-height: 48rpx;
background: #006ECF;
border-radius: 6rpx;
font-size: 24rpx;
margin: 0;
color: #fff;
text-align: center;
}
}
}
</style>
}
</style>
\ No newline at end of file
import appConfig from '@/static/config/index.js';
export function getBaseUrl() {
if (process.env.NODE_ENV === 'development') {
console.log(121)
return appConfig.devApi;
} else {
return appConfig.prodApi;
}
if (process.env.NODE_ENV === 'development') {
return appConfig.devApi;
} else {
return appConfig.prodApi;
}
}
module.exports = (vm) => {
console.log(vm.$store)
uni.$u.http.setConfig((config) => {
config.baseURL= getBaseUrl();
uni.$u.http.setConfig((config) => {
config.baseURL = getBaseUrl();
// showLoading: process.env.NODE_ENV === 'development',
config.method= 'POST';
config.method = 'POST';
// 设置为json,返回后会对数据进行一次JSON.parse()
config.dataType = 'json';
config.timeout = 3000; // 在此时间内,请求还没回来的话,就显示加载中动画,单位ms
// 配置请求头信息
config.header= {
'Content-Type': 'application/json' // 'application/x-www-form-urlencoded'
}
config.header = {
'Content-Type': 'application/json', // 'application/x-www-form-urlencoded'
};
return config;
});
// 请求拦截
uni.$u.http.interceptors.request.use((config) => { // 可使用async await 做异步操作
uni.showLoading({
});
// 请求拦截
uni.$u.http.interceptors.request.use(
(config) => {
// 可使用async await 做异步操作
uni.showLoading({
title: '加载中',
mask: true,
});
let Authorization = uni.getStorageSync(`Authorization`);
if (Authorization && config.url == '/order') {
config.header.Authorization = Authorization;
}
console.log(config,4444)
if (!Authorization) { // 如果token不存在,return Promise.reject(config) 会取消本次请求
// return Promise.reject(config);
});
let Authorization = uni.getStorageSync(`Authorization`);
const configUrl = [
'/weixin/login',
'/weixin/getShop',
'/weixin/infoByShop',
'/application/getData',
];
if (Authorization && configUrl.indexOf(config.url) == -1) {
config.header.Authorization = Authorization;
}
console.log(config, 4444);
if (!Authorization) {
// 如果token不存在,return Promise.reject(config) 会取消本次请求
// return Promise.reject(config);
}
return config;
},
(config) => {
// 可使用async await 做异步操作
return Promise.reject(config);
}
return config
}, config => { // 可使用async await 做异步操作
return Promise.reject(config)
});
// 响应拦截
uni.$u.http.interceptors.response.use((response) => {
uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) { // 服务端返回的状态码不等于200,则reject()
);
// 响应拦截
uni.$u.http.interceptors.response.use(
(response) => {
uni.hideLoading();
/* 对响应成功做点什么 可使用async await 做异步操作*/
if (response.data.code !== 200) {
// 服务端返回的状态码不等于200,则reject()
uni.showToast({
title: response.data.msg,
icon: 'none',
duration: 2000
})
return Promise.reject(response)
} // return Promise.reject 可使promise状态进入catch
console.log(response)
return response
}, (response) => {
uni.hideLoading();
/* 对响应错误做点什么 (statusCode !== 200)*/
console.log(response)
return Promise.reject(response)
});
}
\ No newline at end of file
title: response.data.msg,
icon: 'none',
duration: 2000,
});
return Promise.reject(response);
} // return Promise.reject 可使promise状态进入catch
return response;
},
(response) => {
uni.hideLoading();
/* 对响应错误做点什么 (statusCode !== 200)*/
console.log(response);
return Promise.reject(response);
}
);
};
export default{
valiFrequency(id) {
}
}
\ No newline at end of file
export default {
getMyOrder() {
return uni.$u.http
.get('/app/getMyOrder', {
params: {},
})
.then((res) => res)
.catch((err) => uni.showToast({ title: '服务器错误', icon: 'none' }));
},
orderRefund(data) {
return uni.$u.http
.post('/system/refund', data)
.then((res) => res)
.catch((err) => uni.showToast({ title: '服务器错误', icon: 'none' }));
},
};
import Store from '@/store'
import Store from '@/store';
import { $EventBus } from '../../utils/EventBus';
export default{
getLocation() {
let _this = this;
return uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
success: function (res) {
console.log(res, 'res')
var params = {
lat: res.latitude,
lng: res.longitude
}
Store.commit('saveLocation',params);
// return params;
_this.getAddress(params);
},
fail: function (res) {
console.log(res,3333)
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none'
});
}
})
},
// 获取具体位置店铺/weixin/getShop
getAddress(params) {
return uni.$u.http.get('/weixin/getShop',{
params
}).then((res)=>{
if(res.data.code==200){
console.log(res.data.data,12345678)
Store.commit('saveShopInfo', res.data.data);
if (res.data.data.length){
$EventBus.$emit('getMenuList', res.data.data[0])
}
}
return res;
}).catch(err=>{
return err;
});
},
// 通过地址选择店铺xxxx
// getAddress(params) {
// return uni.$u.http.get('/weixin/getShop', {
// params
// }).then((res) => {
// if (res.data.code == 200) {
// console.log(res.data.data, 12345678)
// Store.commit('saveShopInfo', res.data.data);
// }
// return res;
// }).catch(err => {
// return err;
// });
// },
uniLogin(res,orderId) {
uni.login({
provider: 'weixin',
success: function (data) {
// 传给后台接口所需登录数据
uni.$u.http.post('/weixin/login', {
code: data.code,
source: 3, //默认是3,扫码进来是2
iv: res.iv,
encryptedData: res.encryptedData
}).then((response) => {
if (response.statusCode == 200 && response.data && response.data.code==200) {
uni.setStorage({key:'Authorization',data:response.data.token});
Store.commit('setAuthorization', response.data.token);
uni.showToast({
title:'登录成功',
success() {
setTimeout(()=>{
// 如果扫码进来的带有orderId则授权成功之后跳入结算页面
if (orderId) {
uni.navigateTo({
url: '/menuSubPackage/pages/settlement/settlement?orderId=' + orderId
})
}
},1500)
}
});
}
}).catch((err) => {
uni.showToast({
title: err.msg
});
})
}
})
},
// 手机号授权登录
getPhoneNumber(res,orderId) {
console.log(res,'还是手机号参数吗')
uni.setStorage({
key: 'userPhoneInfo',
data: res
})
Store.commit("setUserPhoneInfo", res);
this.uniLogin(res.detail,orderId);
},
async uniGetUserInfo(e) {
uni.getUserProfile({ //授权后可以通过uni.getUserProfile得到用户信息
lang: "zh_CN",
desc: '用于完善用户信息',
success: res => {
uni.setStorage({key:'userInfo', data:res})
Store.commit("setUserInfo",res)
// this.uniLogin(res);
export default {
getLocation() {
let _this = this;
return uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度
success: function (res) {
console.log(res, 'res');
var params = {
lat: res.latitude,
lng: res.longitude,
};
Store.commit('saveLocation', params);
// return params;
_this.getAddress(params);
},
fail: function (res) {
console.log(res, 3333);
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none',
});
},
});
},
// 获取具体位置店铺/weixin/getShop
getAddress(params) {
return uni.$u.http
.get('/weixin/getShop', {
params,
})
.then((res) => {
if (res.data.code == 200) {
console.log(res.data.data, 12345678);
Store.commit('saveShopInfo', res.data.data);
if (res.data.data.length) {
$EventBus.$emit('getMenuList', res.data.data[0]);
}
}
return res;
})
.catch((err) => {
return err;
});
},
// 通过地址选择店铺xxxx
// getAddress(params) {
// return uni.$u.http.get('/weixin/getShop', {
// params
// }).then((res) => {
// if (res.data.code == 200) {
// console.log(res.data.data, 12345678)
// Store.commit('saveShopInfo', res.data.data);
// }
// return res;
// }).catch(err => {
// return err;
// });
// },
uniLogin(res, orderId) {
uni.login({
provider: 'weixin',
success: function (data) {
// 传给后台接口所需登录数据
uni.$u.http
.post('/weixin/login', {
code: data.code,
source: 3, //默认是3,扫码进来是2
iv: res.iv,
encryptedData: res.encryptedData,
})
.then((response) => {
if (response.statusCode == 200 && response.data && response.data.code == 200) {
uni.setStorage({ key: 'Authorization', data: response.data.token });
Store.commit('setAuthorization', response.data.token);
uni.showToast({
title: '登录成功',
success() {
setTimeout(() => {
// 如果扫码进来的带有orderId则授权成功之后跳入结算页面
if (orderId) {
uni.navigateTo({
url: '/menuSubPackage/pages/settlement/settlement?orderId=' + orderId,
});
} else {
}
})
}, 1500);
},
});
}
}
\ No newline at end of file
})
.catch((err) => {
uni.showToast({
title: err.msg,
});
});
},
});
},
// 手机号授权登录
getPhoneNumber(res, orderId) {
uni.setStorage({
key: 'userPhoneInfo',
data: res,
});
Store.commit('setUserPhoneInfo', res);
this.uniLogin(res.detail, orderId);
},
async uniGetUserInfo(e) {
uni.getUserProfile({
//授权后可以通过uni.getUserProfile得到用户信息
lang: 'zh_CN',
desc: '用于完善用户信息',
success: (res) => {
uni.setStorage({ key: 'userInfo', data: res });
Store.commit('setUserInfo', res);
// this.uniLogin(res);
},
});
},
};
import Config from '../static/config/index.js';
import WXBizDataCrypt from "./WXBizDataCrypt.js";
import {$EventBus} from './EventBus'
import Store from '@/store'
export default{
// 组装提交订单数据
AssemblyOrder(totalPrice, totalNum) {
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v => v.flag == true);
if (shopCarInfo && totalPrice > 0 && totalNum > 0) {
let orderDetails = [];
for (let i = 0; i < shopCarInfo.length; i++) {
let item = shopCarInfo[i];
let res = {
goodsId: item.goodsId, //商品id
goodsName: item.name, //商品名称
machineId: undefined, //点单屏机器ID
num: item.num, //当前sku数量
realAmount: item.skus[0].price * item.num, //实付金额
specRuleDetail: JSON.stringify(item.skus[0].rules), //规格选项详情
skuId: item.skus[0].skuId, //"sku ID"
goodsCategory: item.categoryId //商品分类
};
orderDetails.push(res);
}
let DAta = {
amount: totalPrice, //商品总金额
goodsNum: totalNum, //商品总数量
shopId: Store.getters.shopInfo[0].id, //店铺
machineId: undefined, //机器ID
source: 3, //小程序固定传3
orderDetails: orderDetails
}
return DAta;
} else {
uni.showToast({
title: '请选择商品'
})
}
},
// 加入购物车数据
getallNum(Obj){
let shopCarInfo = uni.getStorageSync('shopCarInfo');
let s = 0;
shopCarInfo.forEach(function (val) {
s += val.num;
}, 0);
if (s >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none'
});
return;
}
console.log(shopCarInfo,'oooooo')
if (shopCarInfo){
let currentGoods = shopCarInfo.find(v => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId);
if (currentGoods){
console.log(currentGoods,'pppppp')
currentGoods.num+=1;
}else{
shopCarInfo.push(Obj);
}
console.log(shopCarInfo,7777)
}else{
shopCarInfo = [Obj];
}
uni.setStorageSync('shopCarInfo', shopCarInfo);
$EventBus.$emit('updateCar');
},
// 解密手机
async onGetPhoneNumber(appid,session_key,encryptedData,iv) {
let pc = await new WXBizDataCrypt(appid,session_key);
let data = await pc.decryptData(encryptedData ,iv);
return data;
},
// 扫码方法
scanCode() {
uni.scanCode({
success:(res)=> {
this.scaninfo=res;
if(res.result){//res.result
if(res.result.includes(Config.AVScanUrl)){
uni.reLaunch({
url:`/pages/index/index?q=${res.result}`
})
}else{
uni.showToast({
title:'二维码错误',
icon:'none'
})
}
// '0016429'||
// `../pages/index/index`
// console.log(res.result,'内部扫码')
}
},
fail() {
uni.showToast({
icon:'none',
title:'扫码失败'
})
}
});
},
formatDate(value) {
var date = new Date();
date.setTime(value);
var month = date.getMonth() + 1;
if (month < 10)
month = "0" + month;
var cdate = date.getDate();
if (cdate < 10)
cdate = "0" + cdate;
var hours = date.getHours();
if (hours < 10)
hours = "0" + hours;
var minutes = date.getMinutes();
if (minutes < 10)
minutes = "0" + minutes;
var time = date.getFullYear() + "-" + month + "-" + cdate +
" " + hours + ":" + minutes;
return time;
},
numberFixed(data,fixed=2){
if(data==undefined){
return undefined
}else if(data == 0){
return '0'
}else{
return (Math.round(Number(data) * Math.pow(10,fixed)) / Math.pow(10,fixed)).toFixed(fixed);
}
}
}
\ No newline at end of file
import WXBizDataCrypt from './WXBizDataCrypt.js';
import { $EventBus } from './EventBus';
import Store from '@/store';
export default {
// 组装提交订单数据
AssemblyOrder(totalPrice, totalNum) {
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter((v) => v.flag == true);
if (shopCarInfo && totalPrice > 0 && totalNum > 0) {
let orderDetails = [];
for (let i = 0; i < shopCarInfo.length; i++) {
let item = shopCarInfo[i];
let res = {
goodsId: item.goodsId, //商品id
goodsName: item.name, //商品名称
machineId: undefined, //点单屏机器ID
num: item.num, //当前sku数量
realAmount: item.sku.discount * item.num, //实付金额
specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情
specRuleIds: item.sku.rules.map((item) => item.ruleId).join(','), //规格选项详情
skuId: item.skuId, //"sku ID"
goodsCategory: item.categoryId, //商品分类
};
orderDetails.push(res);
}
let DAta = {
amount: totalPrice, //商品总金额
goodsNum: totalNum, //商品总数量
shopId: '12', //店铺
machineId: undefined, //机器ID
source: 3, //小程序固定传3
orderDetails: orderDetails,
};
return DAta;
} else {
uni.showToast({
title: '请选择商品',
});
}
},
// 加入购物车数据
getallNum(Obj) {
let shopCarInfo = uni.getStorageSync('shopCarInfo') || [];
let size = 0;
shopCarInfo.forEach((item) => (size += item.num), 0);
if (size >= 9) {
uni.showToast({
title: '最多可一次购买9杯',
icon: 'none',
});
return;
}
if (shopCarInfo) {
let currentGoods = shopCarInfo.find((v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId);
if (currentGoods) {
currentGoods.num += 1;
} else {
shopCarInfo.push(Obj);
}
} else {
shopCarInfo = [Obj];
}
uni.setStorageSync('shopCarInfo', shopCarInfo);
console.log(shopCarInfo);
$EventBus.$emit('updateCar');
},
// 解密手机
async onGetPhoneNumber(appid, session_key, encryptedData, iv) {
let pc = await new WXBizDataCrypt(appid, session_key);
let data = await pc.decryptData(encryptedData, iv);
return data;
},
// 扫码方法
scanCode() {
uni.scanCode({
success: (res) => {
this.scaninfo = res;
if (res.result) {
if (res.result.includes(Config.AVScanUrl)) {
uni.reLaunch({
url: `/pages/index/index?q=${res.result}`,
});
} else {
uni.showToast({
title: '二维码错误',
icon: 'none',
});
}
}
},
fail() {
uni.showToast({
icon: 'none',
title: '扫码失败',
});
},
});
},
formatDate(value) {
var date = new Date();
date.setTime(value);
var month = date.getMonth() + 1;
if (month < 10) month = '0' + month;
var cdate = date.getDate();
if (cdate < 10) cdate = '0' + cdate;
var hours = date.getHours();
if (hours < 10) hours = '0' + hours;
var minutes = date.getMinutes();
if (minutes < 10) minutes = '0' + minutes;
var time = date.getFullYear() + '-' + month + '-' + cdate + ' ' + hours + ':' + minutes;
return time;
},
numberFixed(data, fixed = 2) {
if (data == undefined) {
return undefined;
} else if (data == 0) {
return '0';
} else {
return (Math.round(Number(data) * Math.pow(10, fixed)) / Math.pow(10, fixed)).toFixed(fixed);
}
},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment