Skip to content

Commit

Permalink
fix:切换账号重开app之后还是上一个号的课程
Browse files Browse the repository at this point in the history
fix:登录新账号重开app之后还是上一个号的课程
  • Loading branch information
eric-gitta-moore committed May 30, 2022
1 parent a9d3e69 commit 2f435ff
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
14 changes: 11 additions & 3 deletions biz/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import userApi from '../api/user.js'
import UserEntity from '@/entity/User.js'
import WeappCookie from 'weapp-cookie'

/**
* 登录
Expand All @@ -13,6 +14,13 @@ async function login({
validateCode
}, raw = false) {
// await userApi.loginPage()

console.log(`WeappCookie.dir()`, WeappCookie.getCookies())
WeappCookie.clearCookies()
console.log(`%c loginAs.UserBiz.doLogin`, `color:skyblue`, {
account,
pwd
}, WeappCookie.getCookies())
let r = await userApi.login({
account,
pwd,
Expand Down Expand Up @@ -116,8 +124,8 @@ async function doLogin(context, {
// await context.$store.dispatch('user/getLoginParams')
// await context.$store.dispatch('course/getCourseList', true)
// await context.$store.dispatch('course/refreshActivitiesOfAllCourse')


// uni.unPreloadPage({
// url: "/pages/activity/activity"
// })
Expand All @@ -130,7 +138,7 @@ async function doLogin(context, {
// uni.preloadPage({
// url: "/pages/user/user"
// });

// }
// a()
// }, 0)
Expand Down
5 changes: 0 additions & 5 deletions pages/user/user.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@
account,
pwd
}) {
uni.removeStorageSync(Constant.cookieStorageKey)
console.log(`%c loginAs.UserBiz.doLogin`, `color:skyblue`, {
account,
pwd
})
let r = UserBiz.doLogin(this, {
account,
pwd
Expand Down
43 changes: 22 additions & 21 deletions store/modules/course.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@ const actions = {
/**
* 获取课程列表
*/
async getCourseList(context, forceRefresh = false) {
async getCourseList(context, forceRefresh = true) {
let courseList = context.state.courseList
if (courseList.length === 0) {
let storage = await uni.getStorage({
key: Constant.courseList
})
// debugger
if (storage.length === 2) {
courseList = []
for (let item of storage[1].data) {
courseList.push(new CourseEntity(item))
}
}
}
if (courseList.length === 0 || forceRefresh) {
courseList = await courseBiz.getCourse()
// debugger
uni.setStorage({
key: Constant.courseList,
data: courseList
})
}
// if (courseList.length === 0) {
// let storage = await uni.getStorage({
// key: Constant.courseList
// })
// // debugger
// if (storage.length === 2) {
// courseList = []
// for (let item of storage[1].data) {
// courseList.push(new CourseEntity(item))
// }
// }
// }
// if (courseList.length === 0 || forceRefresh) {
// courseList = await courseBiz.getCourse()
// // debugger
// uni.setStorage({
// key: Constant.courseList,
// data: courseList
// })
// }
courseList = await courseBiz.getCourse()
// console.warn(courseList, forceRefresh)
context.commit('SET_LIST', courseList)
return courseList
Expand Down

0 comments on commit 2f435ff

Please sign in to comment.