From b61c95035ef0460f917e05103a14f8421b02c31f Mon Sep 17 00:00:00 2001
From: Gaoxs <704041637@qq.com>
Date: Mon, 28 Sep 2020 11:02:36 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=B5=8B=E8=AF=95log;?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B4=AD=E7=89=A9=E8=BD=A6=E6=97=A0=E6=B3=95?=
=?UTF-8?q?=E9=80=89=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
libs/wechat.js | 7 +++++--
pages/Loading/index.vue | 7 +++----
pages/shop/GoodsCon/index.vue | 8 +++++++-
pages/shop/ShoppingCart/index.vue | 4 ++--
pages/user/UserAccount/index.vue | 30 +++++++++++++++---------------
store/index.js | 28 +++++++++++++++-------------
6 files changed, 47 insertions(+), 37 deletions(-)
diff --git a/libs/wechat.js b/libs/wechat.js
index 021ddee..222a4a4 100644
--- a/libs/wechat.js
+++ b/libs/wechat.js
@@ -157,7 +157,7 @@ export async function auth(code) {
return new Promise((resolve, reject) => {
let loginType = cookie.get(LOGINTYPE);
let spread = cookie.get('spread');
- alert(spread)
+ console.log('微信授权登录前获取spread', spread)
wechatAuth(code, spread, loginType)
.then(({ data }) => {
console.log(data)
@@ -167,7 +167,10 @@ export async function auth(code) {
cookie.set(WX_AUTH, code, expires_time);
cookie.remove(STATE_KEY);
loginType && cookie.remove(LOGINTYPE);
- resolve();
+ console.log('微信公众号授权登录,获取用户信息')
+ store.dispatch('getUser').finally(() => {
+ resolve();
+ })
})
.catch(reject);
}).catch(error => {
diff --git a/pages/Loading/index.vue b/pages/Loading/index.vue
index 178598d..713628e 100644
--- a/pages/Loading/index.vue
+++ b/pages/Loading/index.vue
@@ -18,6 +18,7 @@
wxappAuth,
} from "@/api/user";
import dayjs from "dayjs";
+ import store from "@/store";
import cookie from "@/utils/store/cookie";
import {
parseQuery,
@@ -34,7 +35,7 @@
return {};
},
onShow() {
-
+ console.log('getUser')
var url = handleQrCode();
if (!url) {
url = handleUrlParam(getCurrentPageUrlWithArgs())
@@ -55,9 +56,7 @@
if (this.$store.getters.token) {
// 如果token存在,直接进行进页面
console.log('登录状态存在,直接进页面')
- this.getUser().finally(() => {
- this.toLaunch();
- })
+ this.toLaunch();
return;
}
console.log('进行登录操作')
diff --git a/pages/shop/GoodsCon/index.vue b/pages/shop/GoodsCon/index.vue
index 1833391..3fb1b88 100644
--- a/pages/shop/GoodsCon/index.vue
+++ b/pages/shop/GoodsCon/index.vue
@@ -135,7 +135,10 @@
-
+
+
+ 首页
+
收藏
@@ -351,6 +354,9 @@
}
}
},
+ goHome() {
+ this.$yrouter.switchTab("/pages/home/index");
+ },
goShoppingCart() {
this.$yrouter.switchTab("/pages/shop/ShoppingCart/index");
},
diff --git a/pages/shop/ShoppingCart/index.vue b/pages/shop/ShoppingCart/index.vue
index d0f2798..5bdc52d 100644
--- a/pages/shop/ShoppingCart/index.vue
+++ b/pages/shop/ShoppingCart/index.vue
@@ -28,7 +28,7 @@
@@ -113,7 +113,7 @@
diff --git a/pages/user/UserAccount/index.vue b/pages/user/UserAccount/index.vue
index 0b6cfbc..956001f 100644
--- a/pages/user/UserAccount/index.vue
+++ b/pages/user/UserAccount/index.vue
@@ -97,21 +97,21 @@ export default {
},
getActivity: function() {
let that = this;
- getActivityStatus().then(
- res => {
- that.activity.is_bargin = res.data.is_bargin;
- that.activity.is_pink = res.data.is_pink;
- that.activity.is_seckill = res.data.is_seckill;
- },
- err => {
- uni.showToast({
- title:
- err.msg || err.response.data.msg || err.response.data.message,
- icon: "none",
- duration: 2000
- });
- }
- );
+ // getActivityStatus().then(
+ // res => {
+ // that.activity.is_bargin = res.data.is_bargin;
+ // that.activity.is_pink = res.data.is_pink;
+ // that.activity.is_seckill = res.data.is_seckill;
+ // },
+ // err => {
+ // uni.showToast({
+ // title:
+ // err.msg || err.response.data.msg || err.response.data.message,
+ // icon: "none",
+ // duration: 2000
+ // });
+ // }
+ // );
}
}
};
diff --git a/store/index.js b/store/index.js
index e6e45dc..29f34df 100644
--- a/store/index.js
+++ b/store/index.js
@@ -90,22 +90,24 @@ const vuexStore = new Vuex.Store({
userInfo({ state, commit }, force) {
if (state.userInfo !== null && !force) {
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 }) {
+ if (!state.token) {
+ return Promise.reject('未获取到token');
+ }
return new Promise(reslove => {
getUserInfo().then(res => {
console.log(res)