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