Commit 55374e15 by 宋冰琦

修改toast文案 修改头像昵称获取方式

parent 546e7ac8
<template> <template>
<view class="page-body"> <view class="page-body">
<scroll-view class="nav-left" :style="[heightStyle]" :class="[shopCarFlag?'shopCarcss':'' ]" scroll-y :scroll-top="scrollLeftTop" scroll-with-animation> <scroll-view
<view class="nav-left-item" v-for="(item,index) in classifyData" @click="categoryClickMain(item.id)" :key="item.id" class="nav-left"
:class="item.id == categoryId ? 'active' : ''" :style="[scrollBottom]"> :style="[heightStyle]"
<view class="imgbox" v-if="item.icon&&sizeList[index].width"> :class="[shopCarFlag ? 'shopCarcss' : '']"
<image :style="{'height':sizeList[index].height+'rpx','width':sizeList[index].width+'rpx'}" :src="item.icon"/> scroll-y
:scroll-top="scrollLeftTop"
scroll-with-animation
>
<view
class="nav-left-item"
v-for="(item, index) in classifyData"
@click="categoryClickMain(item.id)"
:key="item.id"
:class="item.id == categoryId ? 'active' : ''"
:style="[scrollBottom]"
>
<view class="imgbox" v-if="item.icon && sizeList[index].width">
<image
:style="{
height: sizeList[index].height + 'rpx',
width: sizeList[index].width + 'rpx',
}"
:src="item.icon"
/>
</view> </view>
<view :style="{'margin-top':'4rpx'}"><span>{{ item.name }}</span></view> <view :style="{ 'margin-top': '4rpx' }"
><span>{{ item.name }}</span></view
>
<!-- <view :class="item.id == categoryId ? 'active-line' : ''"></view> --> <!-- <view :class="item.id == categoryId ? 'active-line' : ''"></view> -->
</view> </view>
</scroll-view> </scroll-view>
<scroll-view class="nav-right" :style="[heightStyle]" :class="[shopCarFlag?'shopCarcss':'' ]" scroll-y :scroll-top="scrollTop" @scroll="scroll" @touchstart="openScroll" <scroll-view
scroll-with-animation> class="nav-right"
<view v-for="(category,index) in classifyData" :id="category.id" :key="category.id" class="box" :style="[goodBottom,scrollBottom]"> :style="[heightStyle]"
:class="[shopCarFlag ? 'shopCarcss' : '']"
scroll-y
:scroll-top="scrollTop"
@scroll="scroll"
@touchstart="openScroll"
scroll-with-animation
>
<view
v-for="(category, index) in classifyData"
:id="category.id"
:key="category.id"
class="box"
:style="[goodBottom, scrollBottom]"
>
<view :style="loads" class="right-title">{{ category.name }}</view> <view :style="loads" class="right-title">{{ category.name }}</view>
<view class="nav-right-item" v-for="item in category.goods" :key="item.goodsId"> <view
class="nav-right-item"
v-for="item in category.goods"
:key="item.goodsId"
>
<view class="thumbnailBox"> <view class="thumbnailBox">
<!-- <image src="/static/imgs/aixin.png" v-if="item.isRecommend == 1" class="isRecommend" /> --> <!-- <image src="/static/imgs/aixin.png" v-if="item.isRecommend == 1" class="isRecommend" /> -->
<image @click="cart(item, category)" class="thumbnail" v-if="item.pics.thumbnailApplet" :src="item.pics.thumbnailApplet" /> <image
<image @click="cart(item, category)" class="thumbnail" v-else :src="item.pics.thumbnail" /> @click="cart(item, category)"
class="thumbnail"
v-if="item.pics.thumbnailApplet"
:src="item.pics.thumbnailApplet"
/>
<image
@click="cart(item, category)"
class="thumbnail"
v-else
:src="item.pics.thumbnail"
/>
</view> </view>
<view @click="cart(item, category)" class="info"> <view @click="cart(item, category)" class="info">
<view class="goods-name">{{ item.name }}</view> <view class="goods-name">{{ item.name }}</view>
<view class="tags" v-if="item.tags"> <view class="tags" v-if="item.tags">
<view class="tag-item" v-for="tag in item.tags" :key="tag">{{ tag }}</view> <view class="tag-item" v-for="tag in item.tags" :key="tag">{{
tag
}}</view>
</view> </view>
<view class="desc-box"> <view class="desc-box">
<view class="desc">{{ item.desc || '' }}</view> <view class="desc">{{ item.desc || "" }}</view>
</view> </view>
<view class="mon"> <view class="mon">
<view class="priceBox"> <view class="priceBox">
<view class="discount"><text class="moneyLog"></text>{{ Utils.isInteger(getSku(item).discount) }}</view> <view class="discount"
<view class="price" v-if="getSku(item).price!=getSku(item).discount"><text class="num">{{ Utils.isInteger(getSku(item).price) }}</text></view> ><text class="moneyLog"></text
>{{ Utils.isInteger(getSku(item).discount) }}</view
>
<view
class="price"
v-if="getSku(item).price != getSku(item).discount"
><text class="num">{{
Utils.isInteger(getSku(item).price)
}}</text></view
>
</view> </view>
<view class="addbox" v-if="shopState&&isInRange"> <view class="addbox" v-if="shopState && isInRange">
<image v-if="getSku(item).state==1" @click.stop="cart(item, category)" class="add" :src="'../../static/imgs/jiahao.png'" /> <image
v-if="getSku(item).state == 1"
@click.stop="cart(item, category)"
class="add"
:src="'../../static/imgs/jiahao.png'"
/>
<!-- <u-icon class="add" name="plus-circle-fill" color="#0050F6" @click.stop="getallNum(item, category)" size="22"></u-icon> --> <!-- <u-icon class="add" name="plus-circle-fill" color="#0050F6" @click.stop="getallNum(item, category)" size="22"></u-icon> -->
<div v-if="getSku(item).state!=1" style="color: #858585;font-size: 20rpx;margin-top:16rpx">已售罄</div> <div
v-if="getSku(item).state != 1"
style="color: #858585; font-size: 20rpx; margin-top: 16rpx"
>
已售罄
</div>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
<show-toast ref="toast"/> <show-toast ref="toast" />
</view> </view>
</template> </template>
<script> <script>
import { $EventBus } from "../../utils/EventBus"; import { $EventBus } from "../../utils/EventBus";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import Order from '@/request/order' import Order from "@/request/order";
export default { export default {
name: 'menuAssembly', name: "menuAssembly",
props:['buied','shopState','isInRange'], props: ["buied", "shopState", "isInRange"],
data() { data() {
return { return {
scrollBottom: { scrollBottom: {
'--scroll-marginbottom': 0 "--scroll-marginbottom": 0,
}, },
heightStyle: { heightStyle: {
'--scroll-height': 0 "--scroll-height": 0,
}, },
goodBottom: { goodBottom: {
'--good-bottom':0 "--good-bottom": 0,
}, },
Utils, Utils,
categoryId: '', categoryId: "",
categoryPostion: [], categoryPostion: [],
scrollLeftTop: 0, scrollLeftTop: 0,
scrollTop: 0, scrollTop: 0,
scrolled: true, scrolled: true,
goods:[], goods: [],
shopCarFlag:false, shopCarFlag: false,
taBarHeight:0, taBarHeight: 0,
lastNumber:0, lastNumber: 0,
width:0, width: 0,
sizeList:[] sizeList: [],
} };
}, },
watch:{ watch: {
isInRange(val) { isInRange(val) {
if(!val) { if (!val) {
this.scrollBottom['--scroll-marginbottom'] = 131+'rpx' this.scrollBottom["--scroll-marginbottom"] = 131 + "rpx";
}else{ } else {
this.scrollBottom['--scroll-marginbottom'] = 0+'rpx' this.scrollBottom["--scroll-marginbottom"] = 0 + "rpx";
} }
}, },
shopState(val) { shopState(val) {
if(!val) { if (!val) {
this.scrollBottom['--scroll-marginbottom'] = 131+'rpx' this.scrollBottom["--scroll-marginbottom"] = 131 + "rpx";
}else{ } else {
this.scrollBottom['--scroll-marginbottom'] = 0+'rpx' this.scrollBottom["--scroll-marginbottom"] = 0 + "rpx";
} }
}, },
goods(val){ goods(val) {
this.shopCarFlag = val.length>0 this.shopCarFlag = val.length > 0;
}, },
buied(val) { buied(val) {
if(val){ if (val) {
this.heightStyle['--scroll-height'] = (this.taBarHeight+122)+'rpx' this.heightStyle["--scroll-height"] = this.taBarHeight + 122 + "rpx";
this.initScroll() this.initScroll();
} else {
}else{ this.heightStyle["--scroll-height"] = this.taBarHeight + 22 + "rpx";
this.heightStyle['--scroll-height'] = (this.taBarHeight+22)+'rpx'
}
} }
}, },
computed:{ },
classifyData(){ computed: {
this.scrollTop = 0 classifyData() {
let categorys = this.$store.state.menu.setMenuCategorys.length!=0?JSON.parse(JSON.stringify(this.$store.state.menu.setMenuCategorys)):[] this.scrollTop = 0;
let categorys =
this.$store.state.menu.setMenuCategorys.length != 0
? JSON.parse(JSON.stringify(this.$store.state.menu.setMenuCategorys))
: [];
// if(categorys.length!=0){ // if(categorys.length!=0){
// const lastGood = 1 // const lastGood = 1
// this.lastNumber = lastGood<=2?3-lastGood:0 // this.lastNumber = lastGood<=2?3-lastGood:0
...@@ -118,18 +190,18 @@ export default { ...@@ -118,18 +190,18 @@ export default {
// console.log(this.lastNumber) // console.log(this.lastNumber)
// } // }
// 删除没有商品的分类 // 删除没有商品的分类
if(categorys) { if (categorys) {
for(var i=categorys.length-1; i>=0; i--) { for (var i = categorys.length - 1; i >= 0; i--) {
var category = categorys[i]; var category = categorys[i];
if(!category.goods || category.goods.length<=0) { if (!category.goods || category.goods.length <= 0) {
categorys.splice(i, 1); categorys.splice(i, 1);
} }
} }
if(categorys.length>0){ if (categorys.length > 0) {
this.categoryId = categorys[0].id; this.categoryId = categorys[0].id;
} }
} }
this.initScroll() this.initScroll();
// console.log(categorys) // console.log(categorys)
// categorys[0]?categorys[0].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':'' // categorys[0]?categorys[0].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':''
// categorys[1]?categorys[1].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':'' // categorys[1]?categorys[1].icon = 'https://s1.ax1x.com/2022/08/05/vnHQw6.jpg':''
...@@ -137,70 +209,73 @@ export default { ...@@ -137,70 +209,73 @@ export default {
// categorys.map((item,index)=>{ // categorys.map((item,index)=>{
// this.imagesHeight(item.src,index) // this.imagesHeight(item.src,index)
// }) // })
if(categorys.length!=0)this.imagesHeight(categorys) if (categorys.length != 0) this.imagesHeight(categorys);
return categorys return categorys;
} },
}, },
created() { created() {
$EventBus.$off('updateCar'); $EventBus.$off("updateCar");
}, },
mounted(){ mounted() {
this.$nextTick(()=>{ this.$nextTick(() => {
this.taBarHeight = uni.getStorageSync('taBarHeight') this.taBarHeight = uni.getStorageSync("taBarHeight");
this.heightStyle['--scroll-height'] = (this.taBarHeight+44)+'rpx' this.heightStyle["--scroll-height"] = this.taBarHeight + 44 + "rpx";
}) });
this.goods = uni.getStorageSync('shopCarInfo') || []; this.goods = uni.getStorageSync("shopCarInfo") || [];
$EventBus.$on('updateCar', () => { $EventBus.$on("updateCar", () => {
this.goods = uni.getStorageSync('shopCarInfo') || []; this.goods = uni.getStorageSync("shopCarInfo") || [];
}); });
}, },
methods: { methods: {
initScroll() { initScroll() {
this.scrollLeftTop = 0 this.scrollLeftTop = 0;
this.scrollTop = 0 this.scrollTop = 0;
const timer = setTimeout(() => { const timer = setTimeout(() => {
this.$nextTick(() => { this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
query.selectAll('.box').boundingClientRect(data => { query
console.log(data,'data') .selectAll(".box")
this.categoryPostion = data .boundingClientRect((data) => {
clearTimeout(timer) console.log(data, "data");
}).exec(); this.categoryPostion = data;
clearTimeout(timer);
}) })
.exec();
});
}, 1000); }, 1000);
}, },
async imagesHeight(list,index) { async imagesHeight(list, index) {
// return // return
let i = 0 let i = 0;
const newList = list.map(item=>{ const newList = list.map((item) => {
return '' return "";
}) });
const func = async () => { const func = async () => {
if(list[i].icon){ if (list[i].icon) {
const val = await uni.getImageInfo({ const val = await uni.getImageInfo({
src: list[i].icon src: list[i].icon,
}) });
let w = val[1].width let w = val[1].width;
let h = val[1].height let h = val[1].height;
if(w>80){ if (w > 80) {
w = 80 w = 80;
} }
if(h>60){ if (h > 60) {
h = 60 h = 60;
} }
newList[i] = { newList[i] = {
width:w, width: w,
height:h height: h,
} };
}
i++
if(i<newList.length){
func()
}else{
this.sizeList = newList
} }
i++;
if (i < newList.length) {
func();
} else {
this.sizeList = newList;
} }
func() };
func();
// console.log(val) // console.log(val)
// if(val.length==2){ // if(val.length==2){
...@@ -213,18 +288,18 @@ export default { ...@@ -213,18 +288,18 @@ export default {
getSku(data) { getSku(data) {
const { skus } = data; const { skus } = data;
if (!skus || skus.length == 0) { if (!skus || skus.length == 0) {
return { discount: data.discount, price: data.price}; return { discount: data.discount, price: data.price };
} }
const sku = data.skus.find(v => v.isDefault == 1 && v.state == 1) const sku =
|| data.skus.find(v => v.state == 1) data.skus.find((v) => v.isDefault == 1 && v.state == 1) ||
|| data.skus.find(v => v.isDefault == 1) data.skus.find((v) => v.state == 1) ||
|| data.skus[0]; data.skus.find((v) => v.isDefault == 1) ||
data.skus[0];
return sku; return sku;
}, },
createList(data) { createList(data) {
// this.classifyData = data; // this.classifyData = data;
// console.log(this.classifyData); // console.log(this.classifyData);
// // 删除没有商品的分类 // // 删除没有商品的分类
// if(this.classifyData) { // if(this.classifyData) {
// for(var i=this.classifyData.length-1; i>=0; i--) { // for(var i=this.classifyData.length-1; i>=0; i--) {
...@@ -245,65 +320,79 @@ export default { ...@@ -245,65 +320,79 @@ export default {
// }) // })
}, },
getallNum(item, category) { getallNum(item, category) {
this.$emit('getallNum', item, category) this.$emit("getallNum", item, category);
}, },
openScroll() { openScroll() {
this.scrolled = true this.scrolled = true;
}, },
scroll(e) { scroll(e) {
if (!this.scrolled) return; if (!this.scrolled) return;
const { categoryPostion } = this; const { categoryPostion } = this;
let otherHeight = 0 let otherHeight = 0;
if(this.buied){ if (this.buied) {
otherHeight = 320 otherHeight = 320;
}else{ } else {
otherHeight = 270 otherHeight = 270;
} }
if(this.shopCarFlag){ if (this.shopCarFlag) {
otherHeight += 100 otherHeight += 100;
}else{ } else {
otherHeight+=0 otherHeight += 0;
} }
const el = categoryPostion.filter(item => {return item.top <= e.target.scrollTop+otherHeight}); const el = categoryPostion.filter((item) => {
console.log(el[el.length-1],'-------------------',e.target.scrollTop+otherHeight,otherHeight) return item.top <= e.target.scrollTop + otherHeight;
if (el[el.length-1]) this.categoryId = el[el.length-1].id });
console.log(
el[el.length - 1],
"-------------------",
e.target.scrollTop + otherHeight,
otherHeight
);
if (el[el.length - 1]) this.categoryId = el[el.length - 1].id;
}, },
categoryClickMain(id) { categoryClickMain(id) {
this.scrolled = false this.scrolled = false;
this.categoryId = id; this.categoryId = id;
this.categoryPostion.forEach(item => { this.categoryPostion.forEach((item) => {
if (item.id == id) { if (item.id == id) {
this.scrollTop = this.buied ? item.top - 320 : item.top - 270 this.scrollTop = this.buied ? item.top - 320 : item.top - 270;
} }
}); });
}, },
async cart(item, category){ async cart(item, category) {
console.log(item,category) console.log(item, category);
const skuStatus = item.skus.filter(item=>{return (Number(item.state)===1&&item.isDelete === 0)}) const skuStatus = item.skus.filter((item) => {
return Number(item.state) === 1 && item.isDelete === 0;
});
if(skuStatus.length===0){ if (skuStatus.length === 0) {
this.showToast({ this.showToast({
title: '该商品已售罄', title: "此商品已售罄",
icon: 'none', icon: "none",
}) });
}else{
if(this.shopState&&this.isInRange){
const {data} = await Order.checkSku({skuId:skuStatus[0].skuId})
const {goods} = data.data
uni.setStorageSync('goodsInfo', JSON.stringify({ ...goods, category }));
} else { } else {
uni.setStorageSync('goodsInfo', JSON.stringify({ ...item, category })); if (this.shopState && this.isInRange) {
} const { data } = await Order.checkSku({ skuId: skuStatus[0].skuId });
uni.navigateTo({ url: '/menuSubPackage/pages/goodsDetail/goodsDetail' }) const { goods } = data.data;
} uni.setStorageSync(
"goodsInfo",
JSON.stringify({ ...goods, category })
);
} else {
uni.setStorageSync(
"goodsInfo",
JSON.stringify({ ...item, category })
);
} }
uni.navigateTo({
url: "/menuSubPackage/pages/goodsDetail/goodsDetail",
});
} }
} },
},
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.page-body { .page-body {
display: flex; display: flex;
...@@ -320,7 +409,7 @@ export default { ...@@ -320,7 +409,7 @@ export default {
box-sizing: border-box; box-sizing: border-box;
width: 164rpx; width: 164rpx;
background: #fff; background: #fff;
border-right: 2rpx solid #F0F0F0; border-right: 2rpx solid #f0f0f0;
height: calc(100vh - var(--scroll-height)); height: calc(100vh - var(--scroll-height));
overflow-y: auto; overflow-y: auto;
// background: var(--header-color); // background: var(--header-color);
...@@ -355,10 +444,10 @@ export default { ...@@ -355,10 +444,10 @@ export default {
box-shadow: 0px 4px 8px 0px rgba(102, 102, 102, 0.1); box-shadow: 0px 4px 8px 0px rgba(102, 102, 102, 0.1);
font-weight: 500; font-weight: 500;
color: #333333; color: #333333;
background: #FFFFFF; background: #ffffff;
font-size: 24rpx; font-size: 24rpx;
background: #fff; background: #fff;
border-right: 4rpx solid #0050F6; border-right: 4rpx solid #0050f6;
} }
.nav-left-item:last-child { .nav-left-item:last-child {
...@@ -373,11 +462,11 @@ export default { ...@@ -373,11 +462,11 @@ export default {
width: 585.21rpx; width: 585.21rpx;
// padding-top: 42rpx; // padding-top: 42rpx;
} }
.buiedcss{ .buiedcss {
height: calc(100vh - 376rpx - 183rpx); height: calc(100vh - 376rpx - 183rpx);
} }
.shopCarcss{ .shopCarcss {
padding-bottom: 100rpx; padding-bottom: 100rpx;
} }
...@@ -411,14 +500,14 @@ export default { ...@@ -411,14 +500,14 @@ export default {
margin-bottom: 60rpx; margin-bottom: 60rpx;
background: #fff; background: #fff;
position: relative; position: relative;
.thumbnailBox{ .thumbnailBox {
position: relative; position: relative;
.isRecommend { .isRecommend {
position: absolute; position: absolute;
width: 22.46rpx; width: 22.46rpx;
height: 22.46rpx; height: 22.46rpx;
top: 28rpx; top: 28rpx;
right: 24rpx right: 24rpx;
} }
.thumbnail { .thumbnail {
//缩略图 //缩略图
...@@ -429,7 +518,6 @@ export default { ...@@ -429,7 +518,6 @@ export default {
} }
} }
.info { .info {
flex: 1; flex: 1;
margin-left: 24rpx; margin-left: 24rpx;
...@@ -448,7 +536,7 @@ export default { ...@@ -448,7 +536,7 @@ export default {
margin-top: 8rpx; margin-top: 8rpx;
.tag-item { .tag-item {
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
background-color: #F0F0F0; background-color: #f0f0f0;
padding: 0rpx 8rpx; padding: 0rpx 8rpx;
font-size: 20rpx; font-size: 20rpx;
color: #999999; color: #999999;
...@@ -480,7 +568,7 @@ export default { ...@@ -480,7 +568,7 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
margin-top: 28rpx; margin-top: 28rpx;
.priceBox{ .priceBox {
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
align-items: flex-end; align-items: flex-end;
...@@ -513,7 +601,7 @@ export default { ...@@ -513,7 +601,7 @@ export default {
} }
} }
} }
.addbox{ .addbox {
// line-height: 26rpx; // line-height: 26rpx;
padding-top: 12rpx; padding-top: 12rpx;
.add { .add {
...@@ -526,21 +614,19 @@ export default { ...@@ -526,21 +614,19 @@ export default {
} }
} }
.sellNull{ .sellNull {
position: absolute; position: absolute;
right: 32rpx; right: 32rpx;
top: 0rpx; top: 0rpx;
} }
} }
.box:first-child { .box:first-child {
margin-top: 40rpx; margin-top: 40rpx;
} }
.box:last-child{ .box:last-child {
// padding-bottom: var(--good-bottom); // padding-bottom: var(--good-bottom);
padding-bottom: 200rpx; padding-bottom: 200rpx;
// height: 100%; // height: 100%;
} }
.nav-right-item image { .nav-right-item image {
......
<template> <template>
<view catchtouchmove="return"> <view catchtouchmove="return">
<u-popup :show="showShopCar && goods.length" mode="bottom" :round="5" :overlay="true" <u-popup
:closeOnClickOverlay="true" @close="closeT" zIndex="10071"> :show="showShopCar && goods.length"
<view class="shop-car" :style="{'padding-bottom':Utils.getPx(bottomPadding)+'px'}"> mode="bottom"
:round="5"
:overlay="true"
:closeOnClickOverlay="true"
@close="closeT"
zIndex="10071"
>
<view
class="shop-car"
:style="{ 'padding-bottom': Utils.getPx(bottomPadding) + 'px' }"
>
<view class="header"> <view class="header">
<text class="left">购物袋</text> <text class="left">购物袋</text>
<text class="right" @click="clearCar"><text class="delete-icon"></text>清空购物车</text> <text class="right" @click="clearCar"
><text class="delete-icon"></text>清空购物车</text
>
</view> </view>
<scroll-view scroll-y="true" class="scroll-Y"> <scroll-view scroll-y="true" class="scroll-Y">
<view class="container"> <view class="container">
<view> <view>
<view class="empty" v-if="show == false"> <view class="empty" v-if="show == false">
<image :src="imgPath" mode="widthFix" style="width: 400rpx;"></image> <image
:src="imgPath"
mode="widthFix"
style="width: 400rpx"
></image>
<view class="empty-text">空空如也的购物</view> <view class="empty-text">空空如也的购物</view>
<view class="empty-button" @click="goshopping">去选购</view> <view class="empty-button" @click="goshopping">去选购</view>
</view> </view>
<view v-if="show == true"> <view v-if="show == true">
<view class="goods-detail" v-for="(item, index) in goods" :key="index"> <view
class="goods-detail"
v-for="(item, index) in goods"
:key="index"
>
<view class="detail-left"> <view class="detail-left">
<view class="goods-left"> <view class="goods-left">
<view class="checkBox"> <view class="checkBox">
<view class="check" @click="selected(item)" :class="item.flag?'checked':'nochecked'"></view> <view
class="check"
@click="selected(item)"
:class="item.flag ? 'checked' : 'nochecked'"
></view>
</view> </view>
<!-- <u-checkbox-group @change="selected(item)"> <!-- <u-checkbox-group @change="selected(item)">
<label> <label>
...@@ -29,29 +53,53 @@ ...@@ -29,29 +53,53 @@
</label> </label>
</u-checkbox-group> --> </u-checkbox-group> -->
<view> <view>
<image :src="item.pics.thumbnailApplet || item.pics.thumbnail" <image
style="width: 120rpx;height: 120rpx;margin-top: 4.24rpx"></image> :src="
item.pics.thumbnailApplet || item.pics.thumbnail
"
style="
width: 120rpx;
height: 120rpx;
margin-top: 4.24rpx;
"
></image>
</view> </view>
</view> </view>
<view class="size"> <view class="size">
<view class="goods-name">{{ item.name }}</view> <view class="goods-name">{{ item.name }}</view>
<view class="goods-skus"> <view class="goods-skus">
<text v-for="(rl, index) in item.sku.rules" :key="rl.ruleName"> <text
v-for="(rl, index) in item.sku.rules"
:key="rl.ruleName"
>
{{ rl.ruleName }} {{ rl.ruleName }}
<text v-if="index != item.sku.rules.length - 1">/</text> <text v-if="index != item.sku.rules.length - 1"
>/</text
>
</text> </text>
</view> </view>
<view class="goods-price"> <view class="goods-price">
<text class="price-discount"><text class="moneyLog"></text>{{ Utils.isInteger(item.sku.discount) }}</text> <text class="price-discount"
<text class="price-x" v-show="item.sku.price!=item.sku.discount"></text> ><text class="moneyLog"></text
<text class="price-xx" v-show="item.sku.price!=item.sku.discount">{{ Utils.isInteger(item.sku.price) }}</text> >{{ Utils.isInteger(item.sku.discount) }}</text
>
<text
class="price-x"
v-show="item.sku.price != item.sku.discount"
></text
>
<text
class="price-xx"
v-show="item.sku.price != item.sku.discount"
>{{ Utils.isInteger(item.sku.price) }}</text
>
</view> </view>
</view> </view>
</view> </view>
<view class="detail-right"> <view class="detail-right">
<view class="subtract" @click="reduce(item, index)"></view> <view class="subtract" @click="reduce(item, index)"></view>
<text class="num">{{ item.num }}</text> <text class="num">{{ item.num }}</text>
<view class="add" @click="add(item)" ></view> <view class="add" @click="add(item)"></view>
<!-- <text class="subtract" @click="reduce(item, index)">-</text> --> <!-- <text class="subtract" @click="reduce(item, index)">-</text> -->
<!-- <u-icon class="subtract" name="minus-circle" @click="reduce(item, index)" color="#2979ff" size="22"></u-icon> --> <!-- <u-icon class="subtract" name="minus-circle" @click="reduce(item, index)" color="#2979ff" size="22"></u-icon> -->
<!-- <text @click="add(item)" class="add">+</text> --> <!-- <text @click="add(item)" class="add">+</text> -->
...@@ -62,17 +110,19 @@ ...@@ -62,17 +110,19 @@
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
</u-popup> </u-popup>
<view class="end" v-if="goods.length" :style="{'bottom':shopCar+'rpx'}"> <view class="end" v-if="goods.length" :style="{ bottom: shopCar + 'rpx' }">
<view @click.stop="openShopCar" class="end-left"> <view @click.stop="openShopCar" class="end-left">
<view style="display:flex"> <view style="display: flex">
<view class="car-img"> <view class="car-img">
<text class="badge" :animation="animationData" v-if="totalNum" >{{ totalNum }}</text> <text class="badge" :animation="animationData" v-if="totalNum">{{
totalNum
}}</text>
</view> </view>
<text class="shopClassStyle">{{ Utils.isInteger(totalPrice.toFixed(2)) }}</text> <text class="shopClassStyle"
>{{ Utils.isInteger(totalPrice.toFixed(2)) }}</text
>
</view> </view>
</view> </view>
<view class="end-right goSubmmit" @click="saveReserve" v-if="userms"> <view class="end-right goSubmmit" @click="saveReserve" v-if="userms">
...@@ -81,60 +131,73 @@ ...@@ -81,60 +131,73 @@
<!-- <view v-if="!userms" class="end-right goSubmmit" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="saveReserve"> <!-- <view v-if="!userms" class="end-right goSubmmit" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="saveReserve">
</view> --> </view> -->
<button v-if="!userms" class="end-right goSubmmit" style="border-radius: 0;" open-type="getPhoneNumber" <button
@getphonenumber="saveReserve">结算 v-if="!userms"
class="end-right goSubmmit"
style="border-radius: 0"
open-type="getPhoneNumber"
@getphonenumber="saveReserve"
>
结算
</button> </button>
</view> </view>
<view class="shopClose" v-if="!shopState||!isInRange" :style="{'bottom':shopCar+'rpx'}"> <view
<view class="content">{{!shopState?"门店已休息":"距离较远,门店暂停接单"}}</view> class="shopClose"
v-if="!shopState || !isInRange"
:style="{ bottom: shopCar + 'rpx' }"
>
<view class="content">{{
!shopState ? "门店已休息" : "距离较远,门店暂停接单"
}}</view>
</view> </view>
<show-toast ref="toast"/> <show-toast ref="toast" />
</view> </view>
</template> </template>
<script> <script>
import { $EventBus } from "../../utils/EventBus"; import { $EventBus } from "../../utils/EventBus";
import Menu from '@/request/menu'; import Menu from "@/request/menu";
import User from '@/request/user'; import User from "@/request/user";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
export default { export default {
props:['shopState','isInRange'], props: ["shopState", "isInRange"],
data() { data() {
return { return {
showShopCar: false,//是否弹出购物车列表 showShopCar: false, //是否弹出购物车列表
show: true, show: true,
allchecked: true, allchecked: true,
// checked:true, // checked:true,
goods: [],//购物车商品信息 goods: [], //购物车商品信息
loginInfo: "", loginInfo: "",
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', 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",
Utils, Utils,
shopCar:0, shopCar: 0,
BottomSafeHeight:0, BottomSafeHeight: 0,
bottomPadding:0, bottomPadding: 0,
animation:'', animation: "",
animationData: {}, animationData: {},
timer:0 timer: 0,
} };
}, },
created() { created() {
$EventBus.$off('updateCar'); $EventBus.$off("updateCar");
}, },
mounted() { mounted() {
this.animation = uni.createAnimation() this.animation = uni.createAnimation();
this.BottomSafeHeight = uni.getStorageSync('BottomSafeHeight')||50 this.BottomSafeHeight = uni.getStorageSync("BottomSafeHeight") || 50;
console.log(this.BottomSafeHeight,'this.BottomSafeHeight') console.log(this.BottomSafeHeight, "this.BottomSafeHeight");
this.bottomPadding = 204 this.bottomPadding = 204;
this.shopCar = uni.getStorageSync('shopCar')+5 this.shopCar = uni.getStorageSync("shopCar") + 5;
if(!this.userms){ if (!this.userms) {
User.wxLoginAndGetOpenid(true).then(loginInfo=>{ User.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.loginInfo = loginInfo this.loginInfo = loginInfo;
}) });
} }
this.goods = uni.getStorageSync('shopCarInfo') || []; this.goods = uni.getStorageSync("shopCarInfo") || [];
$EventBus.$on('updateCar', () => { $EventBus.$on("updateCar", () => {
this.goods = uni.getStorageSync('shopCarInfo') || []; this.goods = uni.getStorageSync("shopCarInfo") || [];
}); });
}, },
...@@ -143,23 +206,33 @@ export default { ...@@ -143,23 +206,33 @@ export default {
openShopCar() { openShopCar() {
this.$nextTick(() => { this.$nextTick(() => {
this.showShopCar = !this.showShopCar; this.showShopCar = !this.showShopCar;
}) });
}, },
// 翻转动画 // 翻转动画
turnAnimation(val) { turnAnimation(val) {
if(this.goods.length>0){ if (this.goods.length > 0) {
this.$nextTick(()=>{ this.$nextTick(() => {
this.animation.opacity(0.5).step({duration:100}).rotateY(90).opacity(1).step({duration:200}).rotateY(30).step({duration:50}).rotateY(-60).step({duration:100}).rotateY(0).step({duration:50}) this.animation
this.animationData = this.animation.export() .opacity(0.5)
.step({ duration: 100 })
.rotateY(90)
.opacity(1)
.step({ duration: 200 })
.rotateY(30)
.step({ duration: 50 })
.rotateY(-60)
.step({ duration: 100 })
.rotateY(0)
.step({ duration: 50 });
this.animationData = this.animation.export();
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.animation.rotateY(0).step({duration:100}) this.animation.rotateY(0).step({ duration: 100 });
this.animationData = this.animation.export() this.animationData = this.animation.export();
clearTimeout(this.timer) clearTimeout(this.timer);
}, 550); }, 550);
}) });
} }
}, },
closeT(e) { closeT(e) {
...@@ -167,8 +240,8 @@ export default { ...@@ -167,8 +240,8 @@ export default {
}, },
// 清空购物车 // 清空购物车
clearCar() { clearCar() {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync("shopCarInfo");
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
}, },
// 购物车为空时点击去购物,收起购物袋 // 购物车为空时点击去购物,收起购物袋
goshopping() { goshopping() {
...@@ -176,131 +249,139 @@ export default { ...@@ -176,131 +249,139 @@ export default {
}, },
//跳转到结算 //跳转到结算
saveReserve(e) { saveReserve(e) {
const settleMentFunc = ()=>{ const settleMentFunc = () => {
if(this.totalPrice < 0 || this.totalNum <= 0) { if (this.totalPrice < 0 || this.totalNum <= 0) {
this.showToast({ title: '请选择商品', icon: 'error' }) this.showToast({ title: "请选择商品", icon: "error" });
return; return;
} }
let Authorization = uni.getStorageSync('Authorization'); let Authorization = uni.getStorageSync("Authorization");
let shopCarInfo = uni.getStorageSync('shopCarInfo').filter(v => v.flag == true); let shopCarInfo = uni
.getStorageSync("shopCarInfo")
.filter((v) => v.flag == true);
if (shopCarInfo) { if (shopCarInfo) {
if (Authorization) { if (Authorization) {
uni.navigateTo({ uni.navigateTo({
url: `/orderSubPackage/pages/settlement/index?buyType=1` url: `/orderSubPackage/pages/settlement/index?buyType=1`,
}) });
} else { } else {
this.loginByPhoneNumber(e) this.loginByPhoneNumber(e);
} }
} }
return; return;
} };
uni.authorize({ uni.authorize({
scope: 'scope.userLocation', scope: "scope.userLocation",
success: () => { //1.1 允许授权 success: () => {
//1.1 允许授权
console.log("允许授权位置"); console.log("允许授权位置");
settleMentFunc() settleMentFunc();
}, },
fail: (err) => { //1.2 拒绝授权 fail: (err) => {
wx.exitMiniProgram({ success: (res) => { } }) //1.2 拒绝授权
console.log("获取位置失败") wx.exitMiniProgram({ success: (res) => {} });
console.log("获取位置失败");
uni.showModal({ uni.showModal({
content: '检测到您没打开地理位置权限,是否去设置打开?', content: "检测到您没打开地理位置权限,是否去设置打开?",
confirmText: "确认", confirmText: "确认",
cancelText: '取消', cancelText: "取消",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
uni.openSetting({//opensetting是调起设置页面的 uni.openSetting({
//opensetting是调起设置页面的
success: (res) => { success: (res) => {
console.log(res) console.log(res);
if(res.authSetting['scope.userLocation'] == true){//判断res.authsetting的值是true还是false if (res.authSetting["scope.userLocation"] == true) {
settleMentFunc() //判断res.authsetting的值是true还是false
}else{ settleMentFunc();
} else {
// console.log("什么也不做"); // console.log("什么也不做");
} }
} },
}) });
} else { } else {
console.log('取消'); console.log("取消");
return false; return false;
} }
} },
}) });
} },
}) });
return return;
}, },
// 付款前未登录发起授权 // 付款前未登录发起授权
loginByPhoneNumber(e) { loginByPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo;
User.getPhoneNumber(e); User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}, },
change(e) { }, change(e) {},
selected(item) { selected(item) {
item.flag = !item.flag item.flag = !item.flag;
if (!item.flag) { if (!item.flag) {
this.allchecked = false this.allchecked = false;
} else { } else {
const a = this.goods.filter((item) => { const a = this.goods.filter((item) => {
return item.flag == true return item.flag == true;
}) });
if (a) { if (a) {
this.allchecked = true this.allchecked = true;
} else { } else {
this.allchecked = false this.allchecked = false;
} }
} }
uni.setStorageSync('shopCarInfo', this.goods); uni.setStorageSync("shopCarInfo", this.goods);
}, },
selectgoods() { selectgoods() {
this.allchecked = !this.allchecked this.allchecked = !this.allchecked;
if (this.allchecked) { if (this.allchecked) {
this.goods.map(item => { this.goods.map((item) => {
item.flag = true item.flag = true;
}) });
} else { } else {
this.goods.map(item => { this.goods.map((item) => {
item.flag = false item.flag = false;
}) });
} }
uni.setStorageSync('shopCarInfo', this.goods); uni.setStorageSync("shopCarInfo", this.goods);
}, },
reduce(item, index) { reduce(item, index) {
item.num -= 1 item.num -= 1;
if (item.num == 0) { if (item.num == 0) {
this.goods.splice(index, 1); this.goods.splice(index, 1);
} }
uni.setStorageSync('shopCarInfo', this.goods); uni.setStorageSync("shopCarInfo", this.goods);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
}, },
add(item) { add(item) {
let s = 0; let s = 0;
this.goods.forEach(function (val) { this.goods.forEach(function (val) {
s += Number(val.num); s += Number(val.num);
}, 0); }, 0);
let countOfOrder = uni.getStorageSync('countOfOrder'); let countOfOrder = uni.getStorageSync("countOfOrder");
console.log(s , countOfOrder) console.log(s, countOfOrder);
if (s >= countOfOrder) { if (s >= countOfOrder) {
this.showToast({ this.showToast({
title: '最多可一次购买'+countOfOrder+'杯', title: "一次最多可购买" + countOfOrder + "杯",
icon: 'none' icon: "none",
}); });
return; return;
} }
let num = Number(item.num) let num = Number(item.num);
item.num = num + 1 item.num = num + 1;
uni.setStorageSync('shopCarInfo', this.goods); uni.setStorageSync("shopCarInfo", this.goods);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
} },
}, },
watch: { watch: {
totalNum(val){ totalNum(val) {
this.turnAnimation(val) this.turnAnimation(val);
} },
}, },
computed: { computed: {
userms() { userms() {
...@@ -308,23 +389,22 @@ export default { ...@@ -308,23 +389,22 @@ export default {
}, },
totalNum() { totalNum() {
let totalNum = 0; let totalNum = 0;
this.goods.map(item => { this.goods.map((item) => {
item.flag ? totalNum += parseInt(item.num) : totalNum += 0 item.flag ? (totalNum += parseInt(item.num)) : (totalNum += 0);
}) });
return totalNum return totalNum;
}, },
totalPrice() { totalPrice() {
let totalPrice = 0; let totalPrice = 0;
this.goods.forEach(item => { this.goods.forEach((item) => {
const sku = item.sku; const sku = item.sku;
item.flag ? totalPrice += item.num * sku.discount : totalPrice += 0 item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0);
}) });
return totalPrice return totalPrice;
} },
} },
} };
</script> </script>
<style lang="scss"> <style lang="scss">
...@@ -345,9 +425,9 @@ export default { ...@@ -345,9 +425,9 @@ export default {
flex-direction: column; flex-direction: column;
.header { .header {
padding:34rpx 31.78rpx 34rpx 31.54rpx; padding: 34rpx 31.78rpx 34rpx 31.54rpx;
display: flex; display: flex;
border-bottom: 0.1px solid #F4F4F4; border-bottom: 0.1px solid #f4f4f4;
.left { .left {
flex: 1; flex: 1;
...@@ -372,7 +452,8 @@ export default { ...@@ -372,7 +452,8 @@ export default {
.delete-icon { .delete-icon {
width: 18rpx; width: 18rpx;
height: 18rpx; height: 18rpx;
background: url(../../static/imgs/icon-delete.png) center center no-repeat; background: url(../../static/imgs/icon-delete.png) center center
no-repeat;
background-size: cover; background-size: cover;
display: inline-block; display: inline-block;
margin-right: 6rpx; margin-right: 6rpx;
...@@ -387,13 +468,11 @@ export default { ...@@ -387,13 +468,11 @@ export default {
flex: 1; flex: 1;
} }
} }
} }
.goods { .goods {
line-height: 80rpx; line-height: 80rpx;
background-color: #FFFFFF; background-color: #ffffff;
&-detail { &-detail {
display: flex; display: flex;
...@@ -411,7 +490,7 @@ export default { ...@@ -411,7 +490,7 @@ export default {
.goods-left { .goods-left {
display: flex; display: flex;
align-items: center; align-items: center;
.checkBox{ .checkBox {
margin-right: 32rpx; margin-right: 32rpx;
width: 40rpx; width: 40rpx;
display: flex; display: flex;
...@@ -419,18 +498,20 @@ export default { ...@@ -419,18 +498,20 @@ export default {
align-items: center; align-items: center;
height: 100%; height: 100%;
.check{ .check {
width: 100%; width: 100%;
height: 40rpx; height: 40rpx;
} }
.checked{ .checked {
background: url('../../static/imgs/duigouxuanzhong.png') center center no-repeat; background: url("../../static/imgs/duigouxuanzhong.png") center
background-size:100% 100%; center no-repeat;
background-size: 100% 100%;
} }
.nochecked{ .nochecked {
background: url('../../static/imgs/weixuanzhong.png') center center no-repeat; background: url("../../static/imgs/weixuanzhong.png") center center
background-size:100% 100%; no-repeat;
background-size: 100% 100%;
} }
} }
} }
...@@ -438,7 +519,7 @@ export default { ...@@ -438,7 +519,7 @@ export default {
.size { .size {
margin-left: 30rpx; margin-left: 30rpx;
.goods-name{ .goods-name {
height: 40rpx; height: 40rpx;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
...@@ -470,7 +551,7 @@ export default { ...@@ -470,7 +551,7 @@ export default {
line-height: 30rpx; line-height: 30rpx;
} }
.price-discount{ .price-discount {
height: 38rpx; height: 38rpx;
font-size: 28rpx; font-size: 28rpx;
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
...@@ -495,8 +576,6 @@ export default { ...@@ -495,8 +576,6 @@ export default {
line-height: 22px; line-height: 22px;
} }
} }
} }
.detail-right { .detail-right {
...@@ -515,9 +594,8 @@ export default { ...@@ -515,9 +594,8 @@ export default {
.subtract { .subtract {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
background: url('../../static/imgs/jianhao.png') center center no-repeat; background: url("../../static/imgs/jianhao.png") center center no-repeat;
background-size:100% 100%; background-size: 100% 100%;
} }
.num { .num {
font-size: 32rpx; font-size: 32rpx;
...@@ -530,15 +608,14 @@ export default { ...@@ -530,15 +608,14 @@ export default {
.add { .add {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
background: url('../../static/imgs/jiahao.png') center center no-repeat; background: url("../../static/imgs/jiahao.png") center center no-repeat;
background-size:100% 100%; background-size: 100% 100%;
} }
} }
} }
} }
.empty { .empty {
position: relative; position: relative;
top: 220rpx; top: 220rpx;
text-align: center; text-align: center;
...@@ -588,7 +665,7 @@ export default { ...@@ -588,7 +665,7 @@ export default {
width: 45rpx; width: 45rpx;
height: 54rpx; height: 54rpx;
display: inline-block; display: inline-block;
background: url('../../static/imgs/gouwudai.png') center center no-repeat; background: url("../../static/imgs/gouwudai.png") center center no-repeat;
background-size: cover; background-size: cover;
position: relative; position: relative;
...@@ -596,20 +673,19 @@ export default { ...@@ -596,20 +673,19 @@ export default {
position: absolute; position: absolute;
height: 32rpx; height: 32rpx;
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
background: #FF63BA; background: #ff63ba;
right: -22rpx; right: -22rpx;
top: -8rpx; top: -8rpx;
min-width: 32rpx; min-width: 32rpx;
font-weight: 500; font-weight: 500;
font-size: 20rpx; font-size: 20rpx;
font-weight: normal; font-weight: normal;
color: #FFFFFF; color: #ffffff;
line-height: 32rpx; line-height: 32rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
border-radius: 50%; border-radius: 50%;
} }
} }
} }
...@@ -618,19 +694,19 @@ export default { ...@@ -618,19 +694,19 @@ export default {
width: 169rpx; width: 169rpx;
font-size: 32rpx; font-size: 32rpx;
line-height: 100rpx; line-height: 100rpx;
background-color: #0050F6; background-color: #0050f6;
text-align: right; text-align: right;
color: #fff; color: #fff;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;
} }
.goSubmmit{ .goSubmmit {
// background: url('../../static/imgs/fukuan.png') center center no-repeat; // background: url('../../static/imgs/fukuan.png') center center no-repeat;
text-align: center; text-align: center;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #ffffff;
line-height: 100rpx; line-height: 100rpx;
width: 200rpx; width: 200rpx;
height: 100%; height: 100%;
...@@ -641,7 +717,7 @@ export default { ...@@ -641,7 +717,7 @@ export default {
.shopClose { .shopClose {
width: 100%; width: 100%;
height: 100rpx; height: 100rpx;
background: rgba(0,83,255,0.7); background: rgba(0, 83, 255, 0.7);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
position: fixed; position: fixed;
left: 0; left: 0;
...@@ -651,7 +727,7 @@ export default { ...@@ -651,7 +727,7 @@ export default {
font-size: 32rpx; font-size: 32rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #ffffff;
text-align: center; text-align: center;
line-height: 100rpx; line-height: 100rpx;
......
import App from './App'; import App from "./App";
//引入vuex //引入vuex
import store from './store'; import store from "./store";
import utils from './utils/utils'; import utils from "./utils/utils";
// console.log(Vue.$u,22) // console.log(Vue.$u,22)
// 需要在Vue.use(uView)之后执行 // 需要在Vue.use(uView)之后执行
// #ifndef VUE3 // #ifndef VUE3
import Vue from 'vue'; import Vue from "vue";
import Vuex from 'vuex' import Vuex from "vuex";
import uView from 'uview-ui'; import uView from "uview-ui";
import User from '@/request/user'; import User from "@/request/user";
// main.js // main.js
import initToast from "@/components/bocft-toast/initToast.js" import initToast from "@/components/bocft-toast/initToast.js";
import showToast from "@/components/bocft-toast/bocft-toast.vue" import showToast from "@/components/bocft-toast/bocft-toast.vue";
import taBar from "@/components/tabBar/tabBar.vue" import taBar from "@/components/tabBar/tabBar.vue";
initToast(Vue); initToast(Vue);
Vue.component('show-toast',showToast); Vue.component("show-toast", showToast);
Vue.component('taBar',taBar); Vue.component("taBar", taBar);
Vue.use(uView); Vue.use(uView);
Vue.prototype.$utils = utils; Vue.prototype.$utils = utils;
Vue.prototype.setPrice = (price) => price && Number(price).toFixed(2); Vue.prototype.setPrice = (price) => price && Number(price).toFixed(2);
Vue.prototype.loginByPhoneNumber = (e) => { Vue.prototype.loginByPhoneNumber = (e) => {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
User.getPhoneNumber(e); User.getPhoneNumber(e);
} else if (e.detail.errMsg == 'getPhoneNumber:fail user deny') { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
uni.showToast({ title: '已拒绝手机号授权', icon: 'error' }); uni.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}; };
Vue.config.productionTip = false; Vue.config.productionTip = false;
App.mpType = 'app'; App.mpType = "app";
const app = new Vue({ const app = new Vue({
...App, ...App,
store, store,
}); });
export default app export default app;
app.$mount(); app.$mount();
require('./request/index')(app); require("./request/index")(app);
// #endif // #endif
// #ifdef VUE3 // #ifdef VUE3
import { createSSRApp } from 'vue'; import { createSSRApp } from "vue";
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);
return { return {
......
<template> <template>
<view class="spec-content"> <view class="spec-content">
<view class="topBar" :style="{'top':topBarTop+'px','height':topBarHeight+'px'}"> <view
<u-icon @click="goBack" name="arrow-left" color="#000000" size="20"></u-icon> class="topBar"
:style="{ top: topBarTop + 'px', height: topBarHeight + 'px' }"
>
<u-icon
@click="goBack"
name="arrow-left"
color="#000000"
size="20"
></u-icon>
</view> </view>
<view v-if="goodInfo"> <view v-if="goodInfo">
<view class="uni-margin-wrap"> <view class="uni-margin-wrap">
<swiper v-if="goodInfo.pics.introImagesApplet" class="swiper"> <swiper v-if="goodInfo.pics.introImagesApplet" class="swiper">
<swiper-item v-for="item in goodInfo.pics.introImagesApplet" :key="item"> <swiper-item
v-for="item in goodInfo.pics.introImagesApplet"
:key="item"
>
<image :src="item" class="swiper_img" mode="scaleToFill"></image> <image :src="item" class="swiper_img" mode="scaleToFill"></image>
</swiper-item> </swiper-item>
</swiper> </swiper>
...@@ -23,12 +34,25 @@ ...@@ -23,12 +34,25 @@
<view v-for="specItem in goodInfo.specs" :key="specItem.specId"> <view v-for="specItem in goodInfo.specs" :key="specItem.specId">
<div class="good-spec-name">{{ specItem.specName }}</div> <div class="good-spec-name">{{ specItem.specName }}</div>
<view class="good-spec-rule"> <view class="good-spec-rule">
<div v-for="specItemRule in specItem.rules":key="specItemRule.ruleId" @click="selectRoles(specItemRule, specItem)"> <div
<div v-if="ShowIt(specItemRule.ruleId)" class="div_item" > v-for="specItemRule in specItem.rules"
<div v-if="specItemRule.isRecommend=='1'" :class="[UseIt(specItemRule.ruleId)?'disabledStyle':'']" class="default"></div> :key="specItemRule.ruleId"
<button class="good-spec-rule-item" :disabled="UseIt(specItemRule.ruleId)" @click="selectRoles(specItemRule, specItem)"
:class="{ active: isActvie(specItemRule) }"> >
<view @click.prevent="checkSku(specItemRule)">{{ specItemRule.ruleName }}</view> <div v-if="ShowIt(specItemRule.ruleId)" class="div_item">
<div
v-if="specItemRule.isRecommend == '1'"
:class="[UseIt(specItemRule.ruleId) ? 'disabledStyle' : '']"
class="default"
></div>
<button
class="good-spec-rule-item"
:disabled="UseIt(specItemRule.ruleId)"
:class="{ active: isActvie(specItemRule) }"
>
<view @click.prevent="checkSku(specItemRule)">{{
specItemRule.ruleName
}}</view>
</button> </button>
</div> </div>
</div> </div>
...@@ -39,58 +63,119 @@ ...@@ -39,58 +63,119 @@
<view class="spec-detail"> <view class="spec-detail">
<view class="spec-detail-title spec-info-left">商品详细</view> <view class="spec-detail-title spec-info-left">商品详细</view>
<view v-if="goodInfo.pics.detailImagesApplet"> <view v-if="goodInfo.pics.detailImagesApplet">
<view class="spec-detail-img" v-for="item in goodInfo.pics.detailImagesApplet" :key="item"> <view
<image class="spec-detail-img-item" :src="item" mode="scaleToFill"></image> class="spec-detail-img"
v-for="item in goodInfo.pics.detailImagesApplet"
:key="item"
>
<image
class="spec-detail-img-item"
:src="item"
mode="scaleToFill"
></image>
</view> </view>
</view> </view>
<view v-else class="spec-detail-img" v-for="item in goodInfo.pics.detailImages" :key="item"> <view
<image class="spec-detail-img-item" :src="item" mode="scaleToFill"></image> v-else
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>
<!-- 底部空白 --> <!-- 底部空白 -->
<view class="good-select-height"></view> <view class="good-select-height"></view>
</view> </view>
<view class="good-select" :style="{'padding-bottom':BottomSafeHeight+'px; height:'+(getPx(268)-BottomSafeHeight)+'px'}"> <view
class="good-select"
:style="{
'padding-bottom':
BottomSafeHeight +
'px; height:' +
(getPx(268) - BottomSafeHeight) +
'px',
}"
>
<view class="good-select-price"> <view class="good-select-price">
<div class="price"> <div class="price">
<view class="good-select-price-normal"><text class="moneyLog"></text>{{ Utils.isInteger(priceTotal.discount) }}</view> <view class="good-select-price-normal"
<view class="good-select-price-small" v-show="priceTotal.price!=priceTotal.discount"><text class="num">{{ Utils.isInteger(priceTotal.price) }}</text></view> ><text class="moneyLog"></text
>{{ Utils.isInteger(priceTotal.discount) }}</view
>
<view
class="good-select-price-small"
v-show="priceTotal.price != priceTotal.discount"
><text class="num">{{
Utils.isInteger(priceTotal.price)
}}</text></view
>
</div> </div>
<div v-if="!size > 0" style="color: orangered">已售罄</div> <div v-if="!size > 0" style="color: orangered">已售罄</div>
<div v-else class="set_size"> <div v-else class="set_size">
<view class="subtract" @click="reduceGood"></view> <view class="subtract" @click="reduceGood"></view>
<span>{{ size }}</span> <span>{{ size }}</span>
<view class="add" @click="addGood" ></view> <view class="add" @click="addGood"></view>
</div> </div>
</view> </view>
<view v-if="size > 0" class="good-select-cont"> <view v-if="size > 0" class="good-select-cont">
<view> <view>
<a :class="!shopState||!isInRange?'good-select-btn1-close':'good-select-btn1'" @click="getallNum()" v-if="userms"> <a
:class="
!shopState || !isInRange
? 'good-select-btn1-close'
: 'good-select-btn1'
"
@click="getallNum()"
v-if="userms"
>
立即购买 立即购买
</a> </a>
<button v-if="!userms" :class="!shopState||!isInRange?'good-select-btn1-close':'good-select-btn1'" style="border-radius: 0;" open-type="getPhoneNumber" <button
@getphonenumber="getallNum"> v-if="!userms"
:class="
!shopState || !isInRange
? 'good-select-btn1-close'
: 'good-select-btn1'
"
style="border-radius: 0"
open-type="getPhoneNumber"
@getphonenumber="getallNum"
>
立即购买 立即购买
</button> </button>
</view> </view>
<span :class="!shopState||!isInRange?'good-select-btn2-close':'good-select-btn2'" @click="shoppingCart" type="default">加入购物袋</span> <span
:class="
!shopState || !isInRange
? 'good-select-btn2-close'
: 'good-select-btn2'
"
@click="shoppingCart"
type="default"
>加入购物袋</span
>
</view> </view>
</view> </view>
</view> </view>
<show-toast ref="toast"/> <show-toast ref="toast" />
</view> </view>
</template> </template>
<script> <script>
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import User from '@/request/user'; import User from "@/request/user";
import Order from '@/request/order' import Order from "@/request/order";
import Menu from '@/request/menu' import Menu from "@/request/menu";
export default { export default {
data() { data() {
return { return {
title: 'Hello1', title: "Hello1",
imglist: [{ img: "/static/logo.png" }, { img: "/static/ggxz01.png" }], imglist: [{ img: "/static/logo.png" }, { img: "/static/ggxz01.png" }],
goodInfo: null, goodInfo: null,
selected: [], selected: [],
...@@ -98,52 +183,55 @@ export default { ...@@ -98,52 +183,55 @@ export default {
goods: {}, goods: {},
skusDefault: [], skusDefault: [],
skusSellout: [], skusSellout: [],
loginInfo:"", loginInfo: "",
pirce: 0, pirce: 0,
size: 1, size: 1,
topBarTop:0, topBarTop: 0,
topBarHeight:0, topBarHeight: 0,
BottomSafeHeight:0, BottomSafeHeight: 0,
Utils, Utils,
shopState:true, shopState: true,
showSku:[], showSku: [],
isInRange:true isInRange: true,
} };
}, },
onShow() { onShow() {
uni.setStorageSync("selectFlag",false) uni.setStorageSync("selectFlag", false);
uni.removeStorageSync('goodsList'); uni.removeStorageSync("goodsList");
this.BottomSafeHeight = uni.getStorageSync('BottomSafeHeight') this.BottomSafeHeight = uni.getStorageSync("BottomSafeHeight");
this.shopState = JSON.parse(uni.getStorageSync("shopState")) this.shopState = JSON.parse(uni.getStorageSync("shopState"));
this.isInRange = uni.getStorageSync("isInRange")===''?true:uni.getStorageSync("isInRange") this.isInRange =
uni.getStorageSync("isInRange") === ""
? true
: uni.getStorageSync("isInRange");
}, },
mounted(){ mounted() {
// 获取胶囊坐标位置 // 获取胶囊坐标位置
const res = wx.getMenuButtonBoundingClientRect() const res = wx.getMenuButtonBoundingClientRect();
const menuInfoTop = res.top const menuInfoTop = res.top;
const menuInfoBottom = res.bottom const menuInfoBottom = res.bottom;
const menuHeight = res.height const menuHeight = res.height;
let headHeight = 0 let headHeight = 0;
wx.getSystemInfo({ wx.getSystemInfo({
success: (res) => { success: (res) => {
headHeight = res.statusBarHeight headHeight = res.statusBarHeight;
} },
}) });
this.topBarTop = menuInfoTop this.topBarTop = menuInfoTop;
this.topBarHeight = menuHeight this.topBarHeight = menuHeight;
}, },
onLoad() { onLoad() {
if(!this.userms){ if (!this.userms) {
User.wxLoginAndGetOpenid(true).then(loginInfo=>{ User.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.loginInfo = loginInfo this.loginInfo = loginInfo;
}) });
} }
uni.removeStorageSync('goodsList'); uni.removeStorageSync("goodsList");
const goodsInfo = JSON.parse(uni.getStorageSync('goodsInfo')); const goodsInfo = JSON.parse(uni.getStorageSync("goodsInfo"));
this.goodInfo = goodsInfo; this.goodInfo = goodsInfo;
console.log(JSON.parse(JSON.stringify(this.goodInfo))); console.log(JSON.parse(JSON.stringify(this.goodInfo)));
this.initInfo(this.goodInfo) this.initInfo(this.goodInfo);
}, },
// watch:{ // watch:{
// selected(val){ // selected(val){
...@@ -158,276 +246,297 @@ export default { ...@@ -158,276 +246,297 @@ export default {
getPx(rpx) { getPx(rpx) {
return rpx * (wx.getSystemInfoSync().windowWidth / 750); return rpx * (wx.getSystemInfoSync().windowWidth / 750);
}, },
initInfo(goodsInfo){ initInfo(goodsInfo) {
this.available = [] this.available = [];
this.showSku = [] this.showSku = [];
this.selected = [] this.selected = [];
const skus = goodsInfo.skus; const skus = goodsInfo.skus;
if (skus) { if (skus) {
const sku = skus.find(v => v.isDefault == 1 && (v.state == 1&&v.isDelete===0)) || skus.find(v => v.isDefault == 0 && (v.state == 1&&v.isDelete===0)); const sku =
this.skusDefault = skus.find(v => v.isDefault == 1&&v.isDelete===0); skus.find(
this.skusSellout = skus.find(v => v.isDefault == 1 && (v.state == 1&&v.isDelete===0)) (v) => v.isDefault == 1 && v.state == 1 && v.isDelete === 0
|| skus.find(v => (v.state == 1&&v.isDelete===0)) ) ||
|| skus.find(v => v.isDefault == 1&&v.isDelete===0) skus.find(
|| skus[0] (v) => v.isDefault == 0 && v.state == 1 && v.isDelete === 0
if (sku){ );
this.selected.push(...sku.rules) this.skusDefault = skus.find(
}else{ (v) => v.isDefault == 1 && v.isDelete === 0
this.selected = [] );
}; this.skusSellout =
skus.forEach(item => { skus.find(
(v) => v.isDefault == 1 && v.state == 1 && v.isDelete === 0
) ||
skus.find((v) => v.state == 1 && v.isDelete === 0) ||
skus.find((v) => v.isDefault == 1 && v.isDelete === 0) ||
skus[0];
if (sku) {
this.selected.push(...sku.rules);
} else {
this.selected = [];
}
skus.forEach((item) => {
if (item.isDelete === 0) { if (item.isDelete === 0) {
item.rules.forEach(rule => { item.rules.forEach((rule) => {
this.showSku.push(rule.ruleId) this.showSku.push(rule.ruleId);
}) });
} }
}) });
skus.forEach(item => { skus.forEach((item) => {
if (item.state == 1) { if (item.state == 1) {
item.rules.forEach(rule => { item.rules.forEach((rule) => {
this.available.push(rule.ruleId) this.available.push(rule.ruleId);
}) });
} }
}) });
console.log(this.selected,this.showSku) console.log(this.selected, this.showSku);
} }
this.$nextTick(() => { this.$nextTick(() => {
this.buildGoods(e => { this.buildGoods((e) => {
if (e) { if (e) {
this.size = 1 this.size = 1;
} else { } else {
this.size = 0 this.size = 0;
} }
}) });
this.$forceUpdate() this.$forceUpdate();
}) });
}, },
goBack(){ goBack() {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1,
}); });
}, },
setDefaultStyle(id) { setDefaultStyle(id) {
let selected = false; let selected = false;
if (this.skusDefault && this.skusDefault.rules) { if (this.skusDefault && this.skusDefault.rules) {
this.skusDefault.rules.forEach(item => { this.skusDefault.rules.forEach((item) => {
if (item.ruleId == id) { if (item.ruleId == id) {
selected = true selected = true;
} }
}); });
} }
return selected return selected;
}, },
checkSku(specItemRule) { checkSku(specItemRule) {
const value = this.UseIt(specItemRule.ruleId) const value = this.UseIt(specItemRule.ruleId);
if(value) { if (value) {
this.showToast({ title: '该选项已售罄', icon: 'none' }); this.showToast({ title: "这款已经卖完啦", icon: "none" });
return return;
} }
}, },
selectRoles(specItemRule, parent) { selectRoles(specItemRule, parent) {
const value = this.UseIt(specItemRule.ruleId) const value = this.UseIt(specItemRule.ruleId);
if(value) { if (value) {
this.showToast({ title: '该选项已售罄', icon: 'none' }); this.showToast({ title: "这款已经卖完啦", icon: "none" });
return return;
} }
const { selected } = this; const { selected } = this;
selected.forEach((item, index) => { selected.forEach((item, index) => {
if (item.specId == parent.specId) { if (item.specId == parent.specId) {
selected.splice(index, 1) selected.splice(index, 1);
} }
}); });
this.selected.push({ ...specItemRule, specId: parent.specId }) this.selected.push({ ...specItemRule, specId: parent.specId });
this.buildGoods() this.buildGoods();
}, },
isActvie(data) { isActvie(data) {
return this.selected.filter(item => item.ruleId == data.ruleId).length > 0 return (
this.selected.filter((item) => item.ruleId == data.ruleId).length > 0
);
}, },
buildGoods(callback) { buildGoods(callback) {
const skusObj = {}; const skusObj = {};
let selectedSku = null let selectedSku = null;
const skus = this.goodInfo.skus; const skus = this.goodInfo.skus;
skus.forEach(item => { skus.forEach((item) => {
const ruleId = item.rules.map(item => item.ruleId); const ruleId = item.rules.map((item) => item.ruleId);
skusObj[item.skuId] = ruleId.sort() skusObj[item.skuId] = ruleId.sort();
}); });
const selectedrules = this.selected.map(item => item.ruleId).sort() const selectedrules = this.selected.map((item) => item.ruleId).sort();
for (let item in skusObj) { for (let item in skusObj) {
const selStr = selectedrules.toString() const selStr = selectedrules.toString();
const itemStr = skusObj[item].toString() const itemStr = skusObj[item].toString();
if (selStr === itemStr) selectedSku = item; if (selStr === itemStr) selectedSku = item;
} }
const [sku] = skus.filter(item => item.skuId == selectedSku); const [sku] = skus.filter((item) => item.skuId == selectedSku);
if (!sku || skus.state == 2) { if (!sku || skus.state == 2) {
this.showToast({ title: '本商品已经售罄', icon: 'none' }); this.showToast({ title: "这款已经卖完啦", icon: "none" });
callback && callback() callback && callback();
} else { } else {
const { category, ...goods } = this.goodInfo; const { category, ...goods } = this.goodInfo;
goods.skus = [sku]; goods.skus = [sku];
goods.sku = sku goods.sku = sku;
goods.flag = true; goods.flag = true;
goods.skuId = selectedSku goods.skuId = selectedSku;
goods.categoryId = category.id; goods.categoryId = category.id;
goods.goodsName = category.name; goods.goodsName = category.name;
this.goods = goods this.goods = goods;
callback && callback(true) callback && callback(true);
} }
}, },
checkNum(type){ checkNum(type) {
const shopCarInfo = uni.getStorageSync('shopCarInfo') || [] const shopCarInfo = uni.getStorageSync("shopCarInfo") || [];
let shopCarNum = (type=='add'?1:0) let shopCarNum = type == "add" ? 1 : 0;
shopCarInfo.forEach(item=> shopCarNum+=item.num) shopCarInfo.forEach((item) => (shopCarNum += item.num));
let countOfOrder = uni.getStorageSync('countOfOrder'); let countOfOrder = uni.getStorageSync("countOfOrder");
if ((Number(this.size) + Number(shopCarNum)) <= countOfOrder) { if (Number(this.size) + Number(shopCarNum) <= countOfOrder) {
return true return true;
} else { } else {
this.showToast({ this.showToast({
title: '最多可一次购买'+countOfOrder+'杯', title: "一次最多可购买" + countOfOrder + "杯",
icon: 'none', icon: "none",
}); });
} }
}, },
addGood() { addGood() {
if(this.checkNum('add')){ if (this.checkNum("add")) {
this.size = this.size + 1; this.size = this.size + 1;
} }
}, },
reduceGood() { reduceGood() {
const { size } = this const { size } = this;
if (size > 1) { if (size > 1) {
this.size = size - 1; this.size = size - 1;
} }
}, },
async shoppingCart() { async shoppingCart() {
if(!this.shopState||!this.isInRange){ if (!this.shopState || !this.isInRange) {
return return;
} }
if(this.checkNum('addShop')){ if (this.checkNum("addShop")) {
const { goods } = this; const { goods } = this;
const { data } = await Order.checkSku({skuId:goods.skuId}) const { data } = await Order.checkSku({ skuId: goods.skuId });
const {state,goods:newgoods} = data.data const { state, goods: newgoods } = data.data;
const newInfo = JSON.parse(JSON.stringify(newgoods)) const newInfo = JSON.parse(JSON.stringify(newgoods));
newInfo.category = this.goodInfo.category newInfo.category = this.goodInfo.category;
this.goodInfo = {...newInfo} this.goodInfo = { ...newInfo };
this.initInfo(this.goodInfo) this.initInfo(this.goodInfo);
if(state == 2){ if (state == 2) {
this.showToast({ title: '本商品已经售罄', icon: 'none' }); this.showToast({ title: "这款已经卖完啦", icon: "none" });
// this.getMenuList() // this.getMenuList()
return; return;
}else{ } else {
goods.num = this.size; goods.num = this.size;
Utils.getallNum(goods) Utils.getallNum(goods);
uni.switchTab({ url: '/pages/menu/menu' }) uni.switchTab({ url: "/pages/menu/menu" });
} }
} }
}, },
async getallNum(e) { async getallNum(e) {
if(!this.shopState||!this.isInRange){ if (!this.shopState || !this.isInRange) {
return return;
} }
const gosettleFun = async ()=> { const gosettleFun = async () => {
const { goods } = this; const { goods } = this;
const { data } = await Order.checkSku({skuId:goods.skuId}) const { data } = await Order.checkSku({ skuId: goods.skuId });
const {state,goods:newgoods} = data.data const { state, goods: newgoods } = data.data;
const newInfo = JSON.parse(JSON.stringify(newgoods)) const newInfo = JSON.parse(JSON.stringify(newgoods));
newInfo.category = this.goodInfo.category newInfo.category = this.goodInfo.category;
this.goodInfo = {...newInfo} this.goodInfo = { ...newInfo };
this.initInfo(this.goodInfo) this.initInfo(this.goodInfo);
if(state == 2){ if (state == 2) {
this.showToast({ title: '本商品已经售罄', icon: 'none' }); this.showToast({ title: "这款已经卖完啦", icon: "none" });
// this.getMenuList() // this.getMenuList()
return; return;
}else{ } else {
goods.num = this.size goods.num = this.size;
Utils.addGoods(goods) Utils.addGoods(goods);
uni.navigateTo({ url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1` }) uni.navigateTo({
} url: `/orderSubPackage/pages/settlement/index?buyType=1&goodsList=1`,
});
} }
};
const checkLocak = () => { const checkLocak = () => {
uni.authorize({ uni.authorize({
scope: 'scope.userLocation', scope: "scope.userLocation",
success: () => { //1.1 允许授权 success: () => {
//1.1 允许授权
console.log("允许授权位置"); console.log("允许授权位置");
gosettleFun() gosettleFun();
}, },
fail: (err) => { //1.2 拒绝授权 fail: (err) => {
wx.exitMiniProgram({ success: (res) => { } }) //1.2 拒绝授权
console.log("获取位置失败") wx.exitMiniProgram({ success: (res) => {} });
console.log("获取位置失败");
uni.showModal({ uni.showModal({
content: '检测到您没打开地理位置权限,是否去设置打开?', content: "检测到您没打开地理位置权限,是否去设置打开?",
confirmText: "确认", confirmText: "确认",
cancelText: '取消', cancelText: "取消",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
uni.openSetting({//opensetting是调起设置页面的 uni.openSetting({
//opensetting是调起设置页面的
success: (res) => { success: (res) => {
uni.setStorageSync("updataLoadtion",true) uni.setStorageSync("updataLoadtion", true);
console.log(res) console.log(res);
if(res.authSetting['scope.userLocation'] == true){//判断res.authsetting的值是true还是false if (res.authSetting["scope.userLocation"] == true) {
gosettleFun() //判断res.authsetting的值是true还是false
}else{ gosettleFun();
} else {
// console.log("什么也不做"); // console.log("什么也不做");
} }
} },
}) });
} else { } else {
console.log('取消'); console.log("取消");
return false; return false;
} }
} },
}) });
} },
}) });
} };
let Authorization = uni.getStorageSync('Authorization'); let Authorization = uni.getStorageSync("Authorization");
if (!Authorization) { if (!Authorization) {
this.loginByPhoneNumber(e); this.loginByPhoneNumber(e);
checkLocak() checkLocak();
return return;
}else{ } else {
checkLocak() checkLocak();
} }
if(!this.shopState||!this.isInRange){ if (!this.shopState || !this.isInRange) {
return return;
} }
// return // return
}, },
async getMenuList() { async getMenuList() {
const shopId = uni.getStorageSync('shopData').id const shopId = uni.getStorageSync("shopData").id;
let { data } = await Menu.getMenuList(shopId); let { data } = await Menu.getMenuList(shopId);
// console.log("menus:"+JSON.stringify(data)); // console.log("menus:"+JSON.stringify(data));
if (data.code == 200) { if (data.code == 200) {
data.data = data.data; data.data = data.data;
this.$store.commit('setMenuAllInfo', data.data); this.$store.commit("setMenuAllInfo", data.data);
this.$store.commit('setMenuCategorys', data.data.categorys); this.$store.commit("setMenuCategorys", data.data.categorys);
uni.setStorageSync('countOfOrder', parseInt(data.data.countOfOrder)); uni.setStorageSync("countOfOrder", parseInt(data.data.countOfOrder));
// this.$refs.MenuAssembly.createList(data.data.categorys) // this.$refs.MenuAssembly.createList(data.data.categorys)
} }
}, },
// 付款前未登录发起授权 // 付款前未登录发起授权
loginByPhoneNumber(e) { loginByPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo;
User.getPhoneNumber(e); User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}, },
UseIt(ruleId) { UseIt(ruleId) {
return this.available.indexOf(ruleId) == -1&&this.shopState&&this.isInRange return (
this.available.indexOf(ruleId) == -1 && this.shopState && this.isInRange
);
}, },
ShowIt(ruleId) { ShowIt(ruleId) {
return this.showSku.indexOf(ruleId) !== -1 return this.showSku.indexOf(ruleId) !== -1;
} },
}, },
computed: { computed: {
userms() { userms() {
...@@ -436,25 +545,22 @@ export default { ...@@ -436,25 +545,22 @@ export default {
priceTotal() { priceTotal() {
let discount = 0; let discount = 0;
let price = 0; let price = 0;
const { goods,skusSellout } = this; const { goods, skusSellout } = this;
if (goods.sku) { if (goods.sku) {
discount = goods.sku.discount * this.size discount = goods.sku.discount * this.size;
price = goods.sku.price * this.size price = goods.sku.price * this.size;
}else if(skusSellout){ } else if (skusSellout) {
discount = Number(skusSellout.discount) discount = Number(skusSellout.discount);
price = Number(skusSellout.price) price = Number(skusSellout.price);
} }
return { discount: discount.toFixed(2), price: price.toFixed(2) } return { discount: discount.toFixed(2), price: price.toFixed(2) };
} },
},
};
}
}
</script> </script>
<style lang="scss"> <style lang="scss">
.topBar{ .topBar {
// border: 1px solid red; // border: 1px solid red;
position: fixed; position: fixed;
z-index: 99999999; z-index: 99999999;
...@@ -468,7 +574,6 @@ export default { ...@@ -468,7 +574,6 @@ export default {
width: 100%; width: 100%;
} }
.swiper { .swiper {
height: 561rpx; height: 561rpx;
width: 100%; width: 100%;
...@@ -539,7 +644,7 @@ export default { ...@@ -539,7 +644,7 @@ export default {
.default { .default {
width: 45rpx; width: 45rpx;
height: 48rpx; height: 48rpx;
background: url('@/static/imgs/tuijian.png') center center no-repeat; background: url("@/static/imgs/tuijian.png") center center no-repeat;
background-size: 100%; background-size: 100%;
position: absolute; position: absolute;
right: -17rpx; right: -17rpx;
...@@ -566,14 +671,14 @@ export default { ...@@ -566,14 +671,14 @@ export default {
border: none; border: none;
font-style: normal; font-style: normal;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
background: #EAEAEA; background: #eaeaea;
pointer-events: none; pointer-events: none;
&.active { &.active {
font-weight: 400; font-weight: 400;
padding: 7rpx 24rpx; padding: 7rpx 24rpx;
background: #0050F6; background: #0050f6;
font-style: normal; font-style: normal;
color: #FFFFFF; color: #ffffff;
border-radius: 0rpx; border-radius: 0rpx;
border: 0rpx; border: 0rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
...@@ -583,14 +688,14 @@ export default { ...@@ -583,14 +688,14 @@ export default {
} }
} }
.good-spec-rule-item::after{ .good-spec-rule-item::after {
z-index: 1; z-index: 1;
border-radius: 0rpx; border-radius: 0rpx;
border: 0rpx; border: 0rpx;
} }
button[disabled]:not([type]) { button[disabled]:not([type]) {
background: url('@/static/imgs/shouqingsku.png') no-repeat; background: url("@/static/imgs/shouqingsku.png") no-repeat;
background-size: 100% 48rpx; background-size: 100% 48rpx;
} }
...@@ -606,7 +711,7 @@ button[disabled]:not([type]) { ...@@ -606,7 +711,7 @@ button[disabled]:not([type]) {
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
color: #333333; color: #333333;
padding-top: 32rpx !important; padding-top: 32rpx !important;
padding-bottom:22rpx !important padding-bottom: 22rpx !important;
} }
.spec-detail-img { .spec-detail-img {
...@@ -615,7 +720,7 @@ button[disabled]:not([type]) { ...@@ -615,7 +720,7 @@ button[disabled]:not([type]) {
height: 500rpx; height: 500rpx;
} }
.spec-detail-img:last-child{ .spec-detail-img:last-child {
margin-bottom: 115rpx; margin-bottom: 115rpx;
} }
...@@ -638,18 +743,18 @@ button[disabled]:not([type]) { ...@@ -638,18 +743,18 @@ button[disabled]:not([type]) {
height: auto; height: auto;
padding-bottom: 20rpx; padding-bottom: 20rpx;
box-shadow: 0px -2px 8px 0px rgba(214, 214, 214, 0.5); box-shadow: 0px -2px 8px 0px rgba(214, 214, 214, 0.5);
z-index: 9999999 z-index: 9999999;
} }
.good-select-price { .good-select-price {
display: flex; display: flex;
align-items: center; align-items: center;
// height: 68rpx; // height: 68rpx;
background: #FFFFFF; background: #ffffff;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 26rpx 32rpx 26rpx 32rpx; padding: 26rpx 32rpx 26rpx 32rpx;
.price{ .price {
display: flex; display: flex;
align-items: flex-end; align-items: flex-end;
justify-content: flex-start; justify-content: flex-start;
...@@ -679,8 +784,6 @@ button[disabled]:not([type]) { ...@@ -679,8 +784,6 @@ button[disabled]:not([type]) {
} }
} }
.good-select-cont { .good-select-cont {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -693,15 +796,15 @@ button[disabled]:not([type]) { ...@@ -693,15 +796,15 @@ button[disabled]:not([type]) {
.good-select-btn1 { .good-select-btn1 {
width: 328rpx; width: 328rpx;
height: 104rpx; height: 104rpx;
border: 2rpx solid #0050F6; border: 2rpx solid #0050f6;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #0050F6; color: #0050f6;
border-radius: 2px; border-radius: 2px;
line-height: 104rpx; line-height: 104rpx;
text-align: center; text-align: center;
background: #FFFFFF; background: #ffffff;
} }
.good-select-btn1-close { .good-select-btn1-close {
...@@ -715,7 +818,7 @@ button[disabled]:not([type]) { ...@@ -715,7 +818,7 @@ button[disabled]:not([type]) {
border-radius: 2px; border-radius: 2px;
line-height: 104rpx; line-height: 104rpx;
text-align: center; text-align: center;
background: #FFFFFF; background: #ffffff;
} }
.good-select-btn2 { .good-select-btn2 {
...@@ -724,7 +827,7 @@ button[disabled]:not([type]) { ...@@ -724,7 +827,7 @@ button[disabled]:not([type]) {
border-radius: 2px; border-radius: 2px;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
background: #0050F6; background: #0050f6;
line-height: 104rpx; line-height: 104rpx;
text-align: center; text-align: center;
color: #fff; color: #fff;
...@@ -750,15 +853,14 @@ button[disabled]:not([type]) { ...@@ -750,15 +853,14 @@ button[disabled]:not([type]) {
.subtract { .subtract {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
background: url('@/static/imgs/jianhao.png') center center no-repeat; background: url("@/static/imgs/jianhao.png") center center no-repeat;
background-size:100% 100%; background-size: 100% 100%;
} }
.add { .add {
width: 40rpx; width: 40rpx;
height: 40rpx; height: 40rpx;
background: url('@/static/imgs/jiahao.png') center center no-repeat; background: url("@/static/imgs/jiahao.png") center center no-repeat;
background-size:100% 100%; background-size: 100% 100%;
} }
span { span {
margin: 0 22rpx 0 26rpx; margin: 0 22rpx 0 26rpx;
......
<template> <template>
<view class="bigBox"> <view class="bigBox">
<view class="topBar" :style="{'padding-top':systemBarHeight.statusBarHeight+'px','height':systemBarHeight.navigationBarHeight+'px'}"> <view
<u-icon @click="Utils.goBack()" name="arrow-left" color="#000000" size="20"></u-icon> class="topBar"
<view class="tabTitle" :style="{'line-height':systemBarHeight.navigationBarHeight+'px'}">个人信息</view> :style="{
'padding-top': systemBarHeight.statusBarHeight + 'px',
height: systemBarHeight.navigationBarHeight + 'px',
}"
>
<u-icon
@click="Utils.goBack()"
name="arrow-left"
color="#000000"
size="20"
></u-icon>
<view
class="tabTitle"
:style="{ 'line-height': systemBarHeight.navigationBarHeight + 'px' }"
>个人信息</view
>
</view> </view>
<view class="page" :style="{'padding-top':(systemBarHeight.statusBarHeight+systemBarHeight.navigationBarHeight)+'px'}"> <view
class="page"
:style="{
'padding-top':
systemBarHeight.statusBarHeight +
systemBarHeight.navigationBarHeight +
'px',
}"
>
<view class="avatarBox"> <view class="avatarBox">
<button class="avatarBtn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"> <button
<image class="avatar" :src="userInfo.avatarUrl"/> class="avatarBtn"
open-type="chooseAvatar"
@chooseavatar="onChooseAvatar"
>
<image class="avatar" :src="userInfo.avatarUrl" />
</button> </button>
</view> </view>
<view class="infoBox"> <view class="infoBox">
<view class="infoItem name"> <view class="infoItem name">
<view class="label">昵称</view> <view class="label">昵称</view>
<view class="input"><input type="nickname" v-model="userInfo.name"></view> <view class="input"
<view class="tip" v-if="valate">{{valateText}}</view> ><input type="nickname" v-model="userInfo.name"
/></view>
<view class="tip" v-if="valate">{{ valateText }}</view>
</view> </view>
<view class="infoItem phone"> <view class="infoItem phone">
<view class="label">手机</view> <view class="label">手机</view>
<view class="input">{{userInfo.phone}}</view> <view class="input">{{ userInfo.phone }}</view>
</view> </view>
<view class="infoItem sex"> <view class="infoItem sex">
<view class="label">性别</view> <view class="label">性别</view>
<view class="input"> <view class="input">
<view class="sexBox"> <view class="sexBox">
<view class="sex" v-for="(item,index) in sexList" :key="index" @click="selectedSex(item)"> <view
<view :class="item.value===userInfo.sex?'checked':'nochecked'"></view> class="sex"
<view class="checkLabel">{{item.label}}</view> v-for="(item, index) in sexList"
:key="index"
@click="selectedSex(item)"
>
<view
:class="item.value === userInfo.sex ? 'checked' : 'nochecked'"
></view>
<view class="checkLabel">{{ item.label }}</view>
</view> </view>
</view> </view>
</view> </view>
...@@ -35,8 +71,12 @@ ...@@ -35,8 +71,12 @@
<view class="label">生日</view> <view class="label">生日</view>
<view class="input"> <view class="input">
<view class="birthdayBox"> <view class="birthdayBox">
<view :class="canEditBirthday?'text':'textDisabled'">{{birthdayComuted}}</view> <view :class="canEditBirthday ? 'text' : 'textDisabled'">{{
<view class="btn" v-if="canEditBirthday" @click="changeBirthday">修改</view> birthdayComuted
}}</view>
<view class="btn" v-if="canEditBirthday" @click="changeBirthday"
>修改</view
>
</view> </view>
</view> </view>
</view> </view>
...@@ -46,12 +86,12 @@ ...@@ -46,12 +86,12 @@
</view> </view>
</view> </view>
<show-toast ref="toast"/> <show-toast ref="toast" />
<!-- <button @click="exit">退出</button> --> <!-- <button @click="exit">退出</button> -->
<u-datetime-picker <u-datetime-picker
:show="timerShow" :show="timerShow"
:maxDate="(new Date()).valueOf()" :maxDate="new Date().valueOf()"
:minDate="-631094400" :minDate="-631094400"
@close="timerShow = false" @close="timerShow = false"
@confirm="choseTime" @confirm="choseTime"
...@@ -71,111 +111,117 @@ ...@@ -71,111 +111,117 @@
</template> </template>
<script> <script>
import Modal from '@/components/Modal/index.vue' import Modal from "@/components/Modal/index.vue";
import Mine from '@/request/mine' import Mine from "@/request/mine";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import Store from '@/store'; import Store from "@/store";
export default { export default {
components: { Modal }, components: { Modal },
computed:{ computed: {
birthdayComuted(){ birthdayComuted() {
const {birthday} = this.userInfo const { birthday } = this.userInfo;
const date = new Date(birthday) const date = new Date(birthday);
const years = date.getFullYear() const years = date.getFullYear();
const month = date.getMonth()+1 const month = date.getMonth() + 1;
const days = date.getDate() const days = date.getDate();
return years+'.'+month+'.'+days return years + "." + month + "." + days;
}, },
userInfoStorage() { userInfoStorage() {
return uni.getStorageSync('UserInfo'); return uni.getStorageSync("UserInfo");
}, },
systemBarHeight(){ systemBarHeight() {
return this.$store.state.user.systemBarHeight return this.$store.state.user.systemBarHeight;
}
}, },
watch:{ },
'userInfo.name':{ watch: {
handler(val){ "userInfo.name": {
console.log(val) handler(val) {
if(!/^[0-9a-zA-z\u4e00-\u9fa5]{0,7}$/.test(val)){ console.log(val);
this.valateText = '最多7个字符,不可输入标点符号及特殊字符' if (!/^[0-9a-zA-z\u4e00-\u9fa5]{0,7}$/.test(val)) {
this.valate = true this.valateText = "最多7个字符,不可输入标点符号及特殊字符";
}else{ this.valate = true;
if(!val){ } else {
this.valateText = '请输入昵称' if (!val) {
this.valate = true this.valateText = "请输入昵称";
}else{ this.valate = true;
this.valateText = '' } else {
this.valate = false this.valateText = "";
} this.valate = false;
}
} }
} }
}, },
},
},
data() { data() {
return { return {
Utils, Utils,
valateText:'', valateText: "",
canEditBirthday:true, canEditBirthday: true,
valate:false, valate: false,
rules:{ rules: {
name:[ name: [
{ {
required: true, required: true,
errorMessage: '请输入姓名' errorMessage: "请输入姓名",
} },
] ],
}, },
timerShow: false, timerShow: false,
birthdayModalShow:false, birthdayModalShow: false,
value1: Number(new Date()), value1: Number(new Date()),
userInfo: { userInfo: {
avatarUrl:'../../../static/touxiang.png', avatarUrl: "../../../static/touxiang.png",
name:'脸脸', name: "脸脸",
phone:'152****8932', phone: "152****8932",
sex:0, sex: 0,
birthday:1658679810130, birthday: 1658679810130,
id:'' id: "",
}, },
sexList:[ sexList: [
{ {
'label':'男', label: "男",
'value':0 value: 0,
}, },
{ {
'label':'女', label: "女",
'value':1 value: 1,
}, },
] ],
} };
}, },
async onLoad(option) { async onLoad(option) {
const {info} = option const { info } = option;
// if(info){ // if(info){
const {avatarUrl,gender=0,nickName='点点'} = info?JSON.parse(decodeURIComponent(info)):{} const {
const {data} = await Mine.getUserInfo() avatarUrl,
const { birthday, createTime, id, phone, sex, userName } = data.data gender = 0,
this.userInfo.id = id nickName = "点点",
this.canEditBirthday = !birthday } = info ? JSON.parse(decodeURIComponent(info)) : {};
if(!birthday){ const { data } = await Mine.getUserInfo();
this.userInfo.birthday = new Date(createTime.replace(/-/g,'/')).valueOf() const { birthday, createTime, id, phone, sex, userName } = data.data;
}else{ this.userInfo.id = id;
this.userInfo.birthday = Date.parse(birthday) this.canEditBirthday = !birthday;
} if (!birthday) {
this.userInfo.birthday = new Date(
this.userInfo.avatarUrl = avatarUrl createTime.replace(/-/g, "/")
this.userInfo.sex = sex?sex?1:0:gender ).valueOf();
this.userInfo.name = nickName } else {
this.userInfo.phone = phone.substr(0,3) + "****" + phone.substr(7) this.userInfo.birthday = Date.parse(birthday);
}
const {...result} = this.userInfoStorage
const sendData ={ this.userInfo.avatarUrl = avatarUrl;
this.userInfo.sex = sex ? (sex ? 1 : 0) : gender;
this.userInfo.name = nickName;
this.userInfo.phone = phone.substr(0, 3) + "****" + phone.substr(7);
const { ...result } = this.userInfoStorage;
const sendData = {
...result, ...result,
avatarUrl, avatarUrl,
canEditBirthday:this.canEditBirthday canEditBirthday: this.canEditBirthday,
} };
Store.commit('setUserInfo', sendData); Store.commit("setUserInfo", sendData);
// this.save(false) // this.save(false)
// }else{ // }else{
// const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage // const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage
...@@ -187,22 +233,21 @@ export default { ...@@ -187,22 +233,21 @@ export default {
// this.userInfo.id = id // this.userInfo.id = id
// this.userInfo.phone = phone // this.userInfo.phone = phone
// } // }
}, },
methods:{ methods: {
async choseTime(e) { async choseTime(e) {
const sendDate = { const sendDate = {
birthday:this.userInfo.birthday, birthday: this.userInfo.birthday,
id:this.userInfo.id id: this.userInfo.id,
} };
const {data} = await Mine.editBirthdat(sendDate) const { data } = await Mine.editBirthdat(sendDate);
const {code} = data const { code } = data;
if(code===200){ if (code === 200) {
this.canEditBirthday = false this.canEditBirthday = false;
this.showToast({ title: '修改成功'}) this.showToast({ title: "信息修改成功" });
this.userInfo.birthday = e.value this.userInfo.birthday = e.value;
} }
this.timerShow = false this.timerShow = false;
}, },
// editAvatar(e) { // editAvatar(e) {
// console.log(123) // console.log(123)
...@@ -221,100 +266,103 @@ export default { ...@@ -221,100 +266,103 @@ export default {
// }) // })
// }, // },
async onChooseAvatar(e) { async onChooseAvatar(e) {
const { detail } = e const { detail } = e;
const { avatarUrl } = detail const { avatarUrl } = detail;
this.userInfo.avatarUrl = avatarUrl this.userInfo.avatarUrl = avatarUrl;
let Authorization = uni.getStorageSync(`Authorization`); let Authorization = uni.getStorageSync(`Authorization`);
// await Mine.upLoadImg(formData) // await Mine.upLoadImg(formData)
// 上传头像接口 // 上传头像接口
uni.uploadFile({ uni.uploadFile({
url:`${this.getBaseUrl()}/common/uploadOss`, url: `${this.getBaseUrl()}/common/uploadOss`,
filePath:avatarUrl, filePath: avatarUrl,
name:'file', name: "file",
header: { header: {
'Authorization':Authorization Authorization: Authorization,
}, },
success: (uploadFileRes)=>{ success: (uploadFileRes) => {
const { data } =uploadFileRes const { data } = uploadFileRes;
this.userInfo.avatarUrl = data this.userInfo.avatarUrl = data;
} },
}) });
}, },
getBaseUrl() { getBaseUrl() {
let path = process.env.ENV_PATH == undefined?require('../../../env/dev.js'): require(process.env.ENV_PATH) let path =
process.env.ENV_PATH == undefined
? require("../../../env/dev.js")
: require(process.env.ENV_PATH);
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// ---------------- 根据微信开发环境配置请求地址 -------------------- // ---------------- 根据微信开发环境配置请求地址 --------------------
// 获取当前帐号信息 // 获取当前帐号信息
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
// env类型 develop:开发版、trial:体验版、release:正式版 // env类型 develop:开发版、trial:体验版、release:正式版
const envWx = accountInfo.miniProgram.envVersion; const envWx = accountInfo.miniProgram.envVersion;
if(envWx === 'release'){ if (envWx === "release") {
path = 'https://api.ihaoin.com' path = "https://api.ihaoin.com";
}else{ } else {
path = 'https://hooloo-dev-api.gdatac.com' path = "https://hooloo-dev-api.gdatac.com";
} }
// #endif // #endif
return path return path;
}, },
openTimer() { openTimer() {
this.birthdayModalShow = false this.birthdayModalShow = false;
this.timerShow = true this.timerShow = true;
}, },
changeBirthday(){ changeBirthday() {
this.birthdayModalShow = true this.birthdayModalShow = true;
}, },
selectedSex(val){ selectedSex(val) {
console.log(val) console.log(val);
this.userInfo.sex = val.value this.userInfo.sex = val.value;
}, },
exit(){ exit() {
wx.exitMiniProgram({ wx.exitMiniProgram({
success:()=>{ success: () => {
console.log(123) console.log(123);
} },
}) });
}, },
async save(isReturn = true) { async save(isReturn = true) {
const {customerName,...result} = this.userInfoStorage const { customerName, ...result } = this.userInfoStorage;
if(!this.valate){ if (!this.valate) {
const {sex,name,id,avatarUrl} = this.userInfo const { sex, name, id, avatarUrl } = this.userInfo;
const sendData = { const sendData = {
sex: Number(sex)===0?false:true, sex: Number(sex) === 0 ? false : true,
userName: name, userName: name,
id id,
} };
console.log(sendData) console.log(sendData);
await Mine.editUserAvatar({avatarUrl:avatarUrl,id}) await Mine.editUserAvatar({ avatarUrl: avatarUrl, id });
const { data } = await Mine.editUserInfo(sendData) const { data } = await Mine.editUserInfo(sendData);
console.log(data) console.log(data);
const {code = 0} = data const { code = 0 } = data;
if(code===200){ if (code === 200) {
this.showToast({ title: '保存成功'}) this.showToast({ title: "保存成功" });
const data = { const data = {
...result, ...result,
customerName:name, customerName: name,
avatarUrl, avatarUrl,
canEditBirthday:this.canEditBirthday, canEditBirthday: this.canEditBirthday,
sex sex,
} };
Store.commit('setUserInfo', data); Store.commit("setUserInfo", data);
uni.setStorage({ key: 'userInfo', data: data }); uni.setStorage({ key: "userInfo", data: data });
uni.setStorageSync('UserInfo',data) uni.setStorageSync("UserInfo", data);
if(isReturn){ if (isReturn) {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1,
}); });
} }
} }
} }
} },
} },
} };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
.bigBox { .bigBox {
.topBar{ .topBar {
position: fixed; position: fixed;
width: 100%; width: 100%;
background: white; background: white;
...@@ -323,30 +371,28 @@ export default { ...@@ -323,30 +371,28 @@ export default {
align-items: center; align-items: center;
z-index: 9999; z-index: 9999;
padding-left: 34rpx; padding-left: 34rpx;
.tabTitle{ .tabTitle {
font-size: 32rpx; font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600; font-weight: 600;
text-align: center; text-align: center;
width: 79%; width: 79%;
color: #333333 color: #333333;
} }
} }
} }
.page {
.page{ background: #f8f8f8;
background: #F8F8F8;
height: 100vh; height: 100vh;
} }
.avatarBox { .avatarBox {
z-index: 1; z-index: 1;
width: 100%; width: 100%;
height: 320rpx; height: 320rpx;
display: flex; display: flex;
align-items: center; align-items: center;
background: #FFFFFF; background: #ffffff;
.avatarBtn { .avatarBtn {
border: 0px; border: 0px;
background: white; background: white;
...@@ -362,12 +408,11 @@ export default { ...@@ -362,12 +408,11 @@ export default {
.avatarBtn::after { .avatarBtn::after {
border: none; border: none;
} }
}
} .infoBox {
.infoBox {
z-index: 1; z-index: 1;
background: #FFFFFF; background: #ffffff;
overflow: hidden; overflow: hidden;
padding: 0rpx 38rpx 0rpx 40rpx; padding: 0rpx 38rpx 0rpx 40rpx;
margin-top: 24rpx; margin-top: 24rpx;
...@@ -386,7 +431,7 @@ export default { ...@@ -386,7 +431,7 @@ export default {
.infoItem { .infoItem {
height: 99rpx; height: 99rpx;
border-bottom: 1rpx solid #ECECEC; border-bottom: 1rpx solid #ececec;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: flex-start; justify-content: flex-start;
...@@ -421,16 +466,18 @@ export default { ...@@ -421,16 +466,18 @@ export default {
.checked { .checked {
width: 24rpx; width: 24rpx;
height: 24rpx; height: 24rpx;
background: url('../../../static/imgs/duigouxuanzhong.png') center center no-repeat; background: url("../../../static/imgs/duigouxuanzhong.png") center
background-size:100% 100%; center no-repeat;
background-size: 100% 100%;
margin-right: 16rpx; margin-right: 16rpx;
} }
.nochecked { .nochecked {
width: 24rpx; width: 24rpx;
height: 24rpx; height: 24rpx;
background: url('../../../static/imgs/weixuanzhong.png') center center no-repeat; background: url("../../../static/imgs/weixuanzhong.png") center
background-size:100% 100%; center no-repeat;
background-size: 100% 100%;
margin-right: 16rpx; margin-right: 16rpx;
} }
...@@ -454,52 +501,49 @@ export default { ...@@ -454,52 +501,49 @@ export default {
width: 96rpx; width: 96rpx;
height: 48rpx; height: 48rpx;
border-radius: 2rpx; border-radius: 2rpx;
border: 2rpx solid #0050F6; border: 2rpx solid #0050f6;
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
text-align: center; text-align: center;
color: #0050F6; color: #0050f6;
line-height: 48rpx; line-height: 48rpx;
margin-left: 192rpx; margin-left: 192rpx;
} }
} }
} }
} }
.infoItem:last-child { .infoItem:last-child {
border: 0rpx; border: 0rpx;
} }
} }
.saveBtn { .saveBtn {
width: 670rpx; width: 670rpx;
height: 98rpx; height: 98rpx;
margin: 0 auto; margin: 0 auto;
margin-top: 32rpx; margin-top: 32rpx;
.btn { .btn {
background: #0050F6; background: #0050f6;
border-radius: 2px; border-radius: 2px;
font-size: 32rpx; font-size: 32rpx;
height: 98rpx; height: 98rpx;
line-height: 98rpx; line-height: 98rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
} }
.btn::before { .btn::before {
background: #0050F6; background: #0050f6;
border-radius: 2px; border-radius: 2px;
font-size: 32rpx; font-size: 32rpx;
height: 98rpx; height: 98rpx;
line-height: 98rpx; line-height: 98rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
}
} }
}
</style> </style>
<template> <template>
<div class="pages"> <div class="pages">
<view class="topBar" :style="{'padding-top':statusBarHeight+'px','height':navigationBarHeight+'px'}"> <view
<u-icon @click="goBackOrder" name="arrow-left" color="#000000" size="20"></u-icon> class="topBar"
<view class="tabTitle" :style="{'line-height':navigationBarHeight+'px'}">订单详情</view> :style="{
'padding-top': statusBarHeight + 'px',
height: navigationBarHeight + 'px',
}"
>
<u-icon
@click="goBackOrder"
name="arrow-left"
color="#000000"
size="20"
></u-icon>
<view
class="tabTitle"
:style="{ 'line-height': navigationBarHeight + 'px' }"
>订单详情</view
>
</view> </view>
<div class="order_status" :style="{'margin-top':(statusBarHeight+navigationBarHeight+getPx(32))+'px'}"> <div
class="order_status"
:style="{
'margin-top': statusBarHeight + navigationBarHeight + getPx(32) + 'px',
}"
>
<view class="status_text">订单状态:{{ orderStatusText }}</view> <view class="status_text">订单状态:{{ orderStatusText }}</view>
<view class="tips"> <view class="tips">
<view v-if="orderInfo.state == 7">为保持口感,请尽快饮用哦~</view> <view v-if="orderInfo.state == 7">为保持口感,请尽快饮用哦~</view>
<view v-if="orderInfo.state == 4">订单已制作完成,请尽快取餐~</view> <view v-if="orderInfo.state == 4">订单已制作完成,请尽快取餐~</view>
<view v-if="orderInfo.state >= 8 && orderInfo.state <= 15">非常抱歉,我们会继续努力的~</view> <view v-if="orderInfo.state >= 8 && orderInfo.state <= 15"
<view v-if="orderInfo.state == 2 || orderInfo.state == 3">请您耐心等候,预计<text class="time">{{waitTime}}</text>分钟后可取</view> >非常抱歉,我们会继续努力的~</view
>
<view v-if="orderInfo.state == 2 || orderInfo.state == 3"
>请您耐心等候,预计<text class="time">{{ waitTime }}</text
>分钟后可取</view
>
</view> </view>
<div class="btns"> <div class="btns">
<a type="primary" @click="cancelOrder" v-if="orderInfo.state == 1" class="btn_cancel">取消订单</a> <a
<a type="primary" @click="PayNow" v-if="orderInfo.state == 1" class="btn">立即支付</a> type="primary"
<a type="primary" @click="toRefund" v-if="orderInfo.state == 2" class="btn_cancel">申请退款</a> @click="cancelOrder"
<a type="primary" @click="oneMoreOrder(orderInfo)" v-if="orderInfo.state != 1" class="btn">再来一单</a> v-if="orderInfo.state == 1"
<a type="primary" @click="refundInfo" v-if="checkStatus(orderInfo.state,[12,13,14,15])" class="btn_cancel">退款详情</a> class="btn_cancel"
>取消订单</a
>
<a
type="primary"
@click="PayNow"
v-if="orderInfo.state == 1"
class="btn"
>立即支付</a
>
<a
type="primary"
@click="toRefund"
v-if="orderInfo.state == 2"
class="btn_cancel"
>申请退款</a
>
<a
type="primary"
@click="oneMoreOrder(orderInfo)"
v-if="orderInfo.state != 1"
class="btn"
>再来一单</a
>
<a
type="primary"
@click="refundInfo"
v-if="checkStatus(orderInfo.state, [12, 13, 14, 15])"
class="btn_cancel"
>退款详情</a
>
</div> </div>
</div> </div>
<div class="order_flow" v-if="qrShow"> <div class="order_flow" v-if="qrShow">
<div v-if="qrShow" class="code">取单码 {{ orderInfo.orderNum }}</div> <div v-if="qrShow" class="code">取单码 {{ orderInfo.orderNum }}</div>
<div class="realQrcodeBox" v-if="qrShow&&isBuild"> <div class="realQrcodeBox" v-if="qrShow && isBuild">
<image mode="aspectFit" :src="ewmImg"/> <image mode="aspectFit" :src="ewmImg" />
</div> </div>
<div v-if="qrShow&&!isBuild" class="qr_code" > <div v-if="qrShow && !isBuild" class="qr_code">
<image mode="aspectFit" :src="'/static/imgs/erweimazhedang.png'" class="qr" /> <image
mode="aspectFit"
:src="'/static/imgs/erweimazhedang.png'"
class="qr"
/>
</div> </div>
<!-- <view class="scan_tips" v-if="qrTextShow">——制作完成后才能扫哦——</view> --> <!-- <view class="scan_tips" v-if="qrTextShow">——制作完成后才能扫哦——</view> -->
<canvas v-if="qrShow" class="canvas-code" canvas-id="myQrcode" style="background:#fff;width: 200px;height: 200px; display:block; left:-800rpx;position:absolute;" /> <canvas
v-if="qrShow"
class="canvas-code"
canvas-id="myQrcode"
style="
background: #fff;
width: 200px;
height: 200px;
display: block;
left: -800rpx;
position: absolute;
"
/>
<div v-if="qrShow" class="flow_describe"> <div v-if="qrShow" class="flow_describe">
<view class="titleBox"> <view class="titleBox">
<view class="qrcodeTitle"> <view class="qrcodeTitle">
<view class="title">扫码流程</view> <view class="title">扫码流程</view>
<view class="icon"> <view class="icon">
<u-icon name="question-circle" color="#999999" :size="getPx(34)"></u-icon> <u-icon
name="question-circle"
color="#999999"
:size="getPx(34)"
></u-icon>
</view> </view>
</view> </view>
<view class="right" @click="goShow()"> <view class="right" @click="goShow()">
<view class="Text"> <view class="Text">
<view>查看实景演示</view> <view>查看实景演示</view>
<image class="arrow" :style="{'height':'18rpx','width':'10rpx'}" :src="'../../../static/imgs/jiantouhui.png'" /> <image
class="arrow"
:style="{ height: '18rpx', width: '10rpx' }"
:src="'../../../static/imgs/jiantouhui.png'"
/>
</view> </view>
</view> </view>
</view> </view>
<image :mode="'aspectFit'" class="flow_img" src="/static/imgs/saomaliucheng.png" /> <image
:mode="'aspectFit'"
class="flow_img"
src="/static/imgs/saomaliucheng.png"
/>
</div> </div>
</div> </div>
<div class="shop_info"> <div class="shop_info">
...@@ -56,8 +139,16 @@ ...@@ -56,8 +139,16 @@
<div v-for="item in orderInfo.orderDetails" :key="item.id"> <div v-for="item in orderInfo.orderDetails" :key="item.id">
<div class="goods"> <div class="goods">
<div class="goods_item"> <div class="goods_item">
<image v-if="jsonParse(item.goods.pics).thumbnailApplet" :src="jsonParse(item.goods.pics).thumbnailApplet" class="goods_img" /> <image
<image v-else :src="jsonParse(item.goods.pics).thumbnail" class="goods_img" /> v-if="jsonParse(item.goods.pics).thumbnailApplet"
:src="jsonParse(item.goods.pics).thumbnailApplet"
class="goods_img"
/>
<image
v-else
:src="jsonParse(item.goods.pics).thumbnail"
class="goods_img"
/>
<div class="goods_text"> <div class="goods_text">
<div class="goods_name"> <div class="goods_name">
<div class="name">{{ item.goodsName }}</div> <div class="name">{{ item.goodsName }}</div>
...@@ -65,9 +156,15 @@ ...@@ -65,9 +156,15 @@
</div> </div>
<div class="goods_psce"> <div class="goods_psce">
<div class="psce_name"> <div class="psce_name">
<span v-for="(rule, index) in jsonParse(item.specRuleDetail)" :key="rule.specId"> <span
v-for="(rule, index) in jsonParse(item.specRuleDetail)"
:key="rule.specId"
>
{{ rule.ruleName }} {{ rule.ruleName }}
<text v-if="index != jsonParse(item.specRuleDetail).length - 1">/</text> <text
v-if="index != jsonParse(item.specRuleDetail).length - 1"
>/</text
>
</span> </span>
</div> </div>
<div class="size">x{{ item.num }}</div> <div class="size">x{{ item.num }}</div>
...@@ -80,7 +177,9 @@ ...@@ -80,7 +177,9 @@
<div class="coupon" v-if="orderInfo.couponAmount"> <div class="coupon" v-if="orderInfo.couponAmount">
<div class="title">HOOLOO券</div> <div class="title">HOOLOO券</div>
<div class="num-action"> <div class="num-action">
<span class="price">-¥{{String(orderInfo.couponAmount).replace("-","")}}</span> <span class="price"
>-¥{{ String(orderInfo.couponAmount).replace("-", "") }}</span
>
</div> </div>
</div> </div>
...@@ -88,7 +187,10 @@ ...@@ -88,7 +187,10 @@
<div class="size">{{ totalNum }}件商品</div> <div class="size">{{ totalNum }}件商品</div>
<div class="price"> <div class="price">
<span class="paid_in">实付</span> <span class="paid_in">实付</span>
<span class="money"><text class="money_logo"></text>{{ Utils.isInteger(orderInfo.paidAmount) }}</span> <span class="money"
><text class="money_logo"></text
>{{ Utils.isInteger(orderInfo.paidAmount) }}</span
>
</div> </div>
</div> </div>
</div> </div>
...@@ -111,37 +213,45 @@ ...@@ -111,37 +213,45 @@
</view> </view>
</div> </div>
<div class="customer_service"> <div class="customer_service">
<button class="function_item_text" open-type="contact" bindcontact="handleContact" session-from="sessionFrom"> <button
class="function_item_text"
open-type="contact"
bindcontact="handleContact"
session-from="sessionFrom"
>
<view class="serverBox"> <view class="serverBox">
<u-icon name="server-fill" color="#000000" size="16"></u-icon> <u-icon name="server-fill" color="#000000" size="16"></u-icon>
<span :style="{'margin-left':'16rpx'}">联系客服</span> <span :style="{ 'margin-left': '16rpx' }">联系客服</span>
</view> </view>
<view> <view>
<image class="icno-arrow" :src="'../../../static/imgs/jiantouhei.png'" /> <image
class="icno-arrow"
:src="'../../../static/imgs/jiantouhei.png'"
/>
</view> </view>
</button> </button>
</div> </div>
<show-toast ref="toast"/> <show-toast ref="toast" />
</div> </div>
</template> </template>
<script> <script>
import Order from '@/request/order'; import Order from "@/request/order";
import QRCode from '@/utils/qrCode' import QRCode from "@/utils/qrCode";
import Menu from '@/request/menu'; import Menu from "@/request/menu";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import { systemInfo } from '@/utils/mixin.js' import { systemInfo } from "@/utils/mixin.js";
import { $EventBus } from "@/utils/EventBus"; import { $EventBus } from "@/utils/EventBus";
export default { export default {
mixins: [systemInfo], mixins: [systemInfo],
onLoad(option) { onLoad(option) {
this.Authorization = uni.getStorageSync('Authorization') this.Authorization = uni.getStorageSync("Authorization");
this.initData(option) this.initData(option);
}, },
onShow() { onShow() {
uni.setStorageSync('allow',true) uni.setStorageSync("allow", true);
uni.setStorageSync('goodsList',{}) uni.setStorageSync("goodsList", {});
// this.backToMneu = false // this.backToMneu = false
}, },
// onUnload(){ // onUnload(){
...@@ -150,30 +260,30 @@ export default { ...@@ -150,30 +260,30 @@ export default {
data() { data() {
return { return {
orderInfo: {}, orderInfo: {},
ewmImg: '', ewmImg: "",
Utils, Utils,
isBuild:true, isBuild: true,
waitTime:0, waitTime: 0,
backFlag:false, backFlag: false,
backToMneu:false, backToMneu: false,
Authorization:'' Authorization: "",
} };
}, },
methods: { methods: {
goShow() { goShow() {
uni.navigateTo({url:'/orderSubPackage/pages/showhow/index'}) uni.navigateTo({ url: "/orderSubPackage/pages/showhow/index" });
}, },
refundInfo() { refundInfo() {
const { id } = this.orderInfo const { id } = this.orderInfo;
uni.setStorageSync('orderId', id); uni.setStorageSync("orderId", id);
let url = '/orderSubPackage/pages/refundInfo/index' let url = "/orderSubPackage/pages/refundInfo/index";
uni.navigateTo({ url }) uni.navigateTo({ url });
}, },
checkStatus(status,list){ checkStatus(status, list) {
if(list.includes(Number(status))){ if (list.includes(Number(status))) {
return true return true;
}else{ } else {
return false return false;
} }
}, },
getPx(rpx) { getPx(rpx) {
...@@ -181,90 +291,97 @@ export default { ...@@ -181,90 +291,97 @@ export default {
// console.log(wx.getSystemInfoSync().windowWidth); // console.log(wx.getSystemInfoSync().windowWidth);
return rpx * (wx.getSystemInfoSync().windowWidth / 750); return rpx * (wx.getSystemInfoSync().windowWidth / 750);
}, },
goBackOrder(){ goBackOrder() {
this.backFlag = true this.backFlag = true;
this.goBack() this.goBack();
}, },
goBack(){ goBack() {
console.log(this.backToMneu,'backToMneu') console.log(this.backToMneu, "backToMneu");
if(this.backFlag){ if (this.backFlag) {
if(this.backToMneu){ if (this.backToMneu) {
uni.switchTab({ url: '/pages/menu/menu' }) uni.switchTab({ url: "/pages/menu/menu" });
}else{ } else {
uni.switchTab({ url: '/pages/order/order' }) uni.switchTab({ url: "/pages/order/order" });
} }
this.backFlag = false this.backFlag = false;
} }
}, },
async oneMoreOrder(item) { async oneMoreOrder(item) {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync("shopCarInfo");
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
const numObj = {} const numObj = {};
const { id, shopId, orderDetails } = item; const { id, shopId, orderDetails } = item;
const newOrderDetail = [...orderDetails] const newOrderDetail = [...orderDetails];
newOrderDetail.forEach(item => { newOrderDetail.forEach((item) => {
newOrderDetail[item.skuId] = Number(item.num) newOrderDetail[item.skuId] = Number(item.num);
}) });
const { data } = await Order.moreOrder({ orderId: id, shopId }); const { data } = await Order.moreOrder({ orderId: id, shopId });
if(!data || !data.data){ if (!data || !data.data) {
this.showToast({ title: "该订单中的商品已经售罄了" }); this.showToast({ title: "这款已经卖完啦" });
return; return;
} }
let list = new Array(); let list = new Array();
data.data.forEach(item => { data.data.forEach((item) => {
const skuId = item.skus[0].skuId const skuId = item.skus[0].skuId;
const nextData = { ...item, skuId, num: newOrderDetail[skuId], flag: true, sku: item.skus[0] } const nextData = {
...item,
skuId,
num: newOrderDetail[skuId],
flag: true,
sku: item.skus[0],
};
if (nextData.sku.state == 1) { if (nextData.sku.state == 1) {
list.push(nextData); list.push(nextData);
} }
}); });
if(!list || list.length<=0) { if (!list || list.length <= 0) {
this.showToast({ title: "该订单中的商品已经售罄了", icon: 'error' }); this.showToast({ title: "这款已经卖完啦", icon: "error" });
return; return;
} }
list.forEach(nextData => { list.forEach((nextData) => {
Utils.getallNum(nextData); Utils.getallNum(nextData);
}) });
this.backFlag = false this.backFlag = false;
uni.switchTab({ url: '/pages/menu/menu' }) uni.switchTab({ url: "/pages/menu/menu" });
}, },
async initData(option){ async initData(option) {
this.getSystemInfo() this.getSystemInfo();
this.backToMneu = false this.backToMneu = false;
this.backFlag = true this.backFlag = true;
let oId = uni.getStorageSync('orderId'); let oId = uni.getStorageSync("orderId");
console.log(option,'option') console.log(option, "option");
if(JSON.stringify(option)!=='{}'&&option){ if (JSON.stringify(option) !== "{}" && option) {
this.option = JSON.stringify(option) this.option = JSON.stringify(option);
const { orderId = '',from = '' } = option const { orderId = "", from = "" } = option;
// 从结算进入 // 从结算进入
console.log(from) console.log(from);
if(from==='settlement'){ if (from === "settlement") {
uni.setStorageSync('shopCarInfo',[]) uni.setStorageSync("shopCarInfo", []);
this.backToMneu = true this.backToMneu = true;
} }
// 从订阅消息进入 // 从订阅消息进入
let Authorization = uni.getStorageSync('Authorization') let Authorization = uni.getStorageSync("Authorization");
if(orderId){ if (orderId) {
uni.setStorageSync("updataShopCar",false) uni.setStorageSync("updataShopCar", false);
if(!Authorization){ if (!Authorization) {
this.backFlag = true this.backFlag = true;
uni.switchTab({ url: '/pages/order/order' }) uni.switchTab({ url: "/pages/order/order" });
return return;
}else{ } else {
this.backFlag = false this.backFlag = false;
oId = orderId oId = orderId;
} }
} }
} }
// return // return
const {data = {}} = await Order.getOrderDetail({orderId:oId}) const { data = {} } = await Order.getOrderDetail({ orderId: oId });
this.orderInfo = data?.data this.orderInfo = data?.data;
const getTime = ['2', '3'].indexOf(this.orderInfo.state) >= 0 const getTime = ["2", "3"].indexOf(this.orderInfo.state) >= 0;
const isBuild = ['2','3','4', '5'].indexOf(this.orderInfo.state) >= 0; const isBuild = ["2", "3", "4", "5"].indexOf(this.orderInfo.state) >= 0;
if(getTime){ if (getTime) {
const {data = {}} = await Order.getOrderWaiteTime({orderId:oId})||{} const { data = {} } =
this.waitTime = data?.data (await Order.getOrderWaiteTime({ orderId: oId })) || {};
this.waitTime = data?.data;
} }
if (isBuild) { if (isBuild) {
// new QRCode('myQrcode', { // new QRCode('myQrcode', {
...@@ -274,20 +391,20 @@ export default { ...@@ -274,20 +391,20 @@ export default {
// padding: 0, // 生成二维码四周自动留边宽度,不传入默认为0 // padding: 0, // 生成二维码四周自动留边宽度,不传入默认为0
// correctLevel: QRCode.CorrectLevel.L, // 二维码可辨识度 // correctLevel: QRCode.CorrectLevel.L, // 二维码可辨识度
// callback: (res) => { // callback: (res) => {
this.ewmImg = this.orderInfo.pickCode this.ewmImg = this.orderInfo.pickCode;
// } // }
// }) // })
} }
this.isBuild = isBuild this.isBuild = isBuild;
}, },
async PayNow() { async PayNow() {
const orderInfo = await Order.payOrder({ orderId: this.orderInfo.id }) const orderInfo = await Order.payOrder({ orderId: this.orderInfo.id });
const sendData = { const sendData = {
orderId: this.orderInfo.id, orderId: this.orderInfo.id,
switchTab:false, switchTab: false,
callBack:this.initData, callBack: this.initData,
...orderInfo.data.data ...orderInfo.data.data,
} };
if (orderInfo) { if (orderInfo) {
if (orderInfo && orderInfo.data.code == 200) { if (orderInfo && orderInfo.data.code == 200) {
await Menu.requestPayment(sendData); await Menu.requestPayment(sendData);
...@@ -296,44 +413,46 @@ export default { ...@@ -296,44 +413,46 @@ export default {
}, },
toRefund() { toRefund() {
uni.showModal({ uni.showModal({
title: '确认退款', title: "确认退款",
success: (res) => { success: (res) => {
if (res.confirm) { if (res.confirm) {
Order.orderRefund({ orderId: this.orderInfo.id, refundAmount: this.orderInfo.paidAmount }).then(res => { Order.orderRefund({
this.initData() orderId: this.orderInfo.id,
}) refundAmount: this.orderInfo.paidAmount,
}).then((res) => {
this.initData();
});
} else if (res.cancel) { } else if (res.cancel) {
console.log('用户点击取消'); console.log("用户点击取消");
}
} }
}) },
});
}, },
jsonParse(json) { jsonParse(json) {
return JSON.parse(json) return JSON.parse(json);
}, },
cancelOrder() { cancelOrder() {
Order.cancelOrder({ orderId: this.orderInfo.id }).then(res => { Order.cancelOrder({ orderId: this.orderInfo.id }).then((res) => {
this.backFlag = false this.backFlag = false;
uni.switchTab({ url: '/pages/menu/menu' }) uni.switchTab({ url: "/pages/menu/menu" });
}) });
}, },
}, },
computed: { computed: {
totalNum() { totalNum() {
let totalNum = 0; let totalNum = 0;
const {orderDetails=[]} = this.orderInfo const { orderDetails = [] } = this.orderInfo;
orderDetails.forEach(item => { orderDetails.forEach((item) => {
totalNum += parseInt(item.num); totalNum += parseInt(item.num);
}) });
return totalNum; return totalNum;
}, },
qrShow() { qrShow() {
return ['2','3','4','5'].indexOf(this.orderInfo.state) >= 0; return ["2", "3", "4", "5"].indexOf(this.orderInfo.state) >= 0;
}, },
qrTextShow() { qrTextShow() {
return ['2','3'].indexOf(this.orderInfo.state) >= 0; return ["2", "3"].indexOf(this.orderInfo.state) >= 0;
}, },
// 1 未支付 // 1 未支付
// 2 已支付 // 2 已支付
...@@ -353,58 +472,58 @@ export default { ...@@ -353,58 +472,58 @@ export default {
// 50 其他人工干预状态 // 50 其他人工干预状态
orderStatusText() { orderStatusText() {
switch (this.orderInfo.state) { switch (this.orderInfo.state) {
case '1': case "1":
return '待付款' return "待付款";
case '2': case "2":
return '待制作' return "待制作";
case '3': case "3":
return '制作中' return "制作中";
case '4': case "4":
return '待取餐' return "待取餐";
case '5': case "5":
return '取餐中' return "取餐中";
case '6': case "6":
case '7': case "7":
return '已完成' return "已完成";
case '8': case "8":
case '9': case "9":
case '10': case "10":
case '11': case "11":
return '已取消' return "已取消";
case '12': case "12":
return '退款中' return "退款中";
case '13': case "13":
return '退款失败' return "退款失败";
case '14': case "14":
return '部分退款' return "部分退款";
case '15': case "15":
return '已退款' return "已退款";
default: default:
return '未知状态' return "未知状态";
} }
}, },
qrText() { qrText() {
switch (this.orderInfo.state) { switch (this.orderInfo.state) {
case '2': case "2":
return '待制作' return "待制作";
case '3': case "3":
return '制作中' return "制作中";
default: default:
return '' return "";
} }
}, },
userms() { userms() {
return this.$store.getters.Authorization; return this.$store.getters.Authorization;
}, },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.pages { .pages {
padding-top: 1rpx; padding-top: 1rpx;
padding-bottom: 32rpx; padding-bottom: 32rpx;
.topBar{ .topBar {
position: fixed; position: fixed;
width: 100%; width: 100%;
background: white; background: white;
...@@ -416,20 +535,20 @@ export default { ...@@ -416,20 +535,20 @@ export default {
// .arrow-left { // .arrow-left {
// margin-left: 20rpx; // margin-left: 20rpx;
// } // }
.tabTitle{ .tabTitle {
font-size: 32rpx; font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600; font-weight: 600;
text-align: center; text-align: center;
width: 79%; width: 79%;
color: #333333 color: #333333;
} }
} }
} }
.order_status { .order_status {
// max-height: 174rpx; // max-height: 174rpx;
background: #FFFFFF; background: #ffffff;
margin: 32rpx 32rpx; margin: 32rpx 32rpx;
padding: 24rpx 0rpx 32rpx 0rpx; padding: 24rpx 0rpx 32rpx 0rpx;
...@@ -454,7 +573,7 @@ export default { ...@@ -454,7 +573,7 @@ export default {
font-size: 32rpx; font-size: 32rpx;
font-family: Futura Medium, Arial, sans-serif; font-family: Futura Medium, Arial, sans-serif;
font-weight: normal; font-weight: normal;
color: #0050F6; color: #0050f6;
margin: 0 16rpx; margin: 0 16rpx;
} }
} }
...@@ -475,11 +594,11 @@ export default { ...@@ -475,11 +594,11 @@ export default {
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
width: 167rpx; width: 167rpx;
height: 64rpx; height: 64rpx;
background: #0050F6; background: #0050f6;
border-radius: 2rpx; border-radius: 2rpx;
} }
.btn_cancel { .btn_cancel {
...@@ -487,17 +606,17 @@ export default { ...@@ -487,17 +606,17 @@ export default {
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #0050F6; color: #0050f6;
width: 167rpx; width: 167rpx;
height: 64rpx; height: 64rpx;
border-radius: 2rpx; border-radius: 2rpx;
border: 2rpx solid #0050F6; border: 2rpx solid #0050f6;
} }
} }
.order_flow { .order_flow {
background: #FFFFFF; background: #ffffff;
margin: 32rpx; margin: 32rpx;
padding-top: 55.01rpx; padding-top: 55.01rpx;
...@@ -507,7 +626,7 @@ export default { ...@@ -507,7 +626,7 @@ export default {
font-family: PingFangSC-Semibold, PingFang SC; font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600; font-weight: 600;
color: #333333; color: #333333;
z-index:99 z-index: 99;
} }
.status_text { .status_text {
...@@ -542,14 +661,14 @@ export default { ...@@ -542,14 +661,14 @@ export default {
color: #666666; color: #666666;
text-align: center; text-align: center;
} }
.realQrcodeBox{ .realQrcodeBox {
margin: 0 auto; margin: 0 auto;
width: 474.6rpx; width: 474.6rpx;
margin-top: 38rpx; margin-top: 38rpx;
margin-bottom: 37rpx; margin-bottom: 37rpx;
height: 476rpx; height: 476rpx;
overflow: hidden; overflow: hidden;
image{ image {
width: 100%; width: 100%;
height: 100%; height: 100%;
vertical-align: bottom; vertical-align: bottom;
...@@ -592,9 +711,6 @@ export default { ...@@ -592,9 +711,6 @@ export default {
color: #000000; color: #000000;
} }
.right { .right {
display: flex; display: flex;
margin-left: 8rpx; margin-left: 8rpx;
...@@ -627,7 +743,7 @@ export default { ...@@ -627,7 +743,7 @@ export default {
.shop_info { .shop_info {
margin: 32rpx; margin: 32rpx;
background: #FFFFFF; background: #ffffff;
padding: 40rpx 32rpx 22rpx 32rpx; padding: 40rpx 32rpx 22rpx 32rpx;
h3 { h3 {
...@@ -638,7 +754,7 @@ export default { ...@@ -638,7 +754,7 @@ export default {
} }
.address { .address {
border-bottom: 0.1px solid #F4F4F4; border-bottom: 0.1px solid #f4f4f4;
padding-bottom: 25rpx; padding-bottom: 25rpx;
.address_1 { .address_1 {
...@@ -726,14 +842,14 @@ export default { ...@@ -726,14 +842,14 @@ export default {
} }
} }
.goods:last-child { .goods:last-child {
border-bottom: 1rpx solid #EEEEEE; border-bottom: 1rpx solid #eeeeee;
padding-bottom: 30rpx; padding-bottom: 30rpx;
} }
.discount { .discount {
margin-top: 24rpx; margin-top: 24rpx;
padding-bottom: 24rpx; padding-bottom: 24rpx;
border-bottom: 0.1px solid #F4F4F4; border-bottom: 0.1px solid #f4f4f4;
.discount_1 { .discount_1 {
display: flex; display: flex;
...@@ -745,10 +861,9 @@ export default { ...@@ -745,10 +861,9 @@ export default {
color: #333333; color: #333333;
.price { .price {
font-family: Arial-BoldMT, Arial; font-family: Arial-BoldMT, Arial;
font-weight: normal; font-weight: normal;
color: #EB5F17; color: #eb5f17;
} }
} }
...@@ -777,7 +892,7 @@ export default { ...@@ -777,7 +892,7 @@ export default {
justify-content: space-between; justify-content: space-between;
margin-top: 24rpx; margin-top: 24rpx;
padding-bottom: 23.57rpx; padding-bottom: 23.57rpx;
border-bottom: 1rpx solid #EEEEEE; border-bottom: 1rpx solid #eeeeee;
.title { .title {
font-size: 28rpx; font-size: 28rpx;
...@@ -799,7 +914,7 @@ export default { ...@@ -799,7 +914,7 @@ export default {
.price { .price {
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
} }
.arrow-right-select{ .arrow-right-select {
width: 15.27rpx; width: 15.27rpx;
height: 19.68rpx; height: 19.68rpx;
margin-left: 8rpx; margin-left: 8rpx;
...@@ -812,19 +927,18 @@ export default { ...@@ -812,19 +927,18 @@ export default {
font-weight: 400; font-weight: 400;
display: flex; display: flex;
align-items: center; align-items: center;
color: #FF63BA; color: #ff63ba;
height: 40rpx; height: 40rpx;
line-height: 40rpx; line-height: 40rpx;
.price{ .price {
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
} }
.arrow-right-select{ .arrow-right-select {
width: 15.27rpx; width: 15.27rpx;
height: 19.68rpx; height: 19.68rpx;
margin-left: 8rpx; margin-left: 8rpx;
} }
} }
} }
.total { .total {
...@@ -842,7 +956,6 @@ export default { ...@@ -842,7 +956,6 @@ export default {
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #666666; color: #666666;
} }
.price { .price {
display: flex; display: flex;
...@@ -884,7 +997,7 @@ export default { ...@@ -884,7 +997,7 @@ export default {
color: #333333; color: #333333;
line-height: 40rpx; line-height: 40rpx;
height: 40rpx; height: 40rpx;
border-bottom: 0.1px solid #F4F4F4; border-bottom: 0.1px solid #f4f4f4;
padding-bottom: 24rpx; padding-bottom: 24rpx;
} }
...@@ -920,7 +1033,7 @@ export default { ...@@ -920,7 +1033,7 @@ export default {
.customer_service { .customer_service {
height: 90rpx; height: 90rpx;
line-height: 90rpx; line-height: 90rpx;
background: #FFFFFF; background: #ffffff;
font-weight: 400; font-weight: 400;
color: #000000; color: #000000;
padding: 0rpx 31rpx; padding: 0rpx 31rpx;
...@@ -929,7 +1042,7 @@ export default { ...@@ -929,7 +1042,7 @@ export default {
width: 100%; width: 100%;
margin: 0; margin: 0;
padding: 10rpx 10rpx 10rpx 0rpx; padding: 10rpx 10rpx 10rpx 0rpx;
background-color: #FFFFFF; background-color: #ffffff;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
border-radius: 0px; border-radius: 0px;
...@@ -939,7 +1052,7 @@ export default { ...@@ -939,7 +1052,7 @@ export default {
font-weight: 400; font-weight: 400;
font-style: normal; font-style: normal;
.serverBox{ .serverBox {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
......
<template> <template>
<view class="pages"> <view class="pages">
<view class="topBar" :style="{'padding-top':systemBarHeight.statusBarHeight+'px','height':systemBarHeight.navigationBarHeight+'px'}"> <view
<u-icon @click="returnHome?goHome():Utils.goBack()" name="arrow-left" color="#000000" size="20"></u-icon> class="topBar"
<view class="tabTitle" :style="{'line-height':systemBarHeight.navigationBarHeight+'px'}">订单结算</view> :style="{
'padding-top': systemBarHeight.statusBarHeight + 'px',
height: systemBarHeight.navigationBarHeight + 'px',
}"
>
<u-icon
@click="returnHome ? goHome() : Utils.goBack()"
name="arrow-left"
color="#000000"
size="20"
></u-icon>
<view
class="tabTitle"
:style="{ 'line-height': systemBarHeight.navigationBarHeight + 'px' }"
>订单结算</view
>
</view> </view>
<div class="shop_info" :style="{'margin-top':(systemBarHeight.statusBarHeight+systemBarHeight.navigationBarHeight+Utils.getPx(32))+'px'}"> <div
class="shop_info"
:style="{
'margin-top':
systemBarHeight.statusBarHeight +
systemBarHeight.navigationBarHeight +
Utils.getPx(32) +
'px',
}"
>
<h3>门店确认</h3> <h3>门店确认</h3>
<div class="address"> <div class="address">
<div class="address_1">{{ shopData.name }}</div> <div class="address_1">{{ shopData.name }}</div>
<div v-if="shopData.distance && shopData.distance!=-1" class="address_2">距您{{ shopData.distance }},请确定门店后下单</div> <div
v-if="shopData.distance && shopData.distance != -1"
class="address_2"
>
距您{{ shopData.distance }},请确定门店后下单
</div>
<div v-else class="address_2">请确定门店后下单</div> <div v-else class="address_2">请确定门店后下单</div>
</div> </div>
<div> <div>
<div class="title">取单时间</div> <div class="title">取单时间</div>
<div class="time">现在下单,预计 <span class="min">{{ duration }}</span> 分钟后取餐</div> <div class="time">
现在下单,预计 <span class="min">{{ duration }}</span> 分钟后取餐
</div>
</div> </div>
</div> </div>
<div class="goods_info"> <div class="goods_info">
<span class="goodInfoTitle">商品详细</span> <span class="goodInfoTitle">商品详细</span>
<div class="goods" v-for="item in goods" :key="item.goodsId"> <div class="goods" v-for="item in goods" :key="item.goodsId">
<div class="goods_item"> <div class="goods_item">
<image v-if="item.pics.thumbnailApplet" class="goods_img" :src="item.pics.thumbnailApplet"/> <image
v-if="item.pics.thumbnailApplet"
class="goods_img"
:src="item.pics.thumbnailApplet"
/>
<image v-else class="goods_img" :src="item.pics.thumbnail" /> <image v-else class="goods_img" :src="item.pics.thumbnail" />
<div class="goods_text"> <div class="goods_text">
<div class="goods_name"> <div class="goods_name">
<div class="name">{{ item.name }}</div> <div class="name">{{ item.name }}</div>
<div class="price">¥{{ Utils.isInteger(setPrice(item.sku.discount)) }}</div> <div class="price">
¥{{ Utils.isInteger(setPrice(item.sku.discount)) }}
</div>
</div> </div>
<div class="goods_psce"> <div class="goods_psce">
<div class="psce_name"> <div class="psce_name">
<span v-for="(rule,index) in item.sku.rules" :key="rule.ruleId"> <span
v-for="(rule, index) in item.sku.rules"
:key="rule.ruleId"
>
{{ rule.ruleName }} {{ rule.ruleName }}
<span v-if="index!=item.sku.rules.length-1">/</span> <span v-if="index != item.sku.rules.length - 1">/</span>
</span> </span>
</div> </div>
<div class="size">x {{ item.num }}</div> <div class="size">x {{ item.num }}</div>
...@@ -43,11 +83,23 @@ ...@@ -43,11 +83,23 @@
<div class="coupon" @click="goCouponSelect"> <div class="coupon" @click="goCouponSelect">
<div class="title">HOOLOO券</div> <div class="title">HOOLOO券</div>
<div :class="[ticketNum>0?'num-action':'num']"> <div :class="[ticketNum > 0 ? 'num-action' : 'num']">
<span v-if="selectCoupon.couponAmount" class="price">-¥{{selectCoupon.couponAmount}}</span> <span v-if="selectCoupon.couponAmount" class="price"
<span v-else>{{ticketNum>0?ticketNum+'张可用':'暂无可用优惠'}}</span> >-¥{{ selectCoupon.couponAmount }}</span
<image v-if="!ticketNum>0" class="arrow-right-select" :src="'../../../static/imgs/jiantouhei.png'" /> >
<image v-else class="arrow-right-select" :src="'../../../static/imgs/jiantoufen.png'" /> <span v-else>{{
ticketNum > 0 ? ticketNum + "张可用" : "暂无可用优惠"
}}</span>
<image
v-if="!ticketNum > 0"
class="arrow-right-select"
:src="'../../../static/imgs/jiantouhei.png'"
/>
<image
v-else
class="arrow-right-select"
:src="'../../../static/imgs/jiantoufen.png'"
/>
</div> </div>
</div> </div>
...@@ -62,18 +114,28 @@ ...@@ -62,18 +114,28 @@
<div class="Payment_method"> <div class="Payment_method">
<div>支付方式</div> <div>支付方式</div>
<div class="type"> <div class="type">
<image mode="aspectFit" src="../../../static/imgs/weixin-3.png" class="icon"></image> <image
mode="aspectFit"
src="../../../static/imgs/weixin-3.png"
class="icon"
></image>
<span>微信支付</span> <span>微信支付</span>
</div> </div>
</div> </div>
<div class="TermsOfAgreement" v-if="!TermsStatus"> <div class="TermsOfAgreement" v-if="!TermsStatus">
<div @click="clickAgreeTerms" :class="agreeTerms?'checked':'nochecked'"></div> <div
@click="clickAgreeTerms"
:class="agreeTerms ? 'checked' : 'nochecked'"
></div>
<div class="content"> <div class="content">
已阅读并同意<span @click="goTerms(1)">《用户协议》</span><span @click="goTerms(2)">《隐私权政策》</span><span @click="goTerms(3)">《支付协议》</span> 已阅读并同意<span @click="goTerms(1)">《用户协议》</span><span
@click="goTerms(2)"
>《隐私权政策》</span
><span @click="goTerms(3)">《支付协议》</span>
</div> </div>
</div> </div>
<div style="height:150rpx"></div> <div style="height: 150rpx"></div>
<div class="footer" :style="{'padding-bottom':BottomSafeHeight+'px'}"> <div class="footer" :style="{ 'padding-bottom': BottomSafeHeight + 'px' }">
<div class="total"> <div class="total">
<div class="the_sum"> <div class="the_sum">
<span class="name">实付</span> <span class="name">实付</span>
...@@ -84,22 +146,48 @@ ...@@ -84,22 +146,48 @@
</div> --> </div> -->
</div> </div>
<view v-if="userms" class="payment" @click="messageAndSave">付款</view> <view v-if="userms" class="payment" @click="messageAndSave">付款</view>
<button v-if="!userms" class="payment" style="border-radius: 0;" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">付款</button> <button
v-if="!userms"
class="payment"
style="border-radius: 0"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
付款
</button>
</div> </div>
<show-toast ref="toast"/> <show-toast ref="toast" />
<u-popup :show="messagePopup" mode="bottom" :round="5" :overlay="true" zIndex="10071" :customStyle="{'background':'#2C2C2C'}"> <u-popup
:show="messagePopup"
mode="bottom"
:round="5"
:overlay="true"
zIndex="10071"
:customStyle="{ background: '#2C2C2C' }"
>
<view class="messageBox"> <view class="messageBox">
<view class="title"> <view class="title">
<image class="image" src="../../../static/imgs/messageLogo.png"></image> <image
class="image"
src="../../../static/imgs/messageLogo.png"
></image>
<view class="text">HOOLOO COFFEE 申请</view> <view class="text">HOOLOO COFFEE 申请</view>
</view> </view>
<view class="desc"> <view class="desc">
<view class="">发送一次以下消息</view> <view class="">发送一次以下消息</view>
</view> </view>
<view class="content"> <view class="content">
<view class="contentItem"v-for="(item,index) in messageList" :key="index" @click="changeContentFlag(index)"> <view
<view :class="item.status?'checked':'nochecked'" :style="{'width':'40rpx','height':'40rpx'}"></view> class="contentItem"
<view class="text">{{item.title}}</view> v-for="(item, index) in messageList"
:key="index"
@click="changeContentFlag(index)"
>
<view
:class="item.status ? 'checked' : 'nochecked'"
:style="{ width: '40rpx', height: '40rpx' }"
></view>
<view class="text">{{ item.title }}</view>
</view> </view>
</view> </view>
<view class="btns"> <view class="btns">
...@@ -107,8 +195,14 @@ ...@@ -107,8 +195,14 @@
<view class="submit btn" @click="submitMessage">确定</view> <view class="submit btn" @click="submitMessage">确定</view>
</view> </view>
<view class="save"> <view class="save">
<view :class="saveFlag?'checked':'nochecked'" :style="{'width':'26rpx','height':'26rpx'}" @click="changeSaveFlage"></view> <view
<view class="text" @click="changeSaveFlage">总是保持以上选择,不在询问</view> :class="saveFlag ? 'checked' : 'nochecked'"
:style="{ width: '26rpx', height: '26rpx' }"
@click="changeSaveFlage"
></view>
<view class="text" @click="changeSaveFlage"
>总是保持以上选择,不在询问</view
>
</view> </view>
</view> </view>
</u-popup> </u-popup>
...@@ -117,223 +211,218 @@ ...@@ -117,223 +211,218 @@
<script> <script>
import { $EventBus } from "@/utils/EventBus"; import { $EventBus } from "@/utils/EventBus";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import Menu from '@/request/menu' import Menu from "@/request/menu";
import User from '@/request/user' import User from "@/request/user";
import Order from '@/request/order' import Order from "@/request/order";
export default { export default {
onHide() { onHide() {
console.log('onHide--------',this.cleanFlag,'this.cleanFlag') console.log("onHide--------", this.cleanFlag, "this.cleanFlag");
if(this.cleanFlag) { if (this.cleanFlag) {
this.goods = {} this.goods = {};
} }
}, },
onShow() { onShow() {
const allow = uni.getStorageSync('allow'); const allow = uni.getStorageSync("allow");
console.log('onshow-----------',allow,'allow') console.log("onshow-----------", allow, "allow");
if(allow) { if (allow) {
if ((JSON.stringify(this.goods)!="{}")) { if (JSON.stringify(this.goods) != "{}") {
Order.getWaitTine({ Order.getWaitTine({
shopId: uni.getStorageSync('shopData').id, shopId: uni.getStorageSync("shopData").id,
goods: this.goods goods: this.goods,
}).then(({ data }) => { }).then(({ data }) => {
this.duration = data.data this.duration = data.data;
}) });
}else{ } else {
uni.switchTab({ url: '/pages/menu/menu' }) uni.switchTab({ url: "/pages/menu/menu" });
} }
} }
this.BottomSafeHeight = uni.getStorageSync('BottomSafeHeight') this.BottomSafeHeight = uni.getStorageSync("BottomSafeHeight");
this.TermsStatus = uni.getStorageSync('TermsStatus') || false this.TermsStatus = uni.getStorageSync("TermsStatus") || false;
}, },
async onLoad(option) { async onLoad(option) {
this.returnHome = false this.returnHome = false;
uni.setStorageSync('allow',true) uni.setStorageSync("allow", true);
console.log('onload') console.log("onload");
// 清除优惠卷信息 // 清除优惠卷信息
this.$store.commit("cleanInfo",{}) this.$store.commit("cleanInfo", {});
if(!this.userms){ if (!this.userms) {
User.wxLoginAndGetOpenid(true).then(loginInfo=>{ User.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.loginInfo = loginInfo this.loginInfo = loginInfo;
}) });
} }
// 商品详情页点击立即支付进入 // 商品详情页点击立即支付进入
if (option.goodsList) { if (option.goodsList) {
console.log('详情进入') console.log("详情进入");
// this.getMessageFlag() // this.getMessageFlag()
const shopData = uni.getStorageSync('shopData'); const shopData = uni.getStorageSync("shopData");
this.shopData = shopData this.shopData = shopData;
this.buyType = 3; this.buyType = 3;
console.log(uni.getStorageSync('goodsList')); console.log(uni.getStorageSync("goodsList"));
this.goods = uni.getStorageSync('goodsList') || []; this.goods = uni.getStorageSync("goodsList") || [];
this.payType = '2' this.payType = "2";
this.saveGetTicket() this.saveGetTicket();
return return;
} }
// 微信扫码进入 // 微信扫码进入
this.option = JSON.stringify(option) this.option = JSON.stringify(option);
const { q } = option; const { q } = option;
// console.log(q); // console.log(q);
if (q) { if (q) {
console.log('扫码进入',q) console.log("扫码进入", q);
uni.setStorageSync("selectFlag",false) uni.setStorageSync("selectFlag", false);
// this.getMessageFlag() // this.getMessageFlag()
this.saveGetTicket() this.saveGetTicket();
User.getLocation((state, params) => { User.getLocation((state, params) => {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync("shopCarInfo");
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
// let id = decodeURIComponent(q).split('?')[1].split('=')[1]; // let id = decodeURIComponent(q).split('?')[1].split('=')[1];
const optionDecode = Utils.getUrlParams2(decodeURIComponent(q)) const optionDecode = Utils.getUrlParams2(decodeURIComponent(q));
console.log(optionDecode,'optionDecode') console.log(optionDecode, "optionDecode");
this.optionDecode = optionDecode this.optionDecode = optionDecode;
const loginInfo = uni.getStorageSync("loginInfo") const loginInfo = uni.getStorageSync("loginInfo");
const { id, recognizePerson } = optionDecode const { id, recognizePerson } = optionDecode;
const openid = loginInfo?JSON.parse(loginInfo).openid:"" const openid = loginInfo ? JSON.parse(loginInfo).openid : "";
const sendData = {} const sendData = {};
this.returnHome = true this.returnHome = true;
if(recognizePerson){ if (recognizePerson) {
sendData.faceInfoId = recognizePerson, (sendData.faceInfoId = recognizePerson), (sendData.openid = openid);
sendData.openid = openid }
} Menu.getScreenShopCar(id, params, sendData).then((res) => {
Menu.getScreenShopCar(id, params,sendData).then(res => {
const data = JSON.parse(res.data.data); const data = JSON.parse(res.data.data);
console.log(data); console.log(data);
this.shopData = data.shop; this.shopData = data.shop;
this.buyType = data.screenNo; this.buyType = data.screenNo;
this.goods = data.goods.map(item => { this.goods = data.goods.map((item) => {
const data = { ...item, skuId: item.sku.skuId, flag: true } const data = { ...item, skuId: item.sku.skuId, flag: true };
Utils.getallNum(data, true) // 不校验数量 Utils.getallNum(data, true); // 不校验数量
return data return data;
}) });
}) });
}) });
return return;
} }
// 购物车点击进入 // 购物车点击进入
if(uni.getStorageSync('shopCarInfo').length!=0) { if (uni.getStorageSync("shopCarInfo").length != 0) {
console.log('购物车进入') console.log("购物车进入");
// this.getMessageFlag() // this.getMessageFlag()
console.log(uni.getStorageSync('shopCarInfo')) console.log(uni.getStorageSync("shopCarInfo"));
const shopData = uni.getStorageSync('shopData'); const shopData = uni.getStorageSync("shopData");
this.shopData = shopData this.shopData = shopData;
this.buyType = 3; this.buyType = 3;
const shopCarInfo = uni.getStorageSync('shopCarInfo') || [] const shopCarInfo = uni.getStorageSync("shopCarInfo") || [];
this.goods = shopCarInfo.filter(item => item.flag); this.goods = shopCarInfo.filter((item) => item.flag);
this.saveGetTicket() this.saveGetTicket();
return return;
} }
}, },
data() { data() {
return { return {
cleanFlag:false, cleanFlag: false,
returnHome:false, returnHome: false,
messageList:[ messageList: [
{ {
tmp:'1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU', tmp: "1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU",
title:'下单成功通知', title: "下单成功通知",
status:true status: true,
}, },
{ {
tmp:'Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM', tmp: "Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM",
title:'订单状态变更通知', title: "订单状态变更通知",
status:true status: true,
}, },
{ {
tmp:'Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74', tmp: "Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74",
title:'取餐提醒', title: "取餐提醒",
status:true status: true,
} },
], ],
saveFlag:false, saveFlag: false,
messagePopup: false, messagePopup: false,
goods: [], goods: [],
buyType: '', buyType: "",
shopData: {}, shopData: {},
option: '', option: "",
payType: '1', payType: "1",
duration: '', duration: "",
loginInfo: '', loginInfo: "",
BottomSafeHeight:0, BottomSafeHeight: 0,
Utils, Utils,
agreeTerms:true, agreeTerms: true,
TermsStatus:true, TermsStatus: true,
ticketNum:0, ticketNum: 0,
msgInfo:{ msgInfo: {},
},
sendMsgData: { sendMsgData: {
sendMsgFlag1:false, sendMsgFlag1: false,
sendMsgFlag2:false, sendMsgFlag2: false,
sendMsgFlag3:false sendMsgFlag3: false,
}, },
optionDecode:{} optionDecode: {},
} };
}, },
computed: { computed: {
systemBarHeight(){ systemBarHeight() {
return this.$store.state.user.systemBarHeight return this.$store.state.user.systemBarHeight;
}, },
selectCoupon() { selectCoupon() {
const data = this.$store.state.order.selectTicket const data = this.$store.state.order.selectTicket;
return data return data;
}, },
userms() { userms() {
return this.$store.getters.Authorization; return this.$store.getters.Authorization;
}, },
totalNum() { totalNum() {
if(JSON.stringify(this.goods)=='{}')return 0 if (JSON.stringify(this.goods) == "{}") return 0;
let totalNum = 0; let totalNum = 0;
this.goods.map(item => { this.goods.map((item) => {
item.flag ? totalNum += item.num : totalNum += 0 item.flag ? (totalNum += item.num) : (totalNum += 0);
}) });
return totalNum return totalNum;
}, },
reduction() { reduction() {
if(JSON.stringify(this.goods)=='{}')return 0 if (JSON.stringify(this.goods) == "{}") return 0;
let price = 0; let price = 0;
let discountNum = 0; let discountNum = 0;
this.goods.forEach(item => { this.goods.forEach((item) => {
const sku = item.sku; const sku = item.sku;
if (item.flag) { if (item.flag) {
discountNum += item.num * sku.discount discountNum += item.num * sku.discount;
price += item.num * sku.price price += item.num * sku.price;
} else { } else {
discountNum += 0 discountNum += 0;
price += 0 price += 0;
} }
}) });
return (price - discountNum).toFixed(2) return (price - discountNum).toFixed(2);
}, },
amountOld() { amountOld() {
if(JSON.stringify(this.goods)=='{}')return 0 if (JSON.stringify(this.goods) == "{}") return 0;
let totalPrice = 0; let totalPrice = 0;
this.goods.forEach(item => { this.goods.forEach((item) => {
const sku = item.sku; const sku = item.sku;
item.flag ? totalPrice += (item.num * sku.discount) : (totalPrice += 0) item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0);
}) });
return totalPrice.toFixed(2) return totalPrice.toFixed(2);
}, },
totalPrice() { totalPrice() {
if(JSON.stringify(this.goods)=='{}')return 0 if (JSON.stringify(this.goods) == "{}") return 0;
let totalPrice = 0; let totalPrice = 0;
this.goods.forEach(item => { this.goods.forEach((item) => {
const sku = item.sku; const sku = item.sku;
item.flag ? totalPrice += (item.num * sku.discount) : (totalPrice += 0) item.flag ? (totalPrice += item.num * sku.discount) : (totalPrice += 0);
}) });
totalPrice-=this.selectCoupon.couponAmount||0 totalPrice -= this.selectCoupon.couponAmount || 0;
return totalPrice.toFixed(2) return totalPrice.toFixed(2);
} },
}, },
methods: { methods: {
goHome() { goHome() {
uni.switchTab({ url: '/pages/menu/menu' }) uni.switchTab({ url: "/pages/menu/menu" });
}, },
getPx(rpx) { getPx(rpx) {
// console.log((rpx * (wx.getSystemInfoSync().windowWidth / 750))); // console.log((rpx * (wx.getSystemInfoSync().windowWidth / 750)));
...@@ -341,192 +430,232 @@ export default { ...@@ -341,192 +430,232 @@ export default {
return rpx * (wx.getSystemInfoSync().windowWidth / 750); return rpx * (wx.getSystemInfoSync().windowWidth / 750);
}, },
async getMessageFlag() { async getMessageFlag() {
const {data} = await User.getUserMsgInfo() const { data } = await User.getUserMsgInfo();
console.log(data) console.log(data);
const {data:newdata} = data const { data: newdata } = data;
const {flagExpireDate,sendMsgFlag1 = '',sendMsgFlag2 = '',sendMsgFlag3 = ''} = newdata const {
this.sendMsgData.sendMsgFlag1 = sendMsgFlag1 flagExpireDate,
this.sendMsgData.sendMsgFlag2 = sendMsgFlag2 sendMsgFlag1 = "",
this.sendMsgData.sendMsgFlag3 = sendMsgFlag3 sendMsgFlag2 = "",
this.sendMsgData.flagExpireData = flagExpireDate?Date.parse(flagExpireDate.substring(0,10)):'' sendMsgFlag3 = "",
} = newdata;
this.sendMsgData.sendMsgFlag1 = sendMsgFlag1;
this.sendMsgData.sendMsgFlag2 = sendMsgFlag2;
this.sendMsgData.sendMsgFlag3 = sendMsgFlag3;
this.sendMsgData.flagExpireData = flagExpireDate
? Date.parse(flagExpireDate.substring(0, 10))
: "";
}, },
cancleMessage() { cancleMessage() {
this.messagePopup = false this.messagePopup = false;
this.sendMsgData = { this.sendMsgData = {
sendMsgFlag1:false, sendMsgFlag1: false,
sendMsgFlag2:false, sendMsgFlag2: false,
sendMsgFlag3:false sendMsgFlag3: false,
} };
this.saveReserve() this.saveReserve();
}, },
// 保存用户通知授权信息 // 保存用户通知授权信息
async submitMessage() { async submitMessage() {
this.messageList.forEach((item,index) => { this.messageList.forEach((item, index) => {
this.sendMsgData[`sendMsgFlag${index+1}`] = item.status this.sendMsgData[`sendMsgFlag${index + 1}`] = item.status;
}) });
let { data } = await User.setAllow({...this.sendMsgData,rememberFlag:this.saveFlag}) let { data } = await User.setAllow({
this.messagePopup = false ...this.sendMsgData,
if(data.code===200){ rememberFlag: this.saveFlag,
this.saveReserve() });
this.messagePopup = false;
if (data.code === 200) {
this.saveReserve();
} }
}, },
changeContentFlag(index) { changeContentFlag(index) {
this.messageList[index].status = !this.messageList[index].status this.messageList[index].status = !this.messageList[index].status;
}, },
changeSaveFlage(){ changeSaveFlage() {
console.log(this.saveFlag) console.log(this.saveFlag);
this.saveFlag = !this.saveFlag this.saveFlag = !this.saveFlag;
}, },
closeT(){ closeT() {
this.messagePopup = false this.messagePopup = false;
}, },
// 勾选隐私协议 // 勾选隐私协议
clickAgreeTerms(){ clickAgreeTerms() {
this.agreeTerms = !this.agreeTerms this.agreeTerms = !this.agreeTerms;
}, },
// 跳转隐私协议页面 // 跳转隐私协议页面
goTerms(type) { goTerms(type) {
uni.navigateTo({url:'/orderSubPackage/pages/terms/index?type='+type}) uni.navigateTo({
url: "/orderSubPackage/pages/terms/index?type=" + type,
});
}, },
itemReduction(discount, price, num) { itemReduction(discount, price, num) {
return ((price - discount) * num).toFixed(2) return ((price - discount) * num).toFixed(2);
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo;
const { recognizePerson } = this.optionDecode const { recognizePerson } = this.optionDecode;
if(recognizePerson) { if (recognizePerson) {
e.faceInfoId = recognizePerson e.faceInfoId = recognizePerson;
} }
User.getPhoneNumber(e); User.getPhoneNumber(e);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}, },
messageAndSave() { messageAndSave() {
if(!this.TermsStatus&&!this.agreeTerms){ if (!this.TermsStatus && !this.agreeTerms) {
this.showToast({ title: "请同意下方协议条款" }); this.showToast({ title: "请勾选下方协议条款" });
return return;
}else{ } else {
// if(this.agreeTerms)uni.setStorageSync('TermsStatus',true) // if(this.agreeTerms)uni.setStorageSync('TermsStatus',true)
} }
const tmpid = ['1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU', 'Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM', 'Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74'] const tmpid = [
const val = {} "1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU",
"Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM",
"Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74",
];
const val = {};
wx.requestSubscribeMessage({ wx.requestSubscribeMessage({
tmplIds: tmpid, tmplIds: tmpid,
success: (res) => { success: (res) => {
const finalValue = Object.values(res).indexOf('reject') const finalValue = Object.values(res).indexOf("reject");
tmpid.forEach(item=>{ tmpid.forEach((item) => {
val[item] = res[item]==='accept'?true:false val[item] = res[item] === "accept" ? true : false;
}) });
if(finalValue===-1){ if (finalValue === -1) {
uni.setStorageSync('isMessage', 'true') uni.setStorageSync("isMessage", "true");
// User.setAllow(1) // User.setAllow(1)
this.saveReserve(val) this.saveReserve(val);
}else{ } else {
// User.setAllow(2) // User.setAllow(2)
this.saveReserve(val) this.saveReserve(val);
} }
}, },
fail: (err) => { fail: (err) => {
tmpid.forEach(item=>{ tmpid.forEach((item) => {
val[item] = false val[item] = false;
}) });
console.log(err); console.log(err);
// User.setAllow(2) // User.setAllow(2)
this.saveReserve(val) this.saveReserve(val);
} },
}) });
}, },
// 组装数据 // 组装数据
AssemblyOrder(){ AssemblyOrder() {
let list = []; let list = [];
if (this.payType == '1') { if (this.payType == "1") {
list = uni.getStorageSync('shopCarInfo').filter((v) => v.flag == true); list = uni.getStorageSync("shopCarInfo").filter((v) => v.flag == true);
} else { } else {
list = uni.getStorageSync('goodsList').filter((v) => v.flag == true); list = uni.getStorageSync("goodsList").filter((v) => v.flag == true);
} }
return Utils.AssemblyOrder(this.shopData, this.totalPrice, this.totalNum, this.buyType, list); return Utils.AssemblyOrder(
this.shopData,
this.totalPrice,
this.totalNum,
this.buyType,
list
);
}, },
// 结算组装数据获取优惠卷列表 // 结算组装数据获取优惠卷列表
async saveGetTicket() { async saveGetTicket() {
// 组装购物车数据或者立即支付数据 // 组装购物车数据或者立即支付数据
const res = this.AssemblyOrder() const res = this.AssemblyOrder();
if(res){ if (res) {
const {data:list} = await Menu.requestTicketList(res); const { data: list } = await Menu.requestTicketList(res);
const {data:num} = await Menu.requestTicketNum(res); const { data: num } = await Menu.requestTicketNum(res);
if(list.code==200){ if (list.code == 200) {
const {data} = list const { data } = list;
this.ticketList = data this.ticketList = data;
this.$store.commit('setTickerList',this.ticketList) this.$store.commit("setTickerList", this.ticketList);
} }
if(num.code==200){ if (num.code == 200) {
const {data} = num const { data } = num;
this.ticketNum = data this.ticketNum = data;
} }
} }
}, },
//结算组装数据发起订单 //结算组装数据发起订单
async saveReserve(val = {}) { async saveReserve(val = {}) {
uni.setStorageSync('allow',false) uni.setStorageSync("allow", false);
// 组装购物车数据或者立即支付数据 // 组装购物车数据或者立即支付数据
let list = []; let list = [];
if (this.payType == '1') { if (this.payType == "1") {
list = uni.getStorageSync('shopCarInfo').filter((v) => v.flag == true); list = uni.getStorageSync("shopCarInfo").filter((v) => v.flag == true);
} else { } else {
list = uni.getStorageSync('goodsList').filter((v) => v.flag == true); list = uni.getStorageSync("goodsList").filter((v) => v.flag == true);
} }
const location = uni.getStorageSync("location") const location = uni.getStorageSync("location");
const {lat,lng} = location const { lat, lng } = location;
// sendMsgFlag1:下单成功通知 // sendMsgFlag1:下单成功通知
// sendMsgFlag2:订单状态变更通知 // sendMsgFlag2:订单状态变更通知
// sendMsgFlag3:取餐提醒 // sendMsgFlag3:取餐提醒
const sendMsgFlag1 = val['1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU']?1:0 const sendMsgFlag1 = val["1uErx-15S-3vuopXSvvsxCeM_Jd-1iZC-nXzd2yW3QU"]
const sendMsgFlag2 = val['Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM']?1:0 ? 1
const sendMsgFlag3 = val['Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74']?1:0 : 0;
const sendMsgFlag2 = val["Q4HDwBEvpTXpwtZktqWm4SZOTEuQK1x48xjqjD2GqyM"]
let res = await Utils.AssemblyOrder(this.shopData, this.totalPrice, this.totalNum, this.buyType, list); ? 1
: 0;
const sendMsgFlag3 = val["Fu_CPIXa0cnJ4EDdVKqFQ3qqKJccMqt2oorI5mfNq74"]
? 1
: 0;
let res = await Utils.AssemblyOrder(
this.shopData,
this.totalPrice,
this.totalNum,
this.buyType,
list
);
if (res) { if (res) {
const {amount,...resule} = res const { amount, ...resule } = res;
const sendData = { const sendData = {
...resule, ...resule,
amount:this.amountOld, amount: this.amountOld,
paidAmount:amount, paidAmount: amount,
lat, lat,
lng, lng,
sendMsgFlag1, sendMsgFlag1,
sendMsgFlag2, sendMsgFlag2,
sendMsgFlag3 sendMsgFlag3,
} };
if(JSON.stringify(this.selectCoupon)!="{}"){ if (JSON.stringify(this.selectCoupon) != "{}") {
sendData.couponId = this.selectCoupon.id||'', (sendData.couponId = this.selectCoupon.id || ""),
sendData.couponAmount = this.selectCoupon.couponAmount||0 (sendData.couponAmount = this.selectCoupon.couponAmount || 0);
} }
let orderInfo = await Menu.saveReserve(sendData); let orderInfo = await Menu.saveReserve(sendData);
if (orderInfo && orderInfo.data.code == 200) { if (orderInfo && orderInfo.data.code == 200) {
// const {} // const {}
await Menu.requestPayment(orderInfo.data.data, res, this.buyType, this.agreeTerms); await Menu.requestPayment(
this.cleanFlag = true orderInfo.data.data,
}else{ res,
this.buyType,
this.agreeTerms
);
this.cleanFlag = true;
} else {
} }
} }
}, },
goCouponSelect() { goCouponSelect() {
uni.navigateTo({ url: `/orderSubPackage/pages/coupon/index` }) uni.navigateTo({ url: `/orderSubPackage/pages/coupon/index` });
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.pages { .pages {
padding-top: 1rpx; padding-top: 1rpx;
.topBar{ .topBar {
position: fixed; position: fixed;
width: 100%; width: 100%;
background: white; background: white;
...@@ -538,13 +667,13 @@ export default { ...@@ -538,13 +667,13 @@ export default {
// .arrow-left { // .arrow-left {
// margin-left: 20rpx; // margin-left: 20rpx;
// } // }
.tabTitle{ .tabTitle {
font-size: 32rpx; font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600; font-weight: 600;
text-align: center; text-align: center;
width: 79%; width: 79%;
color: #333333 color: #333333;
} }
} }
} }
...@@ -566,7 +695,7 @@ export default { ...@@ -566,7 +695,7 @@ export default {
margin-left: 8rpx; margin-left: 8rpx;
font-size: 24prx; font-size: 24prx;
font-family: ArialMT; font-family: ArialMT;
color: #DDDDDD; color: #dddddd;
} }
} }
...@@ -575,26 +704,28 @@ export default { ...@@ -575,26 +704,28 @@ export default {
font-size: 26rpx; font-size: 26rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;
color: #DDDDDD; color: #dddddd;
} }
.content { .content {
margin-top: 35rpx; margin-top: 35rpx;
.contentItem{ .contentItem {
padding: 26rpx 0rpx; padding: 26rpx 0rpx;
border-bottom: 1rpx solid #303030; border-bottom: 1rpx solid #303030;
display: flex; display: flex;
align-items: center; align-items: center;
.checked{ .checked {
background: url('../../../static/imgs/messageXuanzhong.png') center center no-repeat; background: url("../../../static/imgs/messageXuanzhong.png") center
background-size:100% 100%; center no-repeat;
background-size: 100% 100%;
border-radius: 50%; border-radius: 50%;
} }
.nochecked{ .nochecked {
background: url('../../../static/imgs/messageWeixuanzhong.png') center center no-repeat; background: url("../../../static/imgs/messageWeixuanzhong.png") center
background-size:100% 100%; center no-repeat;
background-size: 100% 100%;
border-radius: 50%; border-radius: 50%;
} }
...@@ -602,7 +733,7 @@ export default { ...@@ -602,7 +733,7 @@ export default {
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #DDDDDD; color: #dddddd;
margin-left: 28rpx; margin-left: 28rpx;
} }
} }
...@@ -622,32 +753,34 @@ export default { ...@@ -622,32 +753,34 @@ export default {
} }
.cancle { .cancle {
color: #DDDDDD; color: #dddddd;
background: #3D3D3D; background: #3d3d3d;
margin-right: 14rpx; margin-right: 14rpx;
} }
.submit { .submit {
margin-left: 14rpx; margin-left: 14rpx;
color: #DDDDDD; color: #dddddd;
background: #58BE6C; background: #58be6c;
} }
} }
.save { .save {
margin-top:39.82rpx; margin-top: 39.82rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.checked{ .checked {
background: url('../../../static/imgs/messageXuanzhong.png') center center no-repeat; background: url("../../../static/imgs/messageXuanzhong.png") center center
background-size:100% 100%; no-repeat;
background-size: 100% 100%;
border-radius: 50%; border-radius: 50%;
} }
.nochecked{ .nochecked {
background: url('../../../static/imgs/messageWeixuanzhong.png') center center no-repeat; background: url("../../../static/imgs/messageWeixuanzhong.png") center
background-size:100% 100%; center no-repeat;
background-size: 100% 100%;
border-radius: 50%; border-radius: 50%;
} }
...@@ -655,7 +788,7 @@ export default { ...@@ -655,7 +788,7 @@ export default {
font-size: 23rpx; font-size: 23rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #DDDDDD; color: #dddddd;
margin-left: 10rpx; margin-left: 10rpx;
} }
} }
...@@ -663,13 +796,12 @@ export default { ...@@ -663,13 +796,12 @@ export default {
.shop_info { .shop_info {
width: 686rpx; width: 686rpx;
background: #FFFFFF; background: #ffffff;
margin: 0 auto; margin: 0 auto;
margin-top: 32rpx; margin-top: 32rpx;
padding: 24rpx 32rpx; padding: 24rpx 32rpx;
box-sizing: border-box; box-sizing: border-box;
h3 { h3 {
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
...@@ -680,12 +812,11 @@ export default { ...@@ -680,12 +812,11 @@ export default {
.address { .address {
margin-top: 17.81rpx; margin-top: 17.81rpx;
border-bottom: 0.1px solid #F4F4F4; border-bottom: 0.1px solid #f4f4f4;
padding-bottom: 25.02rpx; padding-bottom: 25.02rpx;
margin-bottom: 23.83rpx; margin-bottom: 23.83rpx;
.address_1 { .address_1 {
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;
...@@ -715,7 +846,7 @@ export default { ...@@ -715,7 +846,7 @@ export default {
color: #999999; color: #999999;
.min { .min {
color: #0050F6; color: #0050f6;
font-size: 32rpx; font-size: 32rpx;
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
font-weight: normal; font-weight: normal;
...@@ -727,13 +858,12 @@ export default { ...@@ -727,13 +858,12 @@ export default {
.goods_info { .goods_info {
width: 686rpx; width: 686rpx;
background: #FFFFFF; background: #ffffff;
margin: 0 auto; margin: 0 auto;
margin-top: 32rpx; margin-top: 32rpx;
padding: 26rpx 30rpx 24rpx 30rpx; padding: 26rpx 30rpx 24rpx 30rpx;
box-sizing: border-box; box-sizing: border-box;
.goodInfoTitle { .goodInfoTitle {
height: 40rpx; height: 40rpx;
font-size: 28rpx; font-size: 28rpx;
...@@ -745,7 +875,7 @@ export default { ...@@ -745,7 +875,7 @@ export default {
.goods { .goods {
margin-top: 24rpx; margin-top: 24rpx;
border-bottom: 0.1px solid #F4F4F4; border-bottom: 0.1px solid #f4f4f4;
padding-bottom: 32rpx; padding-bottom: 32rpx;
.goods_item { .goods_item {
...@@ -818,7 +948,7 @@ export default { ...@@ -818,7 +948,7 @@ export default {
.price { .price {
font-family: Arial-BoldMT, Arial; font-family: Arial-BoldMT, Arial;
font-weight: normal; font-weight: normal;
color: #EB5F17; color: #eb5f17;
} }
} }
...@@ -833,7 +963,6 @@ export default { ...@@ -833,7 +963,6 @@ export default {
margin-top: 18rpx; margin-top: 18rpx;
.price { .price {
font-family: Arial-BoldMT, Arial; font-family: Arial-BoldMT, Arial;
font-weight: 700; font-weight: 700;
color: #000; color: #000;
...@@ -869,7 +998,7 @@ export default { ...@@ -869,7 +998,7 @@ export default {
.price { .price {
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
} }
.arrow-right-select{ .arrow-right-select {
width: 15.27rpx; width: 15.27rpx;
height: 20.68rpx; height: 20.68rpx;
margin-left: 8rpx; margin-left: 8rpx;
...@@ -882,19 +1011,18 @@ export default { ...@@ -882,19 +1011,18 @@ export default {
font-weight: 400; font-weight: 400;
display: flex; display: flex;
align-items: center; align-items: center;
color: #FF63BA; color: #ff63ba;
height: 40rpx; height: 40rpx;
line-height: 40rpx; line-height: 40rpx;
.price{ .price {
font-family: Futura-Medium, Futura; font-family: Futura-Medium, Futura;
} }
.arrow-right-select{ .arrow-right-select {
width: 15.27rpx; width: 15.27rpx;
height: 19.68rpx; height: 19.68rpx;
margin-left: 8rpx; margin-left: 8rpx;
} }
} }
} }
.total { .total {
...@@ -903,7 +1031,7 @@ export default { ...@@ -903,7 +1031,7 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding-top: 24.16rpx; padding-top: 24.16rpx;
border-top: 0.1px solid #F4F4F4; border-top: 0.1px solid #f4f4f4;
.size { .size {
font-size: 28rpx; font-size: 28rpx;
...@@ -912,7 +1040,7 @@ export default { ...@@ -912,7 +1040,7 @@ export default {
color: #666666; color: #666666;
} }
.the_sum{ .the_sum {
display: flex; display: flex;
align-items: flex-end; align-items: flex-end;
.paid_in { .paid_in {
...@@ -931,7 +1059,7 @@ export default { ...@@ -931,7 +1059,7 @@ export default {
line-height: 40rpx; line-height: 40rpx;
} }
} }
.priceBox{ .priceBox {
display: flex; display: flex;
align-items: center; align-items: center;
.paid_in { .paid_in {
...@@ -950,7 +1078,6 @@ export default { ...@@ -950,7 +1078,6 @@ export default {
line-height: 40rpx; line-height: 40rpx;
} }
} }
} }
} }
...@@ -958,7 +1085,7 @@ export default { ...@@ -958,7 +1085,7 @@ export default {
width: 686rpx; width: 686rpx;
margin: 32rpx auto 0; margin: 32rpx auto 0;
padding: 26rpx 30rpx; padding: 26rpx 30rpx;
background: #FFFFFF; background: #ffffff;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
...@@ -997,21 +1124,23 @@ export default { ...@@ -997,21 +1124,23 @@ export default {
color: #666666; color: #666666;
line-height: 34rpx; line-height: 34rpx;
span { span {
color: #0050F6; color: #0050f6;
} }
} }
.checked { .checked {
width: 24rpx; width: 24rpx;
height: 24rpx; height: 24rpx;
background: url('../../../static/imgs/duigouxuanzhong.png') center center no-repeat; background: url("../../../static/imgs/duigouxuanzhong.png") center center
background-size:100% 100%; no-repeat;
background-size: 100% 100%;
margin-right: 8rpx; margin-right: 8rpx;
} }
.nochecked { .nochecked {
width: 24rpx; width: 24rpx;
height: 24rpx; height: 24rpx;
background: url('../../../static/imgs/weixuanzhong.png') center center no-repeat; background: url("../../../static/imgs/weixuanzhong.png") center center
background-size:100% 100%; no-repeat;
background-size: 100% 100%;
margin-right: 8rpx; margin-right: 8rpx;
} }
} }
...@@ -1053,7 +1182,7 @@ export default { ...@@ -1053,7 +1182,7 @@ export default {
font-size: 20rpx; font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FF0E00; color: #ff0e00;
margin-top: 10rpx; margin-top: 10rpx;
} }
} }
...@@ -1061,11 +1190,11 @@ export default { ...@@ -1061,11 +1190,11 @@ export default {
.payment { .payment {
width: 200rpx; width: 200rpx;
height: 100%; height: 100%;
background: #0050F6; background: #0050f6;
font-size: 28rpx; font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #ffffff;
line-height: 100rpx; line-height: 100rpx;
text-align: center; text-align: center;
} }
......
<template> <template>
<view class="menu-box"> <view class="menu-box">
<view class="menu-banner" :style="{'height':buied?'360rpx':'450rpx'}"> <view class="menu-banner" :style="{ height: buied ? '360rpx' : '450rpx' }">
<!-- <image :src="img"/> --> <!-- <image :src="img"/> -->
<ImageLoader :defaultSrc="'../../static/imgs/shouyezhanweitu.png'" :realSrc="img" width="100%" height="400rpx"/> <ImageLoader
:defaultSrc="'../../static/imgs/shouyezhanweitu.png'"
:realSrc="img"
width="100%"
height="400rpx"
/>
<!-- <video autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/71d36be0ed966.mp4" /> --> <!-- <video autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/71d36be0ed966.mp4" /> -->
<!-- <HomeBanner /> --> <!-- <HomeBanner /> -->
<view class="shop-info" :style="'top:100rpx'"> <view class="shop-info" :style="'top:100rpx'">
<view class="shop-box"> <view class="shop-box">
<text @click="showArea" class="shop-name">{{ shopInfo.name }}</text> <text @click="showArea" class="shop-name">{{ shopInfo.name }}</text>
<image class="arrow-right-select" :src="'../../static/imgs/jiantoubai.png'" /> <image
class="arrow-right-select"
:src="'../../static/imgs/jiantoubai.png'"
/>
</view> </view>
<view v-if="shopInfo.distance && shopInfo.distance!=-1" class="distance">距您{{ shopInfo.distance }}</view> <view
v-if="shopInfo.distance && shopInfo.distance != -1"
class="distance"
>距您{{ shopInfo.distance }}</view
>
</view> </view>
<view class="login-area"> <view class="login-area">
<view class="avatar"> <view class="avatar">
<image :src="userInfo.avatarUrl?userInfo.avatarUrl:'../../static/touxiang.png'"></image> <image
:src="
userInfo.avatarUrl
? userInfo.avatarUrl
: '../../static/touxiang.png'
"
></image>
</view> </view>
<view class="user-info" @click="goToMyPage(userms)"> <view class="user-info" @click="goToMyPage(userms)">
<view class="user-infocontent"> <view class="user-infocontent">
<view class="user-name" v-if="userms">Hi!{{ userInfo.customerName || '我是谁' }}</view> <view class="user-name" v-if="userms"
>Hi!{{ userInfo.customerName || "我是谁" }}</view
>
<view class="user-name" v-else>未登录</view> <view class="user-name" v-else>未登录</view>
<view class="dialog"> <view class="dialog">
<view class="content" v-if="userms">{{dayTitle}}</view> <view class="content" v-if="userms">{{ dayTitle }}</view>
<view class="content" v-if="!userms">请您尽快登录~</view> <view class="content" v-if="!userms">请您尽快登录~</view>
</view> </view>
</view> </view>
<view> <view>
<image class="arrow-right-select" v-if="userms" :src="'../../static/imgs/jiantouhei.png'" /> <image
<button class="login-btn" v-if="!userms" open-type="getPhoneNumber" class="arrow-right-select"
@getphonenumber="getPhoneNumber">立即登录 v-if="userms"
:src="'../../static/imgs/jiantouhei.png'"
/>
<button
class="login-btn"
v-if="!userms"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
立即登录
</button> </button>
</view> </view>
</view> </view>
...@@ -36,9 +65,20 @@ ...@@ -36,9 +65,20 @@
</view> </view>
<view class="order-banner" v-if="buied" @click="openQrcode"> <view class="order-banner" v-if="buied" @click="openQrcode">
<view class="info"> <view class="info">
<view class="first">取单码:<text class="first-code">{{ orderInfo.orderNum }}</text></view> <view class="first"
<view class="second1" v-if="orderInfo.state =='4'">订单已制作完成,请尽快取餐~</view> >取单码:<text class="first-code">{{
<view class="second" v-else>请您耐心等候,剩余等候时间<text class="time">{{ orderInfo.waitTime }}</text>分钟</view> orderInfo.orderNum
}}</text></view
>
<view class="second1" v-if="orderInfo.state == '4'"
>订单已制作完成,请尽快取餐~</view
>
<view class="second" v-else
>请您耐心等候,剩余等候时间<text class="time">{{
orderInfo.waitTime
}}</text
>分钟</view
>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="barCode-box"> <view class="barCode-box">
...@@ -48,74 +88,103 @@ ...@@ -48,74 +88,103 @@
<view class="barCode-dis">点击二维码取单</view> <view class="barCode-dis">点击二维码取单</view>
</view> </view>
</view> </view>
<MenuAssembly ref="MenuAssembly" @getallNum="getallNum" :buied="buied" :shopState="shopState" :isInRange="isInRange"/> <MenuAssembly
ref="MenuAssembly"
@getallNum="getallNum"
:buied="buied"
:shopState="shopState"
:isInRange="isInRange"
/>
<!-- <u-picker @cancel="show = false" :show="show" :immediateChange="true" ref="uPicker" :columns="columns" <!-- <u-picker @cancel="show = false" :show="show" :immediateChange="true" ref="uPicker" :columns="columns"
@confirm="confirm" keyName="name" @change="changeHandler"></u-picker> --> @confirm="confirm" keyName="name" @change="changeHandler"></u-picker> -->
<AreaPicker ref="AreaPicker" /> <AreaPicker ref="AreaPicker" />
<OrderQrCode ref="OrderQrCode" /> <OrderQrCode ref="OrderQrCode" />
<canvas class="canvas-code" canvas-id="myQrcode2" <canvas
style="background:#fff;width: 200px;height: 200px; display:block; left:-800rpx;position:absolute;" /> class="canvas-code"
<show-toast ref="toast"/> canvas-id="myQrcode2"
style="
background: #fff;
width: 200px;
height: 200px;
display: block;
left: -800rpx;
position: absolute;
"
/>
<show-toast ref="toast" />
<taBar select="0"></taBar> <taBar select="0"></taBar>
<ShopCar ref="shopbar" :shopState="shopState" :isInRange="isInRange"/> <ShopCar ref="shopbar" :shopState="shopState" :isInRange="isInRange" />
</view> </view>
</template> </template>
<script> <script>
import MenuAssembly from '@/components/menuAssembly' import MenuAssembly from "@/components/menuAssembly";
import ImageLoader from '@/components/ImageLoader/index.vue' import ImageLoader from "@/components/ImageLoader/index.vue";
import AreaPicker from '@/components/AreaPicker/index.vue' import AreaPicker from "@/components/AreaPicker/index.vue";
import HomeBanner from '@/components/canvas/HomeBanner.vue' import HomeBanner from "@/components/canvas/HomeBanner.vue";
import User from '@/request/user' import User from "@/request/user";
import ShopCar from '../../components/shopCar/shopCar.vue' import ShopCar from "../../components/shopCar/shopCar.vue";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import Menu from '@/request/menu' import Menu from "@/request/menu";
import { $EventBus } from '@/utils/EventBus'; import { $EventBus } from "@/utils/EventBus";
import Store from '@/store'; import Store from "@/store";
import Order from '@/request/order' import Order from "@/request/order";
import OrderQrCode from '@/components/OrderQrCode' import OrderQrCode from "@/components/OrderQrCode";
import QRCode from '@/utils/qrCode' import QRCode from "@/utils/qrCode";
export default { export default {
components: { ShopCar, MenuAssembly, OrderQrCode, AreaPicker, ImageLoader, HomeBanner }, components: {
ShopCar,
MenuAssembly,
OrderQrCode,
AreaPicker,
ImageLoader,
HomeBanner,
},
data() { data() {
return { return {
shopInfo: { name: '请选择' },// 店铺信息 shopInfo: { name: "请选择" }, // 店铺信息
buied: false,//控制首页取单码区域显隐 buied: false, //控制首页取单码区域显隐
orderInfo: {},//即将取餐的订单信息 orderInfo: {}, //即将取餐的订单信息
classifyData: [], classifyData: [],
customerName: '', customerName: "",
loginInfo:"", loginInfo: "",
img:'', img: "",
isInRange:true, isInRange: true,
dayTitle:'' dayTitle: "",
}; };
}, },
computed: { computed: {
shopState() { shopState() {
console.log(this.shopInfo) console.log(this.shopInfo);
const { shopInfo } = this const { shopInfo } = this;
const {startTime,endTime,state} = shopInfo const { startTime, endTime, state } = shopInfo;
if(!startTime||!endTime||!state) return true if (!startTime || !endTime || !state) return true;
function getNowFormatDate() { function getNowFormatDate() {
let date = new Date(), let date = new Date(),
seperator1 = '/', //格式分隔符 seperator1 = "/", //格式分隔符
year = date.getFullYear(), //获取完整的年份(4位) year = date.getFullYear(), //获取完整的年份(4位)
month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月) month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
strDate = date.getDate() // 获取当前日(1-31) strDate = date.getDate(); // 获取当前日(1-31)
if (month >= 1 && month <= 9) month = '0' + month // 如果月份是个位数,在前面补0 if (month >= 1 && month <= 9) month = "0" + month; // 如果月份是个位数,在前面补0
if (strDate >= 0 && strDate <= 9) strDate = '0' + strDate // 如果日是个位数,在前面补0 if (strDate >= 0 && strDate <= 9) strDate = "0" + strDate; // 如果日是个位数,在前面补0
let currentdate = year + seperator1 + month + seperator1 + strDate let currentdate = year + seperator1 + month + seperator1 + strDate;
return currentdate return currentdate;
} }
const startTimeNew = Date.parse(getNowFormatDate()+ ' ' +startTime+':00') const startTimeNew = Date.parse(
const endTimeNew = Date.parse(getNowFormatDate()+ ' ' +endTime+':00') getNowFormatDate() + " " + startTime + ":00"
if(startTimeNew<new Date().valueOf()&&new Date().valueOf()<endTimeNew&&state===1) { );
uni.setStorageSync("shopState",true) const endTimeNew = Date.parse(getNowFormatDate() + " " + endTime + ":00");
return true if (
}else{ startTimeNew < new Date().valueOf() &&
uni.setStorageSync("shopState",false) new Date().valueOf() < endTimeNew &&
return false state === 1
) {
uni.setStorageSync("shopState", true);
return true;
} else {
uni.setStorageSync("shopState", false);
return false;
} }
}, },
userms() { userms() {
...@@ -128,13 +197,13 @@ export default { ...@@ -128,13 +197,13 @@ export default {
created() { created() {
let platform = uni.getSystemInfoSync().platform; let platform = uni.getSystemInfoSync().platform;
uni.downloadFile({ uni.downloadFile({
url: 'https://hooloo-dev-api.gdatac.com/resources/menu.mp4', //仅为示例,并非真实的资源 url: "https://hooloo-dev-api.gdatac.com/resources/menu.mp4", //仅为示例,并非真实的资源
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
console.log(res); console.log(res);
this.img = res.tempFilePath this.img = res.tempFilePath;
}
} }
},
}); });
// if(platform == 'android'){ // if(platform == 'android'){
// this.img = '../../static/imgs/shouyezhanweitu.png' // this.img = '../../static/imgs/shouyezhanweitu.png'
...@@ -144,32 +213,32 @@ export default { ...@@ -144,32 +213,32 @@ export default {
}, },
onLoad: async function (option) { onLoad: async function (option) {
// 通过扫码进入 // 通过扫码进入
const{q} = option const { q } = option;
if(q){ if (q) {
const optionDecode = Utils.getUrlParams2(decodeURIComponent(q)) const optionDecode = Utils.getUrlParams2(decodeURIComponent(q));
console.log(Utils.getUrlParams2(decodeURIComponent(q)),this.userInfo) console.log(Utils.getUrlParams2(decodeURIComponent(q)), this.userInfo);
const {num,serial_no,source} = optionDecode const { num, serial_no, source } = optionDecode;
if(source&&this.userms) { if (source && this.userms) {
const sendData = { const sendData = {
phone:this.userInfo.phoneNumber, phone: this.userInfo.phoneNumber,
user_id:this.userInfo.id, user_id: this.userInfo.id,
source:source, source: source,
param:JSON.stringify({ param: JSON.stringify({
serial_no, serial_no,
num num,
}) }),
} };
Menu.sendUserCoupon(sendData) Menu.sendUserCoupon(sendData);
}else{ } else {
Store.commit('setMenuOption', optionDecode); Store.commit("setMenuOption", optionDecode);
} }
} }
uni.getSetting({ uni.getSetting({
success: (res) => { success: (res) => {
// 已经授权位置不获取默认店铺 // 已经授权位置不获取默认店铺
if(res.authSetting['scope.userLocation']){ if (res.authSetting["scope.userLocation"]) {
User.getLocation((state, params) => { User.getLocation((state, params) => {
if(state != 1) { if (state != 1) {
return; return;
} }
this.getShopMenus(params); this.getShopMenus(params);
...@@ -178,12 +247,12 @@ export default { ...@@ -178,12 +247,12 @@ export default {
// this.getShopMenus(); // this.getShopMenus();
this.authLocation(); this.authLocation();
} }
} },
}) });
if(!this.userms){ if (!this.userms) {
User.wxLoginAndGetOpenid(true).then(loginInfo=>{ User.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.loginInfo = loginInfo this.loginInfo = loginInfo;
}) });
} }
}, },
onHide() { onHide() {
...@@ -195,22 +264,22 @@ export default { ...@@ -195,22 +264,22 @@ export default {
}, },
async onShow() { async onShow() {
const dayTitleList = [ const dayTitleList = [
'呼噜咖啡,用对待人生的态度,做一杯专业好咖啡~', "呼噜咖啡,用对待人生的态度,做一杯专业好咖啡~",
'随手一杯好咖啡,希望你今天,明天,天天都开心~', "随手一杯好咖啡,希望你今天,明天,天天都开心~",
'咖啡哪有打工苦,喝完这杯再上班~', "咖啡哪有打工苦,喝完这杯再上班~",
'今天不听大道理,只喝专业好咖啡~', "今天不听大道理,只喝专业好咖啡~",
'来杯美式,少点破事~', "来杯美式,少点破事~",
'用咖啡拯救疲惫的灵魂~', "用咖啡拯救疲惫的灵魂~",
'呼噜咖啡由37%的咖啡加63%的生活构成~' "呼噜咖啡由37%的咖啡加63%的生活构成~",
] ];
this.dayTitle = dayTitleList[new Date().getDay()] this.dayTitle = dayTitleList[new Date().getDay()];
uni.setStorageSync("selectFlag",false) uni.setStorageSync("selectFlag", false);
const updataLoactionFlag = uni.getStorageSync("updataLoadtion") const updataLoactionFlag = uni.getStorageSync("updataLoadtion");
if(updataLoactionFlag) { if (updataLoactionFlag) {
this.authLocation(); this.authLocation();
uni.setStorageSync("updataLoadtion",false) uni.setStorageSync("updataLoadtion", false);
} }
this.getHomeOrder() this.getHomeOrder();
}, },
methods: { methods: {
getShareData(type) { getShareData(type) {
...@@ -221,47 +290,51 @@ export default { ...@@ -221,47 +290,51 @@ export default {
title, title,
imageUrl, imageUrl,
path, path,
} };
}, },
getShopMenus(params) { getShopMenus(params) {
$EventBus.$off('getMenuList'); $EventBus.$off("getMenuList");
$EventBus.$on('getMenuList', (data) => { $EventBus.$on("getMenuList", (data) => {
if(this.shopInfo && this.shopInfo.id != data.id) { if (this.shopInfo && this.shopInfo.id != data.id) {
// 切换店铺清空购物车 // 切换店铺清空购物车
if(this.shopInfo.id){ if (this.shopInfo.id) {
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync("shopCarInfo");
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
} }
} }
this.shopInfo = data; this.shopInfo = data;
uni.setStorageSync("shopInfo",JSON.stringify(this.shopInfo)) uni.setStorageSync("shopInfo", JSON.stringify(this.shopInfo));
this.getMenuList(data.id); this.getMenuList(data.id);
this.getHomeOrder(data.id) this.getHomeOrder(data.id);
// 判断店铺是否在范围内 // 判断店铺是否在范围内
const shopInfo = uni.getStorageSync("shopInfo") const shopInfo = uni.getStorageSync("shopInfo");
const {distanceLimit,realDistance} = JSON.parse(shopInfo) const { distanceLimit, realDistance } = JSON.parse(shopInfo);
const distance = realDistance/1000 const distance = realDistance / 1000;
if(!distanceLimit){ if (!distanceLimit) {
this.isInRange = true this.isInRange = true;
}else{ } else {
console.log(parseInt(distance),parseInt(distanceLimit),JSON.parse(shopInfo)) console.log(
this.isInRange = parseInt(distance)<parseInt(distanceLimit) parseInt(distance),
} parseInt(distanceLimit),
uni.setStorageSync("isInRange",this.isInRange) JSON.parse(shopInfo)
);
this.isInRange = parseInt(distance) < parseInt(distanceLimit);
}
uni.setStorageSync("isInRange", this.isInRange);
}); });
User.getShopInfo(params); User.getShopInfo(params);
}, },
async getHomeOrder(id = this.shopInfo.id){ async getHomeOrder(id = this.shopInfo.id) {
if (!this.userms) return; if (!this.userms) return;
const res = await Order.getHomeOrder({shopId:id}) const res = await Order.getHomeOrder({ shopId: id });
const data = res?.data const data = res?.data;
if (data?.data) { if (data?.data) {
// this.$set(data.data, 'state', '2'); // this.$set(data.data, 'state', '2');
// console.log("getHomeOrder:"+JSON.stringify(data.data)); // console.log("getHomeOrder:"+JSON.stringify(data.data));
this.buied = true; this.buied = true;
this.orderInfo = data.data this.orderInfo = data.data;
} else { } else {
this.buied = false this.buied = false;
} }
}, },
openQrcode() { openQrcode() {
...@@ -270,7 +343,7 @@ export default { ...@@ -270,7 +343,7 @@ export default {
// this.$refs.OrderQrCode.open(this.orderInfo, ""); // this.$refs.OrderQrCode.open(this.orderInfo, "");
// return; // return;
// } else { // } else {
this.$refs.OrderQrCode.open(this.orderInfo, this.orderInfo.pickCode) this.$refs.OrderQrCode.open(this.orderInfo, this.orderInfo.pickCode);
// } // }
// new QRCode('myQrcode2', { // new QRCode('myQrcode2', {
...@@ -285,16 +358,19 @@ export default { ...@@ -285,16 +358,19 @@ export default {
// }) // })
}, },
showArea() { showArea() {
console.log(this.$refs) console.log(this.$refs);
this.$refs.AreaPicker.showArea() this.$refs.AreaPicker.showArea();
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo;
User.getPhoneNumber(e,this.getHomeOrder); User.getPhoneNumber(e, this.getHomeOrder);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}, },
// 获取定位授权 // 获取定位授权
...@@ -302,79 +378,88 @@ export default { ...@@ -302,79 +378,88 @@ export default {
uni.getSetting({ uni.getSetting({
success: (res) => { success: (res) => {
uni.authorize({ uni.authorize({
scope: 'scope.userLocation', scope: "scope.userLocation",
success: () => { //1.1 允许授权 success: () => {
//1.1 允许授权
// console.log("允许授权位置"); // console.log("允许授权位置");
User.getLocation((state, params) => { User.getLocation((state, params) => {
if(state != 1){ if (state != 1) {
return; return;
} }
callback ? callback(params) : this.getShopMenus(params); callback ? callback(params) : this.getShopMenus(params);
}); });
}, },
fail: (err) => { //1.2 拒绝授权 fail: (err) => {
//1.2 拒绝授权
this.getShopMenus(); this.getShopMenus();
wx.exitMiniProgram({ success: (res) => { } }) wx.exitMiniProgram({ success: (res) => {} });
// console.log("获取位置失败") // console.log("获取位置失败")
this.showToast({ "title" : "获取位置失败,请打开位置授权", icon : 'error'}) this.showToast({
} title: "获取位置失败,请同意授权",
}) icon: "error",
} });
}) },
});
},
});
}, },
async getMenuList(id) { async getMenuList(id) {
let { data } = await Menu.getMenuList(id); let { data } = await Menu.getMenuList(id);
// console.log("menus:"+JSON.stringify(data)); // console.log("menus:"+JSON.stringify(data));
if (data.code == 200) { if (data.code == 200) {
data.data = data.data; data.data = data.data;
this.$store.commit('setMenuAllInfo', data.data); this.$store.commit("setMenuAllInfo", data.data);
this.$store.commit('setMenuCategorys', data.data.categorys); this.$store.commit("setMenuCategorys", data.data.categorys);
uni.setStorageSync('countOfOrder', parseInt(data.data.countOfOrder)); uni.setStorageSync("countOfOrder", parseInt(data.data.countOfOrder));
// this.$refs.MenuAssembly.createList(data.data.categorys) // this.$refs.MenuAssembly.createList(data.data.categorys)
} }
}, },
// 加入购物车数据 // 加入购物车数据
async getallNum(item, category) { async getallNum(item, category) {
let itemCopy = JSON.parse(JSON.stringify(item)); let itemCopy = JSON.parse(JSON.stringify(item));
const sku = itemCopy.skus.find(v => v.isDefault == 1); const sku = itemCopy.skus.find((v) => v.isDefault == 1);
const {data} = await Order.checkSku({skuId:sku.skuId}) const { data } = await Order.checkSku({ skuId: sku.skuId });
const {state,goods} = data.data const { state, goods } = data.data;
const newsku = goods.skus.find(v => v.isDefault == 1 && v.state != 2) || goods.skus.find(v => v.isDefault == 0 && v.state != 2); const newsku =
if(state == 2){ goods.skus.find((v) => v.isDefault == 1 && v.state != 2) ||
if(newsku){ goods.skus.find((v) => v.isDefault == 0 && v.state != 2);
if(newsku.isDefault != 1){ if (state == 2) {
this.showToast({ title: '默认规格已售罄,已添加其他规格', icon: 'none' }); if (newsku) {
if (newsku.isDefault != 1) {
this.showToast({
title: "默认规格已售罄,已添加其他规格",
icon: "none",
});
itemCopy.skus = [newsku]; itemCopy.skus = [newsku];
itemCopy.sku = newsku itemCopy.sku = newsku;
itemCopy.skuId = newsku?.skuId itemCopy.skuId = newsku?.skuId;
itemCopy.num = 1; itemCopy.num = 1;
itemCopy.flag = true; itemCopy.flag = true;
itemCopy.categoryId = category.id; itemCopy.categoryId = category.id;
itemCopy.goodsName = category.name; itemCopy.goodsName = category.name;
Utils.getallNum(itemCopy); Utils.getallNum(itemCopy);
} }
}else{ } else {
this.showToast({ title: '本商品已经售罄', icon: 'none' }); this.showToast({ title: "这款已经卖完啦", icon: "none" });
return; return;
} }
}else{ } else {
itemCopy.skus = [newsku]; itemCopy.skus = [newsku];
itemCopy.sku = newsku itemCopy.sku = newsku;
itemCopy.skuId = newsku?.skuId itemCopy.skuId = newsku?.skuId;
itemCopy.num = 1; itemCopy.num = 1;
itemCopy.flag = true; itemCopy.flag = true;
itemCopy.categoryId = category.id; itemCopy.categoryId = category.id;
itemCopy.goodsName = category.name; itemCopy.goodsName = category.name;
Utils.getallNum(itemCopy); Utils.getallNum(itemCopy);
} }
return return;
}, },
goToMyPage(logined) { goToMyPage(logined) {
logined && uni.switchTab({ url: '/pages/mine/mine' }) logined && uni.switchTab({ url: "/pages/mine/mine" });
}
}, },
},
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -385,12 +470,12 @@ export default { ...@@ -385,12 +470,12 @@ export default {
z-index: 100; z-index: 100;
position: absolute; position: absolute;
left: 32rpx; left: 32rpx;
color: #FFFFFF; color: #ffffff;
.shop-box { .shop-box {
font-size: 32rpx; font-size: 32rpx;
font-weight: 500; font-weight: 500;
color: #FFFFFF; color: #ffffff;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
display: flex; display: flex;
align-items: center; align-items: center;
...@@ -415,7 +500,7 @@ export default { ...@@ -415,7 +500,7 @@ export default {
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
line-height: 42rpx; line-height: 42rpx;
} }
} }
...@@ -428,7 +513,6 @@ export default { ...@@ -428,7 +513,6 @@ export default {
video { video {
width: 100%; width: 100%;
height: 400rpx; height: 400rpx;
} }
image { image {
width: 100%; width: 100%;
...@@ -462,15 +546,15 @@ export default { ...@@ -462,15 +546,15 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 72rpx; border-radius: 72rpx;
}; }
} }
.user-info { .user-info {
display: flex; display: flex;
align-items: center; align-items: center;
width: 530.55rpx; width: 530.55rpx;
justify-content:space-between; justify-content: space-between;
flex-wrap:nowrap; flex-wrap: nowrap;
.user-name { .user-name {
margin-top: 2.68rpx; margin-top: 2.68rpx;
font-size: 24rpx; font-size: 24rpx;
...@@ -490,7 +574,7 @@ export default { ...@@ -490,7 +574,7 @@ export default {
flex: 1; flex: 1;
} }
} }
.arrow-right-select{ .arrow-right-select {
width: 15.27rpx; width: 15.27rpx;
height: 21.68rpx; height: 21.68rpx;
} }
...@@ -501,13 +585,13 @@ export default { ...@@ -501,13 +585,13 @@ export default {
margin-right: -5rpx; margin-right: -5rpx;
width: 167rpx; width: 167rpx;
height: 64rpx; height: 64rpx;
background: #0050F6; background: #0050f6;
border-radius: 2rpx; border-radius: 2rpx;
text-align: center; text-align: center;
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
line-height: 64rpx; line-height: 64rpx;
} }
} }
...@@ -516,8 +600,9 @@ export default { ...@@ -516,8 +600,9 @@ export default {
.order-banner { .order-banner {
width: 718rpx; width: 718rpx;
height: 179rpx; height: 179rpx;
background: #FFFFFF; background: #ffffff;
box-shadow: -2px -2px 8px 0px rgba(102, 102, 102, 0.1), 2px 2px 8px 0px rgba(102, 102, 102, 0.1); box-shadow: -2px -2px 8px 0px rgba(102, 102, 102, 0.1),
2px 2px 8px 0px rgba(102, 102, 102, 0.1);
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
left: 16rpx; left: 16rpx;
...@@ -537,7 +622,7 @@ export default { ...@@ -537,7 +622,7 @@ export default {
color: #666666; color: #666666;
line-height: 44rpx; line-height: 44rpx;
margin-top: 44rpx; margin-top: 44rpx;
.first-code{ .first-code {
font-family: Arial, Helvetica SC; font-family: Arial, Helvetica SC;
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
...@@ -560,7 +645,7 @@ export default { ...@@ -560,7 +645,7 @@ export default {
font-size: 32rpx; font-size: 32rpx;
font-family: Futura Medium, Arial, sans-serif; font-family: Futura Medium, Arial, sans-serif;
font-weight: normal; font-weight: normal;
color: #0050F6; color: #0050f6;
margin: 0 16rpx; margin: 0 16rpx;
} }
} }
...@@ -572,7 +657,7 @@ export default { ...@@ -572,7 +657,7 @@ export default {
.line { .line {
width: 4rpx; width: 4rpx;
height: 104rpx; height: 104rpx;
border-right: 1rpx solid #E8E8E8; border-right: 1rpx solid #e8e8e8;
position: absolute; position: absolute;
left: 510rpx; left: 510rpx;
box-shadow: -2px -4px 8px 0px rgba(102, 102, 102, 0.1); box-shadow: -2px -4px 8px 0px rgba(102, 102, 102, 0.1);
......
...@@ -5,25 +5,42 @@ ...@@ -5,25 +5,42 @@
<!-- <image class="logImg" src="/static/imgs/hooloo.png"></image> --> <!-- <image class="logImg" src="/static/imgs/hooloo.png"></image> -->
<!-- <view class="logText">未 来 咖 啡</view> --> <!-- <view class="logText">未 来 咖 啡</view> -->
</view> </view>
<image :src="img"/> <image :src="img" />
<!-- <video class="video" autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"></video> --> <!-- <video class="video" autoplay muted loop :controls="false" :enable-progress-gesture="false" objectFit='cover' src="http://songclound.oss-cn-hongkong.aliyuncs.com/2022/06/27/e6582afb60924.mp4"></video> -->
<view class="mod11" @click="goToPage('userInfo')"> <view class="mod11" @click="goToPage('userInfo')">
<view class="avatar"> <view class="avatar">
<image :src="userInfo.avatarUrl?userInfo.avatarUrl:'../../static/touxiang.png'"></image> <image
:src="
userInfo.avatarUrl
? userInfo.avatarUrl
: '../../static/touxiang.png'
"
></image>
</view> </view>
<view class="user-info"> <view class="user-info">
<view class="user-infocontent"> <view class="user-infocontent">
<view class="user-name" v-if="userms">HI!{{ userInfo.customerName || '我是谁' }}</view> <view class="user-name" v-if="userms"
>HI!{{ userInfo.customerName || "我是谁" }}</view
>
<view class="user-name" v-else>未登录</view> <view class="user-name" v-else>未登录</view>
<view class="dialog"> <view class="dialog">
<view class="content" v-if="userms">{{dayTitle}}</view> <view class="content" v-if="userms">{{ dayTitle }}</view>
<view class="content" v-if="!userms">请您尽快登录~</view> <view class="content" v-if="!userms">请您尽快登录~</view>
</view> </view>
</view> </view>
<view> <view>
<image class="arrow-right-select" v-if="userms" :src="'../../static/imgs/jiantouhei.png'" /> <image
<button class="login-btn" v-if="!userms" open-type="getPhoneNumber" class="arrow-right-select"
@getphonenumber="getPhoneNumber">立即登录 v-if="userms"
:src="'../../static/imgs/jiantouhei.png'"
/>
<button
class="login-btn"
v-if="!userms"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
立即登录
</button> </button>
</view> </view>
</view> </view>
...@@ -34,45 +51,97 @@ ...@@ -34,45 +51,97 @@
<view class="contents" v-if="userms"> <view class="contents" v-if="userms">
<view class="myOrder" @click="goToPage('order')"> <view class="myOrder" @click="goToPage('order')">
<view class="text">我的订单</view> <view class="text">我的订单</view>
<view class="iconbox"><image class="icon" src="/static/imgs/dingdan.png"></image></view> <view class="iconbox"
><image class="icon" src="/static/imgs/dingdan.png"></image
></view>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="right_box"> <view class="right_box">
<view class="box" @click.stop="goToPage('coupon')"> <view class="box" @click.stop="goToPage('coupon')">
<view class="left"> <view class="left">
<view class="text">HOOLOO券</view> <view class="text">HOOLOO券</view>
<view class="tickNum" v-if="tickNum"><span :style="{'color':'#FA5151'}">{{tickNum}}</span>张可用</view> <view class="tickNum" v-if="tickNum"
><span :style="{ color: '#FA5151' }">{{ tickNum }}</span
>张可用</view
>
</view> </view>
<view class="right"><image class="icon" src="/static/imgs/youhuijuan.png"></image></view> <view class="right"
><image class="icon" src="/static/imgs/youhuijuan.png"></image
></view>
</view> </view>
<view class="line"></view> <view class="line"></view>
<view class="box_two" @click="goToPage('msg')"> <view class="box_two" @click="goToPage('msg')">
<view class="left"> <view class="left">
<view class="text">我的消息</view> <view class="text">我的消息</view>
</view> </view>
<view class="right"><image class="icon" src="/static/imgs/xiaoxi.png"></image></view> <view class="right"
><image class="icon" src="/static/imgs/xiaoxi.png"></image
></view>
</view> </view>
</view> </view>
</view> </view>
<view class="contents" v-if="!userms" :style="{'padding-bottom':'65rpx'}"> <view
<button class="myOrder" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" style="line-height:30rpx; margin-left:0rpx; margin-right:0rpx; padding-left:0rpx; padding-right:0rpx;"> class="contents"
v-if="!userms"
:style="{ 'padding-bottom': '65rpx' }"
>
<button
class="myOrder"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
style="
line-height: 30rpx;
margin-left: 0rpx;
margin-right: 0rpx;
padding-left: 0rpx;
padding-right: 0rpx;
"
>
<view class="text">我的订单</view> <view class="text">我的订单</view>
<view class="iconbox"><image class="icon" src="/static/imgs/dingdan.png"></image></view> <view class="iconbox"
><image class="icon" src="/static/imgs/dingdan.png"></image
></view>
</button> </button>
<view class="line"></view> <view class="line"></view>
<view class="right_box"> <view class="right_box">
<button class="box" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" style="line-height:30rpx; margin-left:0rpx; margin-right:0rpx; padding-left:0rpx; padding-right:0rpx;"> <button
class="box"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
style="
line-height: 30rpx;
margin-left: 0rpx;
margin-right: 0rpx;
padding-left: 0rpx;
padding-right: 0rpx;
"
>
<view class="left"> <view class="left">
<view class="text">HOOLOO券</view> <view class="text">HOOLOO券</view>
</view> </view>
<view class="right"><image class="icon" src="/static/imgs/youhuijuan.png"></image></view> <view class="right"
><image class="icon" src="/static/imgs/youhuijuan.png"></image
></view>
</button> </button>
<view class="line"></view> <view class="line"></view>
<button class="box_two" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" style="line-height:30rpx; margin-left:0rpx; margin-right:0rpx; padding-left:0rpx; padding-right:0rpx;"> <button
class="box_two"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
style="
line-height: 30rpx;
margin-left: 0rpx;
margin-right: 0rpx;
padding-left: 0rpx;
padding-right: 0rpx;
"
>
<view class="left"> <view class="left">
<view class="text">我的消息</view> <view class="text">我的消息</view>
</view> </view>
<view class="right"><image class="icon" src="/static/imgs/xiaoxi.png"></image></view> <view class="right"
><image class="icon" src="/static/imgs/xiaoxi.png"></image
></view>
</button> </button>
</view> </view>
</view> </view>
...@@ -80,48 +149,59 @@ ...@@ -80,48 +149,59 @@
<view class="title">常用功能</view> <view class="title">常用功能</view>
<view class="function_item"> <view class="function_item">
<u-icon name="server-fill" color="#000000" size="16"></u-icon> <u-icon name="server-fill" color="#000000" size="16"></u-icon>
<button class="function_item_text" open-type="contact" bindcontact="handleContact" session-from="sessionFrom">联系客服</button> <button
class="function_item_text"
open-type="contact"
bindcontact="handleContact"
session-from="sessionFrom"
>
联系客服
</button>
<view class="function_item_icon"> <view class="function_item_icon">
<image :style="{'height':'100%','width':'100%'}" v-if="userms" :src="'../../static/imgs/jiantouhei.png'" /> <image
:style="{ height: '100%', width: '100%' }"
v-if="userms"
:src="'../../static/imgs/jiantouhei.png'"
/>
</view> </view>
</view> </view>
</view> </view>
<taBar select="2"></taBar> <taBar select="2"></taBar>
<show-toast ref="toast"/> <show-toast ref="toast" />
</view> </view>
</template> </template>
<script> <script>
import User from '@/request/user' import User from "@/request/user";
export default { export default {
onLoad() { onLoad() {
if(!this.userms){ if (!this.userms) {
User.wxLoginAndGetOpenid(true).then(loginInfo=>{ User.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.loginInfo = loginInfo this.loginInfo = loginInfo;
}) });
} }
let platform = uni.getSystemInfoSync().platform; let platform = uni.getSystemInfoSync().platform;
if(platform == 'android'){ if (platform == "android") {
this.img = '../../static/imgs/wodezhanweitu.png' this.img = "../../static/imgs/wodezhanweitu.png";
}else{ } else {
this.img = 'https://s3.bmp.ovh/imgs/2022/07/05/1768111c5c7f5300.gif' this.img = "https://s3.bmp.ovh/imgs/2022/07/05/1768111c5c7f5300.gif";
} }
}, },
async onShow() { async onShow() {
const dayTitleList = [ const dayTitleList = [
'呼噜咖啡,用对待人生的态度,做一杯专业好咖啡~', "呼噜咖啡,用对待人生的态度,做一杯专业好咖啡~",
'随手一杯好咖啡,希望你今天,明天,天天都开心~', "随手一杯好咖啡,希望你今天,明天,天天都开心~",
'咖啡哪有打工苦,喝完这杯再上班~', "咖啡哪有打工苦,喝完这杯再上班~",
'今天不听大道理,只喝专业好咖啡~', "今天不听大道理,只喝专业好咖啡~",
'来杯美式,少点破事~', "来杯美式,少点破事~",
'用咖啡拯救疲惫的灵魂~', "用咖啡拯救疲惫的灵魂~",
'呼噜咖啡由37%的咖啡加63%的生活构成~' "呼噜咖啡由37%的咖啡加63%的生活构成~",
] ];
this.dayTitle = dayTitleList[new Date().getDay()] this.dayTitle = dayTitleList[new Date().getDay()];
if(this.userInfo){ if (this.userInfo) {
const {data} = await User.getCouponNum() const { data } = await User.getCouponNum();
this.tickNum = data?.data||0 this.tickNum = data?.data || 0;
} }
}, },
// 微信小程序右上角分享 // 微信小程序右上角分享
...@@ -130,11 +210,11 @@ export default { ...@@ -130,11 +210,11 @@ export default {
}, },
data() { data() {
return { return {
loginInfo:"", loginInfo: "",
img:'', img: "",
tickNum:0, tickNum: 0,
dayTitle:'', dayTitle: "",
} };
}, },
computed: { computed: {
userms() { userms() {
...@@ -153,32 +233,36 @@ export default { ...@@ -153,32 +233,36 @@ export default {
title, title,
imageUrl, imageUrl,
path, path,
} };
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo;
User.getPhoneNumber(e,async ()=>{ User.getPhoneNumber(e, async () => {
setTimeout(async () => { setTimeout(async () => {
const {data:couponData} = await User.getCouponNum() const { data: couponData } = await User.getCouponNum();
this.tickNum = couponData?.data||0 this.tickNum = couponData?.data || 0;
}, 1000); }, 1000);
}); });
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}, },
goToPage(page) { goToPage(page) {
page == 'coupon' && uni.navigateTo({ url: '/mineSubPackage/pages/coupon/index' }) page == "coupon" &&
uni.navigateTo({ url: "/mineSubPackage/pages/coupon/index" });
if (!this.userms) { if (!this.userms) {
// this.loginByPhoneNumber(page) // this.loginByPhoneNumber(page)
return return;
} }
page == 'order' && uni.switchTab({ url: '/pages/order/order' }) page == "order" && uni.switchTab({ url: "/pages/order/order" });
page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' }) page == "msg" &&
if(page == 'userInfo'){ uni.navigateTo({ url: "/mineSubPackage/pages/msg/index" });
if (page == "userInfo") {
// console.log(this.userInfo,'this.userInfo') // console.log(this.userInfo,'this.userInfo')
// if(this.userInfo.avatarUrl){ // if(this.userInfo.avatarUrl){
// uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index'}) // uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index'})
...@@ -186,23 +270,29 @@ export default { ...@@ -186,23 +270,29 @@ export default {
// wx.getUserProfile({ // wx.getUserProfile({
// desc:'用于完善用户资料', // desc:'用于完善用户资料',
// success:(res)=>{ // success:(res)=>{
const {userInfo} = this const { userInfo } = this;
console.log(userInfo,'userInfo') console.log(userInfo, "userInfo");
let defaultImg = "https://hooloo-mp.oss-cn-shanghai.aliyuncs.com/resources/touxiang.png"; let defaultImg =
"https://hooloo-mp.oss-cn-shanghai.aliyuncs.com/resources/touxiang.png";
const Info = JSON.stringify({ const Info = JSON.stringify({
avatarUrl:userInfo.avatarUrl||defaultImg, avatarUrl: userInfo.avatarUrl || defaultImg,
gender:userInfo.gender, gender: userInfo.gender,
nickName:userInfo.customerName nickName: userInfo.customerName,
}) });
// console.log(res) // console.log(res)
page == 'userInfo' && uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index?info='+encodeURIComponent(Info) }) page == "userInfo" &&
uni.navigateTo({
url:
"/mineSubPackage/pages/userInfo/index?info=" +
encodeURIComponent(Info),
});
// } // }
// }) // })
// } // }
} }
} },
} },
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -219,7 +309,8 @@ button::after { ...@@ -219,7 +309,8 @@ button::after {
left: 0; left: 0;
} }
.menu-box {} .menu-box {
}
.menu-banner { .menu-banner {
position: relative; position: relative;
...@@ -243,7 +334,7 @@ button::after { ...@@ -243,7 +334,7 @@ button::after {
font-size: 42rpx; font-size: 42rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600; font-weight: 600;
color: #FFFFFF; color: #ffffff;
} }
} }
...@@ -268,8 +359,6 @@ button::after { ...@@ -268,8 +359,6 @@ button::after {
backdrop-filter: blur(0px); backdrop-filter: blur(0px);
z-index: 9; z-index: 9;
.avatar { .avatar {
display: flex; display: flex;
justify-items: center; justify-items: center;
...@@ -282,15 +371,15 @@ button::after { ...@@ -282,15 +371,15 @@ button::after {
width: 100%; width: 100%;
height: 100%; height: 100%;
border-radius: 72rpx; border-radius: 72rpx;
}; }
} }
.user-info { .user-info {
display: flex; display: flex;
align-items: center; align-items: center;
width: 530.55rpx; width: 530.55rpx;
justify-content:space-between; justify-content: space-between;
flex-wrap:nowrap; flex-wrap: nowrap;
.user-name { .user-name {
margin-top: 2.68rpx; margin-top: 2.68rpx;
font-size: 24rpx; font-size: 24rpx;
...@@ -310,7 +399,7 @@ button::after { ...@@ -310,7 +399,7 @@ button::after {
flex: 1; flex: 1;
} }
} }
.arrow-right-select{ .arrow-right-select {
width: 15.27rpx; width: 15.27rpx;
height: 21.68rpx; height: 21.68rpx;
} }
...@@ -321,17 +410,17 @@ button::after { ...@@ -321,17 +410,17 @@ button::after {
margin-right: -5rpx; margin-right: -5rpx;
width: 167rpx; width: 167rpx;
height: 64rpx; height: 64rpx;
background: #0050F6; background: #0050f6;
border-radius: 2rpx; border-radius: 2rpx;
text-align: center; text-align: center;
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
line-height: 64rpx; line-height: 64rpx;
} }
} }
.mod11::after{ .mod11::after {
border-radius: 0rpx; border-radius: 0rpx;
} }
...@@ -341,13 +430,13 @@ button::after { ...@@ -341,13 +430,13 @@ button::after {
margin: -28rpx 32rpx 24rpx 32rpx; margin: -28rpx 32rpx 24rpx 32rpx;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
background: #FFFFFF; background: #ffffff;
// background: #0000FF; // background: #0000FF;
.myOrder { .myOrder {
height: 216rpx; height: 216rpx;
// background: #FF0000; // background: #FF0000;
background: #FFFFFF; background: #ffffff;
align-items: center; align-items: center;
text-align: left; text-align: left;
...@@ -383,10 +472,10 @@ button::after { ...@@ -383,10 +472,10 @@ button::after {
} }
} }
.line{ .line {
height: 216rpx; height: 216rpx;
background: #E4E4E4; background: #e4e4e4;
border: 1rpx solid #E4E4E4; border: 1rpx solid #e4e4e4;
} }
.right_box { .right_box {
...@@ -406,7 +495,7 @@ button::after { ...@@ -406,7 +495,7 @@ button::after {
height: 69rpx; height: 69rpx;
// background: #FF0000; // background: #FF0000;
line-height: 30rpx; line-height: 30rpx;
background: #FFFFFF; background: #ffffff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
...@@ -427,7 +516,7 @@ button::after { ...@@ -427,7 +516,7 @@ button::after {
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #323232; color: #323232;
margin-top: 10rpx margin-top: 10rpx;
} }
} }
...@@ -438,13 +527,13 @@ button::after { ...@@ -438,13 +527,13 @@ button::after {
} }
} }
} }
.box_two::after{ .box_two::after {
line-height: 30rpx; line-height: 30rpx;
} }
.line { .line {
width: 306rpx; width: 306rpx;
height: 2rpx; height: 2rpx;
border: 1rpx solid #E4E4E4; border: 1rpx solid #e4e4e4;
margin: 38rpx 0rpx 40rpx 0rpx; margin: 38rpx 0rpx 40rpx 0rpx;
} }
.box { .box {
...@@ -454,7 +543,7 @@ button::after { ...@@ -454,7 +543,7 @@ button::after {
height: 129rpx; height: 129rpx;
line-height: 30rpx; line-height: 30rpx;
// background: #FF0000; // background: #FF0000;
background: #FFFFFF; background: #ffffff;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
...@@ -484,7 +573,7 @@ button::after { ...@@ -484,7 +573,7 @@ button::after {
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400; font-weight: 400;
color: #323232; color: #323232;
margin-top: 10rpx margin-top: 10rpx;
} }
} }
...@@ -495,7 +584,7 @@ button::after { ...@@ -495,7 +584,7 @@ button::after {
} }
} }
} }
.box::after{ .box::after {
line-height: 30rpx; line-height: 30rpx;
} }
} }
...@@ -503,7 +592,7 @@ button::after { ...@@ -503,7 +592,7 @@ button::after {
.function { .function {
width: 686rpx; width: 686rpx;
background: #FFFFFF; background: #ffffff;
margin: 0 auto; margin: 0 auto;
padding: 21.72rpx 30rpx 29.28rpx 26rpx; padding: 21.72rpx 30rpx 29.28rpx 26rpx;
box-sizing: border-box; box-sizing: border-box;
...@@ -533,7 +622,7 @@ button::after { ...@@ -533,7 +622,7 @@ button::after {
padding: 10rpx; padding: 10rpx;
text-align: left; text-align: left;
line-height: 1; line-height: 1;
background-color: #FFFFFF; background-color: #ffffff;
font-weight: 400; font-weight: 400;
color: #333333; color: #333333;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
......
<template> <template>
<view class="pages"> <view class="pages">
<view class="topBar" :style="{'padding-top':systemBarHeight.statusBarHeight+'px','height':systemBarHeight.navigationBarHeight+'px'}"> <view
class="topBar"
:style="{
'padding-top': systemBarHeight.statusBarHeight + 'px',
height: systemBarHeight.navigationBarHeight + 'px',
}"
>
<!-- <u-icon @click="Utils.goBack()" name="arrow-left" color="#000000" size="20"></u-icon> --> <!-- <u-icon @click="Utils.goBack()" name="arrow-left" color="#000000" size="20"></u-icon> -->
<view class="tabTitle" :style="{'line-height':systemBarHeight.navigationBarHeight+'px'}">我的订单</view> <view
class="tabTitle"
:style="{ 'line-height': systemBarHeight.navigationBarHeight + 'px' }"
>我的订单</view
>
</view> </view>
<view v-show="false">{{userms}}</view> <view v-show="false">{{ userms }}</view>
<view :style="{'padding-top':(systemBarHeight.statusBarHeight+systemBarHeight.navigationBarHeight)+'px'}"> <view
:style="{
'padding-top':
systemBarHeight.statusBarHeight +
systemBarHeight.navigationBarHeight +
'px',
}"
>
<view class="empty" v-show="userms && empty == true"> <view class="empty" v-show="userms && empty == true">
<view :style="{'text-align':'center'}"> <view :style="{ 'text-align': 'center' }">
<image class="empty_icon" src="/static/imgs/wudingdanzhanweitu.png"></image> <image
class="empty_icon"
src="/static/imgs/wudingdanzhanweitu.png"
></image>
</view> </view>
<view class="empty_text">——您还未下单,下单品尝一下吧——</view> <view class="empty_text">——您还未下单,下单品尝一下吧——</view>
<button class="empty_button" @click="goHome">去品尝</button> <button class="empty_button" @click="goHome">去品尝</button>
</view> </view>
<view class="empty_notdl" v-show="!userms"> <view class="empty_notdl" v-show="!userms">
<view :style="{'text-align':'center'}"> <view :style="{ 'text-align': 'center' }">
<image class="empty_icon" src="/static/imgs/weidengluzhanweitu.png"></image> <image
class="empty_icon"
src="/static/imgs/weidengluzhanweitu.png"
></image>
</view> </view>
<view class="empty_text">——您还未登录,请先登录——</view> <view class="empty_text">——您还未登录,请先登录——</view>
<button class="empty_button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">去登录</button> <button
class="empty_button"
open-type="getPhoneNumber"
@getphonenumber="getPhoneNumber"
>
去登录
</button>
</view> </view>
<view class="orders" :style="{'padding-bottom':orderBottom+'rpx'}"> <view class="orders" :style="{ 'padding-bottom': orderBottom + 'rpx' }">
<view class="order_item" v-for="item in list" :key="item.id" @click="openInfo(item)"> <view
class="order_item"
v-for="item in list"
:key="item.id"
@click="openInfo(item)"
>
<view class="order_header"> <view class="order_header">
<view> <view>
<view class="order_adrass">{{ item.shop.name }}</view> <view class="order_adrass">{{ item.shop.name }}</view>
...@@ -29,241 +63,310 @@ ...@@ -29,241 +63,310 @@
</view> </view>
<view class="order_status"> <view class="order_status">
<text>{{ getStateText(item.state) }}</text> <text>{{ getStateText(item.state) }}</text>
<image class="xiaojiantou" src="@/static/imgs/xiaojiantou.png"/> <image class="xiaojiantou" src="@/static/imgs/xiaojiantou.png" />
</view> </view>
</view> </view>
<div class="order_content"> <div class="order_content">
<view class="order_content_box1"> <view class="order_content_box1">
<view class="goods_item" v-for="(good,index) in item.orderDetails" :key="good.id"> <view
<image class="goods_img" v-if="jsonParse(good.goods.pics).thumbnailApplet" :src="jsonParse(good.goods.pics).thumbnailApplet"></image> class="goods_item"
<image v-else class="goods_img" :src="jsonParse(good.goods.pics).thumbnail"></image> v-for="(good, index) in item.orderDetails"
:key="good.id"
>
<image
class="goods_img"
v-if="jsonParse(good.goods.pics).thumbnailApplet"
:src="jsonParse(good.goods.pics).thumbnailApplet"
></image>
<image
v-else
class="goods_img"
:src="jsonParse(good.goods.pics).thumbnail"
></image>
<view class="goods_text"> <view class="goods_text">
<view class="goods_title">{{ good.goodsName }}</view> <view class="goods_title">{{ good.goodsName }}</view>
<view class="goods_spce"> <view class="goods_spce">
<view> <view>
<span v-for="(rule, index) in jsonParse(good.specRuleDetail)" :key="rule.specId"> <span
v-for="(rule, index) in jsonParse(good.specRuleDetail)"
:key="rule.specId"
>
{{ rule.ruleName }} {{ rule.ruleName }}
<span v-if="index!=jsonParse(good.specRuleDetail).length-1">/</span> <span
v-if="
index != jsonParse(good.specRuleDetail).length - 1
"
>/</span
>
</span> </span>
</view> </view>
<view class="numbox"> <view class="numbox">
×{{ good.num }} ×{{ good.num }}
<a class="btntk" v-if="checkStatus(item.state,[12,13,14,15])&&(index+1)===item.orderDetails.length" @click.stop="refundInfo(item)" type="primary">退款详情</a> <a
class="btntk"
v-if="
checkStatus(item.state, [12, 13, 14, 15]) &&
index + 1 === item.orderDetails.length
"
@click.stop="refundInfo(item)"
type="primary"
>退款详情</a
>
</view> </view>
</view> </view>
</view> </view>
<view v-if="index==item.orderDetails.length-1 && (item.state == 2 || item.state == 3 || item.state == 4 || item.state == 5)" class="qr_code"> <view
<image class="qr_code_img" src="/static/imgs/icon-barcode.png"></image> v-if="
index == item.orderDetails.length - 1 &&
(item.state == 2 ||
item.state == 3 ||
item.state == 4 ||
item.state == 5)
"
class="qr_code"
>
<image
class="qr_code_img"
src="/static/imgs/icon-barcode.png"
></image>
<view class="qr_text">点击二维码取单</view> <view class="qr_text">点击二维码取单</view>
</view> </view>
</view> </view>
</view> </view>
</div> </div>
<view class="order_footer" :style="{'margin-top':checkStatus(item.state,[12,13,14,15])?'16rpx':'39rpx'}"> <view
class="order_footer"
:style="{
'margin-top': checkStatus(item.state, [12, 13, 14, 15])
? '16rpx'
: '39rpx',
}"
>
<view class="total"> <view class="total">
{{ orderDetailsSize(item.orderDetails) }}件商品 实付<text class="price">{{ Utils.isInteger(item.paidAmount) }}</text> {{ orderDetailsSize(item.orderDetails) }}件商品 实付<text
class="price"
>{{ Utils.isInteger(item.paidAmount) }}</text
>
</view> </view>
<a class="btn" @click.stop="PayNow(item)" v-if="item.state == 1" type="primary">立即支付</a> <a
<a class="btn" v-else @click.stop="oneMoreOrder(item)" type="primary">再来一单</a> class="btn"
@click.stop="PayNow(item)"
v-if="item.state == 1"
type="primary"
>立即支付</a
>
<a
class="btn"
v-else
@click.stop="oneMoreOrder(item)"
type="primary"
>再来一单</a
>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<show-toast ref="toast"/> <show-toast ref="toast" />
<taBar select="1"></taBar> <taBar select="1"></taBar>
</view> </view>
</template> </template>
<script> <script>
import order from '@/request/order' import order from "@/request/order";
import Menu from '@/request/menu'; import Menu from "@/request/menu";
import Utils from '@/utils/utils' import Utils from "@/utils/utils";
import User from '@/request/user' import User from "@/request/user";
import { $EventBus } from "@/utils/EventBus"; import { $EventBus } from "@/utils/EventBus";
export default { export default {
onLoad() { onLoad() {
if(!this.userms){ if (!this.userms) {
User.wxLoginAndGetOpenid(true).then(loginInfo=>{ User.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.loginInfo = loginInfo this.loginInfo = loginInfo;
}) });
} }
}, },
name: 'order', name: "order",
data() { data() {
return { return {
empty: false, empty: false,
list: [], list: [],
loginInfo:"", loginInfo: "",
Utils, Utils,
orderBottom:0 orderBottom: 0,
} };
}, },
onShow() { onShow() {
this.getList() this.getList();
}, },
mounted() { mounted() {
this.orderBottom = uni.getStorageSync('orderBottom') this.orderBottom = uni.getStorageSync("orderBottom");
// this.getList() // this.getList()
}, },
computed: { computed: {
userms() { userms() {
return this.$store.getters.Authorization; return this.$store.getters.Authorization;
}, },
systemBarHeight(){ systemBarHeight() {
return this.$store.state.user.systemBarHeight return this.$store.state.user.systemBarHeight;
}, },
}, },
methods: { methods: {
refundInfo(item) { refundInfo(item) {
const { id } = item const { id } = item;
uni.setStorageSync('orderId', id); uni.setStorageSync("orderId", id);
let url = '/orderSubPackage/pages/refundInfo/index' let url = "/orderSubPackage/pages/refundInfo/index";
uni.navigateTo({ url }) uni.navigateTo({ url });
}, },
checkStatus(status,list){ checkStatus(status, list) {
if(list.includes(Number(status))){ if (list.includes(Number(status))) {
return true return true;
}else{ } else {
return false return false;
} }
}, },
getStateText(state) { getStateText(state) {
state = '' + state; state = "" + state;
switch (state) { switch (state) {
case '1': case "1":
return '待付款' return "待付款";
case '2': case "2":
return '待制作' return "待制作";
case '3': case "3":
return '制作中' return "制作中";
case '4': case "4":
return '待取餐' return "待取餐";
case '5': case "5":
return '取餐中' return "取餐中";
case '6': case "6":
case '7': case "7":
return '已完成' return "已完成";
case '8': case "8":
case '9': case "9":
case '10': case "10":
case '11': case "11":
return '已取消' return "已取消";
case '12': case "12":
return '退款中' return "退款中";
case '13': case "13":
return '退款失败' return "退款失败";
case '14': case "14":
return '部分退款' return "部分退款";
case '15': case "15":
return '已退款' return "已退款";
default: default:
return '未知状态' return "未知状态";
} }
}, },
async oneMoreOrder(item) { async oneMoreOrder(item) {
// 清空购物车 // 清空购物车
uni.removeStorageSync('shopCarInfo'); uni.removeStorageSync("shopCarInfo");
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
// //
const numObj = {} const numObj = {};
const { id, shopId, orderDetails } = item; const { id, shopId, orderDetails } = item;
orderDetails.forEach(item => { orderDetails.forEach((item) => {
orderDetails[item.skuId] = Number(item.num) orderDetails[item.skuId] = Number(item.num);
}) });
const { data } = await order.moreOrder({ orderId: id, shopId }); const { data } = await order.moreOrder({ orderId: id, shopId });
if(!data || !data.data){ if (!data || !data.data) {
this.showToast({ title: "该订单中的商品已经售罄了" }); this.showToast({ title: "这款已经卖完啦" });
return; return;
} }
let list = new Array(); let list = new Array();
data.data.forEach(item => { data.data.forEach((item) => {
const skuId = item.skus[0].skuId const skuId = item.skus[0].skuId;
const nextData = { ...item, skuId, num: orderDetails[skuId], flag: true, sku: item.skus[0] } const nextData = {
...item,
skuId,
num: orderDetails[skuId],
flag: true,
sku: item.skus[0],
};
if (nextData.sku.state == 1) { if (nextData.sku.state == 1) {
list.push(nextData); list.push(nextData);
} }
}); });
if(!list || list.length<=0) { if (!list || list.length <= 0) {
this.showToast({ title: "该订单中的商品已经售罄了", icon: 'error' }); this.showToast({ title: "这款已经卖完啦", icon: "error" });
return; return;
} }
list.forEach(nextData => { list.forEach((nextData) => {
Utils.getallNum(nextData); Utils.getallNum(nextData);
}) });
uni.switchTab({ url: '/pages/menu/menu' }); uni.switchTab({ url: "/pages/menu/menu" });
}, },
async getList() { async getList() {
if (!this.userms) return if (!this.userms) return;
const { data } = await order.getMyOrder(); const { data } = await order.getMyOrder();
if (data) { if (data) {
this.list = data.rows; this.list = data.rows;
if(this.list && this.list.length>0) { if (this.list && this.list.length > 0) {
this.empty = false; this.empty = false;
} else { } else {
this.empty = true; this.empty = true;
} }
} else { } else {
this.showToast({ title: '请登录!', icon: 'error' }) this.showToast({ title: "请登录!", icon: "error" });
} }
}, },
async PayNow({ id }) { async PayNow({ id }) {
const orderInfo = await order.payOrder({ orderId: id }) const orderInfo = await order.payOrder({ orderId: id });
const sendData = { const sendData = {
orderId:id, orderId: id,
...orderInfo.data.data ...orderInfo.data.data,
} };
console.log(orderInfo,'orderInfo') console.log(orderInfo, "orderInfo");
if (orderInfo) { if (orderInfo) {
if (orderInfo && orderInfo.data.code == 200) { if (orderInfo && orderInfo.data.code == 200) {
await Menu.requestPayment(sendData); await Menu.requestPayment(sendData);
this.getList() this.getList();
} }
} }
}, },
goHome() { goHome() {
uni.switchTab({ url: '/pages/menu/menu' }); uni.switchTab({ url: "/pages/menu/menu" });
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(e) { getPhoneNumber(e) {
if (e.detail.errMsg == 'getPhoneNumber:ok') { if (e.detail.errMsg == "getPhoneNumber:ok") {
e.loginInfo = this.loginInfo e.loginInfo = this.loginInfo;
User.getPhoneNumber(e, this.getList); User.getPhoneNumber(e, this.getList);
} else if (e.detail.errMsg == "getPhoneNumber:fail user deny") { } else if (e.detail.errMsg == "getPhoneNumber:fail user deny") {
this.showToast({ title: '已拒绝手机号授权', icon: 'error' }) this.showToast({
title: "已拒绝手机号授权,请同意授权",
icon: "error",
});
} }
}, },
openInfo(data) { openInfo(data) {
const { id } = data const { id } = data;
uni.setStorageSync('orderId', id); uni.setStorageSync("orderId", id);
let url = '/orderSubPackage/pages/orderInfo/index' let url = "/orderSubPackage/pages/orderInfo/index";
uni.navigateTo({ url }) uni.navigateTo({ url });
}, },
jsonParse(json) { jsonParse(json) {
const data = json || {} const data = json || {};
return JSON.parse(data) return JSON.parse(data);
}, },
orderDetailsSize(orderDetails) { orderDetailsSize(orderDetails) {
let size = 0; let size = 0;
orderDetails.forEach(item => { orderDetails.forEach((item) => {
const { num } = item; const { num } = item;
size += Number(num) size += Number(num);
}); });
return size return size;
} },
},
};
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.pages { .pages {
.topBar {
.topBar{
position: fixed; position: fixed;
width: 100%; width: 100%;
background: white; background: white;
...@@ -275,13 +378,13 @@ export default { ...@@ -275,13 +378,13 @@ export default {
// .arrow-left { // .arrow-left {
// margin-left: 20rpx; // margin-left: 20rpx;
// } // }
.tabTitle{ .tabTitle {
font-size: 32rpx; font-size: 32rpx;
font-family: PingFangSC-Medium, PingFang SC; font-family: PingFangSC-Medium, PingFang SC;
font-weight: 600; font-weight: 600;
text-align: center; text-align: center;
width: 92%; width: 92%;
color: #333333 color: #333333;
} }
} }
} }
...@@ -297,7 +400,6 @@ export default { ...@@ -297,7 +400,6 @@ export default {
.empty_icon { .empty_icon {
width: 324rpx; width: 324rpx;
height: 236rpx; height: 236rpx;
} }
.empty_text { .empty_text {
width: 500rpx; width: 500rpx;
...@@ -317,17 +419,17 @@ export default { ...@@ -317,17 +419,17 @@ export default {
border-radius: 2rpx; border-radius: 2rpx;
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
background: #0050F6; background: #0050f6;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
line-height: 64rpx; line-height: 64rpx;
} }
.empty_button::after{ .empty_button::after {
border-radius: 2rpx; border-radius: 2rpx;
border: 0rpx; border: 0rpx;
} }
} }
.empty_notdl{ .empty_notdl {
position: fixed; position: fixed;
/* 居中对齐begin */ /* 居中对齐begin */
left: 50%; left: 50%;
...@@ -355,12 +457,12 @@ export default { ...@@ -355,12 +457,12 @@ export default {
border-radius: 2rpx; border-radius: 2rpx;
font-size: 24rpx; font-size: 24rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
background: #0050F6; background: #0050f6;
font-weight: 400; font-weight: 400;
color: #FFFFFF; color: #ffffff;
line-height: 64rpx; line-height: 64rpx;
} }
.empty_button::after{ .empty_button::after {
border-radius: 2rpx; border-radius: 2rpx;
border: 0rpx; border: 0rpx;
} }
...@@ -371,7 +473,7 @@ export default { ...@@ -371,7 +473,7 @@ export default {
.order_item { .order_item {
width: 686rpx; width: 686rpx;
background: #FFFFFF; background: #ffffff;
margin: 32rpx auto 0; margin: 32rpx auto 0;
box-sizing: border-box; box-sizing: border-box;
padding: 25rpx 32rpx 32rpx 32rpx; padding: 25rpx 32rpx 32rpx 32rpx;
...@@ -412,7 +514,6 @@ export default { ...@@ -412,7 +514,6 @@ export default {
margin-left: 5rpx; margin-left: 5rpx;
} }
} }
} }
.order_content { .order_content {
...@@ -420,7 +521,7 @@ export default { ...@@ -420,7 +521,7 @@ export default {
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
.order_content_box1{ .order_content_box1 {
flex: 1; flex: 1;
} }
...@@ -479,7 +580,7 @@ export default { ...@@ -479,7 +580,7 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: flex-start; align-items: flex-start;
.numbox{ .numbox {
display: flex; display: flex;
.btntk { .btntk {
box-sizing: border-box; box-sizing: border-box;
...@@ -488,16 +589,15 @@ export default { ...@@ -488,16 +589,15 @@ export default {
line-height: 64rpx; line-height: 64rpx;
border-radius: 2rpx; border-radius: 2rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
border: 2rpx solid #0050F6; border: 2rpx solid #0050f6;
font-size: 24rpx; font-size: 24rpx;
margin: 0; margin: 0;
margin-left: 17rpx; margin-left: 17rpx;
color: #0050F6; color: #0050f6;
font-weight: 400; font-weight: 400;
text-align: center; text-align: center;
} }
} }
} }
} }
} }
...@@ -529,7 +629,7 @@ export default { ...@@ -529,7 +629,7 @@ export default {
height: 64rpx; height: 64rpx;
line-height: 64rpx; line-height: 64rpx;
font-family: PingFangSC-Regular, PingFang SC; font-family: PingFangSC-Regular, PingFang SC;
background: #0050F6; background: #0050f6;
font-size: 24rpx; font-size: 24rpx;
margin: 0; margin: 0;
color: #fff; color: #fff;
...@@ -538,6 +638,5 @@ export default { ...@@ -538,6 +638,5 @@ export default {
} }
} }
} }
} }
</style> </style>
import { $EventBus } from '@/utils/EventBus'; import { $EventBus } from "@/utils/EventBus";
import context from '../../main.js' import context from "../../main.js";
import Order from '@/request/order/index.js' import Order from "@/request/order/index.js";
export default { export default {
// 获取菜单列表 // 获取菜单列表
getMenuList(id) { getMenuList(id) {
return uni.$u.http return uni.$u.http
.get('/weixin/infoByShop', { .get("/weixin/infoByShop", {
params: { params: {
shopId: id, shopId: id,
}, },
...@@ -14,24 +14,27 @@ export default { ...@@ -14,24 +14,27 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 获取点单屏幕的订单信息 // 获取点单屏幕的订单信息
getScreenShopCar(key, location, sendData) { getScreenShopCar(key, location, sendData) {
return uni.$u.http return uni.$u.http
.post('/application/getData', { .post("/application/getData", {
key, key,
location, location,
...sendData ...sendData,
}) })
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
...@@ -39,37 +42,38 @@ export default { ...@@ -39,37 +42,38 @@ export default {
// 下单获取预支付订单 // 下单获取预支付订单
saveReserve(data) { saveReserve(data) {
return uni.$u.http return uni.$u.http
.post('/order', data) .post("/order", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { }); .catch((err) => {});
}, },
// saveReserve 为业务接口 // saveReserve 为业务接口
requestPayment(data, oldData, buyType, agreeTerms) { requestPayment(data, oldData, buyType, agreeTerms) {
// res为调起微信支付所需参数 // res为调起微信支付所需参数
// 调起微信支付 // 调起微信支付
if(data.appId) { if (data.appId) {
const { switchTab = true, callBack } = data const { switchTab = true, callBack } = data;
uni.requestPayment({ uni.requestPayment({
provider: 'wxpay', // 服务提提供商微信支付 provider: "wxpay", // 服务提提供商微信支付
timeStamp: data.timeStamp, // 时间戳 timeStamp: data.timeStamp, // 时间戳
nonceStr: data.nonceStr, // 随机字符串 nonceStr: data.nonceStr, // 随机字符串
package: data.package, package: data.package,
signType: data.signType || 'MD5', // 签名算法 signType: data.signType || "MD5", // 签名算法
paySign: data.paySign, // 签名 paySign: data.paySign, // 签名
success: async function (res) { success: async function (res) {
if (res.errMsg == 'requestPayment:ok') { if (res.errMsg == "requestPayment:ok") {
// 删除购物车数据后重新放回购物车 // 删除购物车数据后重新放回购物车
uni.setStorageSync('shopCarInfo', []); uni.setStorageSync("shopCarInfo", []);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
uni.setStorageSync('orderId', data.orderId); uni.setStorageSync("orderId", data.orderId);
if(agreeTerms)uni.setStorageSync('TermsStatus',true) if (agreeTerms) uni.setStorageSync("TermsStatus", true);
if(switchTab){ if (switchTab) {
let url = '/orderSubPackage/pages/orderInfo/index?from=settlement' let url =
uni.navigateTo({ url }) "/orderSubPackage/pages/orderInfo/index?from=settlement";
}else{ uni.navigateTo({ url });
callBack() } else {
callBack();
} }
} }
...@@ -77,53 +81,52 @@ export default { ...@@ -77,53 +81,52 @@ export default {
}, },
fail: async function (err) { fail: async function (err) {
context.showToast({ context.showToast({
title: '支付失败', title: "支付失败,再试一试!",
icon: 'error', icon: "error",
}); });
uni.setStorageSync('shopCarInfo', []); uni.setStorageSync("shopCarInfo", []);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
uni.setStorageSync('orderId', data.orderId); uni.setStorageSync("orderId", data.orderId);
if(switchTab){ if (switchTab) {
let url = '/orderSubPackage/pages/orderInfo/index?from=settlement' let url = "/orderSubPackage/pages/orderInfo/index?from=settlement";
uni.navigateTo({ url }) uni.navigateTo({ url });
}else{ } else {
callBack() callBack();
} }
}, },
}); });
}else{ } else {
uni.setStorageSync('orderId', data); uni.setStorageSync("orderId", data);
let url = '/orderSubPackage/pages/orderInfo/index?from=settlement' let url = "/orderSubPackage/pages/orderInfo/index?from=settlement";
uni.navigateTo({ url }) uni.navigateTo({ url });
} }
}, },
// 优惠卷信息接口 // 优惠卷信息接口
requestTicketList(data){ requestTicketList(data) {
return uni.$u.http return uni.$u.http
.post('/app/order/coupon/info', data) .post("/app/order/coupon/info", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
}, },
// 下单页面优惠卷可用数量 // 下单页面优惠卷可用数量
requestTicketNum(data){ requestTicketNum(data) {
return uni.$u.http return uni.$u.http
.post('/app/order/coupon/fitable-count', data) .post("/app/order/coupon/fitable-count", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
...@@ -131,16 +134,16 @@ export default { ...@@ -131,16 +134,16 @@ export default {
// 首页调用发送优惠券接口 // 首页调用发送优惠券接口
sendUserCoupon(data) { sendUserCoupon(data) {
return uni.$u.http return uni.$u.http
.post('/v1/issue/user/coupon', data) .post("/v1/issue/user/coupon", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
return err; return err;
}); });
} },
}; };
import context from '../../main.js' import context from "../../main.js";
export default { export default {
getList(id) {}, getList(id) {},
getMsg() { getMsg() {
return uni.$u.http return uni.$u.http
.get('/system/message/list', {}) .get("/system/message/list", {})
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
read(data) { read(data) {
return uni.$u.http return uni.$u.http
.put('/system/message', data) .put("/system/message", data)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
getMessageCount() { getMessageCount() {
return uni.$u.http return uni.$u.http
.get('/app/getMessageCount', {}) .get("/app/getMessageCount", {})
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 获取用户优惠卷列表 // 获取用户优惠卷列表
...@@ -39,7 +48,10 @@ export default { ...@@ -39,7 +48,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 获取用户信息 // 获取用户信息
...@@ -50,7 +62,10 @@ export default { ...@@ -50,7 +62,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 更改用户生日 // 更改用户生日
...@@ -61,8 +76,8 @@ export default { ...@@ -61,8 +76,8 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: err.data.msg, icon: 'none' }); context.showToast({ title: err.data.msg, icon: "none" });
return err return err;
}); });
}, },
// 更改用户昵称、性别 // 更改用户昵称、性别
...@@ -73,7 +88,10 @@ export default { ...@@ -73,7 +88,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
// 更改用户头像 // 更改用户头像
...@@ -84,9 +102,10 @@ export default { ...@@ -84,9 +102,10 @@ export default {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
}; };
export default { export default {
getMyOrder() { getMyOrder() {
return uni.$u.http return uni.$u.http
.get('/app/getMyOrder', { .get("/app/getMyOrder", {
params: {}, params: {},
custom: {noLoading: true}, custom: { noLoading: true },
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
orderRefund(data) { orderRefund(data) {
return uni.$u.http return uni.$u.http
.post('/system/refund', data) .post("/system/refund", data)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getShop(params) { getShop(params) {
return uni.$u.http return uni.$u.http
.get('/weixin/getArea', { .get("/weixin/getArea", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
// 校验sku是否可用 // 校验sku是否可用
chekSku(params) { chekSku(params) {
return uni.$u.http return uni.$u.http
.get('/application/checkSku', { .get("/application/checkSku", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
cancelOrder(params) { cancelOrder(params) {
return uni.$u.http return uni.$u.http
.get('order/cancel', { .get("order/cancel", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
// 立即支付 // 立即支付
payOrder(params) { payOrder(params) {
console.log(params,'params') console.log(params, "params");
return uni.$u.http return uni.$u.http
.get('order/payOrder', { .get("order/payOrder", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getHomeOrder(params) { getHomeOrder(params) {
return uni.$u.http return uni.$u.http
.get(`/app/getHomeOrder?shopId=${params.shopId}`, { .get(`/app/getHomeOrder?shopId=${params.shopId}`, {
params: {}, params: {},
custom: {noLoading: true}, custom: { noLoading: true },
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getWaitTine(data) { getWaitTine(data) {
return uni.$u.http return uni.$u.http
.post('app/getWaitTine', data) .post("app/getWaitTine", data)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
moreOrder(params) { moreOrder(params) {
return uni.$u.http return uni.$u.http
.get('/app/getNextOrder', { .get("/app/getNextOrder", {
params, params,
}) })
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
checkSku(params) { checkSku(params) {
const shopInfo = JSON.parse(uni.getStorageSync('shopInfo')) const shopInfo = JSON.parse(uni.getStorageSync("shopInfo"));
return uni.$u.http return uni.$u.http
.get(`/application/checkSku?shopId=${shopInfo.id}&skuId=${params.skuId}`) .get(`/application/checkSku?shopId=${shopInfo.id}&skuId=${params.skuId}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getOrderDetail(params) { getOrderDetail(params) {
...@@ -114,8 +114,8 @@ export default { ...@@ -114,8 +114,8 @@ export default {
.get(`/order/${params.orderId}`) .get(`/order/${params.orderId}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
getOrderWaiteTime(params) { getOrderWaiteTime(params) {
...@@ -123,8 +123,8 @@ export default { ...@@ -123,8 +123,8 @@ export default {
.get(`/app/getWaitTineByOrderId?orderId=${params.orderId}`) .get(`/app/getWaitTineByOrderId?orderId=${params.orderId}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
}, },
// 获取退款详情 // 获取退款详情
...@@ -133,8 +133,8 @@ export default { ...@@ -133,8 +133,8 @@ export default {
.get(`/system/refund/list/${params}`) .get(`/system/refund/list/${params}`)
.then((res) => res) .then((res) => res)
.catch((err) => { .catch((err) => {
// uni.showToast({ title: '服务器错误', icon: 'none' }) // uni.showToast({ title: '哎哟!刚刚走神了,请退出后重进', icon: 'none' })
console.log('服务器错误'); console.log("哎哟!刚刚走神了,请退出后重进");
}); });
} },
}; };
import Store from '@/store'; import Store from "@/store";
import { $EventBus } from '@/utils/EventBus'; import { $EventBus } from "@/utils/EventBus";
import loadingIcon from 'uview-ui/libs/config/props/loadingIcon'; import loadingIcon from "uview-ui/libs/config/props/loadingIcon";
import { data } from 'uview-ui/libs/mixin/mixin'; import { data } from "uview-ui/libs/mixin/mixin";
import context from '../../main.js' import context from "../../main.js";
export default { export default {
getLocation(callback) { getLocation(callback) {
let _this = this; let _this = this;
return uni.getLocation({ return uni.getLocation({
type: 'gcj02', //返回可以用于uni.openLocation的经纬度 type: "gcj02", //返回可以用于uni.openLocation的经纬度
success: function (res) { success: function (res) {
var params = { var params = {
lat: res.latitude, lat: res.latitude,
lng: res.longitude, lng: res.longitude,
}; };
if(params.lat && params.lng) { if (params.lat && params.lng) {
Store.commit('saveLocation', params); Store.commit("saveLocation", params);
uni.setStorage({ key: 'location', data: params }); uni.setStorage({ key: "location", data: params });
} else { } else {
params = uni.getStorageSync('location'); params = uni.getStorageSync("location");
} }
callback && callback(1, params); callback && callback(1, params);
}, },
fail: function (res) { fail: function (res) {
console.log(res) console.log(res);
const params = uni.getStorageSync('location'); const params = uni.getStorageSync("location");
callback && callback(0, params); callback && callback(0, params);
}, },
}); });
}, },
// 获取店铺信息 // 获取店铺信息
getShopInfo(params) { getShopInfo(params) {
return uni.$u.http.get('/weixin/getShop', { params }) return uni.$u.http
.get("/weixin/getShop", { params })
.then((res) => { .then((res) => {
// console.log("get shop:"+JSON.stringify(res.data.data)); // console.log("get shop:"+JSON.stringify(res.data.data));
if (res.data.code == 200) { if (res.data.code == 200) {
Store.commit('saveShopInfo', res.data.data); Store.commit("saveShopInfo", res.data.data);
uni.setStorage({ key: 'shopData', data: res.data.data }); uni.setStorage({ key: "shopData", data: res.data.data });
if (res.data.data) { if (res.data.data) {
$EventBus.$emit('getMenuList', res.data.data); $EventBus.$emit("getMenuList", res.data.data);
} }
} }
return res; return res;
}).catch((err) => { })
.catch((err) => {
console.log("get shop error"); console.log("get shop error");
return err; return err;
}); });
}, },
uniLogin(res, callback) { uniLogin(res, callback) {
uni.login({ uni.login({
provider: 'weixin', provider: "weixin",
success: function (data) { success: function (data) {
// 传给后台接口所需登录数据 // 传给后台接口所需登录数据
uni.$u.http uni.$u.http
.post('/weixin/login', { .post("/weixin/login", {
code: data.code, code: data.code,
source: 3, source: 3,
iv: res.iv, iv: res.iv,
encryptedData: res.encryptedData, encryptedData: res.encryptedData,
}) })
.then((res) => { .then((res) => {
console.log(res,'resssssssss') console.log(res, "resssssssss");
const { statusCode, data } = res; const { statusCode, data } = res;
const { code, token, phoneNumber } = data; const { code, token, phoneNumber } = data;
if (statusCode == 200 && data && code == 200) { if (statusCode == 200 && data && code == 200) {
uni.setStorage({ key: 'Authorization', data: token }); uni.setStorage({ key: "Authorization", data: token });
uni.setStorage({ key: 'phoneNumber', data: phoneNumber }); uni.setStorage({ key: "phoneNumber", data: phoneNumber });
uni.setStorage({ key: 'userInfo', data: data }); uni.setStorage({ key: "userInfo", data: data });
Store.commit('setUserInfo', data); Store.commit("setUserInfo", data);
Store.commit('setAuthorization', token); Store.commit("setAuthorization", token);
if(callback) if (callback) callback();
callback();
} }
}) })
.catch((err) => { .catch((err) => {
...@@ -81,84 +82,84 @@ export default { ...@@ -81,84 +82,84 @@ export default {
}); });
}, },
getOpenId(res) { getOpenId(res) {
return uni.$u.http.post('/weixin/login', {code:res }) return uni.$u.http.post("/weixin/login", { code: res });
}, },
getAuthorization(phoneNumber) { getAuthorization(phoneNumber) {
uni.$u.http.post('/weixin/refreshToken ', { phoneNumber }).then((res) => { uni.$u.http.post("/weixin/refreshToken ", { phoneNumber }).then((res) => {
const { data } = res; const { data } = res;
uni.setStorage({ key: 'Authorization', data: data.token }); uni.setStorage({ key: "Authorization", data: data.token });
Store.commit('setAuthorization', data.token); Store.commit("setAuthorization", data.token);
context.showToast({ title: '登录成功!' }); context.showToast({ title: "登录成功!" });
}); });
}, },
wxLoginAndGetOpenid(loding, updata) { wxLoginAndGetOpenid(loding, updata) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.login({ uni.login({
provider: 'weixin', provider: "weixin",
success: (res) => { success: (res) => {
const code = res.code const code = res.code;
if(code){ if (code) {
this.getOpenId(code).then((res)=>{ this.getOpenId(code).then((res) => {
const loginInfo = res.data.msg const loginInfo = res.data.msg;
uni.setStorageSync('loginInfo',loginInfo) uni.setStorageSync("loginInfo", loginInfo);
resolve(loginInfo) resolve(loginInfo);
}) });
}
} }
})
})
}, },
loginDecrypt(res){ });
const {faceInfoId} = res });
return uni.$u.http.post('/weixin/decrypt ', { },
session_key:res.loginInfo.session_key, loginDecrypt(res) {
openId:res.loginInfo.openid, const { faceInfoId } = res;
encryptedData:res.data, return uni.$u.http.post("/weixin/decrypt ", {
iv:res.iv, session_key: res.loginInfo.session_key,
openId: res.loginInfo.openid,
encryptedData: res.data,
iv: res.iv,
faceInfoId, faceInfoId,
source:3 source: 3,
}) });
}, },
// 手机号授权登录 // 手机号授权登录
getPhoneNumber(res, callback) { getPhoneNumber(res, callback) {
uni.setStorage({ key: 'userPhoneInfo', data: res }); uni.setStorage({ key: "userPhoneInfo", data: res });
Store.commit('setUserPhoneInfo', res); Store.commit("setUserPhoneInfo", res);
uni.setStorage({ key: 'phoneInfo', data: res }); uni.setStorage({ key: "phoneInfo", data: res });
const loginInfo = res.loginInfo const loginInfo = res.loginInfo;
const iv = res.detail.iv const iv = res.detail.iv;
const data = res.detail.encryptedData const data = res.detail.encryptedData;
const faceInfoId = res.faceInfoId const faceInfoId = res.faceInfoId;
// data.faceInfoId = String(res.faceInfoId) // data.faceInfoId = String(res.faceInfoId)
// if(res.faceInfoId){ // if(res.faceInfoId){
// data.faceInfoId = res.faceInfoId // data.faceInfoId = res.faceInfoId
// } // }
wx.checkSession({ wx.checkSession({
success: (res) => { success: (res) => {
console.log('seeion未过期') console.log("seeion未过期");
this.onLogin(loginInfo,iv,data,faceInfoId,callback) this.onLogin(loginInfo, iv, data, faceInfoId, callback);
}, },
fail: (res) => { fail: (res) => {
console.log('seeion已过期') console.log("seeion已过期");
this.wxLoginAndGetOpenid(true).then(loginInfo => { this.wxLoginAndGetOpenid(true).then((loginInfo) => {
this.onLogin(loginInfo,iv,data,faceInfoId,callback) this.onLogin(loginInfo, iv, data, faceInfoId, callback);
}) });
} },
}) });
}, },
// 首页调用发送优惠券接口 // 首页调用发送优惠券接口
sendUserCoupon(data) { sendUserCoupon(data) {
return uni.$u.http return uni.$u.http
.post('/v1/issue/user/coupon', data) .post("/v1/issue/user/coupon", data)
.then((res) => { .then((res) => {
Store.commit('setMenuOption', {}); Store.commit("setMenuOption", {});
return res; return res;
}) })
.catch((err) => { .catch((err) => {
context.showToast({ context.showToast({
title: '服务器错误', title: "哎哟!刚刚走神了,请退出后重进",
icon: 'none', icon: "none",
}); });
Store.commit('setMenuOption', {}); Store.commit("setMenuOption", {});
return err; return err;
}); });
}, },
...@@ -167,61 +168,71 @@ export default { ...@@ -167,61 +168,71 @@ export default {
return uni.$u.http return uni.$u.http
.get(`/system/customer/detail`, {}) .get(`/system/customer/detail`, {})
.then((res) => { .then((res) => {
console.log(res,data) console.log(res, data);
const { birthday, createTime, id, phone, sex, userName, avatarUrl } = res.data.data const { birthday, createTime, id, phone, sex, userName, avatarUrl } =
const {avatarUrl:localAvatarUrl} = uni.getStorageSync('UserInfo') res.data.data;
const { avatarUrl: localAvatarUrl } = uni.getStorageSync("UserInfo");
const sendData = { const sendData = {
...data, ...data,
avatarUrl: avatarUrl||localAvatarUrl, avatarUrl: avatarUrl || localAvatarUrl,
sex: sex?1:0, sex: sex ? 1 : 0,
customerName:userName, customerName: userName,
phone: phone.substr(0,3) + "****" + phone.substr(7), phone: phone.substr(0, 3) + "****" + phone.substr(7),
id:id id: id,
} };
if(!birthday){ if (!birthday) {
sendData.canEditBirthday = true sendData.canEditBirthday = true;
sendData.birthday = new Date(createTime.replace(/-/g,'/')).valueOf() sendData.birthday = new Date(createTime.replace(/-/g, "/")).valueOf();
}else{ } else {
sendData.canEditBirthday = false sendData.canEditBirthday = false;
sendData.birthday = Date.parse(birthday) sendData.birthday = Date.parse(birthday);
} }
Store.commit('setUserInfo', sendData); Store.commit("setUserInfo", sendData);
uni.setStorageSync('UserInfo',sendData) uni.setStorageSync("UserInfo", sendData);
const MenuOption = Store.state.user.menuOption const MenuOption = Store.state.user.menuOption;
if(JSON.stringify(MenuOption)!=='{}') { if (JSON.stringify(MenuOption) !== "{}") {
const {num,serial_no,source} = MenuOption const { num, serial_no, source } = MenuOption;
const sendDataOption = { const sendDataOption = {
phone:sendData.phoneNumber, phone: sendData.phoneNumber,
user_id:sendData.id, user_id: sendData.id,
source:source, source: source,
param:JSON.stringify({ param: JSON.stringify({
serial_no, serial_no,
num num,
}) }),
} };
this.sendUserCoupon(sendDataOption) this.sendUserCoupon(sendDataOption);
} }
}) })
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); context.showToast({
title: "哎哟!刚刚走神了,请退出后重进",
icon: "none",
});
}); });
}, },
onLogin(loginInfo,iv,data,faceInfoId,callback) { onLogin(loginInfo, iv, data, faceInfoId, callback) {
this.loginDecrypt({loginInfo:JSON.parse(loginInfo),faceInfoId,iv,data}).then(res => { this.loginDecrypt({
loginInfo: JSON.parse(loginInfo),
faceInfoId,
iv,
data,
})
.then((res) => {
const { statusCode, data } = res; const { statusCode, data } = res;
const { code, token, phoneNumber } = data; const { code, token, phoneNumber } = data;
if (statusCode == 200 && data && code == 200) { if (statusCode == 200 && data && code == 200) {
console.log(token,'-------token') console.log(token, "-------token");
uni.setStorage({ key: 'Authorization', data: token }); uni.setStorage({ key: "Authorization", data: token });
uni.setStorage({ key: 'phoneNumber', data: phoneNumber }); uni.setStorage({ key: "phoneNumber", data: phoneNumber });
uni.setStorage({ key: 'userInfo', data: data }); uni.setStorage({ key: "userInfo", data: data });
Store.commit('setUserInfo', data); Store.commit("setUserInfo", data);
Store.commit('setAuthorization', token); Store.commit("setAuthorization", token);
this.getUserInfo(data) this.getUserInfo(data);
if(callback) if (callback) return callback();
return callback();
} }
}).catch((err) => { })
.catch((err) => {
context.showToast({ context.showToast({
title: err.msg, title: err.msg,
}); });
...@@ -229,43 +240,43 @@ export default { ...@@ -229,43 +240,43 @@ export default {
}, },
setAllow(params) { setAllow(params) {
return uni.$u.http return uni.$u.http
.post('/system/customer/allow', params) .post("/system/customer/allow", params)
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
const {data} = err const { data } = err;
const {msg} = data const { msg } = data;
context.showToast({ title: msg, icon: 'none' }); context.showToast({ title: msg, icon: "none" });
return err return err;
}); });
}, },
// 获取用户订阅消息 // 获取用户订阅消息
getUserMsgInfo(params) { getUserMsgInfo(params) {
return uni.$u.http return uni.$u.http
.get('/system/customer/detail') .get("/system/customer/detail")
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
const {data} = err const { data } = err;
const {msg} = data const { msg } = data;
context.showToast({ title: msg, icon: 'none' }); context.showToast({ title: msg, icon: "none" });
return err return err;
}); });
}, },
// 获取用户优惠券数量 // 获取用户优惠券数量
getCouponNum(params) { getCouponNum(params) {
return uni.$u.http return uni.$u.http
.get('/app/homepage/coupon-count') .get("/app/homepage/coupon-count")
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
const {data} = err const { data } = err;
const {msg} = data const { msg } = data;
context.showToast({ title: msg, icon: 'none' }); context.showToast({ title: msg, icon: "none" });
return err return err;
}); });
} },
}; };
import Config from '../static/config/index.js'; import Config from "../static/config/index.js";
import WXBizDataCrypt from './WXBizDataCrypt.js'; import WXBizDataCrypt from "./WXBizDataCrypt.js";
import context from '../main.js' import context from "../main.js";
import { $EventBus } from './EventBus'; import { $EventBus } from "./EventBus";
export default { export default {
// 组装提交订单数据 // 组装提交订单数据
...@@ -19,7 +19,7 @@ export default { ...@@ -19,7 +19,7 @@ export default {
realAmount: item.sku.discount * item.num, //实付金额 realAmount: item.sku.discount * item.num, //实付金额
amount: item.sku.price * item.num, //总价格 amount: item.sku.price * item.num, //总价格
specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情 specRuleDetail: JSON.stringify(item.sku.rules), //规格选项详情
specRuleIds: item.sku.rules.map((item) => item.ruleId).join(','), //规格选项详情 specRuleIds: item.sku.rules.map((item) => item.ruleId).join(","), //规格选项详情
skuId: item.skuId, //"sku ID" skuId: item.skuId, //"sku ID"
goodsCategory: item.categoryId, //商品分类 goodsCategory: item.categoryId, //商品分类
}; };
...@@ -38,30 +38,32 @@ export default { ...@@ -38,30 +38,32 @@ export default {
return DAta; return DAta;
} else { } else {
context.showToast({ context.showToast({
title: '请选择商品', title: "请选择商品",
}); });
} }
}, },
// 加入购物车数据 // 加入购物车数据
async getallNum(Obj, unCheckCount) { async getallNum(Obj, unCheckCount) {
console.log(Obj); console.log(Obj);
let shopCarInfo = uni.getStorageSync('shopCarInfo') || []; let shopCarInfo = uni.getStorageSync("shopCarInfo") || [];
let size = 0; let size = 0;
shopCarInfo.forEach((item) => (size += item.num)); shopCarInfo.forEach((item) => (size += item.num));
if(!unCheckCount) { if (!unCheckCount) {
let countOfOrder = uni.getStorageSync('countOfOrder') || 9; let countOfOrder = uni.getStorageSync("countOfOrder") || 9;
if (size >= countOfOrder) { if (size >= countOfOrder) {
context.showToast({ context.showToast({
title: '最多可一次购买'+countOfOrder+'杯', title: "一次最多可购买" + countOfOrder + "杯",
icon: 'none', icon: "none",
}); });
return false; return false;
} }
} }
if (shopCarInfo) { if (shopCarInfo) {
let currentGoods = shopCarInfo.find((v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId); let currentGoods = shopCarInfo.find(
(v) => v.goodsId == Obj.goodsId && v.skuId == Obj.skuId
);
if (currentGoods) { if (currentGoods) {
currentGoods.num += Obj.num; currentGoods.num += Obj.num;
} else { } else {
...@@ -71,8 +73,8 @@ export default { ...@@ -71,8 +73,8 @@ export default {
shopCarInfo = [Obj]; shopCarInfo = [Obj];
} }
console.log(Obj); console.log(Obj);
uni.setStorageSync('shopCarInfo', shopCarInfo); uni.setStorageSync("shopCarInfo", shopCarInfo);
$EventBus.$emit('updateCar'); $EventBus.$emit("updateCar");
// if (callback) { // if (callback) {
// callback(); // callback();
// } // }
...@@ -82,11 +84,11 @@ export default { ...@@ -82,11 +84,11 @@ export default {
let goodsList = []; let goodsList = [];
let size = 0; let size = 0;
goodsList.forEach((item) => (size += item.num)); goodsList.forEach((item) => (size += item.num));
let countOfOrder = uni.getStorageSync('countOfOrder'); let countOfOrder = uni.getStorageSync("countOfOrder");
if (size >= countOfOrder) { if (size >= countOfOrder) {
context.showToast({ context.showToast({
title: '最多可一次购买'+countOfOrder+'杯', title: "一次最多可购买" + countOfOrder + "杯",
icon: 'none', icon: "none",
}); });
return false; return false;
} }
...@@ -102,7 +104,7 @@ export default { ...@@ -102,7 +104,7 @@ export default {
} else { } else {
goodsList = [Obj]; goodsList = [Obj];
} }
uni.setStorageSync('goodsList', goodsList); uni.setStorageSync("goodsList", goodsList);
}, },
// 解密手机 // 解密手机
...@@ -123,16 +125,16 @@ export default { ...@@ -123,16 +125,16 @@ export default {
}); });
} else { } else {
context.showToast({ context.showToast({
title: '二维码错误', title: "二维码错误",
icon: 'none', icon: "none",
}); });
} }
} }
}, },
fail() { fail() {
context.showToast({ context.showToast({
icon: 'none', icon: "none",
title: '扫码失败', title: "扫码失败",
}); });
}, },
}); });
...@@ -141,40 +143,57 @@ export default { ...@@ -141,40 +143,57 @@ export default {
var date = new Date(); var date = new Date();
date.setTime(value); date.setTime(value);
var month = date.getMonth() + 1; var month = date.getMonth() + 1;
if (month < 10) month = '0' + month; if (month < 10) month = "0" + month;
var cdate = date.getDate(); var cdate = date.getDate();
if (cdate < 10) cdate = '0' + cdate; if (cdate < 10) cdate = "0" + cdate;
var hours = date.getHours(); var hours = date.getHours();
if (hours < 10) hours = '0' + hours; if (hours < 10) hours = "0" + hours;
var minutes = date.getMinutes(); var minutes = date.getMinutes();
if (minutes < 10) minutes = '0' + minutes; if (minutes < 10) minutes = "0" + minutes;
var time = date.getFullYear() + '-' + month + '-' + cdate + ' ' + hours + ':' + minutes; var time =
date.getFullYear() +
"-" +
month +
"-" +
cdate +
" " +
hours +
":" +
minutes;
return time; return time;
}, },
numberFixed(data, fixed = 2) { numberFixed(data, fixed = 2) {
if (data == undefined) { if (data == undefined) {
return undefined; return undefined;
} else if (data == 0) { } else if (data == 0) {
return '0'; return "0";
} else { } else {
return (Math.round(Number(data) * Math.pow(10, fixed)) / Math.pow(10, fixed)).toFixed(fixed); return (
Math.round(Number(data) * Math.pow(10, fixed)) / Math.pow(10, fixed)
).toFixed(fixed);
} }
}, },
isInteger(value) { isInteger(value) {
return parseFloat(Number(value).toFixed(2)) return parseFloat(Number(value).toFixed(2));
}, },
// 计算经纬度之间的距离 // 计算经纬度之间的距离
// 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度 // 根据经纬度计算距离,参数分别为第一点的纬度,经度;第二点的纬度,经度
getDistances(lat1, lng1, lat2, lng2) { getDistances(lat1, lng1, lat2, lng2) {
function rad(d) { function rad(d) {
return d * Math.PI / 180.0; return (d * Math.PI) / 180.0;
} }
var radLat1 = rad(lat1); var radLat1 = rad(lat1);
var radLat2 = rad(lat2); var radLat2 = rad(lat2);
var a = radLat1 - radLat2; var a = radLat1 - radLat2;
var b = rad(lng1) - rad(lng2); var b = rad(lng1) - rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + var s =
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); 2 *
Math.asin(
Math.sqrt(
Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)
)
);
s = s * 6378.137; // EARTH_RADIUS; s = s * 6378.137; // EARTH_RADIUS;
// 输出为公里 // 输出为公里
s = Math.round(s * 10000) / 10000; s = Math.round(s * 10000) / 10000;
...@@ -199,9 +218,9 @@ export default { ...@@ -199,9 +218,9 @@ export default {
//小小修改,这里返回对象 //小小修改,这里返回对象
let objData = { let objData = {
distance: distance, distance: distance,
distance_str: distance_str distance_str: distance_str,
} };
return objData return objData;
}, },
// 单位转换 // 单位转换
getPx(rpx) { getPx(rpx) {
...@@ -212,22 +231,22 @@ export default { ...@@ -212,22 +231,22 @@ export default {
// 返回上一页 // 返回上一页
goBack() { goBack() {
wx.navigateBack({ wx.navigateBack({
delta: 1 delta: 1,
}); });
}, },
// 解析url参数 // 解析url参数
getUrlParams2(url) { getUrlParams2(url) {
// 通过 ? 分割获取后面的参数字符串 // 通过 ? 分割获取后面的参数字符串
let urlStr = url.split('?')[1] let urlStr = url.split("?")[1];
// 创建空对象存储参数 // 创建空对象存储参数
let obj = {}; let obj = {};
// 再通过 & 将每一个参数单独分割出来 // 再通过 & 将每一个参数单独分割出来
let paramsArr = urlStr.split('&') let paramsArr = urlStr.split("&");
for(let i = 0,len = paramsArr.length;i < len;i++){ for (let i = 0, len = paramsArr.length; i < len; i++) {
// 再通过 = 将每一个参数分割为 key:value 的形式 // 再通过 = 将每一个参数分割为 key:value 的形式
let arr = paramsArr[i].split('=') let arr = paramsArr[i].split("=");
obj[arr[0]] = arr[1]; obj[arr[0]] = arr[1];
} }
return obj return obj;
} },
}; };
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