Skip to content

Commit 2f435ff

Browse files
fix:切换账号重开app之后还是上一个号的课程
fix:登录新账号重开app之后还是上一个号的课程
1 parent a9d3e69 commit 2f435ff

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

biz/user.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import userApi from '../api/user.js'
22
import UserEntity from '@/entity/User.js'
3+
import WeappCookie from 'weapp-cookie'
34

45
/**
56
* 登录
@@ -13,6 +14,13 @@ async function login({
1314
validateCode
1415
}, raw = false) {
1516
// await userApi.loginPage()
17+
18+
console.log(`WeappCookie.dir()`, WeappCookie.getCookies())
19+
WeappCookie.clearCookies()
20+
console.log(`%c loginAs.UserBiz.doLogin`, `color:skyblue`, {
21+
account,
22+
pwd
23+
}, WeappCookie.getCookies())
1624
let r = await userApi.login({
1725
account,
1826
pwd,
@@ -116,8 +124,8 @@ async function doLogin(context, {
116124
// await context.$store.dispatch('user/getLoginParams')
117125
// await context.$store.dispatch('course/getCourseList', true)
118126
// await context.$store.dispatch('course/refreshActivitiesOfAllCourse')
119-
120-
127+
128+
121129
// uni.unPreloadPage({
122130
// url: "/pages/activity/activity"
123131
// })
@@ -130,7 +138,7 @@ async function doLogin(context, {
130138
// uni.preloadPage({
131139
// url: "/pages/user/user"
132140
// });
133-
141+
134142
// }
135143
// a()
136144
// }, 0)

pages/user/user.nvue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,6 @@
202202
account,
203203
pwd
204204
}) {
205-
uni.removeStorageSync(Constant.cookieStorageKey)
206-
console.log(`%c loginAs.UserBiz.doLogin`, `color:skyblue`, {
207-
account,
208-
pwd
209-
})
210205
let r = UserBiz.doLogin(this, {
211206
account,
212207
pwd

store/modules/course.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,29 @@ const actions = {
3232
/**
3333
* 获取课程列表
3434
*/
35-
async getCourseList(context, forceRefresh = false) {
35+
async getCourseList(context, forceRefresh = true) {
3636
let courseList = context.state.courseList
37-
if (courseList.length === 0) {
38-
let storage = await uni.getStorage({
39-
key: Constant.courseList
40-
})
41-
// debugger
42-
if (storage.length === 2) {
43-
courseList = []
44-
for (let item of storage[1].data) {
45-
courseList.push(new CourseEntity(item))
46-
}
47-
}
48-
}
49-
if (courseList.length === 0 || forceRefresh) {
50-
courseList = await courseBiz.getCourse()
51-
// debugger
52-
uni.setStorage({
53-
key: Constant.courseList,
54-
data: courseList
55-
})
56-
}
37+
// if (courseList.length === 0) {
38+
// let storage = await uni.getStorage({
39+
// key: Constant.courseList
40+
// })
41+
// // debugger
42+
// if (storage.length === 2) {
43+
// courseList = []
44+
// for (let item of storage[1].data) {
45+
// courseList.push(new CourseEntity(item))
46+
// }
47+
// }
48+
// }
49+
// if (courseList.length === 0 || forceRefresh) {
50+
// courseList = await courseBiz.getCourse()
51+
// // debugger
52+
// uni.setStorage({
53+
// key: Constant.courseList,
54+
// data: courseList
55+
// })
56+
// }
57+
courseList = await courseBiz.getCourse()
5758
// console.warn(courseList, forceRefresh)
5859
context.commit('SET_LIST', courseList)
5960
return courseList

0 commit comments

Comments
 (0)