feat: 微信支付宝登录对接

This commit is contained in:
2025-09-23 23:19:16 +08:00
parent 0f033c1d8d
commit a22b987ed9
7 changed files with 463 additions and 492 deletions
+16 -20
View File
@@ -52,7 +52,7 @@
@click="registerFun"
:loading="butLoading"
>
登录
登录
</view>
<up-toast ref="uToastRef"></up-toast>
@@ -62,7 +62,7 @@
<script>
import { SMS_TYPE } from "@/utils/enumUtils.js";
import { getUserList } from "@/api/common.js";
import { wechatLogin } from "@/api/auth.js";
import { wechatLogin,alipayLogin } from "@/api/auth.js";
import {
setStorageFun,
TOKEN_NAME,
@@ -77,7 +77,7 @@ export default {
form: {
mobile: null,
smsCode: null, // 验证码
wechatCode: null,
token: null,
},
inputCss: {
height: "80rpx",
@@ -89,17 +89,14 @@ export default {
countdown: false, // 清空倒计时
butLoading: false,
disabled: false,
type: 1, //1.微信 2.支付宝
};
},
onLoad() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const id = currentPage.options?.key;
if (id) {
this.disabled = true;
}
this.form.wechatCode = id;
onLoad(option) {
this.form.token = option.token;
this.type = option.type;
console.log("-----1", option, this.form.token, this.type );
},
methods: {
jumpMine() {
@@ -130,13 +127,12 @@ export default {
mobile: form.mobile,
smsCode: form.smsCode,
isValid: true,
wechatCode: form.id,
token: form.token,
};
const response = await wechatLogin(params);
console.log("微信登录接口返回:", response);
if (resp && resp.bizcode === 100) {
const data = resp.data;
const response = this.type == 1 ? await wechatLogin(params) : await alipayLogin(params);
console.log("微信登录接口返回:", params, response);
if (response && response.bizcode === 100) {
const data = response.data;
setStorageFun(TOKEN_NAME, data.token);
// 用于无感登录
setStorageFun(USER_KEY, "");
@@ -153,7 +149,7 @@ export default {
setStorageFun(USER_LOGIN_TIME, currentTimeStamp);
this.$refs.uToastRef.show({
type: "success",
message: resp.msg,
message: response.msg,
});
setTimeout(() => {
uni.switchTab({
@@ -180,7 +176,7 @@ export default {
const params = {
mobile: form.mobile,
type: SMS_TYPE.WECHAT,
type:this.type == 1 ? SMS_TYPE.WECHAT : SMS_TYPE.ALIPAY,
};
const response = await getUserList(params);
if (response && response.bizcode === 100) {
@@ -200,7 +196,7 @@ export default {
.header_ {
display: flex;
align-items: center;
padding: 0 30rpx;
padding: calc(24rpx + env(safe-area-inset-bottom)) 30rpx 0 30rpx;
.title_ {
font-weight: bold;
font-size: 36rpx;