diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss index 57833cbf..2ef88507 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.scss @@ -53,3 +53,21 @@ } } } + +.alipay-btn { + color: #fff; + border: none; + background: none; + width: 100%; + font-size: 14px; + position: absolute; + left: 0px; + top: 0px; + z-index: 99; + height: 100%; + display: flex; + .btn-tit{ + display: block; + margin: auto; + } +} diff --git a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue index c3dba324..f881ed4e 100644 --- a/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue +++ b/CoreCms.Net.Uni-App/CoreShop/components/coreshop-login-modal/coreshop-login-modal.vue @@ -32,8 +32,19 @@ text="暂不授权"> + + + + + + + @@ -46,7 +57,7 @@ import { useShopConfigStore, useUserInfoStore } from '@/core/store'; import type { Response } from '@/core/models'; import { Invitecode, UserToken } from '@/core/consts'; - import { queryLoginPhoneNumber, queryLogin, queryAliPayAppAuthTokenBYCode } from '@/core/api'; + import { queryLoginPhoneNumber, queryLogin, queryAliPayAppAuthTokenBYCode ,queryDecryptPhoneNumberByAli} from '@/core/api'; import { loginGetCode, handleShowToast, handleRouteNavigateTo } from '@/core/utils'; /** 获取项目配置 */ @@ -97,7 +108,7 @@ // #endif // #ifdef MP-ALIPAY - const login : Response = await queryAliPayAppAuthTokenBYCode({id:code}); + const login : Response = await queryAliPayAppAuthTokenBYCode({ id: code }); // #endif if (login.status) { @@ -137,7 +148,7 @@ state.agreement = false; } - /** 获取授权手机号 */ + /** 微信获取授权手机号 */ const getPhoneNumber = (e : any) => { emits('handleChangePopup', false); if (e.errMsg.includes('ok')) { @@ -156,9 +167,37 @@ } } + /** 支付宝获取授权手机号 */ + const getAliPhoneNumber = () => { + emits('handleChangePopup', false); + my.getPhoneNumber({ + success: (res : any) => { + let encryptedData = JSON.parse(res.response); + let data = { + sessionAuthId: state.sessionAuthIdTool, + sign: encryptedData.sign, + encryptedData: encryptedData.response, + } + /** 有推荐码的话,带上 */ + if (uni.getStorageSync(Invitecode)) { + data['invitecode'] = uni.getStorageSync(Invitecode); + } + handleLogin(data); + } + }) + } + /** 去登录获取数据 */ const handleLogin = async (data : any) => { + + // #ifdef MP-WEIXIN const phoneNumber : Response = await queryLoginPhoneNumber(data); + // #endif + + // #ifdef MP-ALIPAY + const phoneNumber : Response = await queryDecryptPhoneNumberByAli(data); + // #endif + if (phoneNumber.status && phoneNumber.data.token) { uni.setStorageSync(UserToken, phoneNumber.data.token); if (phoneNumber.otherData) { diff --git a/CoreCms.Net.Uni-App/CoreShop/core/api/login.ts b/CoreCms.Net.Uni-App/CoreShop/core/api/login.ts index b0cd1973..3004e5c3 100644 --- a/CoreCms.Net.Uni-App/CoreShop/core/api/login.ts +++ b/CoreCms.Net.Uni-App/CoreShop/core/api/login.ts @@ -1,13 +1,20 @@ import { post } from '@/core/utils/http'; import type { Response } from '@/core/models'; -/** 获取商品分类配置 */ +/** 小程序手机授权(拉取手机号码) */ export const queryLoginPhoneNumber = (data : any) : Promise> => { return post('Api/User/DecryptPhoneNumber', { data, }); } +/** 支付宝小程序手机授权(拉取手机号码) */ +export const queryDecryptPhoneNumberByAli = (data : any) : Promise> => { + return post('Api/User/DecryptPhoneNumberByAli', { + data, + }); +} + /** 小程序解析code */ export const queryLogin = (data : any) : Promise> => { return post('Api/User/OnLogin', { diff --git a/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue b/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue index d6f5a2aa..2e72313a 100644 --- a/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue +++ b/CoreCms.Net.Uni-App/CoreShop/pages/cart/cart.vue @@ -1,7 +1,5 @@