feat: 小程序统一走 Go 后台,咨询与登录切到 /api/v1

去掉协会 WebView 和魔方账密页,微信登录与咨询接口共用同一 token 和拦截器。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-09-15 00:26:28 +08:00
co-authored by Cursor
parent 6e97f01378
commit b09d82df8d
40 changed files with 3852 additions and 285 deletions
+35 -31
View File
@@ -154,25 +154,41 @@
}
}
const afterLogin = () => {
if (type.value == 1) {
uni.reLaunch({
url: "/pages/index/index"
})
} else if (type.value == 3) {
uni.reLaunch({
url: path.value
})
} else {
uni.navigateBack({
delta: 1
})
}
}
const toLogin = (code, encryptedData, iv) => {
const params = {
grantType: "mini_app",
account: code,
}
let others = {
encryptedData: encryptedData,
iv: iv,
code: code
}
params.others = JSON.stringify(others)
dohttp.post(urls.loginUrl, params).then((result) => {
userInfo.value.token = result.accessToken
uni.setStorageSync('token', result.accessToken)
dohttp.post(urls.loginUrl, { code, encryptedData, iv }).then((result) => {
const token = result.token || result.accessToken
userInfo.value.token = token
uni.setStorageSync('token', token)
uni.removeStorageSync('yxg_token')
if (result.user) {
uni.setStorageSync('userinfo', {
id: result.user.id,
avatarUrl: result.user.avatar_url,
nickName: result.user.nickname
})
}
loginPop.value.close()
getUserInfo()
}).catch((e) => {
uni.showToast({
title: (e && e.errMsg ? String(e.errMsg).replace('【request】', '') : '登录失败'),
icon: 'none'
})
})
}
const getUserInfo = () => {
@@ -182,23 +198,11 @@
avatarUrl: result.avatarUrl,
nickName: result.nickName
}
uni.setStorageSync('userinfo', userinfo)
if (type.value == 1) {
uni.reLaunch({
url: "/pages/index/index"
})
} else if (type.value == 3) {
uni.reLaunch({
url: path.value
})
} else {
uni.navigateBack({
delta: 1
})
}
afterLogin()
}).catch(() => {
afterLogin()
})
}