Browse Source

去除测试log;修改购物车无法选中的问题

zyh
Gaoxs 4 years ago
parent
commit
b61c95035e
  1. 7
      libs/wechat.js
  2. 7
      pages/Loading/index.vue
  3. 8
      pages/shop/GoodsCon/index.vue
  4. 4
      pages/shop/ShoppingCart/index.vue
  5. 30
      pages/user/UserAccount/index.vue
  6. 28
      store/index.js

7
libs/wechat.js

@ -157,7 +157,7 @@ export async function auth(code) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let loginType = cookie.get(LOGINTYPE); let loginType = cookie.get(LOGINTYPE);
let spread = cookie.get('spread'); let spread = cookie.get('spread');
alert(spread) console.log('微信授权登录前获取spread', spread)
wechatAuth(code, spread, loginType) wechatAuth(code, spread, loginType)
.then(({ data }) => { .then(({ data }) => {
console.log(data) console.log(data)
@ -167,7 +167,10 @@ export async function auth(code) {
cookie.set(WX_AUTH, code, expires_time); cookie.set(WX_AUTH, code, expires_time);
cookie.remove(STATE_KEY); cookie.remove(STATE_KEY);
loginType && cookie.remove(LOGINTYPE); loginType && cookie.remove(LOGINTYPE);
resolve(); console.log('微信公众号授权登录,获取用户信息')
store.dispatch('getUser').finally(() => {
resolve();
})
}) })
.catch(reject); .catch(reject);
}).catch(error => { }).catch(error => {

7
pages/Loading/index.vue

@ -18,6 +18,7 @@
wxappAuth, wxappAuth,
} from "@/api/user"; } from "@/api/user";
import dayjs from "dayjs"; import dayjs from "dayjs";
import store from "@/store";
import cookie from "@/utils/store/cookie"; import cookie from "@/utils/store/cookie";
import { import {
parseQuery, parseQuery,
@ -34,7 +35,7 @@
return {}; return {};
}, },
onShow() { onShow() {
console.log('getUser')
var url = handleQrCode(); var url = handleQrCode();
if (!url) { if (!url) {
url = handleUrlParam(getCurrentPageUrlWithArgs()) url = handleUrlParam(getCurrentPageUrlWithArgs())
@ -55,9 +56,7 @@
if (this.$store.getters.token) { if (this.$store.getters.token) {
// token // token
console.log('登录状态存在,直接进页面') console.log('登录状态存在,直接进页面')
this.getUser().finally(() => { this.toLaunch();
this.toLaunch();
})
return; return;
} }
console.log('进行登录操作') console.log('进行登录操作')

8
pages/shop/GoodsCon/index.vue

@ -135,7 +135,10 @@
</button> </button>
</view> </view>
<!-- #endif --> <!-- #endif -->
<view class="item" @click="goHome" >
<view class="iconfont icon-shouye-xianxing"></view>
<text>首页</text>
</view>
<view class="item" @click="setCollect" v-if="storeInfo.userCollect"> <view class="item" @click="setCollect" v-if="storeInfo.userCollect">
<view class="iconfont icon-shoucang1"></view> <view class="iconfont icon-shoucang1"></view>
<text>收藏</text> <text>收藏</text>
@ -351,6 +354,9 @@
} }
} }
}, },
goHome() {
this.$yrouter.switchTab("/pages/home/index");
},
goShoppingCart() { goShoppingCart() {
this.$yrouter.switchTab("/pages/shop/ShoppingCart/index"); this.$yrouter.switchTab("/pages/shop/ShoppingCart/index");
}, },

4
pages/shop/ShoppingCart/index.vue

@ -28,7 +28,7 @@
<view class="checkbox-wrapper"> <view class="checkbox-wrapper">
<checkbox-group @change="switchSelect(cartListValidIndex)"> <checkbox-group @change="switchSelect(cartListValidIndex)">
<label class="well-check"> <label class="well-check">
<checkbox value :checked="item.checked+''"></checkbox> <checkbox color="#eb3729" value :checked="item.checked"></checkbox>
</label> </label>
</checkbox-group> </checkbox-group>
</view> </view>
@ -113,7 +113,7 @@
<checkbox-group @change="allChecked"> <checkbox-group @change="allChecked">
<label class="well-check"> <label class="well-check">
<checkbox value="allSelect" :checked="isAllSelect && cartCount > 0"></checkbox> <checkbox color="#eb3729" value="allSelect" :checked="isAllSelect && cartCount > 0"></checkbox>
<text class="checkAll">全选 ({{ cartCount }})</text> <text class="checkAll">全选 ({{ cartCount }})</text>
</label> </label>
</checkbox-group> </checkbox-group>

30
pages/user/UserAccount/index.vue

@ -97,21 +97,21 @@ export default {
}, },
getActivity: function() { getActivity: function() {
let that = this; let that = this;
getActivityStatus().then( // getActivityStatus().then(
res => { // res => {
that.activity.is_bargin = res.data.is_bargin; // that.activity.is_bargin = res.data.is_bargin;
that.activity.is_pink = res.data.is_pink; // that.activity.is_pink = res.data.is_pink;
that.activity.is_seckill = res.data.is_seckill; // that.activity.is_seckill = res.data.is_seckill;
}, // },
err => { // err => {
uni.showToast({ // uni.showToast({
title: // title:
err.msg || err.response.data.msg || err.response.data.message, // err.msg || err.response.data.msg || err.response.data.message,
icon: "none", // icon: "none",
duration: 2000 // duration: 2000
}); // });
} // }
); // );
} }
} }
}; };

28
store/index.js

@ -90,22 +90,24 @@ const vuexStore = new Vuex.Store({
userInfo({ state, commit }, force) { userInfo({ state, commit }, force) {
if (state.userInfo !== null && !force) { if (state.userInfo !== null && !force) {
return Promise.resolve(state.userInfo); return Promise.resolve(state.userInfo);
} else {
return new Promise(reslove => {
getUserInfo().then(res => {
commit("updateUserInfo", res.data);
reslove(res.data);
});
}).catch(() => {
uni.showToast({
title: "获取信息失败!",
icon: "none",
duration: 2000,
});
});
} }
return new Promise(reslove => {
getUserInfo().then(res => {
commit("updateUserInfo", res.data);
reslove(res.data);
});
}).catch(() => {
uni.showToast({
title: "获取信息失败!",
icon: "none",
duration: 2000,
});
});
}, },
getUser({ state, commit }) { getUser({ state, commit }) {
if (!state.token) {
return Promise.reject('未获取到token');
}
return new Promise(reslove => { return new Promise(reslove => {
getUserInfo().then(res => { getUserInfo().then(res => {
console.log(res) console.log(res)

Loading…
Cancel
Save