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
@@ -1,5 +1,5 @@
// export const URL = "https://my.gxfs123.com/api" //正式服务器
export const URL = "https://unifans.gxfs123.com/api" //测试服务器
// export const URL = "http://192.168.10.70:8080" //本地调试
// export const URL = "http://192.168.10.3:8080" //本地调试
export const appid = "wx2165f0be356ae7a9" //小程序appid
+7 -1
View File
@@ -54,7 +54,13 @@
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
"usingComponents" : true,
// "requiredPrivateInfos" : [ "getPhoneNumber" ],
"permission" : {
"scope.getPhoneNumber" : {
"desc" : "您的手机号将用于登录和订单服务"
}
}
},
"mp-alipay" : {
"usingComponents" : true
+245 -3
View File
@@ -126,6 +126,27 @@
@click="handleRent('wx-pay')">
无法免押点这里></view>
</view>
<!-- 手机号授权弹窗 -->
<view class="phone-auth-popup" v-if="showPhoneAuthPopup">
<view class="popup-mask" @click.stop></view>
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">授权获取手机号</text>
</view>
<view class="popup-body">
<view class="auth-desc">
<text>为了提供更好的服务需要授权获取您的手机号</text>
</view>
<button class="auth-btn" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">
一键获取手机号
</button>
<view class="auth-cancel" @click="showPhoneAuthPopup = false">
<text>暂不授权</text>
</view>
</view>
</view>
</view>
</view>
</template>
@@ -151,7 +172,9 @@
URL
} from "@/config/url.js"
import {
initiateWeChatScorePayment
initiateWeChatScorePayment,
getUserInfo,
getUserPhoneNumber
} from '@/util/index.js'
// 响应式状态
@@ -166,6 +189,7 @@
})
const isLoggedIn = ref(true)
const phoneNumber = ref('')
const showPhoneAuthPopup = ref(false)
// 生命周期 onLoad 钩子
onLoad((options) => {
@@ -175,6 +199,116 @@
fetchDeviceInfo()
})
onMounted(()=>{
checkUserPhone()
})
const checkUserPhone = async () => {
try {
const userInfoRes = await getUserInfo()
console.log(userInfoRes.data.phone, 'getUserInfoPhone')
if (userInfoRes.code == 200 && userInfoRes.data && userInfoRes.data.phone) {
phoneNumber.value = userInfoRes.data.phone
} else {
// 如果没有手机号,显示授权弹窗
showPhoneAuthPopup.value = true
}
} catch (error) {
console.error('获取用户信息失败:', error)
}
}
// 处理获取手机号
const onGetPhoneNumber = (e) => {
console.log('getPhoneNumber event:', e.detail)
// 用户拒绝授权的情况
if (e.detail.errMsg && e.detail.errMsg.includes('deny')) {
uni.showToast({
title: '需要授权手机号才能使用设备',
icon: 'none'
})
return
}
// 获取到授权code
if (e.detail.code) {
uni.showLoading({
title: '获取中...'
})
console.log('获取到的授权code:', e.detail.code)
// 添加 try-catch 以捕获任何 Promise 外部的错误
try {
getUserPhoneNumber(e.detail.code)
.then(res => {
console.log('获取手机号API响应原始数据:', JSON.stringify(res))
uni.hideLoading()
// 不立即抛出错误,而是记录问题并继续处理
if (!res) {
console.error('API返回数据为空')
uni.showModal({
title: '数据异常',
content: 'API返回为空',
showCancel: false
})
return
}
// 检查响应格式
console.log('响应code:', res.code, '响应类型:', typeof res.code)
console.log('是否有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
uni.showToast({
title: '手机号获取成功',
icon: 'success'
})
} else {
// 记录详细信息,不抛出错误
console.warn('获取手机号响应异常:', res.msg || '未知错误')
uni.showModal({
title: '获取手机号异常',
content: `状态码: ${res.code}, 消息: ${res.msg || '无'}`,
showCancel: false
})
}
})
.catch(err => {
uni.hideLoading()
console.error('获取手机号码失败(catch):', err)
// 显示更详细的错误信息
let errMsg = err.message || err.toString()
uni.showModal({
title: '获取手机号失败',
content: '错误信息: ' + errMsg,
showCancel: false
})
})
} catch (outerError) {
uni.hideLoading()
console.error('获取手机号外部错误:', outerError)
uni.showModal({
title: '意外错误',
content: '处理过程发生异常: ' + (outerError.message || outerError),
showCancel: false
})
}
} else {
uni.showToast({
title: '获取授权码失败',
icon: 'none'
})
}
}
// 检查登录状态和订单
const fetchDeviceInfo = async () => {
const res = await getDeviceInfo(deviceId.value)
@@ -254,8 +388,14 @@
return
}
// 直接提交订单,不显示确认对话框
submitRentOrder(payWay);
// 检查是否有手机号,如果没有则提示授权
if (!phoneNumber.value) {
showPhoneAuthPopup.value = true
return
}
// 提交订单
submitRentOrder(payWay)
}
const selectedPkg = reactive({
@@ -761,4 +901,106 @@
}
}
}
/* 手机号授权弹窗样式 */
.phone-auth-popup {
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 {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.popup-content {
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 {
margin-bottom: 30rpx;
text-align: center;
}
.popup-title {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
.popup-body {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 30rpx;
}
.auth-desc {
font-size: 28rpx;
color: #666;
text-align: center;
margin-bottom: 30rpx;
line-height: 1.6;
}
.auth-btn {
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;
&:active {
transform: scale(0.98);
opacity: 0.9;
}
}
.auth-cancel {
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;
&:active {
transform: scale(0.98);
opacity: 0.9;
}
}
</style>
+21 -9
View File
@@ -104,6 +104,27 @@
</view>
</view>
</view>
<!-- 手机号授权弹窗 -->
<view class="phone-auth-popup" v-if="showPhoneAuthPopup">
<view class="popup-mask" @click.stop="showPhoneAuthPopup = false"></view>
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">授权获取手机号</text>
</view>
<view class="popup-body">
<view class="auth-desc">
<text>为了提供更好的服务和紧急联系需要授权获取您的手机号</text>
</view>
<button class="auth-btn" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">
<text>一键获取手机号</text>
</button>
<view class="auth-cancel" @click="showPhoneAuthPopup = false">
<text>暂不授权</text>
</view>
</view>
</view>
</view>
</view>
</template>
@@ -131,8 +152,6 @@
console.log(scanResult.path);
let deviceNo = getQueryString(scanResult.path, 'deviceNo')
console.log('扫码路径:', scanResult.path)
console.log('解析到的设备号:', deviceNo)
if (!deviceNo) {
uni.showToast({
@@ -157,12 +176,9 @@
}
})
console.log('使用中订单检查结果:', JSON.stringify(inUseRes))
if (inUseRes.statusCode == 200 && inUseRes.data.code == 200 && inUseRes.data.data) {
// 存在使用中的订单,跳转到归还页面
const inUseOrder = inUseRes.data.data
console.log('检测到使用中订单,准备跳转:', inUseOrder)
// 直接使用reLaunch而不是navigateTo以确保页面跳转
uni.reLaunch({
@@ -187,14 +203,10 @@
if (orderRes.statusCode == 200 && orderRes.data.code == 200 && orderRes.data.data) {
// 存在待支付订单,跳转到支付页面
const unpaidOrder = orderRes.data.data
console.log('检测到待支付订单,准备跳转:', unpaidOrder)
uni.navigateTo({
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
})
} else {
// 修改:直接获取设备信息,而不是跳转到详情页面
console.log('无待支付订单,获取设备信息, deviceNo:', deviceNo)
try {
// 获取设备信息
const deviceInfoRes = await getDeviceInfo(deviceNo)
+5
View File
@@ -39,5 +39,10 @@
}
]
},
"permission": {
"scope.getPhoneNumber": {
"desc": "您的手机号将用于登录和订单服务"
}
},
"usingComponents": {}
}
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
<view class="container data-v-2faa63bb"><view class="device-header data-v-2faa63bb"><view class="{{['device-status-card', 'data-v-2faa63bb', b]}}"><view class="status-indicator data-v-2faa63bb"></view><text class="status-text data-v-2faa63bb">{{a}}</text></view><view class="device-title data-v-2faa63bb"><text class="name data-v-2faa63bb">共享风扇</text><view class="device-meta data-v-2faa63bb"><text class="id-label data-v-2faa63bb">设备号:</text><text class="id-value data-v-2faa63bb">{{c}}</text></view></view></view><view class="card device-info-card data-v-2faa63bb"><view class="card-row data-v-2faa63bb"><view class="card-item data-v-2faa63bb"><view class="item-icon location-icon data-v-2faa63bb"><image class="data-v-2faa63bb" src="{{d}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-2faa63bb"><text class="item-label data-v-2faa63bb">当前位置</text><text class="item-value data-v-2faa63bb">{{e}}</text></view></view><view class="card-item data-v-2faa63bb"><view class="{{['item-icon', 'battery-icon', 'data-v-2faa63bb', g && 'battery-low']}}"><image class="data-v-2faa63bb" src="{{f}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-2faa63bb"><text class="item-label data-v-2faa63bb">电池电量</text><text class="item-value data-v-2faa63bb">{{h}}%</text></view></view></view></view><view class="card pricing-card data-v-2faa63bb"><view class="card-header data-v-2faa63bb"><text class="card-title data-v-2faa63bb">计费规则</text></view><view class="pricing-banner data-v-2faa63bb"><view class="pricing-main data-v-2faa63bb"><text class="price data-v-2faa63bb">¥5.00</text><text class="unit data-v-2faa63bb">/小时</text></view><text class="cap-price data-v-2faa63bb">封顶 ¥99</text></view><view class="pricing-rules data-v-2faa63bb"><view class="rule-item data-v-2faa63bb"><view class="rule-dot data-v-2faa63bb"></view><text class="rule-text data-v-2faa63bb">前15分钟内归还<text class="highlight data-v-2faa63bb">免费</text></text></view><view class="rule-item data-v-2faa63bb"><view class="rule-dot data-v-2faa63bb"></view><text class="rule-text data-v-2faa63bb">不足60分钟按60分钟计费</text></view><view class="rule-item data-v-2faa63bb"><view class="rule-dot data-v-2faa63bb"></view><text class="rule-text data-v-2faa63bb">持续计费至99元视为买断</text></view></view></view><view class="card notice-card data-v-2faa63bb"><view class="card-header data-v-2faa63bb"><text class="card-title data-v-2faa63bb">使用须知</text></view><view class="notice-items data-v-2faa63bb"><view class="notice-item data-v-2faa63bb"><view class="notice-dot data-v-2faa63bb"></view><text class="notice-text data-v-2faa63bb">请在使用前检查设备是否完好</text></view><view class="notice-item data-v-2faa63bb"><view class="notice-dot data-v-2faa63bb"></view><text class="notice-text data-v-2faa63bb">请在指定区域内使用设备</text></view><view class="notice-item data-v-2faa63bb"><view class="notice-dot data-v-2faa63bb"></view><text class="notice-text data-v-2faa63bb">归还时请确保设备完好,避免损坏</text></view></view></view><view class="footer data-v-2faa63bb"><view class="wechat-credit data-v-2faa63bb"><image src="{{i}}" mode="aspectFit" class="wx-icon data-v-2faa63bb"></image><view class="credit-text data-v-2faa63bb"><text class="data-v-2faa63bb">微信支付分</text><text class="credit-divider data-v-2faa63bb">|</text><text class="credit-score data-v-2faa63bb">支付分200分及以上优享</text></view></view><button class="{{['rent-button', 'data-v-2faa63bb', k && 'return-button']}}" bindtap="{{l}}"><text class="data-v-2faa63bb">{{j}}</text></button><view class=" data-v-2faa63bb" style="align-items:center;align-content:center;text-align:center;line-height:50rpx" bindtap="{{m}}"> 无法免押点这里></view></view></view>
<view class="container data-v-981f4200"><view class="device-header data-v-981f4200"><view class="{{['device-status-card', 'data-v-981f4200', b]}}"><view class="status-indicator data-v-981f4200"></view><text class="status-text data-v-981f4200">{{a}}</text></view><view class="device-title data-v-981f4200"><text class="name data-v-981f4200">共享风扇</text><view class="device-meta data-v-981f4200"><text class="id-label data-v-981f4200">设备号:</text><text class="id-value data-v-981f4200">{{c}}</text></view></view></view><view class="card device-info-card data-v-981f4200"><view class="card-row data-v-981f4200"><view class="card-item data-v-981f4200"><view class="item-icon location-icon data-v-981f4200"><image class="data-v-981f4200" src="{{d}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-981f4200"><text class="item-label data-v-981f4200">当前位置</text><text class="item-value data-v-981f4200">{{e}}</text></view></view><view class="card-item data-v-981f4200"><view class="{{['item-icon', 'battery-icon', 'data-v-981f4200', g && 'battery-low']}}"><image class="data-v-981f4200" src="{{f}}" mode="aspectFill" style="width:45rpx;height:45rpx"></image></view><view class="item-content data-v-981f4200"><text class="item-label data-v-981f4200">电池电量</text><text class="item-value data-v-981f4200">{{h}}%</text></view></view></view></view><view class="card pricing-card data-v-981f4200"><view class="card-header data-v-981f4200"><text class="card-title data-v-981f4200">计费规则</text></view><view class="pricing-banner data-v-981f4200"><view class="pricing-main data-v-981f4200"><text class="price data-v-981f4200">¥5.00</text><text class="unit data-v-981f4200">/小时</text></view><text class="cap-price data-v-981f4200">封顶 ¥99</text></view><view class="pricing-rules data-v-981f4200"><view class="rule-item data-v-981f4200"><view class="rule-dot data-v-981f4200"></view><text class="rule-text data-v-981f4200">前15分钟内归还<text class="highlight data-v-981f4200">免费</text></text></view><view class="rule-item data-v-981f4200"><view class="rule-dot data-v-981f4200"></view><text class="rule-text data-v-981f4200">不足60分钟按60分钟计费</text></view><view class="rule-item data-v-981f4200"><view class="rule-dot data-v-981f4200"></view><text class="rule-text data-v-981f4200">持续计费至99元视为买断</text></view></view></view><view class="card notice-card data-v-981f4200"><view class="card-header data-v-981f4200"><text class="card-title data-v-981f4200">使用须知</text></view><view class="notice-items data-v-981f4200"><view class="notice-item data-v-981f4200"><view class="notice-dot data-v-981f4200"></view><text class="notice-text data-v-981f4200">请在使用前检查设备是否完好</text></view><view class="notice-item data-v-981f4200"><view class="notice-dot data-v-981f4200"></view><text class="notice-text data-v-981f4200">请在指定区域内使用设备</text></view><view class="notice-item data-v-981f4200"><view class="notice-dot data-v-981f4200"></view><text class="notice-text data-v-981f4200">归还时请确保设备完好,避免损坏</text></view></view></view><view class="footer data-v-981f4200"><view class="wechat-credit data-v-981f4200"><image src="{{i}}" mode="aspectFit" class="wx-icon data-v-981f4200"></image><view class="credit-text data-v-981f4200"><text class="data-v-981f4200">微信支付分</text><text class="credit-divider data-v-981f4200">|</text><text class="credit-score data-v-981f4200">支付分200分及以上优享</text></view></view><button class="{{['rent-button', 'data-v-981f4200', k && 'return-button']}}" bindtap="{{l}}"><text class="data-v-981f4200">{{j}}</text></button><view class=" data-v-981f4200" 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-981f4200"><view class="popup-mask data-v-981f4200" catchtap="{{o}}"></view><view class="popup-content data-v-981f4200"><view class="popup-header data-v-981f4200"><text class="popup-title data-v-981f4200">授权获取手机号</text></view><view class="popup-body data-v-981f4200"><view class="auth-desc data-v-981f4200"><text class="data-v-981f4200">为了提供更好的服务,需要授权获取您的手机号</text></view><button class="auth-btn data-v-981f4200" open-type="getPhoneNumber" bindgetphonenumber="{{p}}"> 一键获取手机号 </button><view class="auth-cancel data-v-981f4200" bindtap="{{q}}"><text class="data-v-981f4200">暂不授权</text></view></view></view></view></view>
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
"use strict";const e=require("../../common/vendor.js"),o=require("../../util/index.js"),n=require("../../config/url.js"),t=require("../../config/user.js"),i=require("../../common/assets.js"),a={methods:{async handleScan(){try{const d=await new Promise(((o,n)=>{e.index.scanCode({success:o,fail:n})}));console.log(d.path);let r=o.getQueryString(d.path,"deviceNo");if(console.log("扫码路径:",d.path),console.log("解析到的设备号:",r),!r)return void e.index.showToast({title:"无效的设备二维码",icon:"none"});e.index.getStorageSync("token")||await o.wxLogin();const c=await e.index.request({url:`${n.URL||"http://127.0.0.1:8080"}/app/order/inUse`,method:"GET",header:{Authorization:"Bearer "+e.index.getStorageSync("token"),Clientid:e.index.getStorageSync("client_id")}});if(console.log("使用中订单检查结果:",JSON.stringify(c)),200==c.statusCode&&200==c.data.code&&c.data.data){const o=c.data.data;return console.log("检测到使用中订单,准备跳转:",o),e.index.reLaunch({url:`/pages/return/index?orderId=${o.orderId}&deviceId=${r||o.deviceNo}`}),void console.log("已发起页面跳转")}const s=await e.index.request({url:`${n.URL||"http://127.0.0.1:8080"}/app/order/unpaid`,method:"GET",header:{Authorization:"Bearer "+e.index.getStorageSync("token"),Clientid:e.index.getStorageSync("client_id")}});if(console.log("待支付订单检查结果:",JSON.stringify(s)),200==s.statusCode&&200==s.data.code&&s.data.data){const o=s.data.data;console.log("检测到待支付订单,准备跳转:",o),e.index.navigateTo({url:`/pages/order/payment?orderId=${o.orderId}`})}else{console.log("无待支付订单,获取设备信息, deviceNo:",r);try{const o=await t.getDeviceInfo(r);if(200==o.code&&o.data&&o.data.device){const n=o.data.device;if(n.feeConfig){console.log("获取到设备feeConfig信息:",n.feeConfig);try{JSON.parse(n.feeConfig);e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}&feeConfig=${encodeURIComponent(n.feeConfig)}`})}catch(i){console.error("解析feeConfig失败:",i),e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}}else e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}else console.error("获取设备信息失败:",o.msg||"未知错误"),e.index.showToast({title:"获取设备信息失败",icon:"none"}),e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}catch(a){console.error("获取设备信息异常:",a),e.index.showToast({title:"获取设备信息失败",icon:"none"}),e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}}}catch(a){console.error("扫码处理失败:",a),e.index.showToast({title:"扫码失败",icon:"none"})}}}};const d=e._export_sfc(a,[["render",function(o,n,t,a,d,r){return{a:i._imports_0,b:i._imports_1,c:e.o(((...e)=>r.handleScan&&r.handleScan(...e)))}}],["__scopeId","data-v-764894e1"]]);wx.createPage(d);
"use strict";const e=require("../../common/vendor.js"),o=require("../../util/index.js"),t=require("../../config/url.js"),n=require("../../config/user.js"),i=require("../../common/assets.js"),a={methods:{async handleScan(){try{const d=await new Promise(((o,t)=>{e.index.scanCode({success:o,fail:t})}));console.log(d.path);let r=o.getQueryString(d.path,"deviceNo");if(!r)return void e.index.showToast({title:"无效的设备二维码",icon:"none"});e.index.getStorageSync("token")||await o.wxLogin();const c=await e.index.request({url:`${t.URL||"http://127.0.0.1:8080"}/app/order/inUse`,method:"GET",header:{Authorization:"Bearer "+e.index.getStorageSync("token"),Clientid:e.index.getStorageSync("client_id")}});if(200==c.statusCode&&200==c.data.code&&c.data.data){const o=c.data.data;return e.index.reLaunch({url:`/pages/return/index?orderId=${o.orderId}&deviceId=${r||o.deviceNo}`}),void console.log("已发起页面跳转")}const s=await e.index.request({url:`${t.URL||"http://127.0.0.1:8080"}/app/order/unpaid`,method:"GET",header:{Authorization:"Bearer "+e.index.getStorageSync("token"),Clientid:e.index.getStorageSync("client_id")}});if(console.log("待支付订单检查结果:",JSON.stringify(s)),200==s.statusCode&&200==s.data.code&&s.data.data){const o=s.data.data;e.index.navigateTo({url:`/pages/order/payment?orderId=${o.orderId}`})}else try{const o=await n.getDeviceInfo(r);if(200==o.code&&o.data&&o.data.device){const t=o.data.device;if(t.feeConfig){console.log("获取到设备feeConfig信息:",t.feeConfig);try{JSON.parse(t.feeConfig);e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}&feeConfig=${encodeURIComponent(t.feeConfig)}`})}catch(i){console.error("解析feeConfig失败:",i),e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}}else e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}else console.error("获取设备信息失败:",o.msg||"未知错误"),e.index.showToast({title:"获取设备信息失败",icon:"none"}),e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}catch(a){console.error("获取设备信息异常:",a),e.index.showToast({title:"获取设备信息失败",icon:"none"}),e.index.navigateTo({url:`/pages/device/detail?deviceNo=${r}`})}}catch(a){console.error("扫码处理失败:",a),e.index.showToast({title:"扫码失败",icon:"none"})}}}};const d=e._export_sfc(a,[["render",function(o,t,n,a,d,r){return e.e({a:i._imports_0,b:i._imports_1,c:e.o(((...e)=>r.handleScan&&r.handleScan(...e))),d:o.showPhoneAuthPopup},o.showPhoneAuthPopup?{e:e.o((e=>o.showPhoneAuthPopup=!1)),f:e.o(((...e)=>o.onGetPhoneNumber&&o.onGetPhoneNumber(...e))),g:e.o((e=>o.showPhoneAuthPopup=!1))}:{})}],["__scopeId","data-v-527ff3b8"]]);wx.createPage(d);
+1 -1
View File
@@ -1 +1 @@
<view class="container data-v-764894e1"><view class="header data-v-764894e1"><view class="header-bg data-v-764894e1"><view class="circle-decoration circle-1 data-v-764894e1"></view><view class="circle-decoration circle-2 data-v-764894e1"></view><view class="wave-decoration data-v-764894e1"></view></view><view class="header-content data-v-764894e1"><view class="brand-area data-v-764894e1"><image class="brand-logo data-v-764894e1" src="{{a}}" mode="aspectFit"></image><view class="brand-text data-v-764894e1"><text class="title data-v-764894e1">共享风扇</text><text class="subtitle data-v-764894e1">随时随地,享受清凉</text></view></view><view class="header-info data-v-764894e1"><view class="service-tag data-v-764894e1"><text class="data-v-764894e1">便捷租赁</text><text class="dot data-v-764894e1">·</text><text class="data-v-764894e1">品质保障</text></view></view></view></view><view class="scan-section data-v-764894e1"><view class="scan-card data-v-764894e1"><view class="scan-btn data-v-764894e1" bindtap="{{c}}"><image class="scan-icon data-v-764894e1" src="{{b}}" mode="aspectFit"/><text class="scan-text data-v-764894e1">扫码使用</text></view><view class="scan-desc data-v-764894e1"><text class="data-v-764894e1">扫描设备二维码即可使用或归还</text></view></view></view><view class="price-card data-v-764894e1"><view class="card-header data-v-764894e1"><text class="card-title data-v-764894e1">收费规则</text></view><view class="price-rules data-v-764894e1"><view class="price-item data-v-764894e1"><view class="price-tag data-v-764894e1">5.0<text class="unit data-v-764894e1">元/小时</text></view></view><view class="divider data-v-764894e1"></view><view class="rule-list data-v-764894e1"><view class="rule-item data-v-764894e1"><view class="rule-dot data-v-764894e1"></view><text class="data-v-764894e1">15分钟内归还免费</text></view><view class="rule-item data-v-764894e1"><view class="rule-dot data-v-764894e1"></view><text class="data-v-764894e1">不足1小时按1小时计费</text></view><view class="rule-item data-v-764894e1"><view class="rule-dot data-v-764894e1"></view><text class="data-v-764894e1">封顶99元,计费达99元视为买断</text></view></view></view></view><view class="usage-steps data-v-764894e1"><view class="steps-header data-v-764894e1"><text class="steps-title data-v-764894e1">使用流程</text></view><view class="steps-container data-v-764894e1"><view class="step-item data-v-764894e1"><view class="step-icon data-v-764894e1"><text class="step-number data-v-764894e1">1</text></view><text class="step-text data-v-764894e1">扫码弹出</text></view><view class="step-arrow data-v-764894e1"></view><view class="step-item data-v-764894e1"><view class="step-icon data-v-764894e1"><text class="step-number data-v-764894e1">2</text></view><text class="step-text data-v-764894e1">使用风扇</text></view><view class="step-arrow data-v-764894e1"></view><view class="step-item data-v-764894e1"><view class="step-icon data-v-764894e1"><text class="step-number data-v-764894e1">3</text></view><text class="step-text data-v-764894e1">插入归还</text></view><view class="step-arrow data-v-764894e1"></view><view class="step-item data-v-764894e1"><view class="step-icon data-v-764894e1"><text class="step-number data-v-764894e1">4</text></view><text class="step-text data-v-764894e1">结束订单</text></view></view></view></view>
<view class="container data-v-527ff3b8"><view class="header data-v-527ff3b8"><view class="header-bg data-v-527ff3b8"><view class="circle-decoration circle-1 data-v-527ff3b8"></view><view class="circle-decoration circle-2 data-v-527ff3b8"></view><view class="wave-decoration data-v-527ff3b8"></view></view><view class="header-content data-v-527ff3b8"><view class="brand-area data-v-527ff3b8"><image class="brand-logo data-v-527ff3b8" src="{{a}}" mode="aspectFit"></image><view class="brand-text data-v-527ff3b8"><text class="title data-v-527ff3b8">共享风扇</text><text class="subtitle data-v-527ff3b8">随时随地,享受清凉</text></view></view><view class="header-info data-v-527ff3b8"><view class="service-tag data-v-527ff3b8"><text class="data-v-527ff3b8">便捷租赁</text><text class="dot data-v-527ff3b8">·</text><text class="data-v-527ff3b8">品质保障</text></view></view></view></view><view class="scan-section data-v-527ff3b8"><view class="scan-card data-v-527ff3b8"><view class="scan-btn data-v-527ff3b8" bindtap="{{c}}"><image class="scan-icon data-v-527ff3b8" src="{{b}}" mode="aspectFit"/><text class="scan-text data-v-527ff3b8">扫码使用</text></view><view class="scan-desc data-v-527ff3b8"><text class="data-v-527ff3b8">扫描设备二维码即可使用或归还</text></view></view></view><view class="price-card data-v-527ff3b8"><view class="card-header data-v-527ff3b8"><text class="card-title data-v-527ff3b8">收费规则</text></view><view class="price-rules data-v-527ff3b8"><view class="price-item data-v-527ff3b8"><view class="price-tag data-v-527ff3b8">5.0<text class="unit data-v-527ff3b8">元/小时</text></view></view><view class="divider data-v-527ff3b8"></view><view class="rule-list data-v-527ff3b8"><view class="rule-item data-v-527ff3b8"><view class="rule-dot data-v-527ff3b8"></view><text class="data-v-527ff3b8">15分钟内归还免费</text></view><view class="rule-item data-v-527ff3b8"><view class="rule-dot data-v-527ff3b8"></view><text class="data-v-527ff3b8">不足1小时按1小时计费</text></view><view class="rule-item data-v-527ff3b8"><view class="rule-dot data-v-527ff3b8"></view><text class="data-v-527ff3b8">封顶99元,计费达99元视为买断</text></view></view></view></view><view class="usage-steps data-v-527ff3b8"><view class="steps-header data-v-527ff3b8"><text class="steps-title data-v-527ff3b8">使用流程</text></view><view class="steps-container data-v-527ff3b8"><view class="step-item data-v-527ff3b8"><view class="step-icon data-v-527ff3b8"><text class="step-number data-v-527ff3b8">1</text></view><text class="step-text data-v-527ff3b8">扫码弹出</text></view><view class="step-arrow data-v-527ff3b8"></view><view class="step-item data-v-527ff3b8"><view class="step-icon data-v-527ff3b8"><text class="step-number data-v-527ff3b8">2</text></view><text class="step-text data-v-527ff3b8">使用风扇</text></view><view class="step-arrow data-v-527ff3b8"></view><view class="step-item data-v-527ff3b8"><view class="step-icon data-v-527ff3b8"><text class="step-number data-v-527ff3b8">3</text></view><text class="step-text data-v-527ff3b8">插入归还</text></view><view class="step-arrow data-v-527ff3b8"></view><view class="step-item data-v-527ff3b8"><view class="step-icon data-v-527ff3b8"><text class="step-number data-v-527ff3b8">4</text></view><text class="step-text data-v-527ff3b8">结束订单</text></view></view></view><view wx:if="{{d}}" class="phone-auth-popup data-v-527ff3b8"><view class="popup-mask data-v-527ff3b8" catchtap="{{e}}"></view><view class="popup-content data-v-527ff3b8"><view class="popup-header data-v-527ff3b8"><text class="popup-title data-v-527ff3b8">授权获取手机号</text></view><view class="popup-body data-v-527ff3b8"><view class="auth-desc data-v-527ff3b8"><text class="data-v-527ff3b8">为了提供更好的服务和紧急联系,需要授权获取您的手机号</text></view><button class="auth-btn data-v-527ff3b8" open-type="getPhoneNumber" bindgetphonenumber="{{f}}"><text class="data-v-527ff3b8">一键获取手机号</text></button><view class="auth-cancel data-v-527ff3b8" bindtap="{{g}}"><text class="data-v-527ff3b8">暂不授权</text></view></view></view></view></view>
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
"use strict";const e=require("../common/vendor.js"),n=require("../config/user.js");exports.getQueryString=function(e,n){var o=new RegExp("(^|&|/?)"+n+"=([^&|/?]*)(&|/?|$)","i"),i=e.substr(1).match(o);return null!=i?i[2]:null},exports.getUserInfo=()=>new Promise((async(e,o)=>{e(await n.getMyIndexInfo({isHide:!1}))})),exports.initiateWeChatScorePayment=n=>new Promise(((o,i)=>{n&&n.data&&n.data.package?e.wx$1.openBusinessView({businessType:"wxpayScoreUse",extraData:{mch_id:n.data.mch_id,package:n.data.package},success:e=>{"openBusinessView:ok"===e.errMsg?o(e):i(new Error("支付流程未完成"))},fail:n=>{console.error("微信支付分小程序调用失败",n),e.index.showToast({title:n.errMsg||"支付分接口调用失败",icon:"none"}),i(n)}}):i(new Error("支付参数不完整"))})),exports.wxLogin=()=>new Promise(((o,i)=>{e.index.login({provider:"weixin",success:async s=>{try{if(!s.code)throw new Error("获取微信登录凭证失败");{const i=await n.login({code:s.code,appid:"wx2165f0be356ae7a9"});if(200!==i.code)throw new Error(i.message||"登录失败");e.index.setStorageSync("token",i.data.LoginWxVo.access_token),e.index.setStorageSync("client_id",i.data.LoginWxVo.client_id),o(i.data)}}catch(t){e.index.showToast({title:t.message||"登录失败",icon:"none"}),i(t)}},fail:n=>{e.index.showToast({title:"微信登录失败",icon:"none"}),i(n)}})}));
"use strict";const e=require("../common/vendor.js"),r=require("../config/user.js"),o=require("../config/url.js");exports.getQueryString=function(e,r){var o=new RegExp("(^|&|/?)"+r+"=([^&|/?]*)(&|/?|$)","i"),n=e.substr(1).match(o);return null!=n?n[2]:null},exports.getUserInfo=()=>new Promise((async(e,o)=>{e(await r.getMyIndexInfo({isHide:!1}))})),exports.getUserPhoneNumber=r=>new Promise((async(n,t)=>{try{const s=e.index.getStorageSync("token");if(!s)return void t(new Error("用户未登录"));console.log("开始请求获取手机号,code=",r,"请求地址=",o.URL+"/app/user/getPhoneNumber"),e.index.request({url:o.URL+"/app/user/getPhoneNumber",method:"POST",header:{Authorization:"Bearer "+s,clientId:e.index.getStorageSync("client_id"),"Content-Type":"application/json"},data:{code:r,appid:o.appid},success:e=>{console.log("请求获取手机号接口成功,原始响应:",JSON.stringify(e)),200===e.statusCode?e.data?n(e.data):t(new Error("服务器返回空数据")):t(new Error(`HTTP错误: ${e.statusCode}`))},fail:e=>{console.error("请求获取手机号接口网络错误:",e),t(new Error("请求获取手机号接口失败: "+(e.errMsg||JSON.stringify(e))))}})}catch(s){console.error("获取手机号过程中出现异常:",s),t(new Error("获取手机号异常: "+(s.message||JSON.stringify(s))))}})),exports.initiateWeChatScorePayment=r=>new Promise(((o,n)=>{r&&r.data&&r.data.package?e.wx$1.openBusinessView({businessType:"wxpayScoreUse",extraData:{mch_id:r.data.mch_id,package:r.data.package},success:e=>{"openBusinessView:ok"===e.errMsg?o(e):n(new Error("支付流程未完成"))},fail:r=>{console.error("微信支付分小程序调用失败",r),e.index.showToast({title:r.errMsg||"支付分接口调用失败",icon:"none"}),n(r)}}):n(new Error("支付参数不完整"))})),exports.wxLogin=()=>new Promise(((o,n)=>{e.index.login({provider:"weixin",success:async t=>{try{if(!t.code)throw new Error("获取微信登录凭证失败");{const n=await r.login({code:t.code,appid:"wx2165f0be356ae7a9"});if(200!==n.code)throw new Error(n.message||"登录失败");e.index.setStorageSync("token",n.data.LoginWxVo.access_token),e.index.setStorageSync("client_id",n.data.LoginWxVo.client_id),o(n.data)}}catch(s){e.index.showToast({title:s.message||"登录失败",icon:"none"}),n(s)}},fail:r=>{e.index.showToast({title:"微信登录失败",icon:"none"}),n(r)}})}));
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"url.js","sources":["config/url.js"],"sourcesContent":["// export const URL = \"https://my.gxfs123.com/api\" //正式服务器\r\nexport const URL = \"https://unifans.gxfs123.com/api\" //测试服务器\r\n// export const URL = \"http://192.168.10.70:8080\" \t\t//本地调试\r\n\r\nexport const appid = \"wx2165f0be356ae7a9\" //小程序appid"],"names":[],"mappings":";AACY,MAAC,MAAM;AAGP,MAAC,QAAQ;;;"}
{"version":3,"file":"url.js","sources":["config/url.js"],"sourcesContent":["// export const URL = \"https://my.gxfs123.com/api\" //正式服务器\r\nexport const URL = \"https://unifans.gxfs123.com/api\" //测试服务器\r\n// export const URL = \"http://192.168.10.3:8080\" \t\t//本地调试\r\n\r\nexport const appid = \"wx2165f0be356ae7a9\" //小程序appid"],"names":[],"mappings":";AACY,MAAC,MAAM;AAGP,MAAC,QAAQ;;;"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+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
@@ -302,3 +302,95 @@
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
+69 -11
View File
@@ -2,6 +2,11 @@ import {
login,
getMyIndexInfo
} from "../config/user"
import {
URL,
appid
} from "@/config/url.js"
// import { GET_PHONE_NUMBER_URL } from "../config/url"
// 微信登录方法
export const wxLogin = () => {
@@ -60,11 +65,7 @@ export const wxLogin = () => {
// 获取用户信息
export const getUserInfo = () => {
return new Promise(async (res, rej) => {
const result = await getMyIndexInfo({
isHide: false,
})
@@ -72,6 +73,63 @@ export const getUserInfo = () => {
})
}
// 获取用户手机号
export const getUserPhoneNumber = (code) => {
return new Promise(async (resolve, reject) => {
try {
// 获取登录态信息
const token = uni.getStorageSync('token')
if (!token) {
reject(new Error('用户未登录'))
return
}
console.log('开始请求获取手机号,code=', code, '请求地址=', URL + '/app/user/getPhoneNumber')
// 发送请求到后端获取手机号
uni.request({
url: URL + '/app/user/getPhoneNumber',
method: 'POST',
header: {
'Authorization': 'Bearer ' + token,
'clientId': uni.getStorageSync('client_id'),
'Content-Type': 'application/json'
},
data: {
code: code, // 微信获取手机号授权后的临时code
appid: appid
},
success: (res) => {
console.log('请求获取手机号接口成功,原始响应:', JSON.stringify(res))
// 检查HTTP状态码
if (res.statusCode !== 200) {
reject(new Error(`HTTP错误: ${res.statusCode}`))
return
}
// 确保响应体存在
if (!res.data) {
reject(new Error('服务器返回空数据'))
return
}
// 正常返回响应数据,不做额外判断,由调用方处理业务状态码
resolve(res.data)
},
fail: (err) => {
console.error('请求获取手机号接口网络错误:', err)
reject(new Error('请求获取手机号接口失败: ' + (err.errMsg || JSON.stringify(err))))
}
})
} catch (error) {
console.error('获取手机号过程中出现异常:', error)
reject(new Error('获取手机号异常: ' + (error.message || JSON.stringify(error))))
}
})
}
// 调用微信支付分接口
export const initiateWeChatScorePayment = (paymentData) => {
return new Promise((resolve, reject) => {
@@ -108,11 +166,11 @@ export const initiateWeChatScorePayment = (paymentData) => {
});
}
export const getQueryString = function (url, name) {
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null;
export const getQueryString = function(url, name) {
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
if (r != null) {
return r[2]
}
return null;
}