手机号绑定:接入 100%

pull/32/MERGE
YunaiV 2023-12-24 13:16:45 +08:00
parent b548999e89
commit a7730ddecb
11 changed files with 301 additions and 282 deletions

View File

@ -1,240 +1,225 @@
{ {
"name": "星品", "name" : "星品",
"appid": "__UNI__082C0BA", "appid" : "__UNI__082C0BA",
"description": "Shopro是由SheepJS团队开发使用Uniapp+Vue3技术驱动的在线商城系统内含诸多功能与丰富的活动期待您的使用和反馈。", "description" : "Shopro是由SheepJS团队开发使用Uniapp+Vue3技术驱动的在线商城系统内含诸多功能与丰富的活动期待您的使用和反馈。",
"versionName": "1.8.3", "versionName" : "1.8.3",
"versionCode": 183, "versionCode" : 183,
"transformPx": false, "transformPx" : false,
"app-plus": { "app-plus" : {
"usingComponents": true, "usingComponents" : true,
"nvueCompiler": "uni-app", "nvueCompiler" : "uni-app",
"nvueStyleCompiler": "uni-app", "nvueStyleCompiler" : "uni-app",
"compilerVersion": 3, "compilerVersion" : 3,
"nvueLaunchMode": "fast", "nvueLaunchMode" : "fast",
"splashscreen": { "splashscreen" : {
"alwaysShowBeforeRender": true, "alwaysShowBeforeRender" : true,
"waiting": true, "waiting" : true,
"autoclose": true, "autoclose" : true,
"delay": 0 "delay" : 0
},
"safearea": {
"bottom": {
"offset": "none"
}
},
"modules": {
"Payment": {},
"Share": {},
"VideoPlayer": {},
"OAuth": {}
},
"distribute": {
"android": {
"permissions": [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_MOCK_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.GET_TASKS\"/>",
"<uses-permission android:name=\"android.permission.INTERNET\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.READ_SMS\"/>",
"<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.SEND_SMS\"/>",
"<uses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SMS\"/>",
"<uses-permission android:name=\"android.permission.RECEIVE_USER_PRESENT\"/>"
],
"minSdkVersion": 21,
"schemes": "shopro"
},
"ios": {
"urlschemewhitelist": [
"baidumap",
"iosamap"
],
"dSYMs": false,
"privacyDescription": {
"NSPhotoLibraryUsageDescription": "需要同意访问您的相册选取图片才能完善该条目",
"NSPhotoLibraryAddUsageDescription": "需要同意访问您的相册才能保存该图片",
"NSCameraUsageDescription": "需要同意访问您的摄像头拍摄照片才能完善该条目",
"NSUserTrackingUsageDescription": "开启追踪并不会获取您在其它站点的隐私信息,该行为仅用于标识设备,保障服务安全和提升浏览体验"
}, },
"urltypes": "shopro", "safearea" : {
"capabilities": { "bottom" : {
"entitlements": { "offset" : "none"
"com.apple.developer.associated-domains": [ }
"applinks:shopro.sheepjs.com"
]
}
}, },
"idfa": true "modules" : {
}, "Payment" : {},
"sdkConfigs": { "Share" : {},
"speech": { "VideoPlayer" : {},
"ifly": {} "OAuth" : {}
}, },
"ad": {}, "distribute" : {
"oauth": { "android" : {
"apple": {}, "permissions" : [
"weixin": { "<uses-feature android:name=\"android.hardware.camera\"/>",
"appid": "wxae7a0c156da9383b", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
} "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
}, "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"payment": { "<uses-permission android:name=\"android.permission.ACCESS_MOCK_LOCATION\"/>",
"weixin": { "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"__platform__": [ "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"ios", "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"android" "<uses-permission android:name=\"android.permission.CAMERA\"/>",
], "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"appid": "wxae7a0c156da9383b", "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
}, "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"alipay": { "<uses-permission android:name=\"android.permission.GET_TASKS\"/>",
"__platform__": [ "<uses-permission android:name=\"android.permission.INTERNET\"/>",
"ios", "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"android" "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
] "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
} "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
}, "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"share": { "<uses-permission android:name=\"android.permission.READ_SMS\"/>",
"weixin": { "<uses-permission android:name=\"android.permission.RECEIVE_BOOT_COMPLETED\"/>",
"appid": "wxae7a0c156da9383b", "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"UniversalLinks": "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/" "<uses-permission android:name=\"android.permission.SEND_SMS\"/>",
} "<uses-permission android:name=\"android.permission.SYSTEM_ALERT_WINDOW\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SMS\"/>",
"<uses-permission android:name=\"android.permission.RECEIVE_USER_PRESENT\"/>"
],
"minSdkVersion" : 21,
"schemes" : "shopro"
},
"ios" : {
"urlschemewhitelist" : [ "baidumap", "iosamap" ],
"dSYMs" : false,
"privacyDescription" : {
"NSPhotoLibraryUsageDescription" : "需要同意访问您的相册选取图片才能完善该条目",
"NSPhotoLibraryAddUsageDescription" : "需要同意访问您的相册才能保存该图片",
"NSCameraUsageDescription" : "需要同意访问您的摄像头拍摄照片才能完善该条目",
"NSUserTrackingUsageDescription" : "开启追踪并不会获取您在其它站点的隐私信息,该行为仅用于标识设备,保障服务安全和提升浏览体验"
},
"urltypes" : "shopro",
"capabilities" : {
"entitlements" : {
"com.apple.developer.associated-domains" : [ "applinks:shopro.sheepjs.com" ]
}
},
"idfa" : true
},
"sdkConfigs" : {
"speech" : {
"ifly" : {}
},
"ad" : {},
"oauth" : {
"apple" : {},
"weixin" : {
"appid" : "wxae7a0c156da9383b",
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
}
},
"payment" : {
"weixin" : {
"__platform__" : [ "ios", "android" ],
"appid" : "wxae7a0c156da9383b",
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
},
"alipay" : {
"__platform__" : [ "ios", "android" ]
}
},
"share" : {
"weixin" : {
"appid" : "wxae7a0c156da9383b",
"UniversalLinks" : "https://shopro.sheepjs.com/uni-universallinks/__UNI__082C0BA/"
}
}
},
"orientation" : [ "portrait-primary" ],
"splashscreen" : {
"androidStyle" : "common",
"iosStyle" : "common",
"useOriginalMsgbox" : true
},
"icons" : {
"android" : {
"hdpi" : "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png"
},
"ios" : {
"appstore" : "unpackage/res/icons/1024x1024.png",
"ipad" : {
"app" : "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png"
},
"iphone" : {
"app@2x" : "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png"
}
}
}
} }
}, },
"orientation": [ "quickapp" : {},
"portrait-primary" "quickapp-native" : {
], "icon" : "/static/logo.png",
"splashscreen": { "package" : "com.example.demo",
"androidStyle": "common", "features" : [
"iosStyle": "common", {
"useOriginalMsgbox": true "name" : "system.clipboard"
}, }
"icons": { ]
"android": { },
"hdpi": "unpackage/res/icons/72x72.png", "quickapp-webview" : {
"xhdpi": "unpackage/res/icons/96x96.png", "icon" : "/static/logo.png",
"xxhdpi": "unpackage/res/icons/144x144.png", "package" : "com.example.demo",
"xxxhdpi": "unpackage/res/icons/192x192.png" "minPlatformVersion" : 1070,
"versionName" : "1.0.0",
"versionCode" : 100
},
"mp-weixin" : {
"appid" : "wx63c280fe3248a3e7",
"setting" : {
"urlCheck" : false,
"minified" : true,
"postcss" : true
}, },
"ios": { "optimization" : {
"appstore": "unpackage/res/icons/1024x1024.png", "subPackages" : true
"ipad": { },
"app": "unpackage/res/icons/76x76.png", "plugins" : {},
"app@2x": "unpackage/res/icons/152x152.png", "lazyCodeLoading" : "requiredComponents",
"notification": "unpackage/res/icons/20x20.png", "usingComponents" : {},
"notification@2x": "unpackage/res/icons/40x40.png", "permission" : {},
"proapp@2x": "unpackage/res/icons/167x167.png", "requiredPrivateInfos" : [ "chooseAddress" ]
"settings": "unpackage/res/icons/29x29.png", },
"settings@2x": "unpackage/res/icons/58x58.png", "mp-alipay" : {
"spotlight": "unpackage/res/icons/40x40.png", "usingComponents" : true
"spotlight@2x": "unpackage/res/icons/80x80.png" },
}, "mp-baidu" : {
"iphone": { "usingComponents" : true
"app@2x": "unpackage/res/icons/120x120.png", },
"app@3x": "unpackage/res/icons/180x180.png", "mp-toutiao" : {
"notification@2x": "unpackage/res/icons/40x40.png", "usingComponents" : true
"notification@3x": "unpackage/res/icons/60x60.png", },
"settings@2x": "unpackage/res/icons/58x58.png", "mp-jd" : {
"settings@3x": "unpackage/res/icons/87x87.png", "usingComponents" : true
"spotlight@2x": "unpackage/res/icons/80x80.png", },
"spotlight@3x": "unpackage/res/icons/120x120.png" "h5" : {
} "template" : "index.html",
"router" : {
"mode" : "hash",
"base" : "./"
},
"sdkConfigs" : {
"maps" : {}
},
"async" : {
"timeout" : 20000
},
"title" : "星品购",
"optimization" : {
"treeShaking" : {
"enable" : true
}
} }
}
}
},
"quickapp": {},
"quickapp-native": {
"icon": "/static/logo.png",
"package": "com.example.demo",
"features": [
{
"name": "system.clipboard"
}
]
},
"quickapp-webview": {
"icon": "/static/logo.png",
"package": "com.example.demo",
"minPlatformVersion": 1070,
"versionName": "1.0.0",
"versionCode": 100
},
"mp-weixin": {
"appid": "wx63c280fe3248a3e7",
"setting": {
"urlCheck": false,
"minified": true,
"postcss": true
}, },
"optimization": { "vueVersion" : "3",
"subPackages": true "_spaceID" : "192b4892-5452-4e1d-9f09-eee1ece40639",
}, "locale" : "zh-Hans",
"plugins": {}, "fallbackLocale" : "zh-Hans"
"lazyCodeLoading": "requiredComponents",
"usingComponents": {},
"permission": {},
"requiredPrivateInfos": [
"chooseAddress"
]
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"mp-jd": {
"usingComponents": true
},
"h5": {
"template": "index.html",
"router": {
"mode": "hash",
"base": "./"
},
"sdkConfigs": {
"maps": {}
},
"async": {
"timeout": 20000
},
"title": "星品购",
"optimization": {
"treeShaking": {
"enable": true
}
}
},
"vueVersion": "3",
"_spaceID": "192b4892-5452-4e1d-9f09-eee1ece40639",
"locale": "zh-Hans",
"fallbackLocale": "zh-Hans"
} }

View File

@ -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',

View File

@ -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;

View File

@ -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,31 +90,34 @@
}, },
}); });
// 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) { }
sheep.$store('user').getInfo(); //
closeAuthModal(); const { code } = await UserApi.updateUserMobile(state.model);
} if (code !== 0) {
}); return;
}
sheep.$store('user').getInfo();
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); }
if (result) { const result = await sheep.$platform.useProvider().bindUserPhoneNumber(e.detail);
sheep.$store('user').getInfo(); if (result) {
closeAuthModal(); sheep.$store('user').getInfo();
} closeAuthModal();
} }
} }
</script> </script>

View File

@ -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();
} }
}; };

View File

@ -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;

View File

@ -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 位

View File

@ -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);
@ -140,12 +141,11 @@ export default class SheepPay {
}); });
} }
// 浏览器微信H5支付 TODO 芋艿:待接入 // 浏览器微信 H5 支付 TODO 芋艿:待接入
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');
} }
}, },
}); });

View File

@ -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);

View File

@ -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);
}; };

View File

@ -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);
}; };