fix:新增电话号码授权,修复订单创建/取消时用户手机消失的情况
This commit is contained in:
+48
-1
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../common/vendor.js");
|
||||
const config_user = require("../config/user.js");
|
||||
const config_url = require("../config/url.js");
|
||||
const wxLogin = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.login({
|
||||
@@ -48,6 +49,51 @@ const getUserInfo = () => {
|
||||
res(result);
|
||||
});
|
||||
};
|
||||
const getUserPhoneNumber = (code) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const token = common_vendor.index.getStorageSync("token");
|
||||
if (!token) {
|
||||
reject(new Error("用户未登录"));
|
||||
return;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at util/index.js:88", "开始请求获取手机号,code=", code, "请求地址=", config_url.URL + "/app/user/getPhoneNumber");
|
||||
common_vendor.index.request({
|
||||
url: config_url.URL + "/app/user/getPhoneNumber",
|
||||
method: "POST",
|
||||
header: {
|
||||
"Authorization": "Bearer " + token,
|
||||
"clientId": common_vendor.index.getStorageSync("client_id"),
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
data: {
|
||||
code,
|
||||
// 微信获取手机号授权后的临时code
|
||||
appid: config_url.appid
|
||||
},
|
||||
success: (res) => {
|
||||
common_vendor.index.__f__("log", "at util/index.js:104", "请求获取手机号接口成功,原始响应:", JSON.stringify(res));
|
||||
if (res.statusCode !== 200) {
|
||||
reject(new Error(`HTTP错误: ${res.statusCode}`));
|
||||
return;
|
||||
}
|
||||
if (!res.data) {
|
||||
reject(new Error("服务器返回空数据"));
|
||||
return;
|
||||
}
|
||||
resolve(res.data);
|
||||
},
|
||||
fail: (err) => {
|
||||
common_vendor.index.__f__("error", "at util/index.js:122", "请求获取手机号接口网络错误:", err);
|
||||
reject(new Error("请求获取手机号接口失败: " + (err.errMsg || JSON.stringify(err))));
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at util/index.js:127", "获取手机号过程中出现异常:", error);
|
||||
reject(new Error("获取手机号异常: " + (error.message || JSON.stringify(error))));
|
||||
}
|
||||
});
|
||||
};
|
||||
const initiateWeChatScorePayment = (paymentData) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!paymentData || !paymentData.data || !paymentData.data.package) {
|
||||
@@ -68,7 +114,7 @@ const initiateWeChatScorePayment = (paymentData) => {
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
common_vendor.index.__f__("error", "at util/index.js:100", "微信支付分小程序调用失败", error);
|
||||
common_vendor.index.__f__("error", "at util/index.js:158", "微信支付分小程序调用失败", error);
|
||||
common_vendor.index.showToast({
|
||||
title: error.errMsg || "支付分接口调用失败",
|
||||
icon: "none"
|
||||
@@ -88,6 +134,7 @@ const getQueryString = function(url, name) {
|
||||
};
|
||||
exports.getQueryString = getQueryString;
|
||||
exports.getUserInfo = getUserInfo;
|
||||
exports.getUserPhoneNumber = getUserPhoneNumber;
|
||||
exports.initiateWeChatScorePayment = initiateWeChatScorePayment;
|
||||
exports.wxLogin = wxLogin;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/util/index.js.map
|
||||
|
||||
Reference in New Issue
Block a user