完善功能

This commit is contained in:
wangxiaowei
2026-04-17 21:52:51 +08:00
parent c3639526d1
commit 7f8f15b809
12 changed files with 1364 additions and 426 deletions

View File

@ -230,11 +230,12 @@ import {
smsCodeLogin,
opLogin,
authLogin,
updateUser
updateUser,
scanLogin
} from '@/api/app'
import { bindSuperior } from '@/api/user'
import wechath5 from '@/utils/wechath5'
import { isWeixinClient, currentPage, client, trottle } from '@/utils/tools'
import { isWeixinClient, currentPage, client, trottle, strToParams } from '@/utils/tools'
import { SMSType } from '@/utils/type'
import Cache from '@/utils/cache'
import { BACK_URL, INVITE_CODE } from '@/config/cachekey'
@ -259,11 +260,14 @@ export default {
showLoginPop: false,
loginData: {},
showModel: false,
phoneLogin: false
phoneLogin: false,
scanParams: {},
isScanEntry: false
}
},
async onLoad(option) {
async onLoad(args) {
// this.initScanParams()
this.mnpLoginFun = trottle(this.mnpLoginFun)
this.appWxLogin = trottle(this.appWxLogin)
this.getCodeUrl = trottle(this.getCodeUrl)
@ -276,6 +280,64 @@ export default {
methods: {
...mapMutations(['login']),
...mapActions(['getUser']),
initScanParams() {
const backUrl = Cache.get(BACK_URL)
console.log("🚀 ~ backUrl:", backUrl)
if (!backUrl || typeof backUrl !== 'string') {
this.isScanEntry = false
return
}
const href = backUrl.includes('?') ? backUrl.split('?')[0] : ''
const queryString = backUrl.includes('?') ? backUrl.split('?')[1] : ''
if (!queryString) {
this.isScanEntry = false
return
}
if (!queryString && !href && href != '/bundle/pages/user_spread/user_spread') {
this.isScanEntry = false
return
}
let scanQuery = {}
try {
scanQuery = strToParams(queryString)
} catch (error) {
scanQuery = {}
}
// scene 里可能还包了一层参数,如 scene=type%3Dxx%26id%3D1
if (scanQuery.scene && typeof scanQuery.scene === 'string') {
try {
const sceneQuery = strToParams(decodeURIComponent(scanQuery.scene))
scanQuery = {
...scanQuery,
...sceneQuery
}
} catch (error) {}
}
console.log("🚀 ~ Object.keys(scanQuery):", Object.keys(scanQuery).length)
console.log("🚀 ~ href:", href)
console.log(scanQuery.type)
if (href && href == '/bundle/pages/user_spread/user_spread' && Object.keys(scanQuery).length > 0 && scanQuery.type) {
this.isScanEntry = true
} else {
this.isScanEntry = false
}
},
async handleScanLogin() {
if (!this.isScanEntry) return true
const { code, msg } = await scanLogin(this.scanParams)
if (code != 1) {
this.$toast({
title: msg || '扫码登录处理失败'
})
return false
}
return true
},
// 开启小程序微信授权
isOaWxAuth() {
const { h5_wechat_auth } = this.appConfig
@ -337,6 +399,7 @@ export default {
nickname: nickName,
headimgurl: avatarUrl
})
console.log("🚀 ~ data:", data)
if (code == 1) {
if (data.is_new_user) {
uni.hideLoading()
@ -407,6 +470,8 @@ export default {
async loginHandle(data) {
this.login(data)
uni.hideLoading()
const scanSuccess = await this.handleScanLogin()
if (!scanSuccess) return
// 绑定邀请码
const inviteCode = Cache.get(INVITE_CODE)
if (inviteCode) {