diff --git a/pages/order/OrderSubmission/index.vue b/pages/order/OrderSubmission/index.vue index 05052d6..b151b14 100644 --- a/pages/order/OrderSubmission/index.vue +++ b/pages/order/OrderSubmission/index.vue @@ -327,7 +327,7 @@ }, mounted: function() { let that = this; - this.$store.dispatch('USERINFO', true) + this.$store.dispatch('getUser', true) that.getCartInfo(); if (that.$yroute.query.pinkid !== undefined) that.pinkId = that.$yroute.query.pinkid; diff --git a/pages/shop/ShoppingCart/index.vue b/pages/shop/ShoppingCart/index.vue index 94ec59f..970cd91 100644 --- a/pages/shop/ShoppingCart/index.vue +++ b/pages/shop/ShoppingCart/index.vue @@ -118,7 +118,7 @@ <checkbox-group @change="allChecked"> <label class="well-check"> - <checkbox value :checked="isAllSelect && cartCount > 0"></checkbox> + <checkbox value="allSelect" :checked="isAllSelect && cartCount > 0"></checkbox> <text class="checkAll">全选 ({{ cartCount }})</text> </label> </checkbox-group> @@ -441,8 +441,10 @@ export default { }, //全选 allChecked: function(e) { + console.log(e) let that = this; - let selectAllStatus = e.mp.detail.value[0] ? true : false; + let selectAllStatus = e.mp.detail.value[0]=='allSelect' ? true : false; + console.log(selectAllStatus) // let selectAllStatus = that.isAllSelect; let checkedIds = []; // for (let i = 0; i < array.length; i++) { @@ -460,6 +462,7 @@ export default { }; that.cartList = []; that.cartList = cartList; + console.log(this.cartList) this.$set(this, 'cartList', this.cartList); this.$set(this, 'isAllSelect', selectAllStatus); this.checkedIds = checkedIds; diff --git a/pages/user/User/index.vue b/pages/user/User/index.vue index ffed25d..0fb71d0 100644 --- a/pages/user/User/index.vue +++ b/pages/user/User/index.vue @@ -146,15 +146,12 @@ </view>--> </view> <view class="by"> - <text class="by-text">By@意象</text> + <text class="by-text">By@Yshop</text> </view> <view class="by"> <view> <text class="by-text">Copyright © 2020</text> </view> - <view> - <text class="by-text">漯河市大有前途网络科技有限公司</text> - </view> </view> <view class="footer-line-height"></view> <!-- <SwitchWindow @@ -220,7 +217,7 @@ export default { this.$yrouter.push("/pages/user/PersonalData/index"); }, getPhoneNumber: function(e) { - let thit=this + let thit = this; // 判断一下这里是不是小程序 如果是小程序,走获取微信手机号进行绑定 if (e.mp.detail.errMsg == "getPhoneNumber:ok") { uni.showLoading({ @@ -287,10 +284,10 @@ export default { }, User: function() { let that = this; - // getUser().then(res => { - // that.user = res.data; - // that.orderStatusNum = res.data.orderStatusNum; - // }); + getUser().then(res => { + that.user = res.data; + that.orderStatusNum = res.data.orderStatusNum; + }); }, MenuUser: function() { let that = this; @@ -338,7 +335,9 @@ export default { }, onShow() { if (this.$store.getters.token) { - this.User(); + // + this.$store.dispatch('getUser', true) + this.MenuUser(); this.isWeixin = isWeixin(); } diff --git a/store/index.js b/store/index.js index 2f89844..ff6d3b1 100644 --- a/store/index.js +++ b/store/index.js @@ -6,7 +6,8 @@ const debug = process.env.NODE_ENV !== "production"; import cookie from "@/utils/store/cookie"; import { - getUserInfo + getUserInfo, + getUser } from "@/api/user"; import dialog from "@/utils/dialog"; @@ -58,8 +59,13 @@ const vuexStore = new Vuex.Store({ state.color = color; // document.body.style.backgroundColor = color; }, - UPDATE_USERINFO(state, userInfo) { + UPDATE_USERINFO(state, userInfo) { state.userInfo = userInfo; + if (userInfo) { + cookie.set('userInfo', userInfo) + } else { + cookie.set('userInfo', null) + } }, UPDATE_AUTHORIZATIONPAGE(state, isAuthorizationPage) { state.isAuthorizationPage = isAuthorizationPage; @@ -72,13 +78,10 @@ const vuexStore = new Vuex.Store({ }, }, actions: { - USERINFO({ - state, - commit - }, force) { - if (state.userInfo !== null && !force) + USERINFO({ state, commit }, force) { + if (state.userInfo !== null && !force) { return Promise.resolve(state.userInfo); - else + } else { return new Promise(reslove => { getUserInfo().then(res => { commit("UPDATE_USERINFO", res.data); @@ -87,6 +90,19 @@ const vuexStore = new Vuex.Store({ }).catch(() => { dialog.error("获取信息失败!"); }); + } + }, + getUser({ state, commit }) { + return new Promise(reslove => { + getUser().then(res => { + console.log(res) + commit("UPDATE_USERINFO", res.data); + reslove(res.data); + }); + }).catch((error) => { + console.log(error) + dialog.error("获取信息失败!"); + }); }, changeLogin({ state, @@ -99,11 +115,6 @@ const vuexStore = new Vuex.Store({ commit }, user) { commit("UPDATE_USERINFO", user); - if (user) { - cookie.set('userInfo', user) - } else { - cookie.set('userInfo', null) - } }, changeAuthorizationPage({ state,