1
This commit is contained in:
34
App.vue
34
App.vue
@@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import Api from '@/common/js/api.js'
|
||||||
export default {
|
export default {
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
@@ -8,7 +9,8 @@
|
|||||||
// #endif
|
// #endif
|
||||||
uni.cache.set('NAME', '零点八零');
|
uni.cache.set('NAME', '零点八零');
|
||||||
},
|
},
|
||||||
onLoad() {},
|
onLoad() {
|
||||||
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
|
this.$store.dispatch("HeightActions"); //获取随时获取页面的高度
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
@@ -48,6 +50,36 @@
|
|||||||
onHide: function() {
|
onHide: function() {
|
||||||
// console.log('App Hide');
|
// console.log('App Hide');
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
userlogin() {
|
||||||
|
if (!uni.cache.get('token')) {
|
||||||
|
// this.$store.dispatch("loginEvent"); //获取shapid
|
||||||
|
uni.login({
|
||||||
|
provider: 'weixin',
|
||||||
|
success: (data) => {
|
||||||
|
uni.getUserInfo({
|
||||||
|
provider: 'weixin',
|
||||||
|
success: async (infoRes) => {
|
||||||
|
uni.cache.set('weixincode', data.code);
|
||||||
|
let res = await Api.userwxlogin({
|
||||||
|
code: uni.cache.get('weixincode'), //临时登录凭证
|
||||||
|
rawData: infoRes.rawData,
|
||||||
|
})
|
||||||
|
if (res.code == 0) {
|
||||||
|
uni.cache.set('token', res.data.token);
|
||||||
|
uni.cache.set('miniAppOpenId', res.data.userInfo
|
||||||
|
.miniAppOpenId)
|
||||||
|
uni.cache.set('userInfo', res.data.userInfo);
|
||||||
|
this.$isResolve()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -104,13 +104,16 @@ async function request(options) {
|
|||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
console.log(options)
|
console.log(options)
|
||||||
if (res.code == -4) {
|
if (res.code == -4) {
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: res.message || res.msg,
|
// title: res.message || res.msg,
|
||||||
icon: "none",
|
// icon: "none",
|
||||||
success: () => {
|
// success: () => {
|
||||||
|
// // setTimeout(res => {
|
||||||
}
|
// // store.dispatch("loginEvent"); //获取shapid
|
||||||
})
|
// // }, 1000)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
uni.$u.throttle(store.dispatch("loginEvent"), 1000); //获取shapid
|
||||||
|
|
||||||
} else if (res.code == 482) {
|
} else if (res.code == 482) {
|
||||||
let nowTime = new Date() / 1000 | 0
|
let nowTime = new Date() / 1000 | 0
|
||||||
|
|||||||
4
main.js
4
main.js
@@ -23,6 +23,10 @@ uni.$u.config.unit = 'rpx'
|
|||||||
Vue.prototype.useStorage = useStorage
|
Vue.prototype.useStorage = useStorage
|
||||||
Vue.prototype.api = Api;
|
Vue.prototype.api = Api;
|
||||||
Vue.prototype.shop = Shop;
|
Vue.prototype.shop = Shop;
|
||||||
|
Vue.prototype.$onLaunched = new Promise(resolve => {
|
||||||
|
Vue.prototype.$isResolve = resolve
|
||||||
|
})
|
||||||
|
|
||||||
// #ifdef VUE3
|
// #ifdef VUE3
|
||||||
import {
|
import {
|
||||||
createSSRApp
|
createSSRApp
|
||||||
|
|||||||
@@ -64,44 +64,23 @@
|
|||||||
usershopUserinfo: null,
|
usershopUserinfo: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
async onLoad(e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
if ( e.type == 'list' || e.type == 'index') {
|
// if ( e.type == 'list' || e.type == 'index') {
|
||||||
this.shopId = e.shopId;
|
// this.shopId = e.shopId;
|
||||||
this.init();
|
// this.init();
|
||||||
}
|
// }
|
||||||
if (e.q) {
|
if (e.q) {
|
||||||
this.shopId = this.getQueryString(decodeURIComponent(e.q), 'shopId')
|
this.shopId = this.getQueryString(decodeURIComponent(e.q), 'shopId')
|
||||||
|
this.tokenShow = false;
|
||||||
|
// 等待登录结果返回
|
||||||
if (!uni.cache.get('token')) {
|
if (!uni.cache.get('token')) {
|
||||||
uni.login({
|
await this.$onLaunched;
|
||||||
provider: 'weixin',
|
|
||||||
success: async (data) => {
|
|
||||||
try {
|
|
||||||
uni.getUserInfo({
|
|
||||||
provider: 'weixin',
|
|
||||||
success: async (infoRes) => {
|
|
||||||
uni.cache.set('weixincode', data.code);
|
|
||||||
let res = await this.api.userwxlogin({
|
|
||||||
code: uni.cache.get('weixincode'), //临时登录凭证
|
|
||||||
rawData: infoRes.rawData
|
|
||||||
})
|
|
||||||
if (res.code == 0) {
|
|
||||||
uni.cache.set('token', res.data.token);
|
|
||||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
|
||||||
.miniAppOpenId)
|
|
||||||
uni.cache.set('userInfo', res.data.userInfo);
|
|
||||||
this.tokenShow = false;
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {}
|
|
||||||
});
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.init();
|
|
||||||
}
|
}
|
||||||
|
this.init();
|
||||||
|
} else{
|
||||||
|
this.shopId = e.shopId;
|
||||||
|
this.init();
|
||||||
}
|
}
|
||||||
console.log(this.shopId)
|
console.log(this.shopId)
|
||||||
},
|
},
|
||||||
@@ -240,14 +219,11 @@
|
|||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 500)
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
uni.exitMiniProgram({
|
setTimeout(res => {
|
||||||
success: function () {
|
uni.switchTab({
|
||||||
console.log('退出成功');
|
url: '/pages/index/index'
|
||||||
},
|
})
|
||||||
fail: function () {
|
}, 500)
|
||||||
console.log('退出失败');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<view class="head">
|
<view class="head">
|
||||||
<view class="head_bg"></view>
|
<view class="head_bg"></view>
|
||||||
<view class="tips">
|
<view class="tips">
|
||||||
<image class="informIcon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/informIcon.png" mode="widthFix"/>
|
<image class="informIcon" src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/informIcon.png" mode="aspectFill"/>
|
||||||
<text class="informText">温馨提示:请适量点餐,避免浪费</text>
|
<text class="informText">温馨提示:请适量点餐,避免浪费</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="tabBox"> -->
|
<!-- <view class="tabBox"> -->
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
<view class="method_list" @click="groupChange(index+1)">
|
<view class="method_list" @click="groupChange(index+1)">
|
||||||
<view class="method_list_top">
|
<view class="method_list_top">
|
||||||
<view class="method_list_top_left">
|
<view class="method_list_top_left">
|
||||||
<image class="icon" :src="item.url" mode="widthFix"/>
|
<image class="icon" :src="item.url" mode="aspectFill"/>
|
||||||
<text class="name"> {{ item.name }} </text>
|
<text class="name"> {{ item.name }} </text>
|
||||||
</view>
|
</view>
|
||||||
<u-radio activeColor="#E8AD7B" icon-size="36" size="36" :name="index+1">
|
<u-radio activeColor="#E8AD7B" icon-size="36" size="36" :name="index+1">
|
||||||
@@ -210,8 +210,8 @@
|
|||||||
this.listinfo.name = JSON.parse(e.storeInfo).shopName;
|
this.listinfo.name = JSON.parse(e.storeInfo).shopName;
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
uni.$on('message', this.getMessage)
|
|
||||||
if (this.listinfoid) {
|
if (this.listinfoid) {
|
||||||
|
uni.$on('message', this.getMessage)
|
||||||
this.orderorderInfo()
|
this.orderorderInfo()
|
||||||
} else {
|
} else {
|
||||||
this.handlemessage()
|
this.handlemessage()
|
||||||
@@ -310,6 +310,7 @@
|
|||||||
userId: uni.cache.get('userInfo').id,
|
userId: uni.cache.get('userInfo').id,
|
||||||
"type": "connect",
|
"type": "connect",
|
||||||
})
|
})
|
||||||
|
uni.$on('message', this.getMessage)
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -590,7 +591,8 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
.informIcon{
|
.informIcon{
|
||||||
width: 26.7rpx;
|
width: 26.79rpx;
|
||||||
|
height: 24.06rpx;
|
||||||
margin-right: 8rpx;
|
margin-right: 8rpx;
|
||||||
}
|
}
|
||||||
.informText{
|
.informText{
|
||||||
@@ -923,7 +925,8 @@
|
|||||||
.method_list_top_left{
|
.method_list_top_left{
|
||||||
display: flex;
|
display: flex;
|
||||||
.icon{
|
.icon{
|
||||||
width: 54rpx!important;
|
width: 54.67rpx!important;
|
||||||
|
height: 48rpx!important;
|
||||||
margin-right: 22rpx;
|
margin-right: 22rpx;
|
||||||
}
|
}
|
||||||
.name{
|
.name{
|
||||||
|
|||||||
@@ -382,7 +382,6 @@
|
|||||||
return `left-${this.leftIndex? this.leftIndex:0}`;
|
return `left-${this.leftIndex? this.leftIndex:0}`;
|
||||||
},
|
},
|
||||||
HeighT() { //手机类型的尺寸 导航栏高度
|
HeighT() { //手机类型的尺寸 导航栏高度
|
||||||
console.log(this.$store.getters.is_BarHeight)
|
|
||||||
return this.$store.getters.is_BarHeight.heightBar + this.$store.getters.is_BarHeight.customBar
|
return this.$store.getters.is_BarHeight.heightBar + this.$store.getters.is_BarHeight.customBar
|
||||||
},
|
},
|
||||||
scrollHeight() {
|
scrollHeight() {
|
||||||
@@ -407,38 +406,18 @@
|
|||||||
uni.$off('message')
|
uni.$off('message')
|
||||||
this.fixedtrue = true
|
this.fixedtrue = true
|
||||||
},
|
},
|
||||||
onShow() {
|
async onShow() {
|
||||||
let _this = this;
|
let _this = this;
|
||||||
this.orderdetailFlag = true;
|
this.orderdetailFlag = true;
|
||||||
uni.pageScrollTo({
|
uni.pageScrollTo({
|
||||||
scrollTop: 0,
|
scrollTop: 0,
|
||||||
duration: 0
|
duration: 0
|
||||||
});
|
});
|
||||||
uni.login({
|
if (!uni.cache.get('token')) {
|
||||||
provider: 'weixin',
|
await this.$onLaunched;
|
||||||
success: async (data) => {
|
}
|
||||||
uni.getUserInfo({
|
uni.$on('message', this.getMessage)
|
||||||
provider: 'weixin',
|
_this.getLocation()
|
||||||
success: async (infoRes) => {
|
|
||||||
uni.cache.set('weixincode', data.code);
|
|
||||||
let res = await this.api.userwxlogin({
|
|
||||||
code: uni.cache.get('weixincode'), //临时登录凭证
|
|
||||||
rawData: infoRes.rawData
|
|
||||||
})
|
|
||||||
if (res.code == 0) {
|
|
||||||
uni.cache.set('token', res.data.token);
|
|
||||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
|
||||||
.miniAppOpenId)
|
|
||||||
uni.cache.set('userInfo', res.data.userInfo);
|
|
||||||
uni.$on('message', this.getMessage)
|
|
||||||
|
|
||||||
_this.getLocation()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
navigateBacknav() {
|
navigateBacknav() {
|
||||||
@@ -496,6 +475,7 @@
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.productqueryShop();
|
this.productqueryShop();
|
||||||
|
//TODO handle the exception
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -505,8 +485,10 @@
|
|||||||
async productqueryShop() {
|
async productqueryShop() {
|
||||||
let res = await this.api.productqueryShop({
|
let res = await this.api.productqueryShop({
|
||||||
code: uni.cache.get('tableCode'),
|
code: uni.cache.get('tableCode'),
|
||||||
lng: uni.cache.get('getLocationstorage').lng ? uni.cache.get('getLocationstorage').lng : '',
|
lng: uni.cache.get('getLocationstorage').lng ? uni.cache.get('getLocationstorage').lng :
|
||||||
lat: uni.cache.get('getLocationstorage').lat ? uni.cache.get('getLocationstorage').lat : '',
|
'',
|
||||||
|
lat: uni.cache.get('getLocationstorage').lat ? uni.cache.get('getLocationstorage').lat :
|
||||||
|
'',
|
||||||
})
|
})
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
uni.cache.set('shopUser', res.data.storeInfo.id)
|
uni.cache.set('shopUser', res.data.storeInfo.id)
|
||||||
@@ -525,9 +507,6 @@
|
|||||||
* 图片加载
|
* 图片加载
|
||||||
*/
|
*/
|
||||||
imageLoaded(item, index, index1) {
|
imageLoaded(item, index, index1) {
|
||||||
console.log(index)
|
|
||||||
console.log(index1)
|
|
||||||
console.log(this.shopProductList.productInfo[index])
|
|
||||||
this.shopProductList.productInfo[index].products[index1]['imgLoad'] = true;
|
this.shopProductList.productInfo[index].products[index1]['imgLoad'] = true;
|
||||||
// e.currentTarget.src
|
// e.currentTarget.src
|
||||||
},
|
},
|
||||||
@@ -567,7 +546,6 @@
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (this.amountcartNumber > 0) {
|
if (this.amountcartNumber > 0) {
|
||||||
console.log(item)
|
|
||||||
if (this.skuNumber < this.skuSuit && this.amountcartNumber <= this.skuSuit) {
|
if (this.skuNumber < this.skuSuit && this.amountcartNumber <= this.skuSuit) {
|
||||||
this.amountcartNumber = this.amountcartNumber - (this.skuSuit == 0 ? 1 : this.skuSuit);
|
this.amountcartNumber = this.amountcartNumber - (this.skuSuit == 0 ? 1 : this.skuSuit);
|
||||||
} else {
|
} else {
|
||||||
@@ -712,6 +690,7 @@
|
|||||||
this.isSpec = true;
|
this.isSpec = true;
|
||||||
// 但但单个规格弹框的处理
|
// 但但单个规格弹框的处理
|
||||||
this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量
|
this.hodgepodge(this.specifications, 2) //获取skuid /2查找价格和数量
|
||||||
|
this.skuBtnText = `添加到购物车`
|
||||||
} else {
|
} else {
|
||||||
// 多规格数据处理
|
// 多规格数据处理
|
||||||
this.isSpec = false;
|
this.isSpec = false;
|
||||||
@@ -742,11 +721,8 @@
|
|||||||
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
|
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
|
||||||
isSkuidname.push(this.specifications.tagSnap[0].children[o].name)
|
isSkuidname.push(this.specifications.tagSnap[0].children[o].name)
|
||||||
//筛选符合条件的规格列表
|
//筛选符合条件的规格列表
|
||||||
console.log(isSkuidname);
|
|
||||||
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
|
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
|
||||||
console.log(filteredJson);
|
|
||||||
for (let i = 0; i < filteredJson.length; i++) {
|
for (let i = 0; i < filteredJson.length; i++) {
|
||||||
console.log(filteredJson[i].isGrounding)
|
|
||||||
if (filteredJson[i].isGrounding) {
|
if (filteredJson[i].isGrounding) {
|
||||||
this.specifications.tagSnap[0].children[o].isGrounding = true
|
this.specifications.tagSnap[0].children[o].isGrounding = true
|
||||||
break; // 终止循环
|
break; // 终止循环
|
||||||
@@ -761,7 +737,6 @@
|
|||||||
// console.log(val)
|
// console.log(val)
|
||||||
// this.skuidname.push(val.children[0].info)
|
// this.skuidname.push(val.children[0].info)
|
||||||
// })
|
// })
|
||||||
console.log(this.specifications.tagSnap)
|
|
||||||
this.hodgepodge(this.specifications.tagSnap[0], 2) //获取skuid /2查找价格和数量
|
this.hodgepodge(this.specifications.tagSnap[0], 2) //获取skuid /2查找价格和数量
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,11 +796,8 @@
|
|||||||
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
|
isSkuidname = JSON.parse(JSON.stringify(this.skuidname));
|
||||||
isSkuidname.push(this.specifications.tagSnap[index + 1].children[o].name)
|
isSkuidname.push(this.specifications.tagSnap[index + 1].children[o].name)
|
||||||
//筛选符合条件的规格列表
|
//筛选符合条件的规格列表
|
||||||
console.log(isSkuidname);
|
|
||||||
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
|
filteredJson = this.querySpecList.filter(obj => obj.specSnap.indexOf(isSkuidname) == 0);
|
||||||
console.log(filteredJson);
|
|
||||||
for (let i = 0; i < filteredJson.length; i++) {
|
for (let i = 0; i < filteredJson.length; i++) {
|
||||||
console.log(filteredJson[i].isGrounding)
|
|
||||||
if (filteredJson[i].isGrounding) {
|
if (filteredJson[i].isGrounding) {
|
||||||
this.specifications.tagSnap[index + 1].children[o].isGrounding = true
|
this.specifications.tagSnap[index + 1].children[o].isGrounding = true
|
||||||
break; // 终止循环
|
break; // 终止循环
|
||||||
@@ -839,7 +811,6 @@
|
|||||||
// res.data.forEach((v,e)=>{
|
// res.data.forEach((v,e)=>{
|
||||||
// // this.$set(this.specifications.tagSnap[e], 'children', v.value)
|
// // this.$set(this.specifications.tagSnap[e], 'children', v.value)
|
||||||
// })
|
// })
|
||||||
console.log(this.specifications.tagSnap)
|
|
||||||
|
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
this.hodgepodge(item, 2)
|
this.hodgepodge(item, 2)
|
||||||
@@ -854,7 +825,7 @@
|
|||||||
*/
|
*/
|
||||||
async hodgepodge(item, a, c, num) { //此接口去获取商品id !!!赋值库存 数量 价格等
|
async hodgepodge(item, a, c, num) { //此接口去获取商品id !!!赋值库存 数量 价格等
|
||||||
try {
|
try {
|
||||||
console.log(this.skuidname.join(","))
|
// console.log(this.skuidname.join(","))
|
||||||
let res = await this.api.productqueryProductSku({
|
let res = await this.api.productqueryProductSku({
|
||||||
code: uni.cache.get('tableCode'),
|
code: uni.cache.get('tableCode'),
|
||||||
shopId: uni.cache.get('shopUser'),
|
shopId: uni.cache.get('shopUser'),
|
||||||
@@ -1049,14 +1020,11 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(index)
|
|
||||||
/* 查找当前滚动距离 */
|
/* 查找当前滚动距离 */
|
||||||
if (index >= this.lastbottom) { //
|
if (index >= this.lastbottom) { //
|
||||||
console.log(index, this.leftIndex)
|
|
||||||
this.leftIndex = index > this.leftIndex ? index : this.leftIndex
|
this.leftIndex = index > this.leftIndex ? index : this.leftIndex
|
||||||
// this.leftIndex = this.leftIndex
|
// this.leftIndex = this.leftIndex
|
||||||
} else {
|
} else {
|
||||||
console.log(22918)
|
|
||||||
this.leftIndex = (index < 0 ? 0 : index);
|
this.leftIndex = (index < 0 ? 0 : index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,12 @@ const store = new Vuex.Store({
|
|||||||
uni.cache.set('miniAppOpenId', res.data.userInfo
|
uni.cache.set('miniAppOpenId', res.data.userInfo
|
||||||
.miniAppOpenId)
|
.miniAppOpenId)
|
||||||
uni.cache.set('userInfo', res.data.userInfo);
|
uni.cache.set('userInfo', res.data.userInfo);
|
||||||
|
let pages = getCurrentPages()
|
||||||
|
let curPage = pages[pages.length -1 ]
|
||||||
|
curPage.onLoad(curPage.options)
|
||||||
|
curPage.onShow()
|
||||||
|
curPage.onReady()
|
||||||
|
this.$isResolve()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {}
|
fail: (err) => {}
|
||||||
|
|||||||
Reference in New Issue
Block a user