Browse Source

[bug]修改个人中心小标丢失的情况;修改购物车无法全选的问题

master
gaoxs 5 years ago
parent
commit
1f3fbde86e
  1. 2
      pages/order/OrderSubmission/index.vue
  2. 7
      pages/shop/ShoppingCart/index.vue
  3. 19
      pages/user/User/index.vue
  4. 37
      store/index.js

2
pages/order/OrderSubmission/index.vue

@ -327,7 +327,7 @@
}, },
mounted: function() { mounted: function() {
let that = this; let that = this;
this.$store.dispatch('USERINFO', true) this.$store.dispatch('getUser', true)
that.getCartInfo(); that.getCartInfo();
if (that.$yroute.query.pinkid !== undefined) if (that.$yroute.query.pinkid !== undefined)
that.pinkId = that.$yroute.query.pinkid; that.pinkId = that.$yroute.query.pinkid;

7
pages/shop/ShoppingCart/index.vue

@ -118,7 +118,7 @@
<checkbox-group @change="allChecked"> <checkbox-group @change="allChecked">
<label class="well-check"> <label class="well-check">
<checkbox value :checked="isAllSelect && cartCount > 0"></checkbox> <checkbox value="allSelect" :checked="isAllSelect && cartCount > 0"></checkbox>
<text class="checkAll">全选 ({{ cartCount }})</text> <text class="checkAll">全选 ({{ cartCount }})</text>
</label> </label>
</checkbox-group> </checkbox-group>
@ -441,8 +441,10 @@ export default {
}, },
// //
allChecked: function(e) { allChecked: function(e) {
console.log(e)
let that = this; 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 selectAllStatus = that.isAllSelect;
let checkedIds = []; let checkedIds = [];
// for (let i = 0; i < array.length; i++) { // for (let i = 0; i < array.length; i++) {
@ -460,6 +462,7 @@ export default {
}; };
that.cartList = []; that.cartList = [];
that.cartList = cartList; that.cartList = cartList;
console.log(this.cartList)
this.$set(this, 'cartList', this.cartList); this.$set(this, 'cartList', this.cartList);
this.$set(this, 'isAllSelect', selectAllStatus); this.$set(this, 'isAllSelect', selectAllStatus);
this.checkedIds = checkedIds; this.checkedIds = checkedIds;

19
pages/user/User/index.vue

@ -146,15 +146,12 @@
</view>--> </view>-->
</view> </view>
<view class="by"> <view class="by">
<text class="by-text">By@意象</text> <text class="by-text">By@Yshop</text>
</view> </view>
<view class="by"> <view class="by">
<view> <view>
<text class="by-text">Copyright © 2020</text> <text class="by-text">Copyright © 2020</text>
</view> </view>
<view>
<text class="by-text">漯河市大有前途网络科技有限公司</text>
</view>
</view> </view>
<view class="footer-line-height"></view> <view class="footer-line-height"></view>
<!-- <SwitchWindow <!-- <SwitchWindow
@ -220,7 +217,7 @@ export default {
this.$yrouter.push("/pages/user/PersonalData/index"); this.$yrouter.push("/pages/user/PersonalData/index");
}, },
getPhoneNumber: function(e) { getPhoneNumber: function(e) {
let thit=this let thit = this;
// //
if (e.mp.detail.errMsg == "getPhoneNumber:ok") { if (e.mp.detail.errMsg == "getPhoneNumber:ok") {
uni.showLoading({ uni.showLoading({
@ -287,10 +284,10 @@ export default {
}, },
User: function() { User: function() {
let that = this; let that = this;
// getUser().then(res => { getUser().then(res => {
// that.user = res.data; that.user = res.data;
// that.orderStatusNum = res.data.orderStatusNum; that.orderStatusNum = res.data.orderStatusNum;
// }); });
}, },
MenuUser: function() { MenuUser: function() {
let that = this; let that = this;
@ -338,7 +335,9 @@ export default {
}, },
onShow() { onShow() {
if (this.$store.getters.token) { if (this.$store.getters.token) {
this.User(); //
this.$store.dispatch('getUser', true)
this.MenuUser(); this.MenuUser();
this.isWeixin = isWeixin(); this.isWeixin = isWeixin();
} }

37
store/index.js

@ -6,7 +6,8 @@ const debug = process.env.NODE_ENV !== "production";
import cookie from "@/utils/store/cookie"; import cookie from "@/utils/store/cookie";
import { import {
getUserInfo getUserInfo,
getUser
} from "@/api/user"; } from "@/api/user";
import dialog from "@/utils/dialog"; import dialog from "@/utils/dialog";
@ -58,8 +59,13 @@ const vuexStore = new Vuex.Store({
state.color = color; state.color = color;
// document.body.style.backgroundColor = color; // document.body.style.backgroundColor = color;
}, },
UPDATE_USERINFO(state, userInfo) { UPDATE_USERINFO(state, userInfo) {
state.userInfo = userInfo; state.userInfo = userInfo;
if (userInfo) {
cookie.set('userInfo', userInfo)
} else {
cookie.set('userInfo', null)
}
}, },
UPDATE_AUTHORIZATIONPAGE(state, isAuthorizationPage) { UPDATE_AUTHORIZATIONPAGE(state, isAuthorizationPage) {
state.isAuthorizationPage = isAuthorizationPage; state.isAuthorizationPage = isAuthorizationPage;
@ -72,13 +78,10 @@ const vuexStore = new Vuex.Store({
}, },
}, },
actions: { actions: {
USERINFO({ USERINFO({ state, commit }, force) {
state, if (state.userInfo !== null && !force) {
commit
}, force) {
if (state.userInfo !== null && !force)
return Promise.resolve(state.userInfo); return Promise.resolve(state.userInfo);
else } else {
return new Promise(reslove => { return new Promise(reslove => {
getUserInfo().then(res => { getUserInfo().then(res => {
commit("UPDATE_USERINFO", res.data); commit("UPDATE_USERINFO", res.data);
@ -87,6 +90,19 @@ const vuexStore = new Vuex.Store({
}).catch(() => { }).catch(() => {
dialog.error("获取信息失败!"); 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({ changeLogin({
state, state,
@ -99,11 +115,6 @@ const vuexStore = new Vuex.Store({
commit commit
}, user) { }, user) {
commit("UPDATE_USERINFO", user); commit("UPDATE_USERINFO", user);
if (user) {
cookie.set('userInfo', user)
} else {
cookie.set('userInfo', null)
}
}, },
changeAuthorizationPage({ changeAuthorizationPage({
state, state,

Loading…
Cancel
Save