Commit e13c521e by 张立顺

解决合并冲突

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