fix:新增电话号码授权,修复订单创建/取消时用户手机消失的情况

This commit is contained in:
2025-07-11 17:03:34 +08:00
parent 4851e0500d
commit f8ff55758b
24 changed files with 628 additions and 70 deletions
+1 -1
View File
@@ -6990,7 +6990,7 @@ function isConsoleWritable() {
function initRuntimeSocketService() {
const hosts = "192.168.10.59,127.0.0.1";
const port = "8090";
const id = "mp-weixin_f_V2rb";
const id = "mp-weixin_1_bom0";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();
+106 -9
View File
@@ -17,12 +17,99 @@ const _sfc_main = {
});
const isLoggedIn = common_vendor.ref(true);
const phoneNumber = common_vendor.ref("");
const showPhoneAuthPopup = common_vendor.ref(false);
common_vendor.onLoad((options) => {
deviceId.value = options.deviceNo;
checkOrderStatus();
common_vendor.index.__f__("log", "at pages/device/detail.vue:174", options.deviceNo);
common_vendor.index.__f__("log", "at pages/device/detail.vue:198", options.deviceNo);
fetchDeviceInfo();
});
common_vendor.onMounted(() => {
checkUserPhone();
});
const checkUserPhone = async () => {
try {
const userInfoRes = await util_index.getUserInfo();
common_vendor.index.__f__("log", "at pages/device/detail.vue:209", userInfoRes.data.phone, "getUserInfoPhone");
if (userInfoRes.code == 200 && userInfoRes.data && userInfoRes.data.phone) {
phoneNumber.value = userInfoRes.data.phone;
} else {
showPhoneAuthPopup.value = true;
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:218", "获取用户信息失败:", error);
}
};
const onGetPhoneNumber = (e) => {
common_vendor.index.__f__("log", "at pages/device/detail.vue:224", "getPhoneNumber event:", e.detail);
if (e.detail.errMsg && e.detail.errMsg.includes("deny")) {
common_vendor.index.showToast({
title: "需要授权手机号才能使用设备",
icon: "none"
});
return;
}
if (e.detail.code) {
common_vendor.index.showLoading({
title: "获取中..."
});
common_vendor.index.__f__("log", "at pages/device/detail.vue:241", "获取到的授权code:", e.detail.code);
try {
util_index.getUserPhoneNumber(e.detail.code).then((res) => {
common_vendor.index.__f__("log", "at pages/device/detail.vue:247", "获取手机号API响应原始数据:", JSON.stringify(res));
common_vendor.index.hideLoading();
if (!res) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:252", "API返回数据为空");
common_vendor.index.showModal({
title: "数据异常",
content: "API返回为空",
showCancel: false
});
return;
}
common_vendor.index.__f__("log", "at pages/device/detail.vue:262", "响应code:", res.code, "响应类型:", typeof res.code);
common_vendor.index.__f__("log", "at pages/device/detail.vue:263", "是否有data:", !!res.data, "是否有phone:", res.data && !!res.data.phone);
if (res.code == 200 && res.data && res.data.phoneNumber) {
phoneNumber.value = res.data.phoneNumber;
showPhoneAuthPopup.value = false;
common_vendor.index.showToast({
title: "手机号获取成功",
icon: "success"
});
} else {
common_vendor.index.__f__("warn", "at pages/device/detail.vue:275", "获取手机号响应异常:", res.msg || "未知错误");
common_vendor.index.showModal({
title: "获取手机号异常",
content: `状态码: ${res.code}, 消息: ${res.msg || "无"}`,
showCancel: false
});
}
}).catch((err) => {
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/device/detail.vue:285", "获取手机号码失败(catch):", err);
let errMsg = err.message || err.toString();
common_vendor.index.showModal({
title: "获取手机号失败",
content: "错误信息: " + errMsg,
showCancel: false
});
});
} catch (outerError) {
common_vendor.index.hideLoading();
common_vendor.index.__f__("error", "at pages/device/detail.vue:297", "获取手机号外部错误:", outerError);
common_vendor.index.showModal({
title: "意外错误",
content: "处理过程发生异常: " + (outerError.message || outerError),
showCancel: false
});
}
} else {
common_vendor.index.showToast({
title: "获取授权码失败",
icon: "none"
});
}
};
const fetchDeviceInfo = async () => {
const res = await config_user.getDeviceInfo(deviceId.value);
if (res.code == 200) {
@@ -84,6 +171,10 @@ const _sfc_main = {
showLoginTip();
return;
}
if (!phoneNumber.value) {
showPhoneAuthPopup.value = true;
return;
}
submitRentOrder(payWay);
};
const selectedPkg = common_vendor.reactive({
@@ -104,7 +195,7 @@ const _sfc_main = {
if (payWay == "wx-pay") {
common_vendor.index.hideLoading();
const res = await config_user.getOrderByOrderNo(order.orderNo);
common_vendor.index.__f__("log", "at pages/device/detail.vue:287", res);
common_vendor.index.__f__("log", "at pages/device/detail.vue:427", res);
try {
let packageTimeMinutes = 0;
if (selectedPkg.time.includes("小时")) {
@@ -120,12 +211,12 @@ const _sfc_main = {
packagePrice: parseFloat(selectedPkg.price)
});
if (updateRes.code !== 200) {
common_vendor.index.__f__("warn", "at pages/device/detail.vue:304", "更新订单套餐信息失败:", updateRes.msg);
common_vendor.index.__f__("warn", "at pages/device/detail.vue:444", "更新订单套餐信息失败:", updateRes.msg);
} else {
common_vendor.index.__f__("log", "at pages/device/detail.vue:307", "订单套餐信息已提前更新");
common_vendor.index.__f__("log", "at pages/device/detail.vue:447", "订单套餐信息已提前更新");
}
} catch (updateError) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:310", "更新订单套餐信息时出错:", updateError);
common_vendor.index.__f__("error", "at pages/device/detail.vue:450", "更新订单套餐信息时出错:", updateError);
}
const deposit = parseFloat(deviceInfo.value.depositAmount);
const packagePrice = parseFloat(selectedPkg.price);
@@ -143,7 +234,7 @@ const _sfc_main = {
const payResult = await util_index.initiateWeChatScorePayment(res);
if (payResult.errCode == "0") {
const res2 = await config_user.getOrderByOrderNoScorePayStatus(order.orderNo);
common_vendor.index.__f__("log", "at pages/device/detail.vue:340", res2.data.orderStatus);
common_vendor.index.__f__("log", "at pages/device/detail.vue:480", res2.data.orderStatus);
if (res2.data.orderStatus == "in_used") {
common_vendor.index.showToast({
title: "设备租借成功",
@@ -191,7 +282,7 @@ const _sfc_main = {
}
};
return (_ctx, _cache) => {
return {
return common_vendor.e({
a: common_vendor.t(deviceStatus.text),
b: common_vendor.n(deviceStatus.class),
c: common_vendor.t(deviceId.value),
@@ -204,8 +295,14 @@ const _sfc_main = {
j: common_vendor.t(hasActiveOrder.value ? "归还设备" : "免押金租借"),
k: hasActiveOrder.value ? 1 : "",
l: common_vendor.o(($event) => handleRent("wx-score-pay")),
m: common_vendor.o(($event) => handleRent("wx-pay"))
};
m: common_vendor.o(($event) => handleRent("wx-pay")),
n: showPhoneAuthPopup.value
}, showPhoneAuthPopup.value ? {
o: common_vendor.o(() => {
}),
p: common_vendor.o(onGetPhoneNumber),
q: common_vendor.o(($event) => showPhoneAuthPopup.value = false)
} : {});
};
}
};
+1 -1
View File
@@ -1 +1 @@
<view class="container data-v-d65de3a7"><view class="device-header data-v-d65de3a7"><view class="{{['device-status-card', 'data-v-d65de3a7', b]}}"><view class="status-indicator data-v-d65de3a7"></view><text class="status-text data-v-d65de3a7">{{a}}</text></view><view class="device-title data-v-d65de3a7"><text class="name data-v-d65de3a7">共享风扇</text><view class="device-meta data-v-d65de3a7"><text class="id-label data-v-d65de3a7">设备号:</text><text class="id-value data-v-d65de3a7">{{c}}</text></view></view></view><view class="card device-info-card data-v-d65de3a7"><view class="card-row data-v-d65de3a7"><view class="card-item data-v-d65de3a7"><view class="item-icon location-icon data-v-d65de3a7"><image class="data-v-d65de3a7" src="{{d}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-d65de3a7"><text class="item-label data-v-d65de3a7">当前位置</text><text class="item-value data-v-d65de3a7">{{e}}</text></view></view><view class="card-item data-v-d65de3a7"><view class="{{['item-icon', 'battery-icon', 'data-v-d65de3a7', g && 'battery-low']}}"><image class="data-v-d65de3a7" src="{{f}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-d65de3a7"><text class="item-label data-v-d65de3a7">电池电量</text><text class="item-value data-v-d65de3a7">{{h}}%</text></view></view></view></view><view class="card pricing-card data-v-d65de3a7"><view class="card-header data-v-d65de3a7"><text class="card-title data-v-d65de3a7">计费规则</text></view><view class="pricing-banner data-v-d65de3a7"><view class="pricing-main data-v-d65de3a7"><text class="price data-v-d65de3a7">¥5.00</text><text class="unit data-v-d65de3a7">/小时</text></view><text class="cap-price data-v-d65de3a7">封顶 ¥99</text></view><view class="pricing-rules data-v-d65de3a7"><view class="rule-item data-v-d65de3a7"><view class="rule-dot data-v-d65de3a7"></view><text class="rule-text data-v-d65de3a7">前15分钟内归还<text class="highlight data-v-d65de3a7">免费</text></text></view><view class="rule-item data-v-d65de3a7"><view class="rule-dot data-v-d65de3a7"></view><text class="rule-text data-v-d65de3a7">不足60分钟按60分钟计费</text></view><view class="rule-item data-v-d65de3a7"><view class="rule-dot data-v-d65de3a7"></view><text class="rule-text data-v-d65de3a7">持续计费至99元视为买断</text></view></view></view><view class="card notice-card data-v-d65de3a7"><view class="card-header data-v-d65de3a7"><text class="card-title data-v-d65de3a7">使用须知</text></view><view class="notice-items data-v-d65de3a7"><view class="notice-item data-v-d65de3a7"><view class="notice-dot data-v-d65de3a7"></view><text class="notice-text data-v-d65de3a7">请在使用前检查设备是否完好</text></view><view class="notice-item data-v-d65de3a7"><view class="notice-dot data-v-d65de3a7"></view><text class="notice-text data-v-d65de3a7">请在指定区域内使用设备</text></view><view class="notice-item data-v-d65de3a7"><view class="notice-dot data-v-d65de3a7"></view><text class="notice-text data-v-d65de3a7">归还时请确保设备完好,避免损坏</text></view></view></view><view class="footer data-v-d65de3a7"><view class="wechat-credit data-v-d65de3a7"><image src="{{i}}" mode="aspectFit" class="wx-icon data-v-d65de3a7"></image><view class="credit-text data-v-d65de3a7"><text class="data-v-d65de3a7">微信支付分</text><text class="credit-divider data-v-d65de3a7">|</text><text class="credit-score data-v-d65de3a7">支付分200分及以上优享</text></view></view><button class="{{['rent-button', 'data-v-d65de3a7', k && 'return-button']}}" bindtap="{{l}}"><text class="data-v-d65de3a7">{{j}}</text></button><view class=" data-v-d65de3a7" style="align-items:center;align-content:center;text-align:center;line-height:50rpx" bindtap="{{m}}"> 无法免押点这里></view></view></view>
<view class="container data-v-d65de3a7"><view class="device-header data-v-d65de3a7"><view class="{{['device-status-card', 'data-v-d65de3a7', b]}}"><view class="status-indicator data-v-d65de3a7"></view><text class="status-text data-v-d65de3a7">{{a}}</text></view><view class="device-title data-v-d65de3a7"><text class="name data-v-d65de3a7">共享风扇</text><view class="device-meta data-v-d65de3a7"><text class="id-label data-v-d65de3a7">设备号:</text><text class="id-value data-v-d65de3a7">{{c}}</text></view></view></view><view class="card device-info-card data-v-d65de3a7"><view class="card-row data-v-d65de3a7"><view class="card-item data-v-d65de3a7"><view class="item-icon location-icon data-v-d65de3a7"><image class="data-v-d65de3a7" src="{{d}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-d65de3a7"><text class="item-label data-v-d65de3a7">当前位置</text><text class="item-value data-v-d65de3a7">{{e}}</text></view></view><view class="card-item data-v-d65de3a7"><view class="{{['item-icon', 'battery-icon', 'data-v-d65de3a7', g && 'battery-low']}}"><image class="data-v-d65de3a7" src="{{f}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-d65de3a7"><text class="item-label data-v-d65de3a7">电池电量</text><text class="item-value data-v-d65de3a7">{{h}}%</text></view></view></view></view><view class="card pricing-card data-v-d65de3a7"><view class="card-header data-v-d65de3a7"><text class="card-title data-v-d65de3a7">计费规则</text></view><view class="pricing-banner data-v-d65de3a7"><view class="pricing-main data-v-d65de3a7"><text class="price data-v-d65de3a7">¥5.00</text><text class="unit data-v-d65de3a7">/小时</text></view><text class="cap-price data-v-d65de3a7">封顶 ¥99</text></view><view class="pricing-rules data-v-d65de3a7"><view class="rule-item data-v-d65de3a7"><view class="rule-dot data-v-d65de3a7"></view><text class="rule-text data-v-d65de3a7">前15分钟内归还<text class="highlight data-v-d65de3a7">免费</text></text></view><view class="rule-item data-v-d65de3a7"><view class="rule-dot data-v-d65de3a7"></view><text class="rule-text data-v-d65de3a7">不足60分钟按60分钟计费</text></view><view class="rule-item data-v-d65de3a7"><view class="rule-dot data-v-d65de3a7"></view><text class="rule-text data-v-d65de3a7">持续计费至99元视为买断</text></view></view></view><view class="card notice-card data-v-d65de3a7"><view class="card-header data-v-d65de3a7"><text class="card-title data-v-d65de3a7">使用须知</text></view><view class="notice-items data-v-d65de3a7"><view class="notice-item data-v-d65de3a7"><view class="notice-dot data-v-d65de3a7"></view><text class="notice-text data-v-d65de3a7">请在使用前检查设备是否完好</text></view><view class="notice-item data-v-d65de3a7"><view class="notice-dot data-v-d65de3a7"></view><text class="notice-text data-v-d65de3a7">请在指定区域内使用设备</text></view><view class="notice-item data-v-d65de3a7"><view class="notice-dot data-v-d65de3a7"></view><text class="notice-text data-v-d65de3a7">归还时请确保设备完好,避免损坏</text></view></view></view><view class="footer data-v-d65de3a7"><view class="wechat-credit data-v-d65de3a7"><image src="{{i}}" mode="aspectFit" class="wx-icon data-v-d65de3a7"></image><view class="credit-text data-v-d65de3a7"><text class="data-v-d65de3a7">微信支付分</text><text class="credit-divider data-v-d65de3a7">|</text><text class="credit-score data-v-d65de3a7">支付分200分及以上优享</text></view></view><button class="{{['rent-button', 'data-v-d65de3a7', k && 'return-button']}}" bindtap="{{l}}"><text class="data-v-d65de3a7">{{j}}</text></button><view class=" data-v-d65de3a7" style="align-items:center;align-content:center;text-align:center;line-height:50rpx" bindtap="{{m}}"> 无法免押点这里></view></view><view wx:if="{{n}}" class="phone-auth-popup data-v-d65de3a7"><view class="popup-mask data-v-d65de3a7" catchtap="{{o}}"></view><view class="popup-content data-v-d65de3a7"><view class="popup-header data-v-d65de3a7"><text class="popup-title data-v-d65de3a7">授权获取手机号</text></view><view class="popup-body data-v-d65de3a7"><view class="auth-desc data-v-d65de3a7"><text class="data-v-d65de3a7">为了提供更好的服务,需要授权获取您的手机号</text></view><button class="auth-btn data-v-d65de3a7" open-type="getPhoneNumber" bindgetphonenumber="{{p}}"> 一键获取手机号 </button><view class="auth-cancel data-v-d65de3a7" bindtap="{{q}}"><text class="data-v-d65de3a7">暂不授权</text></view></view></view></view></view>
+92
View File
@@ -301,4 +301,96 @@
.footer .rent-button.data-v-d65de3a7:active {
transform: scale(0.98);
opacity: 0.9;
}
/* 手机号授权弹窗样式 */
.phone-auth-popup.data-v-d65de3a7 {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.5);
}
.popup-mask.data-v-d65de3a7 {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.popup-content.data-v-d65de3a7 {
background-color: #fff;
border-radius: 24rpx;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.15);
width: 90%;
max-width: 500rpx;
padding: 40rpx 30rpx;
position: relative;
z-index: 1001;
display: flex;
flex-direction: column;
align-items: center;
}
.popup-header.data-v-d65de3a7 {
margin-bottom: 30rpx;
text-align: center;
}
.popup-title.data-v-d65de3a7 {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
.popup-body.data-v-d65de3a7 {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 30rpx;
}
.auth-desc.data-v-d65de3a7 {
font-size: 28rpx;
color: #666;
text-align: center;
margin-bottom: 30rpx;
line-height: 1.6;
}
.auth-btn.data-v-d65de3a7 {
width: 100%;
height: 92rpx;
border-radius: 46rpx;
background: linear-gradient(135deg, #07c160, #10d673);
color: #fff;
font-size: 32rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
border: none;
margin-bottom: 20rpx;
}
.auth-btn.data-v-d65de3a7:active {
transform: scale(0.98);
opacity: 0.9;
}
.auth-cancel.data-v-d65de3a7 {
width: 100%;
height: 92rpx;
border-radius: 46rpx;
background-color: #f5f7fa;
color: #333;
font-size: 32rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
border: none;
}
.auth-cancel.data-v-d65de3a7:active {
transform: scale(0.98);
opacity: 0.9;
}
+16 -17
View File
@@ -14,10 +14,8 @@ const _sfc_main = {
fail: reject
});
});
common_vendor.index.__f__("log", "at pages/index/index.vue:131", scanResult.path);
common_vendor.index.__f__("log", "at pages/index/index.vue:152", scanResult.path);
let deviceNo = util_index.getQueryString(scanResult.path, "deviceNo");
common_vendor.index.__f__("log", "at pages/index/index.vue:134", "扫码路径:", scanResult.path);
common_vendor.index.__f__("log", "at pages/index/index.vue:135", "解析到的设备号:", deviceNo);
if (!deviceNo) {
common_vendor.index.showToast({
title: "无效的设备二维码",
@@ -36,14 +34,12 @@ const _sfc_main = {
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
common_vendor.index.__f__("log", "at pages/index/index.vue:160", "使用中订单检查结果:", JSON.stringify(inUseRes));
if (inUseRes.statusCode == 200 && inUseRes.data.code == 200 && inUseRes.data.data) {
const inUseOrder = inUseRes.data.data;
common_vendor.index.__f__("log", "at pages/index/index.vue:165", "检测到使用中订单,准备跳转:", inUseOrder);
common_vendor.index.reLaunch({
url: `/pages/return/index?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
});
common_vendor.index.__f__("log", "at pages/index/index.vue:171", "已发起页面跳转");
common_vendor.index.__f__("log", "at pages/index/index.vue:187", "已发起页面跳转");
return;
}
const orderRes = await common_vendor.index.request({
@@ -54,28 +50,26 @@ const _sfc_main = {
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
common_vendor.index.__f__("log", "at pages/index/index.vue:185", "待支付订单检查结果:", JSON.stringify(orderRes));
common_vendor.index.__f__("log", "at pages/index/index.vue:201", "待支付订单检查结果:", JSON.stringify(orderRes));
if (orderRes.statusCode == 200 && orderRes.data.code == 200 && orderRes.data.data) {
const unpaidOrder = orderRes.data.data;
common_vendor.index.__f__("log", "at pages/index/index.vue:190", "检测到待支付订单,准备跳转:", unpaidOrder);
common_vendor.index.navigateTo({
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
});
} else {
common_vendor.index.__f__("log", "at pages/index/index.vue:196", "无待支付订单,获取设备信息, deviceNo:", deviceNo);
try {
const deviceInfoRes = await config_user.getDeviceInfo(deviceNo);
if (deviceInfoRes.code == 200 && deviceInfoRes.data && deviceInfoRes.data.device) {
const deviceInfo = deviceInfoRes.data.device;
if (deviceInfo.feeConfig) {
common_vendor.index.__f__("log", "at pages/index/index.vue:207", "获取到设备feeConfig信息:", deviceInfo.feeConfig);
common_vendor.index.__f__("log", "at pages/index/index.vue:219", "获取到设备feeConfig信息:", deviceInfo.feeConfig);
try {
const feeConfig = JSON.parse(deviceInfo.feeConfig);
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`
});
} catch (e) {
common_vendor.index.__f__("error", "at pages/index/index.vue:218", "解析feeConfig失败:", e);
common_vendor.index.__f__("error", "at pages/index/index.vue:230", "解析feeConfig失败:", e);
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
@@ -86,7 +80,7 @@ const _sfc_main = {
});
}
} else {
common_vendor.index.__f__("error", "at pages/index/index.vue:232", "获取设备信息失败:", deviceInfoRes.msg || "未知错误");
common_vendor.index.__f__("error", "at pages/index/index.vue:244", "获取设备信息失败:", deviceInfoRes.msg || "未知错误");
common_vendor.index.showToast({
title: "获取设备信息失败",
icon: "none"
@@ -96,7 +90,7 @@ const _sfc_main = {
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:244", "获取设备信息异常:", error);
common_vendor.index.__f__("error", "at pages/index/index.vue:256", "获取设备信息异常:", error);
common_vendor.index.showToast({
title: "获取设备信息失败",
icon: "none"
@@ -107,7 +101,7 @@ const _sfc_main = {
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:257", "扫码处理失败:", error);
common_vendor.index.__f__("error", "at pages/index/index.vue:269", "扫码处理失败:", error);
common_vendor.index.showToast({
title: "扫码失败",
icon: "none"
@@ -117,11 +111,16 @@ const _sfc_main = {
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
return common_vendor.e({
a: common_assets._imports_0,
b: common_assets._imports_1,
c: common_vendor.o((...args) => $options.handleScan && $options.handleScan(...args))
};
c: common_vendor.o((...args) => $options.handleScan && $options.handleScan(...args)),
d: _ctx.showPhoneAuthPopup
}, _ctx.showPhoneAuthPopup ? {
e: common_vendor.o(($event) => _ctx.showPhoneAuthPopup = false),
f: common_vendor.o((...args) => _ctx.onGetPhoneNumber && _ctx.onGetPhoneNumber(...args)),
g: common_vendor.o(($event) => _ctx.showPhoneAuthPopup = false)
} : {});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-1cf27b2a"]]);
wx.createPage(MiniProgramPage);
+1 -1
View File
@@ -1 +1 @@
<view class="container data-v-1cf27b2a"><view class="header data-v-1cf27b2a"><view class="header-bg data-v-1cf27b2a"><view class="circle-decoration circle-1 data-v-1cf27b2a"></view><view class="circle-decoration circle-2 data-v-1cf27b2a"></view><view class="wave-decoration data-v-1cf27b2a"></view></view><view class="header-content data-v-1cf27b2a"><view class="brand-area data-v-1cf27b2a"><image class="brand-logo data-v-1cf27b2a" src="{{a}}" mode="aspectFit"></image><view class="brand-text data-v-1cf27b2a"><text class="title data-v-1cf27b2a">共享风扇</text><text class="subtitle data-v-1cf27b2a">随时随地,享受清凉</text></view></view><view class="header-info data-v-1cf27b2a"><view class="service-tag data-v-1cf27b2a"><text class="data-v-1cf27b2a">便捷租赁</text><text class="dot data-v-1cf27b2a">·</text><text class="data-v-1cf27b2a">品质保障</text></view></view></view></view><view class="scan-section data-v-1cf27b2a"><view class="scan-card data-v-1cf27b2a"><view class="scan-btn data-v-1cf27b2a" bindtap="{{c}}"><image class="scan-icon data-v-1cf27b2a" src="{{b}}" mode="aspectFit"/><text class="scan-text data-v-1cf27b2a">扫码使用</text></view><view class="scan-desc data-v-1cf27b2a"><text class="data-v-1cf27b2a">扫描设备二维码即可使用或归还</text></view></view></view><view class="price-card data-v-1cf27b2a"><view class="card-header data-v-1cf27b2a"><text class="card-title data-v-1cf27b2a">收费规则</text></view><view class="price-rules data-v-1cf27b2a"><view class="price-item data-v-1cf27b2a"><view class="price-tag data-v-1cf27b2a">5.0<text class="unit data-v-1cf27b2a">元/小时</text></view></view><view class="divider data-v-1cf27b2a"></view><view class="rule-list data-v-1cf27b2a"><view class="rule-item data-v-1cf27b2a"><view class="rule-dot data-v-1cf27b2a"></view><text class="data-v-1cf27b2a">15分钟内归还免费</text></view><view class="rule-item data-v-1cf27b2a"><view class="rule-dot data-v-1cf27b2a"></view><text class="data-v-1cf27b2a">不足1小时按1小时计费</text></view><view class="rule-item data-v-1cf27b2a"><view class="rule-dot data-v-1cf27b2a"></view><text class="data-v-1cf27b2a">封顶99元,计费达99元视为买断</text></view></view></view></view><view class="usage-steps data-v-1cf27b2a"><view class="steps-header data-v-1cf27b2a"><text class="steps-title data-v-1cf27b2a">使用流程</text></view><view class="steps-container data-v-1cf27b2a"><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">1</text></view><text class="step-text data-v-1cf27b2a">扫码弹出</text></view><view class="step-arrow data-v-1cf27b2a"></view><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">2</text></view><text class="step-text data-v-1cf27b2a">使用风扇</text></view><view class="step-arrow data-v-1cf27b2a"></view><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">3</text></view><text class="step-text data-v-1cf27b2a">插入归还</text></view><view class="step-arrow data-v-1cf27b2a"></view><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">4</text></view><text class="step-text data-v-1cf27b2a">结束订单</text></view></view></view></view>
<view class="container data-v-1cf27b2a"><view class="header data-v-1cf27b2a"><view class="header-bg data-v-1cf27b2a"><view class="circle-decoration circle-1 data-v-1cf27b2a"></view><view class="circle-decoration circle-2 data-v-1cf27b2a"></view><view class="wave-decoration data-v-1cf27b2a"></view></view><view class="header-content data-v-1cf27b2a"><view class="brand-area data-v-1cf27b2a"><image class="brand-logo data-v-1cf27b2a" src="{{a}}" mode="aspectFit"></image><view class="brand-text data-v-1cf27b2a"><text class="title data-v-1cf27b2a">共享风扇</text><text class="subtitle data-v-1cf27b2a">随时随地,享受清凉</text></view></view><view class="header-info data-v-1cf27b2a"><view class="service-tag data-v-1cf27b2a"><text class="data-v-1cf27b2a">便捷租赁</text><text class="dot data-v-1cf27b2a">·</text><text class="data-v-1cf27b2a">品质保障</text></view></view></view></view><view class="scan-section data-v-1cf27b2a"><view class="scan-card data-v-1cf27b2a"><view class="scan-btn data-v-1cf27b2a" bindtap="{{c}}"><image class="scan-icon data-v-1cf27b2a" src="{{b}}" mode="aspectFit"/><text class="scan-text data-v-1cf27b2a">扫码使用</text></view><view class="scan-desc data-v-1cf27b2a"><text class="data-v-1cf27b2a">扫描设备二维码即可使用或归还</text></view></view></view><view class="price-card data-v-1cf27b2a"><view class="card-header data-v-1cf27b2a"><text class="card-title data-v-1cf27b2a">收费规则</text></view><view class="price-rules data-v-1cf27b2a"><view class="price-item data-v-1cf27b2a"><view class="price-tag data-v-1cf27b2a">5.0<text class="unit data-v-1cf27b2a">元/小时</text></view></view><view class="divider data-v-1cf27b2a"></view><view class="rule-list data-v-1cf27b2a"><view class="rule-item data-v-1cf27b2a"><view class="rule-dot data-v-1cf27b2a"></view><text class="data-v-1cf27b2a">15分钟内归还免费</text></view><view class="rule-item data-v-1cf27b2a"><view class="rule-dot data-v-1cf27b2a"></view><text class="data-v-1cf27b2a">不足1小时按1小时计费</text></view><view class="rule-item data-v-1cf27b2a"><view class="rule-dot data-v-1cf27b2a"></view><text class="data-v-1cf27b2a">封顶99元,计费达99元视为买断</text></view></view></view></view><view class="usage-steps data-v-1cf27b2a"><view class="steps-header data-v-1cf27b2a"><text class="steps-title data-v-1cf27b2a">使用流程</text></view><view class="steps-container data-v-1cf27b2a"><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">1</text></view><text class="step-text data-v-1cf27b2a">扫码弹出</text></view><view class="step-arrow data-v-1cf27b2a"></view><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">2</text></view><text class="step-text data-v-1cf27b2a">使用风扇</text></view><view class="step-arrow data-v-1cf27b2a"></view><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">3</text></view><text class="step-text data-v-1cf27b2a">插入归还</text></view><view class="step-arrow data-v-1cf27b2a"></view><view class="step-item data-v-1cf27b2a"><view class="step-icon data-v-1cf27b2a"><text class="step-number data-v-1cf27b2a">4</text></view><text class="step-text data-v-1cf27b2a">结束订单</text></view></view></view><view wx:if="{{d}}" class="phone-auth-popup data-v-1cf27b2a"><view class="popup-mask data-v-1cf27b2a" catchtap="{{e}}"></view><view class="popup-content data-v-1cf27b2a"><view class="popup-header data-v-1cf27b2a"><text class="popup-title data-v-1cf27b2a">授权获取手机号</text></view><view class="popup-body data-v-1cf27b2a"><view class="auth-desc data-v-1cf27b2a"><text class="data-v-1cf27b2a">为了提供更好的服务和紧急联系,需要授权获取您的手机号</text></view><button class="auth-btn data-v-1cf27b2a" open-type="getPhoneNumber" bindgetphonenumber="{{f}}"><text class="data-v-1cf27b2a">一键获取手机号</text></button><view class="auth-cancel data-v-1cf27b2a" bindtap="{{g}}"><text class="data-v-1cf27b2a">暂不授权</text></view></view></view></view></view>
+48 -1
View File
@@ -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