Merge branch 'master' of https://gitea.zianxin.com/zax/biz-mobile-react-cloud
This commit is contained in:
commit
b2d022ce5f
16 files changed
+520
-35
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { APPENV } from "@/sheep/constant"
|
||||
import { getAppInfo, getLaunchParam, isDevEnv } from "@/sheep/utils/app"
|
||||
import { getAppInfo, getLaunchParam, getUrlQueryParam, isDevEnv } from "@/sheep/utils/app"
|
||||
import { onShow } from "@dcloudio/uni-app"
|
||||
|
||||
const moduleList = [
|
||||
@@ -61,7 +61,10 @@ const moduleList = [
|
||||
]
|
||||
|
||||
onShow(() => {
|
||||
uni.removeStorageSync("launchParam")
|
||||
const fromUrl = getUrlQueryParam("launchParam")
|
||||
if (fromUrl) {
|
||||
uni.setStorageSync("launchParam", fromUrl)
|
||||
}
|
||||
jumpByParam()
|
||||
})
|
||||
|
||||
@@ -69,9 +72,15 @@ const jumpByParam = async () => {
|
||||
const appInfo = await getAppInfo() // 环境判断
|
||||
const launchParam = getLaunchParam() // 获取启动参数
|
||||
|
||||
// 浙政钉环境
|
||||
// 浙政钉环境(诗画不走此分支)
|
||||
if (appInfo == APPENV.ZZD) {
|
||||
const { tryZzdEntryLogin } = await import("@/sheep/utils/request")
|
||||
const zzdR = await tryZzdEntryLogin()
|
||||
if (zzdR !== "ok") return
|
||||
switch (launchParam) {
|
||||
case "thirdApp":
|
||||
uni.setStorageSync("launchParam", launchParam)
|
||||
return uni.reLaunch({ url: "/pages/thirdApp/happyMall" })
|
||||
case "canteen": // 食堂
|
||||
uni.setStorageSync("launchParam", launchParam)
|
||||
uni.switchTab({ url: "/pages/tabbar/canteen" })
|
||||
@@ -101,6 +110,11 @@ const jumpByParam = async () => {
|
||||
uni.switchTab({ url: "/pages/tabbar/prosperityShopMchList" })
|
||||
break
|
||||
default:
|
||||
if (!launchParam) {
|
||||
uni.showToast({ title: "缺少入口参数,请从工作台重新进入", icon: "none", duration: 3500 })
|
||||
} else {
|
||||
uni.showToast({ title: "暂不支持的入口:" + launchParam, icon: "none", duration: 3500 })
|
||||
}
|
||||
uni.hideTabBar()
|
||||
break
|
||||
}
|
||||
|
||||
+14
-5
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<crud-layout mainIsScroll bg="/static/page/blue-bg.png">
|
||||
<template #main-top>
|
||||
<view class="flex items-center py-3 px-5" @tap="doUserArea">
|
||||
<view class="flex items-center" v-if="state.userInfo?.sysUser?.userId">
|
||||
<view class="flex items-center py-3 px-5">
|
||||
<view class="flex items-center" v-if="state.userInfo?.sysUser?.userId" @tap="doUserArea">
|
||||
<image v-if="state.userInfo?.sysUser?.avatar" class="size-100rpx rounded-full"
|
||||
:src="filePath(state.userInfo.sysUser.avatar)" mode="aspectFill" />
|
||||
<image v-else class="w-100rpx h-100rpx rounded-full" src="/static/icon/default-avatar.png"
|
||||
@@ -115,6 +115,7 @@ const STORAGE_KEYS = {
|
||||
}
|
||||
|
||||
const doUserArea = () => {
|
||||
if (!state.userInfo?.sysUser?.userId) return
|
||||
modifyUserRef.value?.open()
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ const storage = {
|
||||
if (res.confirm) {
|
||||
uni.clearStorageSync()
|
||||
state.userInfo = {}
|
||||
uni.reLaunch({ url: "/pages/tabbar/my" })
|
||||
uni.reLaunch({ url: "/pages/tabbar/my?reauth=1" })
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -233,6 +234,9 @@ const login = {
|
||||
if (response.msg == "token已失效") {
|
||||
uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", icon: "none", duration: 6000 })
|
||||
} else {
|
||||
if (response.code == -1) {
|
||||
storage.saveToken({ data: -1 })
|
||||
}
|
||||
uni.showToast({ title: response.msg || "登录失败", icon: "none" })
|
||||
}
|
||||
}
|
||||
@@ -242,7 +246,7 @@ const login = {
|
||||
if (isEmpty(tokenStorage) || isEmpty(userStorage)) {
|
||||
try {
|
||||
uni.showLoading({ title: "登录中...", mask: true })
|
||||
const res = await userApi.auth(token)
|
||||
const res = await userApi.auth({ token })
|
||||
|
||||
if (res.code == 0) {
|
||||
storage.saveToken(res.data)
|
||||
@@ -376,7 +380,7 @@ const initMenuConfig = () => {
|
||||
}
|
||||
}
|
||||
|
||||
onLoad(async () => {
|
||||
onLoad(async (options: Record<string, string | undefined>) => {
|
||||
const app = getApp()
|
||||
app._initTabbar()
|
||||
|
||||
@@ -393,6 +397,11 @@ onLoad(async () => {
|
||||
|
||||
// 获取存储中的用户信息
|
||||
storage.getUserInfo()
|
||||
|
||||
if (options?.reauth === "1") {
|
||||
await login.checkAppInfo()
|
||||
storage.getUserInfo()
|
||||
}
|
||||
})
|
||||
|
||||
const isMallMchUser = async () => {
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue"
|
||||
import { onLoad } from "@dcloudio/uni-app"
|
||||
import { constant } from "@@/index"
|
||||
import { userApi } from "@@/api"
|
||||
|
||||
/** 与后端 ThirdPartyZzdBizCodes.SYS_USER_NOT_FOUND_FOR_ZZD_BIND 一致 */
|
||||
const CODE_ZZD_SYS_USER_NOT_FOUND = 46001
|
||||
|
||||
const bindSessionId = ref("")
|
||||
const displayName = ref("")
|
||||
const mobile = ref("")
|
||||
const smsCode = ref("")
|
||||
|
||||
onLoad((q: Record<string, string | undefined>) => {
|
||||
bindSessionId.value = decodeURIComponent(q.bindSessionId || "")
|
||||
displayName.value = decodeURIComponent(q.displayName || "")
|
||||
})
|
||||
|
||||
async function sendSms() {
|
||||
const m = mobile.value.trim()
|
||||
if (!m) {
|
||||
uni.showToast({ title: "请输入手机号", icon: "none" })
|
||||
return
|
||||
}
|
||||
try {
|
||||
const r: any = await userApi.zzdLoginSms(m)
|
||||
if (r?.code !== 0) {
|
||||
uni.showToast({ title: r?.msg || "发送失败", icon: "none" })
|
||||
return
|
||||
}
|
||||
uni.showToast({ title: "验证码已发送", icon: "none" })
|
||||
} catch (e: any) {
|
||||
uni.showToast({ title: e?.message || "发送失败", icon: "none" })
|
||||
}
|
||||
}
|
||||
|
||||
async function confirm() {
|
||||
const m = mobile.value.trim()
|
||||
const code = smsCode.value.trim()
|
||||
if (!bindSessionId.value || !m || !code) {
|
||||
uni.showToast({ title: "请填写手机号与验证码", icon: "none" })
|
||||
return
|
||||
}
|
||||
uni.showLoading({ title: "核验中...", mask: true })
|
||||
try {
|
||||
const r: any = await userApi.zzdSsoConfirmPhone({
|
||||
bindSessionId: bindSessionId.value,
|
||||
mobilePhone: m,
|
||||
smsCode: code,
|
||||
})
|
||||
if (r?.code !== 0) {
|
||||
if (r?.code === CODE_ZZD_SYS_USER_NOT_FOUND) {
|
||||
uni.showModal({
|
||||
title: "暂无系统账号",
|
||||
content:
|
||||
r?.msg ||
|
||||
"本系统暂无该手机号对应的用户,请联系管理员申请开通账号后,再使用本机号码完成浙政钉绑定登录。",
|
||||
showCancel: false,
|
||||
})
|
||||
} else {
|
||||
uni.showToast({ title: r?.msg || "核验失败", icon: "none" })
|
||||
}
|
||||
return
|
||||
}
|
||||
const tokenKey = constant.storageConstant.TOKEN
|
||||
const userInfoKey = constant.storageConstant.USERINFO
|
||||
uni.setStorageSync(tokenKey, r.data)
|
||||
const { data: userData } = await userApi.userInfo()
|
||||
uni.setStorageSync(userInfoKey, userData)
|
||||
uni.showToast({ title: "登录成功", icon: "none" })
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: "/pages/tabbar/index" })
|
||||
}, 400)
|
||||
} catch (e: any) {
|
||||
uni.showToast({ title: e?.message || "核验失败", icon: "none" })
|
||||
} finally {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<crud-layout title="手机号核验" bg="/static/page/blue-bg.png">
|
||||
<view class="h-30rpx" />
|
||||
<view class="card p-x-30rpx p-y-40rpx">
|
||||
<view v-if="displayName" class="m-b-24rpx text-28rpx color-#666">浙政钉用户:{{ displayName }}</view>
|
||||
<tm-form direction="vertical">
|
||||
<tm-form-item label="手机号" :showBottom="false">
|
||||
<tm-input v-model="mobile" type="number" placeholder="请输入手机号" />
|
||||
</tm-form-item>
|
||||
<view class="h-30rpx" />
|
||||
<tm-form-item label="短信验证码" :showBottom="false">
|
||||
<tm-input v-model="smsCode" type="number" placeholder="验证码" />
|
||||
</tm-form-item>
|
||||
</tm-form>
|
||||
</view>
|
||||
<view
|
||||
class="bg-#f0f5ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-40rpx sub-text-30 color-#0958d9!"
|
||||
@tap="sendSms"
|
||||
>
|
||||
获取验证码
|
||||
</view>
|
||||
<view
|
||||
class="bg-#0094ff p-y-20rpx text-center rounded-40rpx m-x-30rpx m-t-30rpx sub-text-30 color-white!"
|
||||
@tap="confirm"
|
||||
>
|
||||
核验并进入应用
|
||||
</view>
|
||||
</crud-layout>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep() {
|
||||
.tmFormItemLabel {
|
||||
padding-bottom: 10rpx !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user