Commit 37806a6b by 李伟康

修改登录

1 parent 97b1dcb1
......@@ -12,7 +12,7 @@ import { setSystem_info } from '~/utils/cache/storageApi'
import getUpdateManager from './utils/lib/wxUpdateManager'
// 埋点
import './utils/track/Track'
// import './utils/track/Track'
import eventbus from './utils/evenbus'
......
// login/index/components/LoginBox.js
import USERAPI from '~/api/usersApi/index'
import { setSessionId } from '~/utils/cache/storageApi'
import {
setSessionId,
setUserInfo
} from '~/utils/cache/storageApi'
import {
setRouteData
} from '~/login/lib/index'
let thisPage
Component({
options: {
......@@ -175,17 +180,27 @@ Component({
const {
loginUserInfoList,
sessionId
} = data
} = data, {
options: {
targetPath
}
} = thisPage
if (loginUserInfoList.length > 1) {
wx.$router.go('login.accountItems')
} else {
wx.$router.go('login.accountItems')
USERAPI.selectAccountLogin({
id: loginUserInfoList[0].uuid,
sessionId
}).then(res =>{
console.log(res)
}).then(res => {
setUserInfo(loginUserInfoList[0])
setSessionId(sessionId)
if (targetPath) {
const {
url,
obj
} = setRouteData(targetPath)
wx.$router.reLaunch(url, obj)
} else wx.$router.go('pages.index')
})
}
} else wx.$api.showToast(message || '系统异常')
......
......@@ -9,7 +9,6 @@ Page({
disabled: true
},
onRoute(options){
console.log(options)
},
/**
* 生命周期函数--监听页面加载
......
export const setRouteData = targetPath => {
let [url, query] = targetPath.split('?'),
obj = {}
if (query) {
const [key, val] = query.split('=')
obj = {
[key]: val
}
}
return {
url,
obj
}
}
\ No newline at end of file
import {
setRouteData
} from '../lib/index'
import {
getSessionId,
} from '~/utils/cache/storageApi'
Page({
/**
......@@ -26,23 +32,26 @@ Page({
*/
onShow() {
wx.$api.showLoading()
const {
sessionId,
} = wx.$storage.get(), {
url,
targetPath = decodeURIComponent(url)
} = this.options
console.log(targetPath)
const sessionId = getSessionId(),
{
url,
targetPath = url ? decodeURIComponent(url) : ''
} = this.options
wx.nextTick(() => {
if (sessionId) {
// wx.$router.reLaunch('login.index')
let url = 'pages.index',
obj = {}
if (targetPath) {
url = setRouteData(targetPath).url
obj = setRouteData(targetPath).obj
}
wx.$router.reLaunch(url, obj)
} else {
wx.$router.reLaunch('login.index', {
targetPath
})
let obj = {}
if (targetPath) obj.targetPath = targetPath
wx.$router.reLaunch('login.index', obj)
}
})
},
/**
......@@ -71,12 +80,5 @@ Page({
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
......@@ -17,7 +17,7 @@
{
"name": "携带目标页面",
"pathName": "login/loading/loading",
"query": "url=pages%2Ftab%2Findex%2Findex%3Fid%3D123",
"query": "url=%2Fpages%2Ftab%2Foutput%2Foutput%3Fid%3D123",
"launchMode": "default",
"scene": null
}
......
......@@ -20,6 +20,7 @@ class Router {
wx.onAppRoute(e => {
let thisPage = this.getPageInstance()
if (thisPage) {
thisPage.options = this[_query]
this.setNavigationBarTitleText(thisPage)
let onRoute = thisPage.onRoute
typeof onRoute === 'function' && onRoute(this[_query])
......
......@@ -51,7 +51,6 @@ class Storage {
*/
get = (key, syncFlag = true) => {
// 有值默认取key值
debugger
if (key) {
// 判断值是否是指定的对象值
let tmpKey = this.checkKeyType(key, 1)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!