✨ 手机号绑定:接入 100%
parent
b548999e89
commit
a7730ddecb
|
|
@ -69,10 +69,7 @@
|
|||
"schemes" : "shopro"
|
||||
},
|
||||
"ios" : {
|
||||
"urlschemewhitelist": [
|
||||
"baidumap",
|
||||
"iosamap"
|
||||
],
|
||||
"urlschemewhitelist" : [ "baidumap", "iosamap" ],
|
||||
"dSYMs" : false,
|
||||
"privacyDescription" : {
|
||||
"NSPhotoLibraryUsageDescription" : "需要同意访问您的相册选取图片才能完善该条目",
|
||||
|
|
@ -83,9 +80,7 @@
|
|||
"urltypes" : "shopro",
|
||||
"capabilities" : {
|
||||
"entitlements" : {
|
||||
"com.apple.developer.associated-domains": [
|
||||
"applinks:shopro.sheepjs.com"
|
||||
]
|
||||
"com.apple.developer.associated-domains" : [ "applinks:shopro.sheepjs.com" ]
|
||||
}
|
||||
},
|
||||
"idfa" : true
|
||||
|
|
@ -104,18 +99,12 @@
|
|||
},
|
||||
"payment" : {
|
||||
"weixin" : {
|
||||
"__platform__": [
|
||||
"ios",
|
||||
"android"
|
||||
],
|
||||
"__platform__" : [ "ios", "android" ],
|
||||
"appid" : "wxae7a0c156da9383b",
|
||||
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
|
||||
},
|
||||
"alipay" : {
|
||||
"__platform__": [
|
||||
"ios",
|
||||
"android"
|
||||
]
|
||||
"__platform__" : [ "ios", "android" ]
|
||||
}
|
||||
},
|
||||
"share" : {
|
||||
|
|
@ -125,9 +114,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"orientation": [
|
||||
"portrait-primary"
|
||||
],
|
||||
"orientation" : [ "portrait-primary" ],
|
||||
"splashscreen" : {
|
||||
"androidStyle" : "common",
|
||||
"iosStyle" : "common",
|
||||
|
|
@ -198,9 +185,7 @@
|
|||
"lazyCodeLoading" : "requiredComponents",
|
||||
"usingComponents" : {},
|
||||
"permission" : {},
|
||||
"requiredPrivateInfos": [
|
||||
"chooseAddress"
|
||||
]
|
||||
"requiredPrivateInfos" : [ "chooseAddress" ]
|
||||
},
|
||||
"mp-alipay" : {
|
||||
"usingComponents" : true
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ const AuthUtil = {
|
|||
},
|
||||
// 微信小程序的一键登录
|
||||
weixinMiniAppLogin: (phoneCode, loginCode, state) => {
|
||||
debugger
|
||||
return request({
|
||||
url: '/app-api/member/auth/weixin-mini-app-login',
|
||||
method: 'POST',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import request from '@/sheep/request2';
|
||||
import request from '@/sheep/request';
|
||||
|
||||
const UserApi = {
|
||||
// 修改基本信息
|
||||
|
|
@ -13,6 +13,34 @@ const UserApi = {
|
|||
},
|
||||
});
|
||||
},
|
||||
// 修改用户手机
|
||||
updateUserMobile: (data) => {
|
||||
return request({
|
||||
url: '/app-api/member/user/update-mobile',
|
||||
method: 'PUT',
|
||||
data,
|
||||
custom: {
|
||||
loadingMsg: '验证中',
|
||||
showSuccess: true,
|
||||
successMsg: '修改成功'
|
||||
},
|
||||
});
|
||||
},
|
||||
// 基于微信小程序的授权码,修改用户手机
|
||||
updateUserMobileByWeixin: (code) => {
|
||||
return request({
|
||||
url: '/app-api/member/user/update-mobile-by-weixin',
|
||||
method: 'PUT',
|
||||
data: {
|
||||
code
|
||||
},
|
||||
custom: {
|
||||
showSuccess: true,
|
||||
loadingMsg: '获取中',
|
||||
successMsg: '修改成功'
|
||||
},
|
||||
});
|
||||
},
|
||||
// 修改密码
|
||||
updateUserPassword: (data) => {
|
||||
return request({
|
||||
|
|
@ -39,6 +67,7 @@ const UserApi = {
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default UserApi;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<!-- 标题栏 -->
|
||||
<view class="head-box ss-m-b-60">
|
||||
<view class="head-title ss-m-b-20">
|
||||
{{ userInfo.verification.mobile ? '更换手机号' : '绑定手机号' }}
|
||||
{{ userInfo.mobile ? '更换手机号' : '绑定手机号' }}
|
||||
</view>
|
||||
<view class="head-subtitle">为了您的账号安全,请使用本人手机号码</view>
|
||||
</view>
|
||||
|
|
@ -54,6 +54,8 @@
|
|||
</uni-easyinput>
|
||||
</uni-forms-item>
|
||||
</uni-forms>
|
||||
|
||||
<!-- 微信独有:读取手机号 -->
|
||||
<button
|
||||
v-if="'WechatMiniProgram' === sheep.$platform.name"
|
||||
class="ss-reset-button type-btn"
|
||||
|
|
@ -66,13 +68,15 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, watch, ref, reactive, unref } from 'vue';
|
||||
import { computed, ref, reactive, unref } from 'vue';
|
||||
import sheep from '@/sheep';
|
||||
import { code, mobile } from '@/sheep/validate/form';
|
||||
import { showAuthModal, closeAuthModal, getSmsCode, getSmsTimer } from '@/sheep/hooks/useModal';
|
||||
import { closeAuthModal, getSmsCode, getSmsTimer } from '@/sheep/hooks/useModal';
|
||||
import UserApi from '@/sheep/api/member/user';
|
||||
|
||||
const changeMobileRef = ref(null);
|
||||
const userInfo = computed(() => sheep.$store('user').userInfo);
|
||||
|
||||
// 数据
|
||||
const state = reactive({
|
||||
isMobileEnd: false, // 手机号输入完毕
|
||||
|
|
@ -86,33 +90,36 @@
|
|||
},
|
||||
});
|
||||
|
||||
// 5.绑定手机号
|
||||
// 绑定手机号
|
||||
async function changeMobileSubmit() {
|
||||
const validate = await unref(changeMobileRef)
|
||||
.validate()
|
||||
.catch((error) => {
|
||||
console.log('error: ', error);
|
||||
});
|
||||
if (!validate) return;
|
||||
sheep.$api.user.changeMobile(state.model).then((res) => {
|
||||
if (res.error === 0) {
|
||||
if (!validate) {
|
||||
return;
|
||||
}
|
||||
// 提交更新请求
|
||||
const { code } = await UserApi.updateUserMobile(state.model);
|
||||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
sheep.$store('user').getInfo();
|
||||
closeAuthModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 使用微信手机号
|
||||
async function getPhoneNumber(e) {
|
||||
if (e.detail.errMsg !== 'getPhoneNumber:ok') {
|
||||
} else {
|
||||
let result = await sheep.$platform.useProvider().bindUserPhoneNumber(e.detail);
|
||||
return;
|
||||
}
|
||||
const result = await sheep.$platform.useProvider().bindUserPhoneNumber(e.detail);
|
||||
if (result) {
|
||||
sheep.$store('user').getInfo();
|
||||
closeAuthModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@
|
|||
}
|
||||
let result = await sheep.$platform.useProvider().mobileLogin(e.detail);
|
||||
if (result) {
|
||||
debugger
|
||||
closeAuthModal();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ export function getSmsCode(event, mobile) {
|
|||
case 'changePassword':
|
||||
scene = 3;
|
||||
break;
|
||||
case 'changeMobile':
|
||||
scene = 2;
|
||||
break;
|
||||
case 'smsLogin':
|
||||
scene = 1;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -162,7 +162,6 @@ export default {
|
|||
// 微信支付
|
||||
wxpay(data, callback) {
|
||||
this.isReady(() => {
|
||||
debugger
|
||||
jweixin.chooseWXPay({
|
||||
timestamp: data.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
||||
nonceStr: data.nonceStr, // 支付签名随机串,不长于 32 位
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ export default class SheepPay {
|
|||
channelExtras: {}
|
||||
};
|
||||
// 特殊逻辑:微信公众号、小程序支付时,必须传入 openid
|
||||
if (['wx_pub'].includes(channel)) {
|
||||
if (['wx_pub', 'wx_lite'].includes(channel)) {
|
||||
const openid = await sheep.$platform.useProvider('wechat').getOpenid();
|
||||
// 如果获取不到 openid,微信无法发起支付,此时需要引导
|
||||
if (!openid) {
|
||||
|
|
@ -101,6 +101,7 @@ export default class SheepPay {
|
|||
}
|
||||
data.channelExtras.openid = openid;
|
||||
}
|
||||
// 发起预支付 API 调用
|
||||
PayOrderApi.submitOrder(data).then((res) => {
|
||||
// 成功时
|
||||
res.code === 0 && resolve(res);
|
||||
|
|
@ -144,8 +145,7 @@ export default class SheepPay {
|
|||
async wechatWapPay() {
|
||||
const { error, data } = await this.prepay();
|
||||
if (error === 0) {
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?id=${this.id}&payment=${this.payment
|
||||
}&orderType=${this.orderType}`;
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?id=${this.id}&payment=${this.payment}&orderType=${this.orderType}`;
|
||||
location.href = `${data.pay_data.h5_url}&redirect_url=${encodeURIComponent(redirect_url)}`;
|
||||
}
|
||||
}
|
||||
|
|
@ -154,29 +154,37 @@ export default class SheepPay {
|
|||
async redirectPay() {
|
||||
let { error, data } = await this.prepay();
|
||||
if (error === 0) {
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?id=${this.id}&payment=${this.payment
|
||||
}&orderType=${this.orderType}`;
|
||||
const redirect_url = `${getRootUrl()}pages/pay/result?id=${this.id}&payment=${this.payment}&orderType=${this.orderType}`;
|
||||
location.href = data.pay_data + encodeURIComponent(redirect_url);
|
||||
}
|
||||
}
|
||||
|
||||
// #endif
|
||||
|
||||
// 微信小程序支付 TODO 芋艿:待接入
|
||||
// 微信小程序支付
|
||||
async wechatMiniProgramPay() {
|
||||
let that = this;
|
||||
let result = await this.prepay();
|
||||
// let that = this;
|
||||
let { code, data } = await this.prepay('wx_lite');
|
||||
if (code !== 0) {
|
||||
return;
|
||||
}
|
||||
// 调用微信小程序支付
|
||||
const payConfig = JSON.parse(data.displayContent);
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay',
|
||||
...result.data.pay_data,
|
||||
timeStamp: payConfig.timeStamp,
|
||||
nonceStr: payConfig.nonceStr,
|
||||
package: payConfig.packageValue,
|
||||
signType: payConfig.signType,
|
||||
paySign: payConfig.paySign,
|
||||
success: (res) => {
|
||||
that.payResult('success');
|
||||
this.payResult('success');
|
||||
},
|
||||
fail: (err) => {
|
||||
if (err.errMsg === 'requestPayment:fail cancel') {
|
||||
sheep.$helper.toast('支付已手动取消');
|
||||
} else {
|
||||
that.payResult('fail');
|
||||
this.payResult('fail');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import third from '@/sheep/api/third';
|
||||
import AuthUtil from '@/sheep/api/member/auth';
|
||||
import SocialApi from '@/sheep/api/member/social';
|
||||
import UserApi from '@/sheep/api/member/user';
|
||||
|
||||
const socialType = 34; // 社交类型 - 微信小程序
|
||||
|
||||
|
|
@ -86,18 +87,8 @@ const unbind = async (openid) => {
|
|||
// 绑定用户手机号
|
||||
const bindUserPhoneNumber = (e) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const { error } = await third.wechat.bindUserPhoneNumber({
|
||||
platform: 'miniProgram',
|
||||
payload: encodeURIComponent(
|
||||
JSON.stringify({
|
||||
sessionId: uni.getStorageSync('sessionId'),
|
||||
iv: e.iv,
|
||||
encryptedData: e.encryptedData,
|
||||
code: e.code,
|
||||
}),
|
||||
),
|
||||
});
|
||||
if (error === 0) {
|
||||
const { code } = await UserApi.updateUserMobileByWeixin(e.code);
|
||||
if (code === 0) {
|
||||
resolve(true);
|
||||
}
|
||||
resolve(false);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ http.interceptors.response.use(
|
|||
}
|
||||
// TODO 芋艿:如果是登录的 API,则自动设置 token
|
||||
if (response.data?.data?.accessToken) {
|
||||
debugger
|
||||
$store('user').setToken(response.data.data.accessToken);
|
||||
}
|
||||
|
||||
|
|
@ -220,8 +219,8 @@ const request = (config) => {
|
|||
// TODO 芋艿:额外拼接
|
||||
if (config.url.indexOf('/app-api/') >= 0) {
|
||||
// config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
|
||||
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
config.url = 'http://yunai.natapp1.cc' + config.url; // 调用【natapp】
|
||||
config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
// config.url = 'http://yunai.natapp1.cc' + config.url; // 调用【natapp】
|
||||
}
|
||||
return http.middleware(config);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -217,8 +217,8 @@ const request = (config) => {
|
|||
// 设置接口地址
|
||||
// config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
|
||||
// config.url = 'https://app.test.huizhizao.vip/prod-api' + config.url; // 调用【云端】
|
||||
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
config.url = 'http://yunai.natapp1.cc' + config.url; // 调用【natapp】
|
||||
config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
|
||||
// config.url = 'http://yunai.natapp1.cc' + config.url; // 调用【natapp】
|
||||
}
|
||||
return http.middleware(config);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue