feat:apple登录

This commit is contained in:
2026-08-17 17:13:40 +08:00
parent 718bd079a6
commit 619c0cacc5
6 changed files with 850 additions and 857 deletions
+8 -1
View File
@@ -8,8 +8,15 @@
"type" : "uni-app:app-android"
},
{
"customPlaygroundType" : "device",
"bundleId" : "com.trustbridge.mm",
"certificateFile" : "/Users/qinxingxing/Documents/alpha/资料/商城证书/int/ios/malldev.p12",
"certificateProfileFile" : "/Users/qinxingxing/Documents/alpha/资料/商城证书/int/ios/malldev.mobileprovision",
"customPlaygroundType" : "local",
"iOSProjectStandardBaseHistory" : {
"current" : "iOS_debug_5.24.ipa"
},
"playground" : "custom",
"runSignStatus" : 0,
"type" : "uni-app:app-ios"
},
{
+32 -68
View File
@@ -2,13 +2,7 @@
<view class="register_warp">
<view class="header_">
<view style="margin-top: 10rpx">
<up-image
src="/static/common/left.png"
width="18"
height="20"
bgColor="#f1f6ff00"
@click="jumpMine"
/>
<up-image src="/static/common/left.png" width="18" height="20" bgColor="#f1f6ff00" @click="jumpMine" />
</view>
<view class="title_">绑定手机号</view>
<view></view>
@@ -16,79 +10,48 @@
<view class="register_ifo_warp">
<view class="register_info_item">
<up-input
placeholder="请输入手机号"
border="surround"
v-model="form.mobile"
:customStyle="inputCss"
></up-input>
<up-input placeholder="请输入手机号" border="surround" v-model="form.mobile" :customStyle="inputCss"></up-input>
</view>
<view class="register_info_item">
<up-input
placeholder="请输入验证码"
border="surround"
v-model="form.smsCode"
:customStyle="inputCss"
>
<up-input placeholder="请输入验证码" border="surround" v-model="form.smsCode" :customStyle="inputCss">
<template #suffix style="margin-right: 10rpx">
<view v-if="countdown" class="code-warp">
<up-count-down
:time="60 * 1000"
format="ss"
@finish="countdown = false"
></up-count-down>
<up-count-down :time="60 * 1000" format="ss" @finish="countdown = false"></up-count-down>
<text style="margin-left: 10rpx">s</text>
</view>
<view v-else @click="getMobileCode" class="code_msg">
获取验证码
<qiaobao-assistant page-key="pages/login_package/bind-phone/bind-phone" title="账户登录" />
</view>
<qiaobao-assistant page-key="pages/login_package/bind-phone/bind-phone" title="账户登录" />
</view>
</template>
</up-input>
</view>
</view>
<view
class="login_comm_but login_comm_but_yes"
@click="submit"
:loading="butLoading"
>
<view class="login_comm_but login_comm_but_yes" @click="submit" :loading="butLoading">
登录
</view>
<view class="policy_warp">
<up-checkbox
name="isCheck"
usedAlone
v-model:checked="isPolicy"
shape="circle"
activeColor="#7934F6"
size="19"
iconSize="18"
>
<view class="policy_warp">
<up-checkbox name="isCheck" usedAlone v-model:checked="isPolicy" shape="circle" activeColor="#7934F6" size="19"
iconSize="18">
<template #label>
<text @click="aa">已阅读并同意</text>
<text class="policy_a_warp" @click="jumpUserAgreement"
>《服务协议》</text
>
<text class="policy_a_warp" @click="jumpUserAgreement">《服务协议》</text>
<text>、</text>
<text class="policy_a_warp" @click="jumpPrivacyAgreement"
>《隐私政策》</text
>
<text class="policy_a_warp" @click="jumpPrivacyAgreement">《隐私政策》</text>
<text>、</text>
<text class="policy_a_warp" @click="jumpProductAgreement"
>《售后保障协议》</text
>
<text class="policy_a_warp" @click="jumpProductAgreement">《售后保障协议》</text>
</template>
</up-checkbox>
</view>
<up-toast ref="uToastRef"></up-toast>
<u-modal :show="tipsShow" title="提示" showCancelButton @cancel="onCancel" @confirm="onConfirm">
<u-modal :show="tipsShow" title="提示" showCancelButton @cancel="onCancel" @confirm="onConfirm">
<view class="slot-content">
我已阅读并同意
<text style="color: #007AFF;">用户协议</text>和<text style="color: #007AFF;">隐私政策</text>
</view>
我已阅读并同意
<text style="color: #007AFF;">用户协议</text>和<text style="color: #007AFF;">隐私政策</text>
</view>
</u-modal>
</view>
</template>
@@ -96,7 +59,7 @@
<script>
import { SMS_TYPE } from "@/utils/enumUtils.js";
import { getUserList } from "@/api/common.js";
import { wechatLogin, alipayLogin } from "@/api/auth.js";
import { wechatLogin, alipayLogin, appleLogin } from "@/api/auth.js";
import {
setStorageFun,
TOKEN_NAME,
@@ -123,7 +86,7 @@ export default {
countdown: false, // 清空倒计时
butLoading: false,
disabled: false,
type: 1, //1.微信 2.支付宝
type: 1, //1.微信 2.支付宝,3.apple
tipsShow: false,
content: '确认绑定手机号吗?',
isPolicy: false,
@@ -136,25 +99,25 @@ export default {
console.log("-----1", option, this.form.token, this.type);
},
methods: {
submit(){
if(!this.isPolicy){
submit() {
if (!this.isPolicy) {
this.tipsShow = true;
}
},
onCancel(){
this.tipsShow = false;
},
onConfirm(){
this.tipsShow = false;
onCancel() {
this.tipsShow = false;
},
onConfirm() {
this.tipsShow = false;
this.isPolicy = true;
this.registerFun();
},
},
jumpMine() {
uni.reLaunch({
url: "/pages/login_package/login/login",
});
},
// 用户协议
// 用户协议
jumpUserAgreement() {
uni.navigateTo({
url: "/pages/mine_package/mine_user_agreement/mine_user_agreement?backPath=login",
@@ -166,7 +129,7 @@ export default {
url: "/pages/mine_package/mine_privacy_agreement/mine_privacy_agreement?backPath=login",
});
},
// 售后保障协议
// 售后保障协议
jumpProductAgreement() {
uni.navigateTo({
url: "/pages/mine_package/mine_product_agreement/mine_product_agreement?backPath=login",
@@ -197,7 +160,7 @@ export default {
token: form.token,
};
const response =
this.type == 1 ? await wechatLogin(params) : await alipayLogin(params);
this.type == 1 ? await wechatLogin(params) : this.type == 2 ? await alipayLogin(params) : await appleLogin(params);
console.log("微信登录接口返回:", params, response);
if (response && response.bizcode === 100) {
const data = response.data;
@@ -257,7 +220,7 @@ export default {
const params = {
mobile: form.mobile,
type: this.type == 1 ? SMS_TYPE.WECHAT : SMS_TYPE.ALIPAY,
type: this.type == 1 ? SMS_TYPE.WECHAT : this.type == 2 ? SMS_TYPE.ALIPAY : SMS_TYPE.APPLE,
};
const response = await getUserList(params);
if (response && response.bizcode === 100) {
@@ -278,6 +241,7 @@ export default {
display: flex;
align-items: center;
padding: calc(24rpx + env(safe-area-inset-bottom)) 30rpx 0 30rpx;
.title_ {
font-weight: bold;
font-size: 36rpx;
+66 -48
View File
@@ -13,8 +13,8 @@
<view class="login_info_item">
<up-input placeholder="请输入手机号/账户名称" border="surround" v-model="form.name" :customStyle="inputCss"
:adjust-position="false" @change="checkNameParam"></up-input>
<qiaobao-assistant page-key="pages/login_package/login/login" title="账户登录" />
</view>
<qiaobao-assistant page-key="pages/login_package/login/login" title="账户登录" />
</view>
<!-- 密码登录 -->
<view class="login_info_item" v-if="loginWay === 'password'">
<up-input placeholder="请输入密码" border="surround" v-model="form.password" :customStyle="inputCss"
@@ -81,7 +81,7 @@
<view class="login_other_item" @click="wechatOneLogin(1)">
<up-image src="/pages/login_package/static/login/WXICON.png" width="44" height="44"
bgColor="#f1f6ff00"></up-image>
微信登录11
微信登录
</view>
</view>
<view class="login_other_icon">
@@ -524,57 +524,75 @@ export default {
}
// #ifdef APP-PLUS
uni.login({
provider: 'apple',
success: async (loginRes) => {
console.log('Apple 登录成功:', loginRes);
const authResult = loginRes.authResult || {};
const params = {
identityToken: authResult.identityToken,
openId: authResult.user,
fullName: authResult.fullName ? `${authResult.fullName.familyName || ''}${authResult.fullName.givenName || ''}` : '',
authorizationCode: authResult.authorizationCode
};
try {
const response = await appleLogin(params);
if (response && response.bizcode === 100) {
if (response.data && response.data.userId) {
this.loginWay = "apple";
this.loginFun(response);
} else {
uni.navigateTo({
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=3`,
});
}
} else {
this.$refs.uToastRef.show({
type: "error",
message: response?.msg || "Apple登录失败",
});
}
} catch (error) {
console.error("Apple登录异常:", error);
uni.getProvider({
service: 'oauth',
success: (provRes) => {
if (!provRes.provider || !provRes.provider.includes('apple')) {
this.loading = false;
this.$refs.uToastRef.show({
type: "error",
message: "Apple登录异常,请重试",
message: "当前运行环境或自定义基座未支持 Apple 登录",
});
} finally {
this.loading = false;
return;
}
},
fail: (err) => {
this.loading = false;
console.error('Apple登录授权失败:', err);
this.$refs.uToastRef.show({
type: "error",
message: "Apple登录授权失败",
uni.login({
provider: 'apple',
success: async (loginRes) => {
console.log('Apple 登录成功:', loginRes);
const authResult = loginRes.appleInfo || {};
const params = {
identityToken: authResult.identityToken,
// openId: authResult.user,
// fullName: authResult.fullName ? `${authResult.fullName.familyName || ''}${authResult.fullName.givenName || ''}` : '',
// authorizationCode: authResult.authorizationCode
};
console.log("Apple 登录成功-0:", params)
try {
const response = await appleLogin(params);
console.log("Apple 登录成功-1:", response)
if (response && response.bizcode === 100) {
if (response.data && response.data.userId) {
this.loginWay = "apple";
this.loginFun(response);
} else {
uni.navigateTo({
url: `/pages/login_package/bind-phone/bind-phone?token=${response.data.token}&type=3`,
});
}
} else {
console.log("Apple 登录成功-2:", response)
this.$refs.uToastRef.show({
type: "error",
message: response?.msg || "Apple登录失败",
});
}
} catch (error) {
console.error("Apple登录异常:", error);
this.$refs.uToastRef.show({
type: "error",
message: "Apple登录异常,请重试",
});
} finally {
this.loading = false;
}
},
fail: (err) => {
this.loading = false;
console.error('Apple登录授权失败:', err);
this.$refs.uToastRef.show({
type: "error",
message: "Apple登录授权失败",
});
}
});
}
});
// #endif
},
// #endif
},
})
}
},
computed: {
isIOS() {
// #ifdef APP-PLUS
+5 -5
View File
@@ -99,7 +99,7 @@
<view>共{{ item.buyNum }}件,合计¥{{ item.sumAmount }}</view>
</view> -->
<view class="collect_msg" v-if="item.buyDeductionValue">共{{ item.buyNum }}件,合计数字积分{{ item.buyDeductionValue
}}
}}
+¥{{ item.sumAmount }}</view>
<view class="collect_msg" v-if="!item.buyDeductionValue">运费:¥{{ item.postage }},商品总价:¥{{ item.sumAmount }}
</view>
@@ -296,8 +296,8 @@
<u-modal class="sure_pay" :show="surePayShow" title="提示" showCancelButton @cancel="surePayShow = false"
@confirm="cancelPay" confirmColor="#7934F6" content="确定取消支付吗?"></u-modal>
<qiaobao-assistant page-key="pages/mine_package/mine_order/mine_order" title="我的订单" />
</view>
<qiaobao-assistant page-key="pages/mine_package/mine_order/mine_order" title="我的订单" />
</view>
</template>
<script>
@@ -538,11 +538,11 @@ export default {
if (this.$refs.uToastRef) {
this.$refs.uToastRef.show({
type: 'success',
message: '地址修改成功'
message: '申请修改地址已提交,请等待'
});
} else {
uni.showToast({
title: '地址修改成功',
title: '申请修改地址已提交,请等待',
icon: 'success'
});
}
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -24,7 +24,8 @@ export const SMS_TYPE = {
"LOGIN": "login",
"REGISTER": "register",
"WECHAT": "wechatValid",
"ALIPAY": "alipayValid"
"ALIPAY": "alipayValid",
"APPLE": "appleValid"
}
// 图片类型 图片分类:COMMON-公共,CATEGORY-商品类目图标,BRAND-品牌LOGO,SHOP-店铺LOGO,GOODS-商品图片,SPECS-商品规格图片