Commit ff257415 by 张立顺

feat v4.34.1 功能需求开发

1 parent f4099b51
import {
setSessionId,
setUserInfo
} from '~/utils/cache/storageApi'
import { setSessionId, setUserInfo } from '~/utils/cache/storageApi'
import USERAPI from '~/api/usersApi/index'
const setRouteData = targetPath => {
let [url, query] = targetPath.split('?'),
......@@ -19,18 +16,11 @@ const setRouteData = targetPath => {
}
}
/**选择账号登录 */
const selectAccountLogin = ({
id,
sessionId
}) => {
const selectAccountLogin = ({ id, sessionId }) => {
USERAPI.selectAccountLogin({
id,
sessionId
}).then(({
code,
data,
message
}) => {
}).then(({ code, data, message }) => {
if (code == '0') {
console.log(data)
setLoginInfo(data.loginUserInfoList[0], data.sessionId)
......@@ -43,6 +33,25 @@ const setLoginInfo = (userInfo, sessionId) => {
wx.$api.showToast('仅支持服务商类型账户登录')
return
}
const {
options: { reportDate }
} = wx.$router.getPageInstance()
// 跳转别的小程序
if (reportDate) {
let params = `approvedBy=${userInfo.name}&`
for (const key in options) {
params += `${key}=${options[key]}&`
}
return wx.navigateToMiniProgram({
appId: 'wx570d9331f9ace0bd',
path: `tabWorkOrder/pages/staffDaily/staffDaily` + '?' + params,
envVersion: 'trial',
success(res) {
// 打开成功
}
})
}
// 自动创建服务中心
initServiceCenter()
setUserInfo(userInfo)
......@@ -55,23 +64,14 @@ const initServiceCenter = () => {
/**成功跳转 */
const loginSuccess = () => {
const {
options: {
targetPath
}
options: { targetPath }
} = wx.$router.getPageInstance()
if (targetPath) {
const {
url,
obj
} = setRouteData(targetPath)
const { url, obj } = setRouteData(targetPath)
wx.$router.reLaunch(url, obj)
} else wx.$router.reLaunch('pages.index')
}
const loginModal = async ({
message,
confirmText,
cancelText
}) => {
const loginModal = async ({ message, confirmText, cancelText }) => {
return new Promise((resolve, reject) => {
wx.showModal({
content: message || '网络异常',
......@@ -86,10 +86,7 @@ const loginModal = async ({
})
}
/**手机号&微信登录:是否跳转登录列表页 */
const checkLoginUserInfo = ({
loginUserInfoList,
sessionId
}) => {
const checkLoginUserInfo = ({ loginUserInfoList, sessionId }) => {
const thisPage = wx.$router.getPageInstance()
/**多个账号 */
if (loginUserInfoList.length > 1)
......@@ -97,8 +94,7 @@ const checkLoginUserInfo = ({
sessionId,
...thisPage.options
})
/**只有一个账号 */
else
/**只有一个账号 */ else
selectAccountLogin({
id: loginUserInfoList[0].uuid,
sessionId
......@@ -112,4 +108,4 @@ module.exports = {
setLoginInfo,
loginModal,
initServiceCenter
}
\ No newline at end of file
}
......@@ -98,10 +98,17 @@ Page({
init() {
wx.nextTick(() => {
const sessionId = getSessionId(),
{ url, targetPath = url ? decodeURIComponent(url) : '' } = this.options
{ url, targetPath = url ? decodeURIComponent(url) : '', reportDate } = this.options
let path = 'pages.index',
obj = {}
if (targetPath) obj.targetPath = targetPath
// 如果是日报跳转进来的
if (reportDate) {
obj = {
...obj,
...this.options
}
}
if (sessionId) {
USERAPI.checkSession().then(({ code }) => {
if (code == '0') {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!