From d0837aa8f716b9e332e6cc02697d08c99b96b228 Mon Sep 17 00:00:00 2001 From: h30830569 <30830569@qq.com> Date: Mon, 9 May 2022 17:41:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E9=80=89=E6=8B=A9=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mixin/router.mixin.js | 1 - .../select_product/components/goods-item.vue | 15 +++--- src/pageB/select_product/index.vue | 50 ++++++++++++++----- src/pageB/select_store/index.vue | 5 +- src/pages/login/index.vue | 30 ++++++----- src/pages/me/me.vue | 12 +++-- src/pages/order_details/index.vue | 4 +- src/store/getters.js | 2 +- src/store/modules/user.js | 2 +- src/style/index.scss | 2 +- src/utils/login.js | 9 +++- 11 files changed, 81 insertions(+), 51 deletions(-) diff --git a/src/mixin/router.mixin.js b/src/mixin/router.mixin.js index 6212547..bf6b6f7 100644 --- a/src/mixin/router.mixin.js +++ b/src/mixin/router.mixin.js @@ -7,7 +7,6 @@ const whiteList = [ export default { created() { - // 登录判断跳转 this.$u.routeAuth = (...args) => { let url = args[0] diff --git a/src/pageB/select_product/components/goods-item.vue b/src/pageB/select_product/components/goods-item.vue index 414a0bd..43de28c 100644 --- a/src/pageB/select_product/components/goods-item.vue +++ b/src/pageB/select_product/components/goods-item.vue @@ -9,7 +9,7 @@ {{goods.vip_price}}元 vip 添加 - + @@ -27,19 +27,16 @@ type:Object, default:()=>{} } - }, - data(){ - return { - goodsItem:{}, - } - }, - mounted() { - }, methods:{ //添加商品 add(){ this.$emit('addGood',this.goods.id) + }, + //商品数量改变 + valChange(e){ + const {value}=e + this.$emit('numChange',this.goods.id,value) } } }; diff --git a/src/pageB/select_product/index.vue b/src/pageB/select_product/index.vue index e4bb900..9d41aba 100644 --- a/src/pageB/select_product/index.vue +++ b/src/pageB/select_product/index.vue @@ -23,13 +23,13 @@ 默认已提货量》 - + - - + + @@ -39,11 +39,11 @@ 合计 - 15元 + {{totalPrice}}元 - + vip - 15元 + {{vipPrice}}元 { + return pr+cu.sell_price*cu.num + },0) + return total + }, + //会员价合计 + vipPrice(){ + const total=this.chooseList.reduce((pr, cu)=>{ + return pr+cu.vip_price*cu.num + },0) + return total + } + }, methods: { async searchGoods() { - this.isShow=false const resDate = await this.$api.get(`/v1/product/products`, { params: { keyword: this.keyword @@ -93,21 +108,32 @@ if (this.list.length == 0) { return this.$u.toast('暂未搜索到该商品') } + this.isShow=false let goodsObj = resDate.data.length > 0 ? resDate.data[0] : {} - goodsObj.defaultNum = 1 + goodsObj.defaultNum =1 goodsObj.num = 1 this.goodItem = goodsObj - console.log( this.goodItem) }, //添加商品 addGood(e) { - const result=this.chooseList.findIndex(item=> item.id=e) - console.log(result); + const result=this.chooseList.findIndex(item=> item.id==e) if(result==-1){ this.chooseList.unshift(this.goodItem) }else{ - + const num= this.chooseList[result].num+1 + this.getUpdate(result,num) } + }, + //商品数量改变 + numChange(id,value){ + const Index= this.chooseList.findIndex(item=>item.id==id) + this.getUpdate(Index,value) + }, + //刷新页面 + getUpdate(Index,val){ + this.chooseList[Index].num=val + this.chooseList[Index].defaultNum=val + this.chooseList=[...this.chooseList] } } } diff --git a/src/pageB/select_store/index.vue b/src/pageB/select_store/index.vue index 9741a38..9e0d0ee 100644 --- a/src/pageB/select_store/index.vue +++ b/src/pageB/select_store/index.vue @@ -3,10 +3,9 @@ - - + - {{item.title}} diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index ad81b35..a719990 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -1,11 +1,12 @@ @@ -92,7 +93,7 @@ export default { }; }, onReady() { - this.$refs.uForm.setRules(this.rules); + // this.$refs.uForm.setRules(this.rules); }, async onLoad({ type, phone }) { this.form.phone = phone ?? ''; @@ -110,17 +111,14 @@ export default { //微信快捷登录 async getPhoneNumber(e) { - const { encryptedData, iv } = e.detail; - if(!iv) return + const { code } = e.detail; + if(!code) return const invite_code = uni.getStorageSync('INVITE_CODE'); // const code = await getWxCode(); const params = {} if(!!invite_code) params.inviter_code = invite_code - const resData = await this.$api.post('/v1/socialite/code-bind-user/wechat-mini', { - type: 'wechat-mini', - code:this.code, - iv, - data: encryptedData, + const resData = await this.$api.post('/v1/wechat-mini/bind-phone', { + code:code, ...params }); this.LOGIN(resData.token); diff --git a/src/pages/me/me.vue b/src/pages/me/me.vue index f2f93e9..4fec84d 100644 --- a/src/pages/me/me.vue +++ b/src/pages/me/me.vue @@ -185,8 +185,9 @@ @@ -275,9 +276,9 @@ --> - + 服务协议 @@ -357,6 +358,11 @@ export default { order_count() { return this.$store.getters.order_count ?? {}; }, + //是否为店员 + is_company(){ + // return this.user?.is_company??false + return true + } }, onShow() { this.$store.dispatch('user/getOrderNum'); diff --git a/src/pages/order_details/index.vue b/src/pages/order_details/index.vue index 49a7f6b..4189b59 100644 --- a/src/pages/order_details/index.vue +++ b/src/pages/order_details/index.vue @@ -125,11 +125,11 @@ 运费 ¥{{ detail.shipping_fee }} - + 优惠券 -¥{{ detail.coupon_discount_amount }} - + 会员优惠 -¥{{ detail.vip_discount_amount }} diff --git a/src/store/getters.js b/src/store/getters.js index 13222d4..a4e9e19 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -1,5 +1,5 @@ const getters = { - isLogin: state => !!state.user.token, + isLogin: state => !!state.user.user?.phone, token: state => state.user.token, user:state => state.user.user, allaccounts:state => state.user.allaccounts, diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 2717ad9..14b8752 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -129,7 +129,7 @@ const actions = { commit }) { /* #ifdef MP-WEIXIN */ - await http.post('/v1/socialite/unbind-user/wechat-mini') + //await http.post('/v1/socialite/unbind-user/wechat-mini') /* #endif */ return new Promise((resolve, reject) => { http.post('/v1/logout', {}, { diff --git a/src/style/index.scss b/src/style/index.scss index 6dc25c3..09b5e77 100644 --- a/src/style/index.scss +++ b/src/style/index.scss @@ -192,7 +192,7 @@ page { .translate-center { position: absolute; left: 50%; - top: 50%; + top: 40%; transform: translate(-50%, -50%); } diff --git a/src/utils/login.js b/src/utils/login.js index 48ce8a3..268fc5f 100644 --- a/src/utils/login.js +++ b/src/utils/login.js @@ -27,8 +27,13 @@ export async function wxMnpLogin(){ async function silentLogin(data){ - const provider = 'wechat-mini' - const resData = await http.post(`/v1/socialite/code-auth/${provider}`,data,{ + // const provider = 'wechat-mini' + // const resData = await http.post(`/v1/socialite/code-auth/${provider}`,data,{ + // custom:{ + // toast:false + // } + // }) + const resData = await http.post(`/v1/wechat-mini/login`,data,{ custom:{ toast:false }