功能:重建指尖管理师规划系统
This commit is contained in:
@@ -7,6 +7,11 @@ assert.strictEqual(
|
||||
'/pages/order-detail/index?id=10'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.normalizeActionPath('/orders'),
|
||||
'/pages/orders/index'
|
||||
)
|
||||
|
||||
assert.strictEqual(
|
||||
navigation.normalizeActionPath('/after-sales?orderId=10'),
|
||||
'/pages/after-sales/index?orderId=10'
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
const CUSTOMER_HOME_PATH = '/pages/home/index'
|
||||
const ADMIN_LOGIN_PATH = '/admin/pages/login/index'
|
||||
|
||||
function getCurrentApp() {
|
||||
return typeof getApp === 'function' ? getApp() : null
|
||||
}
|
||||
|
||||
function clearCustomerSession() {
|
||||
const app = getCurrentApp()
|
||||
if (app && typeof app.clearUserSession === 'function') {
|
||||
app.clearUserSession()
|
||||
return
|
||||
}
|
||||
try {
|
||||
wx.removeStorageSync('accessToken')
|
||||
wx.removeStorageSync('refreshToken')
|
||||
wx.removeStorageSync('userInfo')
|
||||
wx.removeStorageSync('needSetPassword')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
function clearAdminSession() {
|
||||
const app = getCurrentApp()
|
||||
if (app && typeof app.clearAdminSession === 'function') {
|
||||
app.clearAdminSession()
|
||||
return
|
||||
}
|
||||
try {
|
||||
wx.removeStorageSync('adminAccessToken')
|
||||
wx.removeStorageSync('adminRefreshToken')
|
||||
wx.removeStorageSync('adminUserInfo')
|
||||
wx.removeStorageSync('adminPermissions')
|
||||
wx.removeStorageSync('adminCurrentShop')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
function relaunch(url) {
|
||||
wx.reLaunch({ url })
|
||||
}
|
||||
|
||||
function openAdminLogin() {
|
||||
clearCustomerSession()
|
||||
relaunch(ADMIN_LOGIN_PATH)
|
||||
}
|
||||
|
||||
function openCustomerHome() {
|
||||
clearAdminSession()
|
||||
relaunch(CUSTOMER_HOME_PATH)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ADMIN_LOGIN_PATH,
|
||||
CUSTOMER_HOME_PATH,
|
||||
clearCustomerSession,
|
||||
clearAdminSession,
|
||||
openAdminLogin,
|
||||
openCustomerHome
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
const assert = require('assert')
|
||||
|
||||
let relaunchedTo = ''
|
||||
let customerCleared = false
|
||||
let adminCleared = false
|
||||
|
||||
global.wx = {
|
||||
reLaunch(options) {
|
||||
relaunchedTo = options.url
|
||||
if (typeof options.success === 'function') {
|
||||
options.success()
|
||||
}
|
||||
},
|
||||
removeStorageSync() {},
|
||||
setStorageSync() {},
|
||||
getStorageSync() {
|
||||
return ''
|
||||
},
|
||||
removeTabBarBadge(options) {
|
||||
if (options && typeof options.fail === 'function') {
|
||||
options.fail()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global.getApp = () => ({
|
||||
clearUserSession() {
|
||||
customerCleared = true
|
||||
},
|
||||
clearAdminSession() {
|
||||
adminCleared = true
|
||||
}
|
||||
})
|
||||
|
||||
const sessionSwitch = require('./session-switch')
|
||||
|
||||
sessionSwitch.openAdminLogin()
|
||||
assert.strictEqual(customerCleared, true)
|
||||
assert.strictEqual(relaunchedTo, '/admin/pages/login/index')
|
||||
|
||||
sessionSwitch.openCustomerHome()
|
||||
assert.strictEqual(adminCleared, true)
|
||||
assert.strictEqual(relaunchedTo, '/pages/home/index')
|
||||
Reference in New Issue
Block a user