成功修改订单页面套餐金额 为 套餐金额/套餐小时 ,而不是固定的10元/小时

This commit is contained in:
8vd8
2025-04-25 17:10:15 +08:00
parent 9e10ea7f30
commit 1f264393b9
44 changed files with 5984 additions and 5872 deletions
+1 -1
View File
@@ -1 +1 @@
node_modules
node_modules
+43 -43
View File
@@ -1,44 +1,44 @@
<script>
import {
wxLogin,
getUserInfo
} from './util/index'
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: async function() {
console.log('App Show')
await this.autoLogin()
},
onHide: function() {
console.log('App Hide')
},
methods: {
async autoLogin() {
try {
const loginResult = await wxLogin()
console.log('自动登录成功:', loginResult)
// await getUserInfo()
} catch (error) {
console.error('自动登录失败:', error)
// 登录失败的处理可以在 wxLogin 中统一处理
// 这里可以添加特殊的错误处理逻辑
}
}
}
}
</script>
<style lang="scss">
@import "uview-ui/index.scss"
/*每个页面公共css */
<script>
import {
wxLogin,
getUserInfo
} from './util/index'
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: async function() {
console.log('App Show')
await this.autoLogin()
},
onHide: function() {
console.log('App Hide')
},
methods: {
async autoLogin() {
try {
const loginResult = await wxLogin()
console.log('自动登录成功:', loginResult)
// await getUserInfo()
} catch (error) {
console.error('自动登录失败:', error)
// 登录失败的处理可以在 wxLogin 中统一处理
// 这里可以添加特殊的错误处理逻辑
}
}
}
}
</script>
<style lang="scss">
@import "uview-ui/index.scss"
/*每个页面公共css */
</style>
+87 -87
View File
@@ -1,88 +1,88 @@
import {
URL,
appid
} from './url'
const request = (option) => {
return new Promise((resolve, reject) => {
// Debug request info
console.log(`发起请求: ${option.method} ${URL + option.url}`, option.data)
// 默认不显示加载中提示
if (!option.hideLoading) {
uni.showLoading({
title: option.loadingText || '加载中...',
mask: true
})
}
uni.request({
url: URL + option.url,
method: option.method,
data: option.data,
header: {
"Content-Type": "application/x-www-form-urlencoded",
...option.headers,
'appid': appid,
'Authorization': "Bearer " + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
},
success(res) {
// 记录响应
console.log(`请求响应: ${option.url}`, res)
// 检查响应状态码
if (res.statusCode !== 200) {
console.error(`HTTP状态码错误: ${res.statusCode}`, res.data)
// 为了适应某些服务器的异常响应,我们仍然返回数据
if (res.data) {
resolve(res.data)
return
}
reject({msg: `请求失败,状态码:${res.statusCode}`})
return
}
// 检查业务状态码
if (res.data && res.data.code !== 200) {
console.warn(`业务状态码错误: ${res.data.code}`, res.data)
// 判断是否需要忽略数据为空的错误
if (option.ignoreEmptyError &&
(res.data.code === 500 && res.data.msg &&
(res.data.msg.includes('未找到') || res.data.msg.includes('不存在')))) {
// 对于指定需要忽略的错误,返回一个标准的"成功但数据为空"的响应
resolve({
code: 200,
msg: "操作成功",
data: []
})
return
}
// 仍然返回数据,由业务逻辑处理
resolve(res.data)
return
}
resolve(res.data)
},
fail(err) {
// 网络请求本身失败
console.error(`请求失败: ${option.url}`, err)
reject(err)
},
complete() {
// 隐藏加载提示
if (!option.hideLoading) {
uni.hideLoading()
}
}
})
})
}
import {
URL,
appid
} from './url'
const request = (option) => {
return new Promise((resolve, reject) => {
// Debug request info
console.log(`发起请求: ${option.method} ${URL + option.url}`, option.data)
// 默认不显示加载中提示
if (!option.hideLoading) {
uni.showLoading({
title: option.loadingText || '加载中...',
mask: true
})
}
uni.request({
url: URL + option.url,
method: option.method,
data: option.data,
header: {
"Content-Type": "application/x-www-form-urlencoded",
...option.headers,
'appid': appid,
'Authorization': "Bearer " + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
},
success(res) {
// 记录响应
console.log(`请求响应: ${option.url}`, res)
// 检查响应状态码
if (res.statusCode !== 200) {
console.error(`HTTP状态码错误: ${res.statusCode}`, res.data)
// 为了适应某些服务器的异常响应,我们仍然返回数据
if (res.data) {
resolve(res.data)
return
}
reject({msg: `请求失败,状态码:${res.statusCode}`})
return
}
// 检查业务状态码
if (res.data && res.data.code !== 200) {
console.warn(`业务状态码错误: ${res.data.code}`, res.data)
// 判断是否需要忽略数据为空的错误
if (option.ignoreEmptyError &&
(res.data.code === 500 && res.data.msg &&
(res.data.msg.includes('未找到') || res.data.msg.includes('不存在')))) {
// 对于指定需要忽略的错误,返回一个标准的"成功但数据为空"的响应
resolve({
code: 200,
msg: "操作成功",
data: []
})
return
}
// 仍然返回数据,由业务逻辑处理
resolve(res.data)
return
}
resolve(res.data)
},
fail(err) {
// 网络请求本身失败
console.error(`请求失败: ${option.url}`, err)
reject(err)
},
complete() {
// 隐藏加载提示
if (!option.hideLoading) {
uni.hideLoading()
}
}
})
})
}
export default request
+3 -3
View File
@@ -1,4 +1,4 @@
// export const URL = "https://unifans.gxfs123.com"
export const URL = "http://127.0.0.1:8080"
// export const URL = "https://unifans.gxfs123.com"
export const URL = "http://127.0.0.1:8080"
export const appid = "wxe752f45e7f7aa271"
+38 -38
View File
@@ -1,39 +1,39 @@
// 帮助中心文案配置
export const HELP_CONTENT = {
// FAQ列表
FAQ_LIST: [
{
question: '如何租借风扇?',
answer: '点击首页"扫码租借"按钮,使用微信扫描设备上的二维码,按提示完成支付即可使用。'
},
{
question: '收费标准是怎样的?',
answer: '使用费用为2元/小时,不足1小时按1小时计算。押金99元,归还后自动退还。'
},
{
question: '如何归还风扇?',
answer: '将风扇带到任意归还点,点击首页"扫码归还"按钮,扫描归还点二维码即可完成归还。'
},
{
question: '押金多久能退还?',
answer: '归还设备后押金将自动发起退款,预计0-7个工作日到账。'
},
{
question: '设备无法正常使用怎么办?',
answer: '您可以通过"我的-投诉与建议"提交故障反馈,或直接拨打客服电话处理。'
}
],
// 联系方式
CONTACT: {
TITLE: '联系客服',
PHONE: {
LABEL: '客服电话',
VALUE: '400-888-8888'
},
SERVICE_TIME: {
LABEL: '服务时间',
VALUE: '周一至周日 09:00-22:00'
}
}
// 帮助中心文案配置
export const HELP_CONTENT = {
// FAQ列表
FAQ_LIST: [
{
question: '如何租借风扇?',
answer: '点击首页"扫码租借"按钮,使用微信扫描设备上的二维码,按提示完成支付即可使用。'
},
{
question: '收费标准是怎样的?',
answer: '使用费用为2元/小时,不足1小时按1小时计算。押金99元,归还后自动退还。'
},
{
question: '如何归还风扇?',
answer: '将风扇带到任意归还点,点击首页"扫码归还"按钮,扫描归还点二维码即可完成归还。'
},
{
question: '押金多久能退还?',
answer: '归还设备后押金将自动发起退款,预计0-7个工作日到账。'
},
{
question: '设备无法正常使用怎么办?',
answer: '您可以通过"我的-投诉与建议"提交故障反馈,或直接拨打客服电话处理。'
}
],
// 联系方式
CONTACT: {
TITLE: '联系客服',
PHONE: {
LABEL: '客服电话',
VALUE: '400-888-8888'
},
SERVICE_TIME: {
LABEL: '服务时间',
VALUE: '周一至周日 09:00-22:00'
}
}
}
+54 -54
View File
@@ -1,55 +1,55 @@
/**
* 订单状态映射
*/
export const OrderStatusMap = {
waiting_for_payment: {
text: '待支付',
class: 'status-waiting'
},
payment_in_progress: {
text: '支付中',
class: 'status-progress'
},
payment_successful: {
text: '支付成功',
class: 'status-success'
},
in_used: {
text: '使用中',
class: 'status-using'
},
payment_failed: {
text: '支付失败',
class: 'status-failed'
},
order_cancelled: {
text: '已取消',
class: 'status-cancelled'
},
used_done: {
text: '已完成',
class: 'status-finished'
}
}
/**
* 订单状态分类
*/
export const OrderStatusTabs = [
{
text: '全部',
status: []
},
{
text: '待支付',
status: ['waiting_for_payment', 'payment_in_progress']
},
{
text: '使用中',
status: ['payment_successful', 'in_used']
},
{
text: '已完成',
status: ['used_done', 'payment_failed', 'order_cancelled']
}
/**
* 订单状态映射
*/
export const OrderStatusMap = {
waiting_for_payment: {
text: '待支付',
class: 'status-waiting'
},
payment_in_progress: {
text: '支付中',
class: 'status-progress'
},
payment_successful: {
text: '支付成功',
class: 'status-success'
},
in_used: {
text: '使用中',
class: 'status-using'
},
payment_failed: {
text: '支付失败',
class: 'status-failed'
},
order_cancelled: {
text: '已取消',
class: 'status-cancelled'
},
used_done: {
text: '已完成',
class: 'status-finished'
}
}
/**
* 订单状态分类
*/
export const OrderStatusTabs = [
{
text: '全部',
status: []
},
{
text: '待支付',
status: ['waiting_for_payment', 'payment_in_progress']
},
{
text: '使用中',
status: ['payment_successful', 'in_used']
},
{
text: '已完成',
status: ['used_done', 'payment_failed', 'order_cancelled']
}
]
+20 -20
View File
@@ -1,20 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>
+34 -34
View File
@@ -1,35 +1,35 @@
import App from './App'
import { orderMonitor } from './utils/orderMonitor.js'
import uView from "uview-ui";
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
// 注册全局订单监控服务
Vue.prototype.$orderMonitor = orderMonitor
App.mpType = 'app'
Vue.use(uView)
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
// 注册全局订单监控服务到VUE3
app.config.globalProperties.$orderMonitor = orderMonitor
return {
app
}
}
import App from './App'
import { orderMonitor } from './utils/orderMonitor.js'
import uView from "uview-ui";
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
// 注册全局订单监控服务
Vue.prototype.$orderMonitor = orderMonitor
App.mpType = 'app'
Vue.use(uView)
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
// 注册全局订单监控服务到VUE3
app.config.globalProperties.$orderMonitor = orderMonitor
return {
app
}
}
// #endif
+1757 -1757
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -1,12 +1,12 @@
{
"dependencies": {
"axios": "^1.7.9",
"axios-miniprogram-adapter": "0.3.4",
"uniapp-axios-adapter": "^0.3.2",
"uview-ui": "1.8.8"
},
"devDependencies": {
"sass": "^1.57.1",
"sass-loader": "^13.2.0"
}
{
"dependencies": {
"axios": "^1.7.9",
"axios-miniprogram-adapter": "0.3.4",
"uniapp-axios-adapter": "^0.3.2",
"uview-ui": "1.8.8"
},
"devDependencies": {
"sass": "^1.57.1",
"sass-loader": "^13.2.0"
}
}
+112 -112
View File
@@ -1,113 +1,113 @@
{
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "共享风扇"
}
},
{
"path": "pages/my/index",
"style": {
"navigationBarTitleText": "个人中心"
}
},
{
"path": "pages/deposit/index",
"style": {
"navigationBarTitleText": "押金管理"
}
},
{
"path": "pages/order/index",
"style": {
"navigationBarTitleText": "租借记录"
}
},
{
"path": "pages/order/payment",
"style": {
"navigationBarTitleText": "订单支付",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/feedback/index",
"style": {
"navigationBarTitleText": "投诉与建议"
}
},
{
"path": "pages/help/index",
"style": {
"navigationBarTitleText": "帮助中心"
}
},
{
"path": "pages/device/detail",
"style": {
"navigationBarTitleText": "设备详情",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/serve/bagCheck/index",
"style": {
"navigationBarTitleText": "共享风扇"
}
},
{
"path": "pages/return/index",
"style": {
"navigationBarTitleText": "归还设备",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/order/success",
"style": {
"navigationBarTitleText": "支付成功",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/order/return-success",
"style": {
"navigationBarTitleText": "归还成功",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "共享风扇",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"tabBar": {
"color": "#999999",
"selectedColor": "#1976D2",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "static/home.png",
"selectedIconPath": "static/home-active.png"
},
{
"pagePath": "pages/my/index",
"text": "我的",
"iconPath": "static/user.png",
"selectedIconPath": "static/user-active.png"
}
]
}
{
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "共享风扇"
}
},
{
"path": "pages/my/index",
"style": {
"navigationBarTitleText": "个人中心"
}
},
{
"path": "pages/deposit/index",
"style": {
"navigationBarTitleText": "押金管理"
}
},
{
"path": "pages/order/index",
"style": {
"navigationBarTitleText": "租借记录"
}
},
{
"path": "pages/order/payment",
"style": {
"navigationBarTitleText": "订单支付",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/feedback/index",
"style": {
"navigationBarTitleText": "投诉与建议"
}
},
{
"path": "pages/help/index",
"style": {
"navigationBarTitleText": "帮助中心"
}
},
{
"path": "pages/device/detail",
"style": {
"navigationBarTitleText": "设备详情",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/serve/bagCheck/index",
"style": {
"navigationBarTitleText": "共享风扇"
}
},
{
"path": "pages/return/index",
"style": {
"navigationBarTitleText": "归还设备",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/order/success",
"style": {
"navigationBarTitleText": "支付成功",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/order/return-success",
"style": {
"navigationBarTitleText": "归还成功",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "共享风扇",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"tabBar": {
"color": "#999999",
"selectedColor": "#1976D2",
"backgroundColor": "#ffffff",
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "static/home.png",
"selectedIconPath": "static/home-active.png"
},
{
"pagePath": "pages/my/index",
"text": "我的",
"iconPath": "static/user.png",
"selectedIconPath": "static/user-active.png"
}
]
}
}
+335 -335
View File
@@ -1,336 +1,336 @@
<template>
<view class="deposit-container">
<!-- 押金金额卡片 -->
<view class="deposit-card">
<view class="title">押金余额</view>
<view class="amount">¥{{ depositAmount }}</view>
<button class="withdraw-btn" @click="handleWithdraw" :disabled="depositAmount <= 0">提现</button>
</view>
<!-- 提现说明 -->
<view class="notice-card">
<view class="notice-title">
<view class="dot"></view>
<text>提现说明</text>
</view>
<view class="notice-content">
<view class="notice-item">1. 提现金额将原路退回支付账户</view>
<view class="notice-item">2. 提现申请提交后预计0-7个工作日到账</view>
<view class="notice-item">3. 如超时未收到请联系客服处理</view>
</view>
</view>
<!-- 押金记录 -->
<view class="record-card" v-if="records.length > 0">
<view class="record-title">押金记录</view>
<view class="record-list">
<view class="record-item" v-for="(item, index) in records" :key="index">
<view class="record-info">
<text class="record-type">{{ item.type }}</text>
<text class="record-time">{{ item.time }}</text>
</view>
<text class="record-amount" :class="item.type === '退还' ? 'refund' : ''">
{{ item.type === '退还' ? '+' : '-' }}¥{{ item.amount }}
</text>
</view>
</view>
</view>
</view>
</template>
<script>
import { getUserInfo } from '../../util/index.js'
import { withdrawDeposit,queryById } from '../../config/user.js'
export default {
data() {
return {
depositAmount: '0.00',
orderNo: '',
records: [],
orderId:''
}
},
onLoad() {
// this.loadUserInfo()
},
onShow() {
this.loadUserInfo()
},
methods: {
async loadUserInfo() {
try {
const res = await getUserInfo()
console.log('loadUserInfo',res);
if (res.code === 200) {
this.depositAmount = res.data.balanceAmount || '0.00'
this.orderNo = res.data.latestOrderNo || ''
this.orderId = res.data.latestOrderId||''
// 如果存在余额,获取押金记录
if (parseFloat(this.depositAmount) > 0 && this.orderNo) {
this.records = [
{
type: '支付',
time: this.formatDate(new Date()),
amount: this.depositAmount
}
]
} else {
this.records = []
}
}
} catch (error) {
console.error('获取用户信息失败:', error)
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
}
},
async handleWithdraw() {
if (parseFloat(this.depositAmount) <= 0) {
uni.showToast({
title: '无可提现余额',
icon: 'none'
})
return
}
if(this.orderId.length!=0||this.orderNo.length!=0){
const res = await queryById(Number(this.orderId))
console.log(res);
}
// if(this.orderNo.length!=0){
// uni.showToast({
// title:'当前存在进行中的订单',
// icon:'none'
// })
// return
// }
uni.showModal({
title: '确认提现',
content: '押金将原路退回,预计0-7个工作日到账',
success: async (res) => {
if (res.confirm) {
uni.showLoading({
title: '提现中...'
})
try {
console.log('发起提现请求,订单号:', this.orderNo)
const result = await withdrawDeposit(this.orderNo)
console.log('提现响应:', result)
if (result.code === 200) {
uni.hideLoading()
uni.showToast({
title: '提现申请已提交',
icon: 'success'
})
// 更新余额为0
this.depositAmount = '0.00'
this.records.push({
type: '退还',
time: this.formatDate(new Date()),
amount: this.depositAmount
})
// 重新加载用户信息
setTimeout(() => {
this.loadUserInfo()
}, 1500)
} else {
throw new Error(result.msg || '提现失败')
}
} catch (error) {
console.error('提现失败:', error)
uni.hideLoading()
// 更详细的错误处理
let errorMessage = '提现失败,请稍后再试';
// 如果有具体错误信息,使用它
if (error.message) {
// 常见错误消息处理
if (error.message.includes('尚未归还')) {
errorMessage = '当前订单尚未归还,请归还后再提现';
} else if (error.message.includes('已退还')) {
errorMessage = '押金已退还,无需重复提现';
} else if (error.message.includes('处理中')) {
errorMessage = '押金退还处理中,请耐心等待';
} else if (error.message.includes('余额为0')) {
errorMessage = '账户余额为0,无法提现';
} else {
// 使用后端返回的具体错误消息
errorMessage = error.message;
}
}
// 显示错误提示
uni.showModal({
title: '提现失败',
content: errorMessage,
showCancel: false
})
}
}
}
})
},
formatDate(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hours = date.getHours().toString().padStart(2, '0')
const minutes = date.getMinutes().toString().padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
}
}
}
</script>
<style lang="scss" scoped>
.deposit-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.deposit-card {
background: linear-gradient(135deg, #1976D2, #64B5F6);
border-radius: 20rpx;
padding: 40rpx;
color: #fff;
text-align: center;
box-shadow: 0 4rpx 20rpx rgba(25,118,210,0.2);
.title {
font-size: 28rpx;
opacity: 0.9;
margin-bottom: 20rpx;
}
.amount {
font-size: 72rpx;
font-weight: bold;
margin-bottom: 40rpx;
}
.withdraw-btn {
background: #fff;
color: #1976D2;
width: 80%;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
font-size: 32rpx;
font-weight: 500;
margin: 0 auto;
&:active {
transform: scale(0.98);
}
&[disabled] {
background: rgba(255,255,255,0.6);
color: rgba(25,118,210,0.5);
}
}
}
.notice-card {
margin-top: 30rpx;
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.notice-title {
display: flex;
align-items: center;
margin-bottom: 20rpx;
.dot {
width: 12rpx;
height: 12rpx;
background: #1976D2;
border-radius: 50%;
margin-right: 10rpx;
}
text {
font-size: 30rpx;
font-weight: 500;
color: #333;
}
}
.notice-content {
.notice-item {
font-size: 26rpx;
color: #666;
line-height: 1.8;
padding-left: 22rpx;
}
}
}
.record-card {
margin-top: 30rpx;
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.record-title {
font-size: 30rpx;
font-weight: 500;
color: #333;
margin-bottom: 20rpx;
border-left: 8rpx solid #1976D2;
padding-left: 20rpx;
}
.record-list {
.record-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.record-info {
.record-type {
font-size: 28rpx;
color: #333;
margin-bottom: 6rpx;
display: block;
}
.record-time {
font-size: 24rpx;
color: #999;
}
}
.record-amount {
font-size: 32rpx;
color: #333;
font-weight: 500;
&.refund {
color: #4CAF50;
}
}
}
}
}
}
<template>
<view class="deposit-container">
<!-- 押金金额卡片 -->
<view class="deposit-card">
<view class="title">押金余额</view>
<view class="amount">¥{{ depositAmount }}</view>
<button class="withdraw-btn" @click="handleWithdraw" :disabled="depositAmount <= 0">提现</button>
</view>
<!-- 提现说明 -->
<view class="notice-card">
<view class="notice-title">
<view class="dot"></view>
<text>提现说明</text>
</view>
<view class="notice-content">
<view class="notice-item">1. 提现金额将原路退回支付账户</view>
<view class="notice-item">2. 提现申请提交后预计0-7个工作日到账</view>
<view class="notice-item">3. 如超时未收到请联系客服处理</view>
</view>
</view>
<!-- 押金记录 -->
<view class="record-card" v-if="records.length > 0">
<view class="record-title">押金记录</view>
<view class="record-list">
<view class="record-item" v-for="(item, index) in records" :key="index">
<view class="record-info">
<text class="record-type">{{ item.type }}</text>
<text class="record-time">{{ item.time }}</text>
</view>
<text class="record-amount" :class="item.type === '退还' ? 'refund' : ''">
{{ item.type === '退还' ? '+' : '-' }}¥{{ item.amount }}
</text>
</view>
</view>
</view>
</view>
</template>
<script>
import { getUserInfo } from '../../util/index.js'
import { withdrawDeposit,queryById } from '../../config/user.js'
export default {
data() {
return {
depositAmount: '0.00',
orderNo: '',
records: [],
orderId:''
}
},
onLoad() {
// this.loadUserInfo()
},
onShow() {
this.loadUserInfo()
},
methods: {
async loadUserInfo() {
try {
const res = await getUserInfo()
console.log('loadUserInfo',res);
if (res.code === 200) {
this.depositAmount = res.data.balanceAmount || '0.00'
this.orderNo = res.data.latestOrderNo || ''
this.orderId = res.data.latestOrderId||''
// 如果存在余额,获取押金记录
if (parseFloat(this.depositAmount) > 0 && this.orderNo) {
this.records = [
{
type: '支付',
time: this.formatDate(new Date()),
amount: this.depositAmount
}
]
} else {
this.records = []
}
}
} catch (error) {
console.error('获取用户信息失败:', error)
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
}
},
async handleWithdraw() {
if (parseFloat(this.depositAmount) <= 0) {
uni.showToast({
title: '无可提现余额',
icon: 'none'
})
return
}
if(this.orderId.length!=0||this.orderNo.length!=0){
const res = await queryById(Number(this.orderId))
console.log(res);
}
// if(this.orderNo.length!=0){
// uni.showToast({
// title:'当前存在进行中的订单',
// icon:'none'
// })
// return
// }
uni.showModal({
title: '确认提现',
content: '押金将原路退回,预计0-7个工作日到账',
success: async (res) => {
if (res.confirm) {
uni.showLoading({
title: '提现中...'
})
try {
console.log('发起提现请求,订单号:', this.orderNo)
const result = await withdrawDeposit(this.orderNo)
console.log('提现响应:', result)
if (result.code === 200) {
uni.hideLoading()
uni.showToast({
title: '提现申请已提交',
icon: 'success'
})
// 更新余额为0
this.depositAmount = '0.00'
this.records.push({
type: '退还',
time: this.formatDate(new Date()),
amount: this.depositAmount
})
// 重新加载用户信息
setTimeout(() => {
this.loadUserInfo()
}, 1500)
} else {
throw new Error(result.msg || '提现失败')
}
} catch (error) {
console.error('提现失败:', error)
uni.hideLoading()
// 更详细的错误处理
let errorMessage = '提现失败,请稍后再试';
// 如果有具体错误信息,使用它
if (error.message) {
// 常见错误消息处理
if (error.message.includes('尚未归还')) {
errorMessage = '当前订单尚未归还,请归还后再提现';
} else if (error.message.includes('已退还')) {
errorMessage = '押金已退还,无需重复提现';
} else if (error.message.includes('处理中')) {
errorMessage = '押金退还处理中,请耐心等待';
} else if (error.message.includes('余额为0')) {
errorMessage = '账户余额为0,无法提现';
} else {
// 使用后端返回的具体错误消息
errorMessage = error.message;
}
}
// 显示错误提示
uni.showModal({
title: '提现失败',
content: errorMessage,
showCancel: false
})
}
}
}
})
},
formatDate(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hours = date.getHours().toString().padStart(2, '0')
const minutes = date.getMinutes().toString().padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
}
}
}
</script>
<style lang="scss" scoped>
.deposit-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.deposit-card {
background: linear-gradient(135deg, #1976D2, #64B5F6);
border-radius: 20rpx;
padding: 40rpx;
color: #fff;
text-align: center;
box-shadow: 0 4rpx 20rpx rgba(25,118,210,0.2);
.title {
font-size: 28rpx;
opacity: 0.9;
margin-bottom: 20rpx;
}
.amount {
font-size: 72rpx;
font-weight: bold;
margin-bottom: 40rpx;
}
.withdraw-btn {
background: #fff;
color: #1976D2;
width: 80%;
height: 80rpx;
line-height: 80rpx;
border-radius: 40rpx;
font-size: 32rpx;
font-weight: 500;
margin: 0 auto;
&:active {
transform: scale(0.98);
}
&[disabled] {
background: rgba(255,255,255,0.6);
color: rgba(25,118,210,0.5);
}
}
}
.notice-card {
margin-top: 30rpx;
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.notice-title {
display: flex;
align-items: center;
margin-bottom: 20rpx;
.dot {
width: 12rpx;
height: 12rpx;
background: #1976D2;
border-radius: 50%;
margin-right: 10rpx;
}
text {
font-size: 30rpx;
font-weight: 500;
color: #333;
}
}
.notice-content {
.notice-item {
font-size: 26rpx;
color: #666;
line-height: 1.8;
padding-left: 22rpx;
}
}
}
.record-card {
margin-top: 30rpx;
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.record-title {
font-size: 30rpx;
font-weight: 500;
color: #333;
margin-bottom: 20rpx;
border-left: 8rpx solid #1976D2;
padding-left: 20rpx;
}
.record-list {
.record-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.record-info {
.record-type {
font-size: 28rpx;
color: #333;
margin-bottom: 6rpx;
display: block;
}
.record-time {
font-size: 24rpx;
color: #999;
}
}
.record-amount {
font-size: 32rpx;
color: #333;
font-weight: 500;
&.refund {
color: #4CAF50;
}
}
}
}
}
}
</style>
+176 -141
View File
@@ -110,9 +110,28 @@
onLoad(options) {
// console.log(options);
this.deviceId = options.deviceNo
this.checkOrderStatus() // 新增状态检查
console.log(options.deviceNo);
this.getDeviceInfo()
// 如果URL中包含了feeConfig参数,直接使用它
if (options.feeConfig) {
try {
console.log('从URL获取到feeConfig:', options.feeConfig)
const feeConfigStr = decodeURIComponent(options.feeConfig)
// 存储到设备信息中,这样后续处理逻辑可以保持不变
this.deviceInfo = { ...this.deviceInfo, feeConfig: feeConfigStr }
// 马上解析feeConfig并生成套餐选项
this.parseFeeConfig()
} catch (e) {
console.error('解析URL中的feeConfig失败:', e)
// 如果解析失败,继续正常流程获取设备信息
this.checkOrderStatus()
this.getDeviceInfo()
}
} else {
// 正常流程
this.checkOrderStatus() // 新增状态检查
console.log(options.deviceNo);
this.getDeviceInfo()
}
},
methods: {
// 检查登录状态和订单
@@ -148,133 +167,8 @@
}
}
// 解析feeConfig并生成套餐选项
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
// 检查是否为新格式 [{"hour":1,"timesPrice":4},{"hour":3,"timesPrice":10},{"hour":5,"timesPrice":15}]
if (feeConfig.length > 0 && 'hour' in feeConfig[0] && 'timesPrice' in feeConfig[0]) {
// 新格式处理 - 直接使用所有套餐
this.packages = feeConfig.map(pkg => {
const hour = pkg.hour;
const price = pkg.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice: unitPrice,
hour: hour // 添加小时信息,用于后续处理
};
});
// 按小时排序
this.packages.sort((a, b) => a.hour - b.hour);
} else {
// 旧格式处理
// 通常使用common规格的配置
const commonConfig = feeConfig.find(item => item.specCode === 'common') || feeConfig[0];
if (commonConfig) {
// 根据收费类型生成套餐
if (this.deviceInfo.feeType === 'hour') {
// 按小时收费
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: '1小时',
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: '6小时',
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: '12小时',
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2)
}
];
} else if (this.deviceInfo.feeType === 'times') {
// 按次收费
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: '1次',
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2)
}
];
} else {
// 默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00'
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67'
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25'
}
];
}
}
}
// 默认选中中间套餐
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
console.error('解析设备费用配置失败:', e);
// 使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00'
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67'
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25'
}
];
}
} else {
// 如果没有feeConfig,使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00'
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67'
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25'
}
];
}
// 使用抽取的方法解析feeConfig并生成套餐选项
this.parseFeeConfig();
}
},
@@ -355,16 +249,8 @@
return
}
const selectedPkg = this.packages[this.selectedPackage]
uni.showModal({
title: '确认租借',
content: `确认支付押金¥{{ depositAmount }}及${selectedPkg.time}套餐费用¥${selectedPkg.price}`,
success: (res) => {
if (res.confirm) {
this.submitRentOrder()
}
}
})
// 直接提交订单,不显示确认对话框
this.submitRentOrder()
},
// 提交租借订单
@@ -424,7 +310,7 @@
// 跳转到订单支付页面,传递订单ID、套餐信息和总金额
uni.redirectTo({
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace('小时', '')}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}`
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace('小时', '')}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}${this.deviceInfo && this.deviceInfo.feeConfig ? '&feeConfig=' + encodeURIComponent(this.deviceInfo.feeConfig) : ''}`
})
} catch (error) {
uni.hideLoading()
@@ -433,6 +319,155 @@
icon: 'none'
})
}
},
// 单独抽取解析feeConfig的逻辑
parseFeeConfig() {
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
// 检查是否为新格式 [{"hour":1,"timesPrice":4},{"hour":3,"timesPrice":10},{"hour":5,"timesPrice":15}]
if (feeConfig.length > 0 && 'hour' in feeConfig[0] && 'timesPrice' in feeConfig[0]) {
// 新格式处理 - 直接使用所有套餐
this.packages = feeConfig.map(pkg => {
const hour = pkg.hour;
const price = pkg.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice: unitPrice,
hour: hour // 添加小时信息,用于后续处理
};
});
// 按小时排序
this.packages.sort((a, b) => a.hour - b.hour);
} else {
// 旧格式处理
// 通常使用common规格的配置
const commonConfig = feeConfig.find(item => item.specCode === 'common') || feeConfig[0];
if (commonConfig) {
// 根据收费类型生成套餐
if (this.deviceInfo.feeType === 'hour') {
// 按小时收费
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: '1小时',
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 1
},
{
time: '6小时',
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 6
},
{
time: '12小时',
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 12
}
];
} else if (this.deviceInfo.feeType === 'times') {
// 按次收费
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: '1次',
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2),
hour: 1
}
];
} else {
// 默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00',
hour: 1
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67',
hour: 6
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25',
hour: 12
}
];
}
}
}
// 默认选中中间套餐
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
console.error('解析设备费用配置失败:', e);
// 使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00',
hour: 1
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67',
hour: 6
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25',
hour: 12
}
];
// 默认选中中间套餐
this.selectedPackage = 1;
}
} else {
// 如果没有feeConfig,使用默认套餐
this.packages = [
{
time: '1小时',
price: '2.00',
unitPrice: '2.00',
hour: 1
},
{
time: '6小时',
price: '10.00',
unitPrice: '1.67',
hour: 6
},
{
time: '12小时',
price: '15.00',
unitPrice: '1.25',
hour: 12
}
];
// 默认选中中间套餐
this.selectedPackage = 1;
}
}
}
}
+299 -299
View File
@@ -1,300 +1,300 @@
<template>
<view class="feedback-container">
<!-- 问题类型选择 -->
<view class="type-section">
<view class="section-title">问题类型</view>
<view class="type-grid">
<view
v-for="(type, index) in types"
:key="index"
class="type-item"
:class="{ active: selectedType === index }"
@click="selectType(index)"
>
{{ type }}
</view>
</view>
</view>
<!-- 问题描述 -->
<view class="description-section">
<view class="section-title">问题描述</view>
<textarea
class="description-input"
v-model="description"
placeholder="请详细描述您遇到的问题,以便我们更好地为您解决"
maxlength="500"
/>
<view class="word-count">{{ description.length }}/500</view>
</view>
<!-- 图片上传 -->
<view class="upload-section">
<view class="section-title">图片上传选填</view>
<view class="upload-grid">
<view
class="upload-item"
v-for="(img, index) in images"
:key="index"
>
<image :src="img" mode="aspectFill" />
<view class="delete-btn" @click="deleteImage(index)">×</view>
</view>
<view class="upload-btn" @click="chooseImage" v-if="images.length < 3">
<text class="plus">+</text>
<text class="tip">上传图片</text>
</view>
</view>
</view>
<!-- 联系方式 -->
<view class="contact-section">
<view class="section-title">联系方式</view>
<input
class="contact-input"
v-model="contact"
placeholder="请留下您的手机号,方便我们联系您"
type="number"
maxlength="11"
/>
</view>
<!-- 提交按钮 -->
<view class="submit-section">
<button class="submit-btn" @click="submitFeedback">提交反馈</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
types: ['设备故障', '收费问题', '使用建议', '其他'],
selectedType: -1,
description: '',
images: [],
contact: ''
}
},
methods: {
selectType(index) {
this.selectedType = index
},
chooseImage() {
uni.chooseImage({
count: 3 - this.images.length,
success: (res) => {
this.images = [...this.images, ...res.tempFilePaths]
}
})
},
deleteImage(index) {
this.images.splice(index, 1)
},
submitFeedback() {
if (this.selectedType === -1) {
uni.showToast({
title: '请选择问题类型',
icon: 'none'
})
return
}
if (!this.description.trim()) {
uni.showToast({
title: '请描述您的问题',
icon: 'none'
})
return
}
if (!this.contact) {
uni.showToast({
title: '请留下联系方式',
icon: 'none'
})
return
}
// TODO: 提交反馈
uni.showToast({
title: '提交成功',
icon: 'success'
})
}
}
}
</script>
<style lang="scss" scoped>
.feedback-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.section-title {
font-size: 30rpx;
color: #333;
font-weight: 500;
margin-bottom: 20rpx;
}
.type-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
.type-grid {
display: flex;
flex-wrap: wrap;
margin: 0 -10rpx;
.type-item {
width: calc(50% - 20rpx);
margin: 10rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f5f5f5;
border-radius: 10rpx;
font-size: 28rpx;
color: #666;
transition: all 0.3s;
&.active {
background: #E3F2FD;
color: #1976D2;
}
}
}
}
.description-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
.description-input {
width: 100%;
height: 240rpx;
background: #f8f8f8;
border-radius: 10rpx;
padding: 20rpx;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
.word-count {
text-align: right;
font-size: 24rpx;
color: #999;
margin-top: 10rpx;
}
}
.upload-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
.upload-grid {
display: flex;
flex-wrap: wrap;
.upload-item {
width: 200rpx;
height: 200rpx;
margin-right: 20rpx;
margin-bottom: 20rpx;
position: relative;
image {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
.delete-btn {
position: absolute;
right: -10rpx;
top: -10rpx;
width: 40rpx;
height: 40rpx;
background: rgba(0,0,0,0.5);
color: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
}
}
.upload-btn {
width: 200rpx;
height: 200rpx;
background: #f5f5f5;
border-radius: 10rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #999;
.plus {
font-size: 60rpx;
line-height: 1;
margin-bottom: 10rpx;
}
.tip {
font-size: 24rpx;
}
}
}
}
.contact-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 40rpx;
.contact-input {
width: 100%;
height: 80rpx;
background: #f8f8f8;
border-radius: 10rpx;
padding: 0 20rpx;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
}
.submit-section {
padding: 0 40rpx;
.submit-btn {
width: 100%;
height: 88rpx;
background: #1976D2;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
&:active {
transform: scale(0.98);
}
}
}
}
<template>
<view class="feedback-container">
<!-- 问题类型选择 -->
<view class="type-section">
<view class="section-title">问题类型</view>
<view class="type-grid">
<view
v-for="(type, index) in types"
:key="index"
class="type-item"
:class="{ active: selectedType === index }"
@click="selectType(index)"
>
{{ type }}
</view>
</view>
</view>
<!-- 问题描述 -->
<view class="description-section">
<view class="section-title">问题描述</view>
<textarea
class="description-input"
v-model="description"
placeholder="请详细描述您遇到的问题,以便我们更好地为您解决"
maxlength="500"
/>
<view class="word-count">{{ description.length }}/500</view>
</view>
<!-- 图片上传 -->
<view class="upload-section">
<view class="section-title">图片上传选填</view>
<view class="upload-grid">
<view
class="upload-item"
v-for="(img, index) in images"
:key="index"
>
<image :src="img" mode="aspectFill" />
<view class="delete-btn" @click="deleteImage(index)">×</view>
</view>
<view class="upload-btn" @click="chooseImage" v-if="images.length < 3">
<text class="plus">+</text>
<text class="tip">上传图片</text>
</view>
</view>
</view>
<!-- 联系方式 -->
<view class="contact-section">
<view class="section-title">联系方式</view>
<input
class="contact-input"
v-model="contact"
placeholder="请留下您的手机号,方便我们联系您"
type="number"
maxlength="11"
/>
</view>
<!-- 提交按钮 -->
<view class="submit-section">
<button class="submit-btn" @click="submitFeedback">提交反馈</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
types: ['设备故障', '收费问题', '使用建议', '其他'],
selectedType: -1,
description: '',
images: [],
contact: ''
}
},
methods: {
selectType(index) {
this.selectedType = index
},
chooseImage() {
uni.chooseImage({
count: 3 - this.images.length,
success: (res) => {
this.images = [...this.images, ...res.tempFilePaths]
}
})
},
deleteImage(index) {
this.images.splice(index, 1)
},
submitFeedback() {
if (this.selectedType === -1) {
uni.showToast({
title: '请选择问题类型',
icon: 'none'
})
return
}
if (!this.description.trim()) {
uni.showToast({
title: '请描述您的问题',
icon: 'none'
})
return
}
if (!this.contact) {
uni.showToast({
title: '请留下联系方式',
icon: 'none'
})
return
}
// TODO: 提交反馈
uni.showToast({
title: '提交成功',
icon: 'success'
})
}
}
}
</script>
<style lang="scss" scoped>
.feedback-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.section-title {
font-size: 30rpx;
color: #333;
font-weight: 500;
margin-bottom: 20rpx;
}
.type-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
.type-grid {
display: flex;
flex-wrap: wrap;
margin: 0 -10rpx;
.type-item {
width: calc(50% - 20rpx);
margin: 10rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
background: #f5f5f5;
border-radius: 10rpx;
font-size: 28rpx;
color: #666;
transition: all 0.3s;
&.active {
background: #E3F2FD;
color: #1976D2;
}
}
}
}
.description-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
.description-input {
width: 100%;
height: 240rpx;
background: #f8f8f8;
border-radius: 10rpx;
padding: 20rpx;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
.word-count {
text-align: right;
font-size: 24rpx;
color: #999;
margin-top: 10rpx;
}
}
.upload-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 20rpx;
.upload-grid {
display: flex;
flex-wrap: wrap;
.upload-item {
width: 200rpx;
height: 200rpx;
margin-right: 20rpx;
margin-bottom: 20rpx;
position: relative;
image {
width: 100%;
height: 100%;
border-radius: 10rpx;
}
.delete-btn {
position: absolute;
right: -10rpx;
top: -10rpx;
width: 40rpx;
height: 40rpx;
background: rgba(0,0,0,0.5);
color: #fff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
}
}
.upload-btn {
width: 200rpx;
height: 200rpx;
background: #f5f5f5;
border-radius: 10rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: #999;
.plus {
font-size: 60rpx;
line-height: 1;
margin-bottom: 10rpx;
}
.tip {
font-size: 24rpx;
}
}
}
}
.contact-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 40rpx;
.contact-input {
width: 100%;
height: 80rpx;
background: #f8f8f8;
border-radius: 10rpx;
padding: 0 20rpx;
font-size: 28rpx;
color: #333;
box-sizing: border-box;
}
}
.submit-section {
padding: 0 40rpx;
.submit-btn {
width: 100%;
height: 88rpx;
background: #1976D2;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
&:active {
transform: scale(0.98);
}
}
}
}
</style>
+162 -162
View File
@@ -1,163 +1,163 @@
<template>
<view class="help-container">
<!-- 常见问题 -->
<view class="faq-list">
<view
class="faq-item"
v-for="(item, index) in faqList"
:key="index"
@click="toggleFaq(index)"
>
<view class="faq-header">
<text class="question">{{ item.question }}</text>
<view class="arrow" :class="{ open: item.isOpen }"></view>
</view>
<view class="answer" v-show="item.isOpen">
{{ item.answer }}
</view>
</view>
</view>
<!-- 联系客服 -->
<view class="contact-card">
<view class="contact-title">{{ HELP_CONTENT.CONTACT.TITLE }}</view>
<view class="contact-content">
<view class="contact-item">
<text class="label">{{ HELP_CONTENT.CONTACT.PHONE.LABEL }}</text>
<text class="value" @click="makePhoneCall">{{ HELP_CONTENT.CONTACT.PHONE.VALUE }}</text>
</view>
<view class="contact-item">
<text class="label">{{ HELP_CONTENT.CONTACT.SERVICE_TIME.LABEL }}</text>
<text class="value">{{ HELP_CONTENT.CONTACT.SERVICE_TIME.VALUE }}</text>
</view>
</view>
</view>
</view>
</template>
<script>
import { HELP_CONTENT } from '@/constants/help'
export default {
data() {
return {
HELP_CONTENT,
faqList: HELP_CONTENT.FAQ_LIST.map(item => ({
...item,
isOpen: false
}))
}
},
methods: {
toggleFaq(index) {
this.faqList[index].isOpen = !this.faqList[index].isOpen
},
makePhoneCall() {
uni.makePhoneCall({
phoneNumber: HELP_CONTENT.CONTACT.PHONE.VALUE
})
}
}
}
</script>
<style lang="scss" scoped>
.help-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.faq-list {
background: #fff;
border-radius: 20rpx;
padding: 20rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.faq-item {
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.faq-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx 20rpx;
.question {
font-size: 30rpx;
color: #333;
flex: 1;
padding-right: 20rpx;
}
.arrow {
width: 16rpx;
height: 16rpx;
border-right: 4rpx solid #999;
border-bottom: 4rpx solid #999;
transform: rotate(45deg);
transition: all 0.3s;
&.open {
transform: rotate(-135deg);
}
}
}
.answer {
font-size: 28rpx;
color: #666;
line-height: 1.6;
padding: 0 20rpx 30rpx;
background: #f9f9f9;
border-radius: 10rpx;
margin: 0 20rpx 20rpx;
}
}
}
.contact-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.contact-title {
font-size: 32rpx;
color: #333;
font-weight: 500;
margin-bottom: 20rpx;
border-left: 8rpx solid #1976D2;
padding-left: 20rpx;
}
.contact-content {
.contact-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
.label {
font-size: 28rpx;
color: #666;
}
.value {
font-size: 28rpx;
color: #333;
font-weight: 500;
&:active {
opacity: 0.7;
}
}
}
}
}
}
<template>
<view class="help-container">
<!-- 常见问题 -->
<view class="faq-list">
<view
class="faq-item"
v-for="(item, index) in faqList"
:key="index"
@click="toggleFaq(index)"
>
<view class="faq-header">
<text class="question">{{ item.question }}</text>
<view class="arrow" :class="{ open: item.isOpen }"></view>
</view>
<view class="answer" v-show="item.isOpen">
{{ item.answer }}
</view>
</view>
</view>
<!-- 联系客服 -->
<view class="contact-card">
<view class="contact-title">{{ HELP_CONTENT.CONTACT.TITLE }}</view>
<view class="contact-content">
<view class="contact-item">
<text class="label">{{ HELP_CONTENT.CONTACT.PHONE.LABEL }}</text>
<text class="value" @click="makePhoneCall">{{ HELP_CONTENT.CONTACT.PHONE.VALUE }}</text>
</view>
<view class="contact-item">
<text class="label">{{ HELP_CONTENT.CONTACT.SERVICE_TIME.LABEL }}</text>
<text class="value">{{ HELP_CONTENT.CONTACT.SERVICE_TIME.VALUE }}</text>
</view>
</view>
</view>
</view>
</template>
<script>
import { HELP_CONTENT } from '@/constants/help'
export default {
data() {
return {
HELP_CONTENT,
faqList: HELP_CONTENT.FAQ_LIST.map(item => ({
...item,
isOpen: false
}))
}
},
methods: {
toggleFaq(index) {
this.faqList[index].isOpen = !this.faqList[index].isOpen
},
makePhoneCall() {
uni.makePhoneCall({
phoneNumber: HELP_CONTENT.CONTACT.PHONE.VALUE
})
}
}
}
</script>
<style lang="scss" scoped>
.help-container {
min-height: 100vh;
background: #f8f8f8;
padding: 30rpx;
.faq-list {
background: #fff;
border-radius: 20rpx;
padding: 20rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.faq-item {
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.faq-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 30rpx 20rpx;
.question {
font-size: 30rpx;
color: #333;
flex: 1;
padding-right: 20rpx;
}
.arrow {
width: 16rpx;
height: 16rpx;
border-right: 4rpx solid #999;
border-bottom: 4rpx solid #999;
transform: rotate(45deg);
transition: all 0.3s;
&.open {
transform: rotate(-135deg);
}
}
}
.answer {
font-size: 28rpx;
color: #666;
line-height: 1.6;
padding: 0 20rpx 30rpx;
background: #f9f9f9;
border-radius: 10rpx;
margin: 0 20rpx 20rpx;
}
}
}
.contact-card {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0,0,0,0.04);
.contact-title {
font-size: 32rpx;
color: #333;
font-weight: 500;
margin-bottom: 20rpx;
border-left: 8rpx solid #1976D2;
padding-left: 20rpx;
}
.contact-content {
.contact-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
.label {
font-size: 28rpx;
color: #666;
}
.value {
font-size: 28rpx;
color: #333;
font-weight: 500;
&:active {
opacity: 0.7;
}
}
}
}
}
}
</style>
+395 -339
View File
@@ -1,339 +1,395 @@
<template>
<view class="container">
<!-- 宣传图片区域 -->
<view class="banner">
<view class="temp-banner">
<text class="banner-text">共享风扇</text>
<text class="banner-subtitle">让清凉随身携带</text>
<view class="banner-bg"></view>
</view>
</view>
<!-- 扫码按钮区域 -->
<view class="scan-area">
<view class="scan-btn" @click="handleScan">
<view class="btn-content">
<image class="btn-icon" src="../../static/scan-icon.png" mode="aspectFit" />
<text class="btn-text">扫一扫</text>
</view>
<text class="btn-desc">扫描设备二维码使用或归还</text>
</view>
</view>
<!-- 使用提示区域 -->
<view class="tips-section">
<view class="tips-header">
<view class="tips-title">使用小贴士</view>
</view>
<view class="tips-list">
<view class="tip-item">
<view class="tip-dot"></view>
<text>租借时间每次最长可租借12小时</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text>押金说明租借需支付99元押金归还后自动退还</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text>收费标准2/小时不足1小时按1小时计算</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text>爱护提示请勿将设备带离指定区域保持设备清洁</text>
</view>
</view>
</view>
</view>
</template>
<script>
import {getQueryString, wxLogin }from '@/util/index.js'
import {
URL
}from"@/config/url.js"
export default {
methods: {
async handleScan() {
try {
const scanResult = await new Promise((resolve, reject) => {
uni.scanCode({
success: resolve,
fail: reject
})
})
let deviceNo = getQueryString(scanResult.path, 'deviceNo')
console.log('扫码路径:', scanResult.path)
console.log('解析到的设备号:', deviceNo)
if (!deviceNo) {
uni.showToast({
title: '无效的设备二维码',
icon: 'none'
})
return
}
// 直接在当前页面查询是否有使用中的订单,避免跳转到中间页面
if (!uni.getStorageSync('token')) {
await wxLogin()
}
// 检查是否有使用中的订单
const inUseRes = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/order/inUse`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
}
})
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({
url: `/pages/return/index?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
})
console.log('已发起页面跳转')
return
}
// 检查是否有待支付订单
const orderRes = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/order/unpaid`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
}
})
console.log('待支付订单检查结果:', JSON.stringify(orderRes))
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)
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} catch (error) {
console.error('扫码处理失败:', error)
uni.showToast({
title: '扫码失败',
icon: 'none'
})
}
}
}
}
</script>
<style lang="scss" scoped>
.container {
height: 87.5vh;
background: #f8f8f8;
padding-bottom: 40rpx;
.banner {
padding: 30rpx;
.temp-banner {
height: 300rpx;
background: linear-gradient(135deg, #1976D2, #42A5F5);
border-radius: 30rpx;
position: relative;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
box-shadow: 0 8rpx 32rpx rgba(25, 118, 210, 0.2);
.banner-text {
font-size: 56rpx;
font-weight: bold;
margin-bottom: 20rpx;
position: relative;
z-index: 1;
text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.1);
}
.banner-subtitle {
font-size: 32rpx;
opacity: 0.95;
position: relative;
z-index: 1;
text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.1);
}
.banner-bg {
position: absolute;
right: -60rpx;
bottom: -60rpx;
width: 300rpx;
height: 300rpx;
background: rgba(255,255,255,0.1);
border-radius: 50%;
transform: rotate(-15deg);
}
&::after {
content: '';
position: absolute;
left: -80rpx;
top: -80rpx;
width: 240rpx;
height: 240rpx;
background: rgba(255,255,255,0.08);
border-radius: 50%;
}
}
}
.scan-area {
padding: 20rpx 30rpx 40rpx;
display: flex;
justify-content: center;
.scan-btn {
width: 460rpx;
height: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #00C853, #69F0AE);
border-radius: 30rpx;
box-shadow: 0 8rpx 32rpx rgba(0, 200, 83, 0.2);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
&:active {
transform: scale(0.98);
box-shadow: 0 4rpx 16rpx rgba(0, 200, 83, 0.15);
}
&::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(rgba(255,255,255,0.1), transparent);
}
.btn-content {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
position: relative;
z-index: 1;
.btn-icon {
width: 48rpx;
height: 48rpx;
margin-right: 16rpx;
}
.btn-text {
font-size: 42rpx;
font-weight: 600;
color: #fff;
text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.1);
}
}
.btn-desc {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.95);
position: relative;
z-index: 1;
}
}
}
.tips-section {
margin: 0 30rpx;
background: #fff;
border-radius: 24rpx;
box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.05);
overflow: hidden;
.tips-header {
padding: 30rpx;
background: linear-gradient(to right, #F5F9FF, #fff);
border-bottom: 2rpx solid #f0f0f0;
.tips-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
position: relative;
padding-left: 24rpx;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 32rpx;
background: #1976D2;
border-radius: 4rpx;
}
}
}
.tips-list {
padding: 20rpx 30rpx;
.tip-item {
display: flex;
align-items: center;
margin-bottom: 24rpx;
padding: 0 10rpx;
&:last-child {
margin-bottom: 0;
}
.tip-dot {
width: 12rpx;
height: 12rpx;
background: #1976D2;
border-radius: 50%;
margin-right: 16rpx;
flex-shrink: 0;
box-shadow: 0 2rpx 6rpx rgba(25,118,210,0.2);
}
text {
font-size: 28rpx;
color: #666;
line-height: 1.6;
}
}
}
}
}
</style>
<template>
<view class="container">
<!-- 宣传图片区域 -->
<view class="banner">
<view class="temp-banner">
<text class="banner-text">共享风扇</text>
<text class="banner-subtitle">让清凉随身携带</text>
<view class="banner-bg"></view>
</view>
</view>
<!-- 扫码按钮区域 -->
<view class="scan-area">
<view class="scan-btn" @click="handleScan">
<view class="btn-content">
<image class="btn-icon" src="../../static/scan-icon.png" mode="aspectFit" />
<text class="btn-text">扫一扫</text>
</view>
<text class="btn-desc">扫描设备二维码使用或归还</text>
</view>
</view>
<!-- 使用提示区域 -->
<view class="tips-section">
<view class="tips-header">
<view class="tips-title">使用小贴士</view>
</view>
<view class="tips-list">
<view class="tip-item">
<view class="tip-dot"></view>
<text>租借时间每次最长可租借12小时</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text>押金说明租借需支付99元押金归还后自动退还</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text>收费标准2/小时不足1小时按1小时计算</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text>爱护提示请勿将设备带离指定区域保持设备清洁</text>
</view>
</view>
</view>
</view>
</template>
<script>
import {getQueryString, wxLogin }from '@/util/index.js'
import {
URL
}from"@/config/url.js"
import { getDeviceInfo } from '@/config/user.js'
export default {
methods: {
async handleScan() {
try {
const scanResult = await new Promise((resolve, reject) => {
uni.scanCode({
success: resolve,
fail: reject
})
})
let deviceNo = getQueryString(scanResult.path, 'deviceNo')
console.log('扫码路径:', scanResult.path)
console.log('解析到的设备号:', deviceNo)
if (!deviceNo) {
uni.showToast({
title: '无效的设备二维码',
icon: 'none'
})
return
}
// 直接在当前页面查询是否有使用中的订单,避免跳转到中间页面
if (!uni.getStorageSync('token')) {
await wxLogin()
}
// 检查是否有使用中的订单
const inUseRes = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/order/inUse`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
}
})
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({
url: `/pages/return/index?orderId=${inUseOrder.orderId}&deviceId=${deviceNo || inUseOrder.deviceNo}`
})
console.log('已发起页面跳转')
return
}
// 检查是否有待支付订单
const orderRes = await uni.request({
url: `${URL || 'http://127.0.0.1:8080'}/app/order/unpaid`,
method: 'GET',
header: {
'Authorization': "Bearer " + uni.getStorageSync('token'),
'Clientid': uni.getStorageSync('client_id')
}
})
console.log('待支付订单检查结果:', JSON.stringify(orderRes))
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)
if (deviceInfoRes.code == 200 && deviceInfoRes.data && deviceInfoRes.data.device) {
const deviceInfo = deviceInfoRes.data.device
// 如果有feeConfig,直接解析并处理
if (deviceInfo.feeConfig) {
console.log('获取到设备feeConfig信息:', deviceInfo.feeConfig)
// 这里可以直接解析feeConfig并进行前端处理
try {
const feeConfig = JSON.parse(deviceInfo.feeConfig)
// 根据解析后的feeConfig进行页面跳转并传递信息
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}&feeConfig=${encodeURIComponent(deviceInfo.feeConfig)}`
})
} catch (e) {
console.error('解析feeConfig失败:', e)
// 解析失败时仍然跳转到详情页面,由详情页面处理
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} else {
// 没有feeConfig时,跳转到详情页面
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} else {
console.error('获取设备信息失败:', deviceInfoRes.msg || '未知错误')
uni.showToast({
title: '获取设备信息失败',
icon: 'none'
})
// 失败时仍然跳转到详情页面
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
} catch (error) {
console.error('获取设备信息异常:', error)
uni.showToast({
title: '获取设备信息失败',
icon: 'none'
})
// 异常时仍然跳转到详情页面
uni.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
})
}
}
} catch (error) {
console.error('扫码处理失败:', error)
uni.showToast({
title: '扫码失败',
icon: 'none'
})
}
}
}
}
</script>
<style lang="scss" scoped>
.container {
height: 87.5vh;
background: #f8f8f8;
padding-bottom: 40rpx;
.banner {
padding: 30rpx;
.temp-banner {
height: 300rpx;
background: linear-gradient(135deg, #1976D2, #42A5F5);
border-radius: 30rpx;
position: relative;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
box-shadow: 0 8rpx 32rpx rgba(25, 118, 210, 0.2);
.banner-text {
font-size: 56rpx;
font-weight: bold;
margin-bottom: 20rpx;
position: relative;
z-index: 1;
text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.1);
}
.banner-subtitle {
font-size: 32rpx;
opacity: 0.95;
position: relative;
z-index: 1;
text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.1);
}
.banner-bg {
position: absolute;
right: -60rpx;
bottom: -60rpx;
width: 300rpx;
height: 300rpx;
background: rgba(255,255,255,0.1);
border-radius: 50%;
transform: rotate(-15deg);
}
&::after {
content: '';
position: absolute;
left: -80rpx;
top: -80rpx;
width: 240rpx;
height: 240rpx;
background: rgba(255,255,255,0.08);
border-radius: 50%;
}
}
}
.scan-area {
padding: 20rpx 30rpx 40rpx;
display: flex;
justify-content: center;
.scan-btn {
width: 460rpx;
height: 200rpx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #00C853, #69F0AE);
border-radius: 30rpx;
box-shadow: 0 8rpx 32rpx rgba(0, 200, 83, 0.2);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
&:active {
transform: scale(0.98);
box-shadow: 0 4rpx 16rpx rgba(0, 200, 83, 0.15);
}
&::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(rgba(255,255,255,0.1), transparent);
}
.btn-content {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12rpx;
position: relative;
z-index: 1;
.btn-icon {
width: 48rpx;
height: 48rpx;
margin-right: 16rpx;
}
.btn-text {
font-size: 42rpx;
font-weight: 600;
color: #fff;
text-shadow: 0 2rpx 4rpx rgba(0,0,0,0.1);
}
}
.btn-desc {
font-size: 26rpx;
color: rgba(255, 255, 255, 0.95);
position: relative;
z-index: 1;
}
}
}
.tips-section {
margin: 0 30rpx;
background: #fff;
border-radius: 24rpx;
box-shadow: 0 8rpx 32rpx rgba(0,0,0,0.05);
overflow: hidden;
.tips-header {
padding: 30rpx;
background: linear-gradient(to right, #F5F9FF, #fff);
border-bottom: 2rpx solid #f0f0f0;
.tips-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
position: relative;
padding-left: 24rpx;
&::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 8rpx;
height: 32rpx;
background: #1976D2;
border-radius: 4rpx;
}
}
}
.tips-list {
padding: 20rpx 30rpx;
.tip-item {
display: flex;
align-items: center;
margin-bottom: 24rpx;
padding: 0 10rpx;
&:last-child {
margin-bottom: 0;
}
.tip-dot {
width: 12rpx;
height: 12rpx;
background: #1976D2;
border-radius: 50%;
margin-right: 16rpx;
flex-shrink: 0;
box-shadow: 0 2rpx 6rpx rgba(25,118,210,0.2);
}
text {
font-size: 28rpx;
color: #666;
line-height: 1.6;
}
}
}
}
}
</style>
+501 -501
View File
File diff suppressed because it is too large Load Diff
+582 -610
View File
File diff suppressed because it is too large Load Diff
+337 -337
View File
@@ -1,338 +1,338 @@
<template>
<view class="success-container">
<!-- 支付成功状态 -->
<view class="status-card">
<view class="status-icon success"></view>
<view class="status-text">支付成功</view>
<view class="status-desc">您的订单已支付成功</view>
</view>
<!-- 订单信息 -->
<view class="order-card">
<view class="card-title">订单信息</view>
<view class="info-item">
<text class="label">订单号</text>
<text class="value">{{ orderInfo.orderNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">设备号</text>
<text class="value">{{ orderInfo.deviceNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">支付金额</text>
<text class="value">{{ orderInfo.amount || '0.00' }}</text>
</view>
<view class="info-item">
<text class="label">支付时间</text>
<text class="value">{{ orderInfo.payTime || '-' }}</text>
</view>
</view>
<!-- 设备状态 -->
<view class="device-status">
<view class="status-message">{{ deviceMessage }}</view>
<view class="loading-animation" v-if="isLoading">
<view class="loading-circle"></view>
</view>
</view>
<!-- 操作按钮 -->
<view class="button-group">
<button class="primary-btn" @click="goToHome">返回首页</button>
<button class="secondary-btn" @click="goToOrderList">查看订单</button>
</view>
</view>
</template>
<script>
import { queryById, confirmPaymentAndRent } from '@/config/user.js'
export default {
data() {
return {
orderId: '',
orderInfo: {},
isLoading: true,
deviceMessage: '正在准备您的设备,请稍候...',
hasTriggeredDevice: false
}
},
onLoad(options) {
if (options && options.orderId) {
this.orderId = options.orderId
this.loadOrderInfo()
// 添加页面显示监听,防止页面切换后重复触发弹出
uni.$once('orderSuccess:' + this.orderId, () => {
console.log('已经触发过弹出逻辑,不再重复触发')
this.hasTriggeredDevice = true
})
} else {
uni.showToast({
title: '订单信息不存在',
icon: 'none'
})
setTimeout(() => {
this.goToHome()
}, 1500)
}
},
methods: {
async loadOrderInfo() {
try {
uni.showLoading({
title: '加载中'
})
const res = await queryById(this.orderId)
if (res.code === 200 && res.data) {
const orderData = res.data
this.orderInfo = {
orderNo: orderData.orderNo || orderData.orderId,
deviceNo: orderData.deviceNo,
amount: orderData.payAmount || orderData.amount,
payTime: orderData.payTime || this.formatTime(new Date())
}
// 检查订单状态
if (orderData.orderStatus === 'IN_USED') {
// 如果已经是使用中状态,可能说明开锁已经完成
this.deviceMessage = '设备已弹出,请取走您的充电宝'
this.isLoading = false
// 如果是第一次加载页面且设备已弹出,记录状态,避免重复弹出
if (!this.hasTriggeredDevice) {
uni.$emit('orderSuccess:' + this.orderId)
this.hasTriggeredDevice = true
}
} else {
// 正常触发弹出逻辑
this.triggerDeviceEject()
}
} else {
throw new Error('获取订单信息失败')
}
uni.hideLoading()
} catch (error) {
uni.hideLoading()
uni.showToast({
title: error.message || '获取订单信息失败',
icon: 'none'
})
}
},
// 触发弹出充电宝
async triggerDeviceEject() {
if (this.hasTriggeredDevice) {
console.log('已经触发过弹出充电宝,不重复触发')
return
}
this.hasTriggeredDevice = true
uni.$emit('orderSuccess:' + this.orderId)
this.isLoading = true
this.deviceMessage = '正在准备您的设备,请稍候...'
try {
console.log(`准备触发弹出充电宝,orderId: ${this.orderId}`)
// 调用确认支付并弹出的方法
const result = await confirmPaymentAndRent(this.orderId)
console.log('确认支付并弹出充电宝结果:', JSON.stringify(result))
if (result && result.code === 200) {
this.deviceMessage = '设备已弹出,请取走您的充电宝'
uni.showToast({
title: '充电宝已弹出',
icon: 'success'
})
} else {
throw new Error((result && result.msg) || '弹出充电宝失败')
}
} catch (error) {
console.error('弹出充电宝错误:', error)
this.deviceMessage = '弹出设备失败,请联系客服'
uni.showToast({
title: error.message || '弹出充电宝失败,请联系客服',
icon: 'none'
})
} finally {
this.isLoading = false
}
},
formatTime(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hour = date.getHours().toString().padStart(2, '0')
const minute = date.getMinutes().toString().padStart(2, '0')
const second = date.getSeconds().toString().padStart(2, '0')
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
},
goToHome() {
uni.switchTab({
url: '/pages/index/index'
})
},
goToOrderList() {
uni.redirectTo({
url: '/pages/order/index'
})
}
}
}
</script>
<style lang="scss" scoped>
.success-container {
padding: 20px;
background-color: #f5f5f5;
min-height: 100vh;
}
.status-card {
background-color: #fff;
border-radius: 12px;
padding: 30px;
text-align: center;
margin-bottom: 20px;
.status-icon {
width: 60px;
height: 60px;
margin: 0 auto 16px;
background-color: #07c160;
border-radius: 50%;
position: relative;
&::after {
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 30px;
height: 20px;
border: 3px solid #fff;
border-top: none;
border-right: none;
transform-origin: center;
transform: translate(-50%, -70%) rotate(-45deg);
}
}
.status-text {
font-size: 24px;
font-weight: bold;
color: #07c160;
margin-bottom: 8px;
}
.status-desc {
font-size: 14px;
color: #666;
}
}
.order-card {
background-color: #fff;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
.card-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 16px;
color: #333;
}
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
.label {
color: #666;
font-size: 14px;
}
.value {
color: #333;
font-size: 14px;
}
}
}
.device-status {
background-color: #fff;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
text-align: center;
.status-message {
font-size: 16px;
color: #333;
margin-bottom: 12px;
}
.loading-animation {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
.loading-circle {
width: 30px;
height: 30px;
border-radius: 50%;
border: 3px solid #f0f0f0;
border-top-color: #07c160;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
}
}
.button-group {
margin-top: 30px;
display: flex;
flex-direction: column;
gap: 16px;
.primary-btn {
background-color: #07c160;
color: #fff;
border: none;
border-radius: 24px;
padding: 12px;
font-size: 16px;
&:active {
opacity: 0.8;
}
}
.secondary-btn {
background-color: #fff;
color: #07c160;
border: 1px solid #07c160;
border-radius: 24px;
padding: 12px;
font-size: 16px;
&:active {
background-color: #f5f5f5;
}
}
}
<template>
<view class="success-container">
<!-- 支付成功状态 -->
<view class="status-card">
<view class="status-icon success"></view>
<view class="status-text">支付成功</view>
<view class="status-desc">您的订单已支付成功</view>
</view>
<!-- 订单信息 -->
<view class="order-card">
<view class="card-title">订单信息</view>
<view class="info-item">
<text class="label">订单号</text>
<text class="value">{{ orderInfo.orderNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">设备号</text>
<text class="value">{{ orderInfo.deviceNo || '-' }}</text>
</view>
<view class="info-item">
<text class="label">支付金额</text>
<text class="value">{{ orderInfo.amount || '0.00' }}</text>
</view>
<view class="info-item">
<text class="label">支付时间</text>
<text class="value">{{ orderInfo.payTime || '-' }}</text>
</view>
</view>
<!-- 设备状态 -->
<view class="device-status">
<view class="status-message">{{ deviceMessage }}</view>
<view class="loading-animation" v-if="isLoading">
<view class="loading-circle"></view>
</view>
</view>
<!-- 操作按钮 -->
<view class="button-group">
<button class="primary-btn" @click="goToHome">返回首页</button>
<button class="secondary-btn" @click="goToOrderList">查看订单</button>
</view>
</view>
</template>
<script>
import { queryById, confirmPaymentAndRent } from '@/config/user.js'
export default {
data() {
return {
orderId: '',
orderInfo: {},
isLoading: true,
deviceMessage: '正在准备您的设备,请稍候...',
hasTriggeredDevice: false
}
},
onLoad(options) {
if (options && options.orderId) {
this.orderId = options.orderId
this.loadOrderInfo()
// 添加页面显示监听,防止页面切换后重复触发弹出
uni.$once('orderSuccess:' + this.orderId, () => {
console.log('已经触发过弹出逻辑,不再重复触发')
this.hasTriggeredDevice = true
})
} else {
uni.showToast({
title: '订单信息不存在',
icon: 'none'
})
setTimeout(() => {
this.goToHome()
}, 1500)
}
},
methods: {
async loadOrderInfo() {
try {
uni.showLoading({
title: '加载中'
})
const res = await queryById(this.orderId)
if (res.code === 200 && res.data) {
const orderData = res.data
this.orderInfo = {
orderNo: orderData.orderNo || orderData.orderId,
deviceNo: orderData.deviceNo,
amount: orderData.payAmount || orderData.amount,
payTime: orderData.payTime || this.formatTime(new Date())
}
// 检查订单状态
if (orderData.orderStatus === 'IN_USED') {
// 如果已经是使用中状态,可能说明开锁已经完成
this.deviceMessage = '设备已弹出,请取走您的充电宝'
this.isLoading = false
// 如果是第一次加载页面且设备已弹出,记录状态,避免重复弹出
if (!this.hasTriggeredDevice) {
uni.$emit('orderSuccess:' + this.orderId)
this.hasTriggeredDevice = true
}
} else {
// 正常触发弹出逻辑
this.triggerDeviceEject()
}
} else {
throw new Error('获取订单信息失败')
}
uni.hideLoading()
} catch (error) {
uni.hideLoading()
uni.showToast({
title: error.message || '获取订单信息失败',
icon: 'none'
})
}
},
// 触发弹出充电宝
async triggerDeviceEject() {
if (this.hasTriggeredDevice) {
console.log('已经触发过弹出充电宝,不重复触发')
return
}
this.hasTriggeredDevice = true
uni.$emit('orderSuccess:' + this.orderId)
this.isLoading = true
this.deviceMessage = '正在准备您的设备,请稍候...'
try {
console.log(`准备触发弹出充电宝,orderId: ${this.orderId}`)
// 调用确认支付并弹出的方法
const result = await confirmPaymentAndRent(this.orderId)
console.log('确认支付并弹出充电宝结果:', JSON.stringify(result))
if (result && result.code === 200) {
this.deviceMessage = '设备已弹出,请取走您的充电宝'
uni.showToast({
title: '充电宝已弹出',
icon: 'success'
})
} else {
throw new Error((result && result.msg) || '弹出充电宝失败')
}
} catch (error) {
console.error('弹出充电宝错误:', error)
this.deviceMessage = '弹出设备失败,请联系客服'
uni.showToast({
title: error.message || '弹出充电宝失败,请联系客服',
icon: 'none'
})
} finally {
this.isLoading = false
}
},
formatTime(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hour = date.getHours().toString().padStart(2, '0')
const minute = date.getMinutes().toString().padStart(2, '0')
const second = date.getSeconds().toString().padStart(2, '0')
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
},
goToHome() {
uni.switchTab({
url: '/pages/index/index'
})
},
goToOrderList() {
uni.redirectTo({
url: '/pages/order/index'
})
}
}
}
</script>
<style lang="scss" scoped>
.success-container {
padding: 20px;
background-color: #f5f5f5;
min-height: 100vh;
}
.status-card {
background-color: #fff;
border-radius: 12px;
padding: 30px;
text-align: center;
margin-bottom: 20px;
.status-icon {
width: 60px;
height: 60px;
margin: 0 auto 16px;
background-color: #07c160;
border-radius: 50%;
position: relative;
&::after {
content: '';
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 30px;
height: 20px;
border: 3px solid #fff;
border-top: none;
border-right: none;
transform-origin: center;
transform: translate(-50%, -70%) rotate(-45deg);
}
}
.status-text {
font-size: 24px;
font-weight: bold;
color: #07c160;
margin-bottom: 8px;
}
.status-desc {
font-size: 14px;
color: #666;
}
}
.order-card {
background-color: #fff;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
.card-title {
font-size: 16px;
font-weight: bold;
margin-bottom: 16px;
color: #333;
}
.info-item {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
.label {
color: #666;
font-size: 14px;
}
.value {
color: #333;
font-size: 14px;
}
}
}
.device-status {
background-color: #fff;
border-radius: 12px;
padding: 20px;
margin-bottom: 20px;
text-align: center;
.status-message {
font-size: 16px;
color: #333;
margin-bottom: 12px;
}
.loading-animation {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
.loading-circle {
width: 30px;
height: 30px;
border-radius: 50%;
border: 3px solid #f0f0f0;
border-top-color: #07c160;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
}
}
.button-group {
margin-top: 30px;
display: flex;
flex-direction: column;
gap: 16px;
.primary-btn {
background-color: #07c160;
color: #fff;
border: none;
border-radius: 24px;
padding: 12px;
font-size: 16px;
&:active {
opacity: 0.8;
}
}
.secondary-btn {
background-color: #fff;
color: #07c160;
border: 1px solid #07c160;
border-radius: 24px;
padding: 12px;
font-size: 16px;
&:active {
background-color: #f5f5f5;
}
}
}
</style>
+136 -136
View File
@@ -1,137 +1,137 @@
<template>
<view>
</view>
</template>
<script>
import {
wxLogin,
} from '../../../util/index'
import {
getMyIndexInfo
} from "../../../config/user.js";
import {
queryHasOrder
} from "../../../config/user.js";
import {
checkOrdersByStatus
} from "../../../config/user.js";
export default {
data() {
return {
}
},
async onLoad(option) {
console.log('bagCheck onLoad option:', option);
try {
uni.showLoading({
title: '处理中...',
mask: true
});
// 检查是否传入设备编号
if (!option || !option.deviceNo) {
throw new Error('未识别到设备编号');
}
const deviceNo = option.deviceNo;
// 检查用户是否有进行中(in_used)或待支付(waiting_for_payment)的订单
const statusesToCheck = ['in_used', 'waiting_for_payment'];
const res = await checkOrdersByStatus(deviceNo, statusesToCheck);
if (res.code === 200 && res.data && res.data.length > 0) {
// 找到相关订单,取最新的一条
const latestOrder = res.data[0]; // 假设返回结果按时间倒序
if (latestOrder.orderStatus === 'in_used') {
// 如果是使用中的订单,跳转到归还页面
console.log('检测到使用中订单,跳转归还页:', latestOrder.orderId);
uni.redirectTo({
url: `/pages/device/return?orderId=${latestOrder.orderId}`
});
} else if (latestOrder.orderStatus === 'waiting_for_payment') {
// 如果是待支付订单,跳转到支付页面,并传递必要信息
console.log('检测到待支付订单,跳转支付页:', latestOrder.orderId);
// 获取套餐时间(分钟)
const packageTimeMinutes = latestOrder.packageTime || 60;
// 套餐小时数
const packageTimeHours = (packageTimeMinutes / 60).toFixed(1);
// 套餐价格
const packagePrice = latestOrder.packagePrice || '0.00';
// 计算每小时费率
const hourlyRate = (parseFloat(packagePrice) / (packageTimeMinutes / 60)).toFixed(2);
// 押金金额
const depositAmount = latestOrder.depositAmount || '99.00';
// 计算总金额(套餐+押金)
const totalAmount = (parseFloat(depositAmount) + parseFloat(packagePrice)).toFixed(2);
uni.redirectTo({
url: `/pages/order/payment?orderId=${latestOrder.orderId}&packageTimeHours=${packageTimeHours}&packagePrice=${packagePrice}&hourlyRate=${hourlyRate}&totalAmount=${totalAmount}&depositAmount=${depositAmount}`
});
} else {
// 其他状态(理论上不应该到这里,除非statusesToCheck配置错误),默认到详情页
console.log('检测到其他状态订单,跳转详情页:', latestOrder.orderId);
uni.redirectTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} else {
// 没有找到相关状态的订单,跳转到设备详情页进行租借
console.log('未检测到相关订单,跳转详情页');
uni.redirectTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} catch (error) {
// 只处理真正的错误,不是"没有订单"的情况
if (error.message && (
error.message.includes('未识别到设备编号') ||
error.message.includes('网络请求失败') ||
error.message.includes('服务器错误')
)) {
console.error('扫码检查订单失败:', error);
uni.showToast({
title: error.message || '处理失败,请稍后重试',
icon: 'none',
duration: 2000
});
} else {
// 对于其他错误,包括"没有找到订单",直接跳转到详情页,不显示错误消息
console.log('没有找到符合条件的订单或发生其他错误,直接跳转详情页');
}
// 无论什么情况,都跳转到一个可用页面
setTimeout(() => {
if (option && option.deviceNo) {
uni.redirectTo({
url: `/pages/device/detail?deviceNo=${option.deviceNo}`
});
} else {
// 如果连deviceNo都没有,则返回首页
uni.switchTab({ url: '/pages/index/index' });
}
}, 2000);
} finally {
uni.hideLoading();
}
},
methods: {
}
}
</script>
<style>
<template>
<view>
</view>
</template>
<script>
import {
wxLogin,
} from '../../../util/index'
import {
getMyIndexInfo
} from "../../../config/user.js";
import {
queryHasOrder
} from "../../../config/user.js";
import {
checkOrdersByStatus
} from "../../../config/user.js";
export default {
data() {
return {
}
},
async onLoad(option) {
console.log('bagCheck onLoad option:', option);
try {
uni.showLoading({
title: '处理中...',
mask: true
});
// 检查是否传入设备编号
if (!option || !option.deviceNo) {
throw new Error('未识别到设备编号');
}
const deviceNo = option.deviceNo;
// 检查用户是否有进行中(in_used)或待支付(waiting_for_payment)的订单
const statusesToCheck = ['in_used', 'waiting_for_payment'];
const res = await checkOrdersByStatus(deviceNo, statusesToCheck);
if (res.code === 200 && res.data && res.data.length > 0) {
// 找到相关订单,取最新的一条
const latestOrder = res.data[0]; // 假设返回结果按时间倒序
if (latestOrder.orderStatus === 'in_used') {
// 如果是使用中的订单,跳转到归还页面
console.log('检测到使用中订单,跳转归还页:', latestOrder.orderId);
uni.redirectTo({
url: `/pages/device/return?orderId=${latestOrder.orderId}`
});
} else if (latestOrder.orderStatus === 'waiting_for_payment') {
// 如果是待支付订单,跳转到支付页面,并传递必要信息
console.log('检测到待支付订单,跳转支付页:', latestOrder.orderId);
// 获取套餐时间(分钟)
const packageTimeMinutes = latestOrder.packageTime || 60;
// 套餐小时数
const packageTimeHours = (packageTimeMinutes / 60).toFixed(1);
// 套餐价格
const packagePrice = latestOrder.packagePrice || '0.00';
// 计算每小时费率
const hourlyRate = (parseFloat(packagePrice) / (packageTimeMinutes / 60)).toFixed(2);
// 押金金额
const depositAmount = latestOrder.depositAmount || '99.00';
// 计算总金额(套餐+押金)
const totalAmount = (parseFloat(depositAmount) + parseFloat(packagePrice)).toFixed(2);
uni.redirectTo({
url: `/pages/order/payment?orderId=${latestOrder.orderId}&packageTimeHours=${packageTimeHours}&packagePrice=${packagePrice}&hourlyRate=${hourlyRate}&totalAmount=${totalAmount}&depositAmount=${depositAmount}`
});
} else {
// 其他状态(理论上不应该到这里,除非statusesToCheck配置错误),默认到详情页
console.log('检测到其他状态订单,跳转详情页:', latestOrder.orderId);
uni.redirectTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} else {
// 没有找到相关状态的订单,跳转到设备详情页进行租借
console.log('未检测到相关订单,跳转详情页');
uni.redirectTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} catch (error) {
// 只处理真正的错误,不是"没有订单"的情况
if (error.message && (
error.message.includes('未识别到设备编号') ||
error.message.includes('网络请求失败') ||
error.message.includes('服务器错误')
)) {
console.error('扫码检查订单失败:', error);
uni.showToast({
title: error.message || '处理失败,请稍后重试',
icon: 'none',
duration: 2000
});
} else {
// 对于其他错误,包括"没有找到订单",直接跳转到详情页,不显示错误消息
console.log('没有找到符合条件的订单或发生其他错误,直接跳转详情页');
}
// 无论什么情况,都跳转到一个可用页面
setTimeout(() => {
if (option && option.deviceNo) {
uni.redirectTo({
url: `/pages/device/detail?deviceNo=${option.deviceNo}`
});
} else {
// 如果连deviceNo都没有,则返回首页
uni.switchTab({ url: '/pages/index/index' });
}
}, 2000);
} finally {
uni.hideLoading();
}
},
methods: {
}
}
</script>
<style>
</style>
+229 -229
View File
@@ -1,230 +1,230 @@
<template>
<view class="container">
<!-- 用户信息卡片 -->
<view class="user-card">
<view class="avatar">
<image :src="userInfo.avatar || '/static/images/default-avatar.png'" mode="aspectFill"></image>
</view>
<view class="user-info">
<text class="nickname">{{ userInfo.nickName || '未登录' }}</text>
<text class="phone">{{ userInfo.phone || '未绑定手机号' }}</text>
</view>
</view>
<!-- 余额卡片 -->
<view class="balance-card">
<view class="balance-title">余额</view>
<view class="balance-amount">{{ userInfo.balanceAmount || '0.00' }}</view>
<view class="balance-desc">可用于租借设备</view>
</view>
<!-- 功能菜单 -->
<view class="menu-list">
<view class="menu-item" @click="navigateTo('/pages/order/list')">
<text class="menu-icon">📋</text>
<text class="menu-text">我的订单</text>
<text class="menu-arrow">></text>
</view>
<view class="menu-item" @click="navigateTo('/pages/user/feedback')">
<text class="menu-icon">💬</text>
<text class="menu-text">意见反馈</text>
<text class="menu-arrow">></text>
</view>
<view class="menu-item" @click="navigateTo('/pages/user/about')">
<text class="menu-icon"></text>
<text class="menu-text">关于我们</text>
<text class="menu-arrow">></text>
</view>
</view>
<!-- 退出登录按钮 -->
<view class="logout-btn" @click="handleLogout" v-if="isLogin">
<text>退出登录</text>
</view>
</view>
</template>
<script>
import { getUserInfo } from '@/api/user'
import { URL } from '@/config/url'
export default {
data() {
return {
userInfo: {},
isLogin: false
}
},
onShow() {
this.checkLoginStatus()
this.loadUserInfo()
},
methods: {
async loadUserInfo() {
try {
const res = await getUserInfo()
if (res.code === 200) {
this.userInfo = res.data
this.isLogin = true
} else {
this.isLogin = false
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
}
} catch (error) {
console.error('加载用户信息失败:', error)
this.isLogin = false
}
},
checkLoginStatus() {
const token = uni.getStorageSync('token')
this.isLogin = !!token
if (!this.isLogin) {
uni.redirectTo({
url: '/pages/login/index'
})
}
},
navigateTo(url) {
uni.navigateTo({ url })
},
handleLogout() {
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
this.isLogin = false
uni.redirectTo({
url: '/pages/login/index'
})
}
}
})
}
}
}
</script>
<style>
.container {
padding: 20rpx;
background-color: #f5f5f5;
min-height: 100vh;
}
.user-card {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
display: flex;
align-items: center;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.avatar {
width: 120rpx;
height: 120rpx;
border-radius: 60rpx;
overflow: hidden;
margin-right: 30rpx;
}
.avatar image {
width: 100%;
height: 100%;
}
.user-info {
flex: 1;
}
.nickname {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
display: block;
}
.phone {
font-size: 28rpx;
color: #666;
}
.balance-card {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.balance-title {
font-size: 28rpx;
color: #666;
margin-bottom: 20rpx;
}
.balance-amount {
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
}
.balance-desc {
font-size: 24rpx;
color: #999;
}
.menu-list {
background-color: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.menu-item {
display: flex;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-icon {
font-size: 36rpx;
margin-right: 20rpx;
}
.menu-text {
flex: 1;
font-size: 28rpx;
color: #333;
}
.menu-arrow {
font-size: 28rpx;
color: #999;
}
.logout-btn {
margin-top: 40rpx;
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
text-align: center;
color: #ff4d4f;
font-size: 28rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
<template>
<view class="container">
<!-- 用户信息卡片 -->
<view class="user-card">
<view class="avatar">
<image :src="userInfo.avatar || '/static/images/default-avatar.png'" mode="aspectFill"></image>
</view>
<view class="user-info">
<text class="nickname">{{ userInfo.nickName || '未登录' }}</text>
<text class="phone">{{ userInfo.phone || '未绑定手机号' }}</text>
</view>
</view>
<!-- 余额卡片 -->
<view class="balance-card">
<view class="balance-title">余额</view>
<view class="balance-amount">{{ userInfo.balanceAmount || '0.00' }}</view>
<view class="balance-desc">可用于租借设备</view>
</view>
<!-- 功能菜单 -->
<view class="menu-list">
<view class="menu-item" @click="navigateTo('/pages/order/list')">
<text class="menu-icon">📋</text>
<text class="menu-text">我的订单</text>
<text class="menu-arrow">></text>
</view>
<view class="menu-item" @click="navigateTo('/pages/user/feedback')">
<text class="menu-icon">💬</text>
<text class="menu-text">意见反馈</text>
<text class="menu-arrow">></text>
</view>
<view class="menu-item" @click="navigateTo('/pages/user/about')">
<text class="menu-icon"></text>
<text class="menu-text">关于我们</text>
<text class="menu-arrow">></text>
</view>
</view>
<!-- 退出登录按钮 -->
<view class="logout-btn" @click="handleLogout" v-if="isLogin">
<text>退出登录</text>
</view>
</view>
</template>
<script>
import { getUserInfo } from '@/api/user'
import { URL } from '@/config/url'
export default {
data() {
return {
userInfo: {},
isLogin: false
}
},
onShow() {
this.checkLoginStatus()
this.loadUserInfo()
},
methods: {
async loadUserInfo() {
try {
const res = await getUserInfo()
if (res.code === 200) {
this.userInfo = res.data
this.isLogin = true
} else {
this.isLogin = false
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
}
} catch (error) {
console.error('加载用户信息失败:', error)
this.isLogin = false
}
},
checkLoginStatus() {
const token = uni.getStorageSync('token')
this.isLogin = !!token
if (!this.isLogin) {
uni.redirectTo({
url: '/pages/login/index'
})
}
},
navigateTo(url) {
uni.navigateTo({ url })
},
handleLogout() {
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
uni.removeStorageSync('token')
uni.removeStorageSync('userInfo')
this.isLogin = false
uni.redirectTo({
url: '/pages/login/index'
})
}
}
})
}
}
}
</script>
<style>
.container {
padding: 20rpx;
background-color: #f5f5f5;
min-height: 100vh;
}
.user-card {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
display: flex;
align-items: center;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.avatar {
width: 120rpx;
height: 120rpx;
border-radius: 60rpx;
overflow: hidden;
margin-right: 30rpx;
}
.avatar image {
width: 100%;
height: 100%;
}
.user-info {
flex: 1;
}
.nickname {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
display: block;
}
.phone {
font-size: 28rpx;
color: #666;
}
.balance-card {
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.balance-title {
font-size: 28rpx;
color: #666;
margin-bottom: 20rpx;
}
.balance-amount {
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
}
.balance-desc {
font-size: 24rpx;
color: #999;
}
.menu-list {
background-color: #fff;
border-radius: 16rpx;
margin-bottom: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.menu-item {
display: flex;
align-items: center;
padding: 30rpx;
border-bottom: 1rpx solid #f5f5f5;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-icon {
font-size: 36rpx;
margin-right: 20rpx;
}
.menu-text {
flex: 1;
font-size: 28rpx;
color: #333;
}
.menu-arrow {
font-size: 28rpx;
color: #999;
}
.logout-btn {
margin-top: 40rpx;
background-color: #fff;
border-radius: 16rpx;
padding: 30rpx;
text-align: center;
color: #ff4d4f;
font-size: 28rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
</style>
+9 -9
View File
@@ -1,10 +1,10 @@
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => res[0] ? reject(res[0]) : resolve(res[1]));
});
},
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => res[0] ? reject(res[0]) : resolve(res[1]));
});
},
});
+77 -77
View File
@@ -1,77 +1,77 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
@import 'uview-ui/theme.scss';
/* 颜色变量 */
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
/* 文字基本颜色 */
$uni-text-color:#333;//基本色
$uni-text-color-inverse:#fff;//反色
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0;
/* 背景颜色 */
$uni-bg-color:#ffffff;
$uni-bg-color-grey:#f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
/* 边框颜色 */
$uni-border-color:#c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
$uni-font-size-lg:16px;
/* 图片尺寸 */
$uni-img-size-sm:20px;
$uni-img-size-base:26px;
$uni-img-size-lg:40px;
/* Border Radius */
$uni-border-radius-sm: 2px;
$uni-border-radius-base: 3px;
$uni-border-radius-lg: 6px;
$uni-border-radius-circle: 50%;
/* 水平间距 */
$uni-spacing-row-sm: 5px;
$uni-spacing-row-base: 10px;
$uni-spacing-row-lg: 15px;
/* 垂直间距 */
$uni-spacing-col-sm: 4px;
$uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 12px;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title:20px;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
@import 'uview-ui/theme.scss';
/* 颜色变量 */
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
/* 文字基本颜色 */
$uni-text-color:#333;//基本色
$uni-text-color-inverse:#fff;//反色
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0;
/* 背景颜色 */
$uni-bg-color:#ffffff;
$uni-bg-color-grey:#f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
/* 边框颜色 */
$uni-border-color:#c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
$uni-font-size-lg:16px;
/* 图片尺寸 */
$uni-img-size-sm:20px;
$uni-img-size-base:26px;
$uni-img-size-lg:40px;
/* Border Radius */
$uni-border-radius-sm: 2px;
$uni-border-radius-base: 3px;
$uni-border-radius-lg: 6px;
$uni-border-radius-circle: 50%;
/* 水平间距 */
$uni-spacing-row-sm: 5px;
$uni-spacing-row-base: 10px;
$uni-spacing-row-lg: 15px;
/* 垂直间距 */
$uni-spacing-col-sm: 4px;
$uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 12px;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title:20px;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZGVwb3NpdC9pbmRleC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/deposit/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/deposit/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/deposit/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"detail.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZGV2aWNlL2RldGFpbC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/device/detail.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"detail.js","sources":["pages/device/detail.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/device/detail.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvZmVlZGJhY2svaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/feedback/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/feedback/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/feedback/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaGVscC9pbmRleC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/help/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/help/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/help/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvaW5kZXgvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/index/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/index/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvbXkvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/my/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/my/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/my/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/order/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"payment.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvcGF5bWVudC52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/payment.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"payment.js","sources":["pages/order/payment.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/payment.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"return-success.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvcmV0dXJuLXN1Y2Nlc3MudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/return-success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"return-success.js","sources":["pages/order/return-success.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/return-success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"success.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvb3JkZXIvc3VjY2Vzcy52dWU"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/order/success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"success.js","sources":["pages/order/success.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/order/success.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvcmV0dXJuL2luZGV4LnZ1ZQ"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/return/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/return/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/return/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
@@ -1 +1 @@
{"version":3,"file":"index.js","sources":["E:/迅雷下载/HBuilderX.4.57.2025032507/HBuilderX/plugins/uniapp-cli-vite/uniPage:/cGFnZXMvc2VydmUvYmFnQ2hlY2svaW5kZXgudnVl"],"sourcesContent":["import MiniProgramPage from 'C:/Users/Administrator.DESKTOP-IRCM9I0/Desktop/locker-fans/locker-fans/uni-fans/pages/serve/bagCheck/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
{"version":3,"file":"index.js","sources":["pages/serve/bagCheck/index.vue?type=page"],"sourcesContent":["import MiniProgramPage from '/Users/apple/Documents/subject/locker-fans/uni-fans/pages/serve/bagCheck/index.vue'\nwx.createPage(MiniProgramPage)"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,GAAG,WAAW,eAAe;"}
+2 -2
View File
@@ -6874,9 +6874,9 @@ function initOnError() {
};
}
function initRuntimeSocketService() {
const hosts = "192.168.1.15,127.0.0.1";
const hosts = "127.0.0.1,192.168.10.22,10.8.0.5";
const port = "8090";
const id = "mp-weixin_DyxEKd";
const id = "mp-weixin_PMV8-V";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();
+149 -126
View File
@@ -23,9 +23,22 @@ const _sfc_main = {
},
onLoad(options) {
this.deviceId = options.deviceNo;
this.checkOrderStatus();
common_vendor.index.__f__("log", "at pages/device/detail.vue:114", options.deviceNo);
this.getDeviceInfo();
if (options.feeConfig) {
try {
common_vendor.index.__f__("log", "at pages/device/detail.vue:117", "从URL获取到feeConfig:", options.feeConfig);
const feeConfigStr = decodeURIComponent(options.feeConfig);
this.deviceInfo = { ...this.deviceInfo, feeConfig: feeConfigStr };
this.parseFeeConfig();
} catch (e) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:124", "解析URL中的feeConfig失败:", e);
this.checkOrderStatus();
this.getDeviceInfo();
}
} else {
this.checkOrderStatus();
common_vendor.index.__f__("log", "at pages/device/detail.vue:132", options.deviceNo);
this.getDeviceInfo();
}
},
methods: {
// 检查登录状态和订单
@@ -54,115 +67,7 @@ const _sfc_main = {
};
}
}
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
if (feeConfig.length > 0 && "hour" in feeConfig[0] && "timesPrice" in feeConfig[0]) {
this.packages = feeConfig.map((pkg) => {
const hour = pkg.hour;
const price = pkg.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice,
hour
// 添加小时信息,用于后续处理
};
});
this.packages.sort((a, b) => a.hour - b.hour);
} else {
const commonConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0];
if (commonConfig) {
if (this.deviceInfo.feeType === "hour") {
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: "1小时",
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: "6小时",
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2)
},
{
time: "12小时",
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2)
}
];
} else if (this.deviceInfo.feeType === "times") {
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: "1次",
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2)
}
];
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00"
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67"
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25"
}
];
}
}
}
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:238", "解析设备费用配置失败:", e);
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00"
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67"
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25"
}
];
}
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00"
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67"
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25"
}
];
}
this.parseFeeConfig();
}
},
// 显示登录提示
@@ -226,16 +131,7 @@ const _sfc_main = {
});
return;
}
const selectedPkg = this.packages[this.selectedPackage];
common_vendor.index.showModal({
title: "确认租借",
content: `确认支付押金¥{{ depositAmount }}及${selectedPkg.time}套餐费用¥${selectedPkg.price}`,
success: (res) => {
if (res.confirm) {
this.submitRentOrder();
}
}
});
this.submitRentOrder();
},
// 提交租借订单
async submitRentOrder() {
@@ -264,19 +160,19 @@ const _sfc_main = {
packagePrice: parseFloat(selectedPkg.price)
});
if (updateRes.code !== 200) {
common_vendor.index.__f__("warn", "at pages/device/detail.vue:406", "更新订单套餐信息失败:", updateRes.msg);
common_vendor.index.__f__("warn", "at pages/device/detail.vue:292", "更新订单套餐信息失败:", updateRes.msg);
} else {
common_vendor.index.__f__("log", "at pages/device/detail.vue:409", "订单套餐信息已提前更新");
common_vendor.index.__f__("log", "at pages/device/detail.vue:295", "订单套餐信息已提前更新");
}
} catch (updateError) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:412", "更新订单套餐信息时出错:", updateError);
common_vendor.index.__f__("error", "at pages/device/detail.vue:298", "更新订单套餐信息时出错:", updateError);
}
const deposit = parseFloat(this.depositAmount);
const packagePrice = parseFloat(selectedPkg.price);
const totalAmount = (deposit + packagePrice).toFixed(2);
common_vendor.index.hideLoading();
common_vendor.index.redirectTo({
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace("小时", "")}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}`
url: `/pages/order/payment?orderId=${order.orderId}&packageTimeHours=${selectedPkg.time.replace("小时", "")}&packagePrice=${selectedPkg.price}&totalAmount=${totalAmount}&depositAmount=${this.depositAmount}${this.deviceInfo && this.deviceInfo.feeConfig ? "&feeConfig=" + encodeURIComponent(this.deviceInfo.feeConfig) : ""}`
});
} catch (error) {
common_vendor.index.hideLoading();
@@ -285,6 +181,133 @@ const _sfc_main = {
icon: "none"
});
}
},
// 单独抽取解析feeConfig的逻辑
parseFeeConfig() {
if (this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
if (feeConfig.length > 0 && "hour" in feeConfig[0] && "timesPrice" in feeConfig[0]) {
this.packages = feeConfig.map((pkg) => {
const hour = pkg.hour;
const price = pkg.timesPrice;
const unitPrice = (price / hour).toFixed(2);
return {
time: `${hour}小时`,
price: price.toFixed(2),
unitPrice,
hour
// 添加小时信息,用于后续处理
};
});
this.packages.sort((a, b) => a.hour - b.hour);
} else {
const commonConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0];
if (commonConfig) {
if (this.deviceInfo.feeType === "hour") {
const hourPrice = commonConfig.hourPrice > 0 ? commonConfig.hourPrice : commonConfig.timesPrice / 6;
this.packages = [
{
time: "1小时",
price: hourPrice.toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 1
},
{
time: "6小时",
price: (hourPrice * 6).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 6
},
{
time: "12小时",
price: (hourPrice * 12).toFixed(2),
unitPrice: hourPrice.toFixed(2),
hour: 12
}
];
} else if (this.deviceInfo.feeType === "times") {
const timesPrice = commonConfig.timesPrice;
this.packages = [
{
time: "1次",
price: timesPrice.toFixed(2),
unitPrice: timesPrice.toFixed(2),
hour: 1
}
];
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00",
hour: 1
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67",
hour: 6
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25",
hour: 12
}
];
}
}
}
this.selectedPackage = Math.min(1, this.packages.length - 1);
} catch (e) {
common_vendor.index.__f__("error", "at pages/device/detail.vue:419", "解析设备费用配置失败:", e);
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00",
hour: 1
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67",
hour: 6
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25",
hour: 12
}
];
this.selectedPackage = 1;
}
} else {
this.packages = [
{
time: "1小时",
price: "2.00",
unitPrice: "2.00",
hour: 1
},
{
time: "6小时",
price: "10.00",
unitPrice: "1.67",
hour: 6
},
{
time: "12小时",
price: "15.00",
unitPrice: "1.25",
hour: 12
}
];
this.selectedPackage = 1;
}
}
}
};
+52 -12
View File
@@ -2,6 +2,7 @@
const common_vendor = require("../../common/vendor.js");
const util_index = require("../../util/index.js");
const config_url = require("../../config/url.js");
const config_user = require("../../config/user.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
methods: {
@@ -14,8 +15,8 @@ const _sfc_main = {
});
});
let deviceNo = util_index.getQueryString(scanResult.path, "deviceNo");
common_vendor.index.__f__("log", "at pages/index/index.vue:67", "扫码路径:", scanResult.path);
common_vendor.index.__f__("log", "at pages/index/index.vue:68", "解析到的设备号:", deviceNo);
common_vendor.index.__f__("log", "at pages/index/index.vue:68", "扫码路径:", scanResult.path);
common_vendor.index.__f__("log", "at pages/index/index.vue:69", "解析到的设备号:", deviceNo);
if (!deviceNo) {
common_vendor.index.showToast({
title: "无效的设备二维码",
@@ -34,14 +35,14 @@ const _sfc_main = {
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
common_vendor.index.__f__("log", "at pages/index/index.vue:93", "使用中订单检查结果:", JSON.stringify(inUseRes));
common_vendor.index.__f__("log", "at pages/index/index.vue:94", "使用中订单检查结果:", 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:98", "检测到使用中订单,准备跳转:", inUseOrder);
common_vendor.index.__f__("log", "at pages/index/index.vue:99", "检测到使用中订单,准备跳转:", 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:104", "已发起页面跳转");
common_vendor.index.__f__("log", "at pages/index/index.vue:105", "已发起页面跳转");
return;
}
const orderRes = await common_vendor.index.request({
@@ -52,21 +53,60 @@ const _sfc_main = {
"Clientid": common_vendor.index.getStorageSync("client_id")
}
});
common_vendor.index.__f__("log", "at pages/index/index.vue:118", "待支付订单检查结果:", JSON.stringify(orderRes));
common_vendor.index.__f__("log", "at pages/index/index.vue:119", "待支付订单检查结果:", 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:123", "检测到待支付订单,准备跳转:", unpaidOrder);
common_vendor.index.__f__("log", "at pages/index/index.vue:124", "检测到待支付订单,准备跳转:", unpaidOrder);
common_vendor.index.navigateTo({
url: `/pages/order/payment?orderId=${unpaidOrder.orderId}`
});
} else {
common_vendor.index.__f__("log", "at pages/index/index.vue:129", "无待支付订单,直接跳转到设备详情页面, deviceNo:", deviceNo);
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
common_vendor.index.__f__("log", "at pages/index/index.vue:130", "无待支付订单,获取设备信息, 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:141", "获取到设备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:152", "解析feeConfig失败:", e);
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} else {
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} else {
common_vendor.index.__f__("error", "at pages/index/index.vue:166", "获取设备信息失败:", deviceInfoRes.msg || "未知错误");
common_vendor.index.showToast({
title: "获取设备信息失败",
icon: "none"
});
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:178", "获取设备信息异常:", error);
common_vendor.index.showToast({
title: "获取设备信息失败",
icon: "none"
});
common_vendor.index.navigateTo({
url: `/pages/device/detail?deviceNo=${deviceNo}`
});
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/index.vue:135", "扫码处理失败:", error);
common_vendor.index.__f__("error", "at pages/index/index.vue:191", "扫码处理失败:", error);
common_vendor.index.showToast({
title: "扫码失败",
icon: "none"
+35 -49
View File
@@ -30,6 +30,19 @@ const _sfc_main = {
const deposit = parseFloat(this.orderInfo.deposit || this.passedDepositAmount || 99);
const packagePrice = parseFloat(this.packageInfo.price || 0);
return (deposit + packagePrice).toFixed(2);
},
// 计算每小时的价格
hourlyRate() {
const price = parseFloat(this.packageInfo.price || 0);
let time = parseFloat(this.packageInfo.time || 1);
if (this.packageInfo.time && this.packageInfo.time.includes("分钟")) {
time = time / 60;
} else if (this.packageInfo.time && this.packageInfo.time.includes("次")) {
return price.toFixed(2);
}
if (time <= 0)
time = 1;
return (price / time).toFixed(2);
}
},
onLoad(options) {
@@ -41,6 +54,15 @@ const _sfc_main = {
if (options.depositAmount) {
this.passedDepositAmount = options.depositAmount;
}
if (options.feeConfig) {
try {
common_vendor.index.__f__("log", "at pages/order/payment.vue:135", "从URL获取到feeConfig:", options.feeConfig);
const feeConfigStr = decodeURIComponent(options.feeConfig);
this.deviceInfo = { feeConfig: feeConfigStr };
} catch (e) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:140", "解析URL中的feeConfig失败:", e);
}
}
this.loadOrderInfo();
} else {
common_vendor.index.showToast({
@@ -72,7 +94,7 @@ const _sfc_main = {
formattedTime = this.formatTime(/* @__PURE__ */ new Date());
}
} catch (e) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:149", "时间格式化错误:", e);
common_vendor.index.__f__("error", "at pages/order/payment.vue:180", "时间格式化错误:", e);
formattedTime = this.formatTime(/* @__PURE__ */ new Date());
}
this.orderInfo = {
@@ -82,6 +104,13 @@ const _sfc_main = {
phone: orderData.phone,
deposit: this.passedDepositAmount || orderData.depositAmount || "99.00"
};
if (orderData.packageTime && orderData.packagePrice) {
const timeInHours = (parseFloat(orderData.packageTime) / 60).toFixed(1);
this.packageInfo = {
time: timeInHours.toString(),
price: orderData.packagePrice.toString()
};
}
this.deviceNo = orderData.deviceNo;
await this.loadDeviceInfo();
} else {
@@ -96,7 +125,7 @@ const _sfc_main = {
});
}
},
// 加载设备信息并解析套餐
// 加载设备信息
async loadDeviceInfo() {
if (!this.deviceNo)
return;
@@ -104,55 +133,12 @@ const _sfc_main = {
const res = await config_user.getDeviceInfo(this.deviceNo);
if (res.code === 200 && res.data) {
this.deviceInfo = res.data.device;
if (this.deviceInfo && this.deviceInfo.feeConfig) {
try {
const feeConfig = JSON.parse(this.deviceInfo.feeConfig);
if (feeConfig.length > 0 && "hour" in feeConfig[0] && "timesPrice" in feeConfig[0]) {
const allPackages = feeConfig.sort((a, b) => a.hour - b.hour);
const middleIndex = Math.floor(allPackages.length / 2);
const selectedPackage = allPackages[middleIndex];
this.packageInfo.time = selectedPackage.hour.toString();
this.packageInfo.price = selectedPackage.timesPrice.toString();
} else if (feeConfig.length > 0 && "Hour" in feeConfig[0] && "Price" in feeConfig[0]) {
const targetHours = 6;
let closestPackage = feeConfig[0];
feeConfig.forEach((pkg) => {
if (Math.abs(pkg.Hour - targetHours) < Math.abs(closestPackage.Hour - targetHours)) {
closestPackage = pkg;
}
});
this.packageInfo.time = closestPackage.Hour.toString();
this.packageInfo.price = closestPackage.Price.toString();
} else {
const selectedConfig = feeConfig.find((item) => item.specCode === "common") || feeConfig[0];
if (selectedConfig) {
const packageHours = 6;
if (this.deviceInfo.feeType === "times") {
this.packageInfo.price = selectedConfig.timesPrice.toString();
this.packageInfo.time = "1次";
} else if (this.deviceInfo.feeType === "hour") {
if (selectedConfig.hourPrice > 0) {
this.packageInfo.price = (selectedConfig.hourPrice * packageHours).toString();
} else {
this.packageInfo.price = selectedConfig.timesPrice.toString();
}
this.packageInfo.time = packageHours.toString();
} else {
this.packageInfo.price = selectedConfig.timesPrice.toString();
this.packageInfo.time = packageHours.toString();
}
}
}
} catch (e) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:252", "解析设备费用配置失败:", e);
}
}
if (this.deviceInfo && this.deviceInfo.depositAmount) {
this.orderInfo.deposit = this.deviceInfo.depositAmount;
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:262", "获取设备信息失败:", error);
common_vendor.index.__f__("error", "at pages/order/payment.vue:234", "获取设备信息失败:", error);
}
},
// 处理支付
@@ -181,7 +167,7 @@ const _sfc_main = {
try {
await config_user.updateUserBalance(this.orderId);
} catch (error) {
common_vendor.index.__f__("warn", "at pages/order/payment.vue:299", "更新用户余额失败:", error);
common_vendor.index.__f__("warn", "at pages/order/payment.vue:271", "更新用户余额失败:", error);
}
setTimeout(() => {
common_vendor.index.redirectTo({
@@ -190,7 +176,7 @@ const _sfc_main = {
}, 1500);
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/order/payment.vue:310", "支付失败:", err);
common_vendor.index.__f__("error", "at pages/order/payment.vue:282", "支付失败:", err);
throw new Error("支付失败,请重试");
}
});
@@ -287,7 +273,7 @@ const _sfc_main = {
throw new Error("查询订单状态失败");
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/order/payment.vue:418", "查询订单状态错误:", error);
common_vendor.index.__f__("error", "at pages/order/payment.vue:390", "查询订单状态错误:", error);
return null;
}
}
+26 -26
View File
@@ -1,29 +1,29 @@
{
"description": "项目配置文件。",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false,
"newFeature": true,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
"description": "项目配置文件。",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
"es6": true,
"postcss": false,
"minified": false,
"newFeature": true,
"bigPackageSizeSupport": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"compileType": "miniprogram",
"libVersion": "3.8.1",
"appid": "wxe752f45e7f7aa271",
"projectname": "fs",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
}
},
"compileType": "miniprogram",
"libVersion": "3.8.0",
"appid": "wxe752f45e7f7aa271",
"projectname": "fs",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}
+5 -5
View File
@@ -1,7 +1,7 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "fs",
"setting": {
"compileHotReLoad": true
}
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "fs",
"setting": {
"compileHotReLoad": true
}
}
+83 -83
View File
@@ -1,84 +1,84 @@
import {
login,
getMyIndexInfo
} from "../config/user"
// 微信登录方法
export const wxLogin = () => {
return new Promise((resolve, reject) => {
// 1. 获取微信登录凭证
uni.login({
provider: 'weixin',
success: async (loginRes) => {
try {
if (loginRes.code) {
// 2. 发送 code 到后端换取 token
const result = await login({
code: loginRes.code,
appid: "wxe752f45e7f7aa271"
})
if (result.code === 200) {
// 3. 保存token和用户信息
uni.setStorageSync('token', result.data.LoginWxVo.access_token)
uni.setStorageSync('client_id', result.data.LoginWxVo.client_id)
resolve(result.data)
} else {
throw new Error(result.message || '登录失败')
}
} else {
throw new Error('获取微信登录凭证失败')
}
} catch (error) {
uni.showToast({
title: error.message || '登录失败',
icon: 'none'
})
reject(error)
}
},
fail: (error) => {
uni.showToast({
title: '微信登录失败',
icon: 'none'
})
reject(error)
}
})
})
}
// 检查登录状态
// export const checkLogin = () => {
// const token = uni.getStorageSync('token')
// return !!token
// }
// 获取用户信息
export const getUserInfo = () => {
return new Promise(async (res, rej) => {
const result = await getMyIndexInfo({
isHide: false,
})
res(result)
})
}
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;
import {
login,
getMyIndexInfo
} from "../config/user"
// 微信登录方法
export const wxLogin = () => {
return new Promise((resolve, reject) => {
// 1. 获取微信登录凭证
uni.login({
provider: 'weixin',
success: async (loginRes) => {
try {
if (loginRes.code) {
// 2. 发送 code 到后端换取 token
const result = await login({
code: loginRes.code,
appid: "wxe752f45e7f7aa271"
})
if (result.code === 200) {
// 3. 保存token和用户信息
uni.setStorageSync('token', result.data.LoginWxVo.access_token)
uni.setStorageSync('client_id', result.data.LoginWxVo.client_id)
resolve(result.data)
} else {
throw new Error(result.message || '登录失败')
}
} else {
throw new Error('获取微信登录凭证失败')
}
} catch (error) {
uni.showToast({
title: error.message || '登录失败',
icon: 'none'
})
reject(error)
}
},
fail: (error) => {
uni.showToast({
title: '微信登录失败',
icon: 'none'
})
reject(error)
}
})
})
}
// 检查登录状态
// export const checkLogin = () => {
// const token = uni.getStorageSync('token')
// return !!token
// }
// 获取用户信息
export const getUserInfo = () => {
return new Promise(async (res, rej) => {
const result = await getMyIndexInfo({
isHide: false,
})
res(result)
})
}
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;
}
+221 -221
View File
@@ -1,222 +1,222 @@
import { queryById } from '@/config/user.js'
/**
* 订单监控服务
* 用于在后台监控订单状态变化特别是归还完成状态
*/
class OrderMonitor {
constructor() {
this.activeOrders = new Map() // 存储活跃订单 Map<orderId, {orderData, pageName}>
this.timer = null
this.checkInterval = 10000 // 10秒检查一次
this.isRunning = false
this.currentPage = null // 当前活跃页面
}
/**
* 添加订单到监控队列
* @param {Object} orderData 订单数据对象必须包含orderId字段
* @param {String} pageName 关联的页面名称默认为'return'
*/
addOrder(orderData, pageName = 'return') {
if (!orderData || !orderData.orderId) {
console.error('添加订单监控失败:无效的订单数据')
return
}
console.log(`添加订单到监控队列: ${orderData.orderId}, 页面: ${pageName}`)
this.activeOrders.set(orderData.orderId, {
...orderData,
pageName
})
// 如果监控服务尚未启动,则启动
if (!this.isRunning) {
this.start()
}
}
/**
* 移除订单的监控
* @param {Object} params 包含orderId或pageName的对象
*/
removeOrder(params) {
if (!params) return
// 如果提供了orderId,直接删除该订单
if (params.orderId && this.activeOrders.has(params.orderId)) {
console.log('从监控队列移除订单:', params.orderId)
this.activeOrders.delete(params.orderId)
}
// 如果提供了pageName,删除该页面关联的所有订单
else if (params.pageName) {
console.log('从监控队列移除页面相关订单:', params.pageName)
for (const [orderId, data] of this.activeOrders.entries()) {
if (data.pageName === params.pageName) {
this.activeOrders.delete(orderId)
}
}
}
// 如果没有订单需要监控了,停止服务
if (this.activeOrders.size === 0) {
this.stop()
}
}
/**
* 设置当前活跃页面
* @param {String} pageName 页面名称
*/
setActivePage(pageName) {
this.currentPage = pageName
console.log('设置当前活跃页面:', pageName)
}
/**
* 启动监控服务
*/
start() {
if (this.isRunning) return
console.log('启动订单监控服务')
this.isRunning = true
this.checkOrders()
this.timer = setInterval(() => {
this.checkOrders()
}, this.checkInterval)
}
/**
* 停止监控服务
*/
stop() {
if (!this.isRunning) return
console.log('停止订单监控服务')
this.isRunning = false
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
}
/**
* 检查所有活跃订单的状态
*/
async checkOrders() {
if (this.activeOrders.size === 0) return
console.log(`检查 ${this.activeOrders.size} 个活跃订单状态, 当前页面: ${this.currentPage}`)
// 只检查当前活跃页面关联的订单,或无页面关联的订单
for (const [orderId, data] of this.activeOrders.entries()) {
try {
// 只在归还页面(或页面未指定时)才执行轮询
if (!data.pageName || data.pageName === 'return') {
if (this.currentPage === 'return' || this.currentPage === null) {
await this.checkOrderStatus(orderId)
} else {
console.log(`跳过订单状态检查: ${orderId}, 当前不在归还页面`)
}
}
} catch (error) {
console.error(`检查订单状态失败: ${orderId}`, error)
}
}
}
/**
* 检查单个订单的状态
* @param {String} orderId 订单ID
*/
async checkOrderStatus(orderId) {
try {
console.log(`检查订单 ${orderId} 的状态`)
const result = await queryById(orderId)
if (result.code === 200 && result.data) {
const orderData = result.data
const existingData = this.activeOrders.get(orderId)
const pageName = existingData ? existingData.pageName : null
// 更新本地存储的订单数据,保留页面关联信息
this.activeOrders.set(orderId, {
...orderData,
pageName
})
// 检查订单是否已完成
if (orderData.orderStatus === 'used_done' || orderData.orderStatus === 'used_down') {
console.log(`订单 ${orderId} 已完成!`)
// 触发全局事件
uni.$emit('orderCompleted', orderData)
// 显示全局通知
uni.showToast({
title: '充电宝归还成功',
icon: 'success',
duration: 2000
})
// 播放通知声音(如果需要)
const innerAudioContext = uni.createInnerAudioContext()
innerAudioContext.src = '/static/audio/return_success.mp3'
innerAudioContext.play()
// 完成的订单不再需要监控
this.removeOrder({orderId})
// 如果用户不在归还页面,则显示归还成功弹窗
setTimeout(() => {
uni.showModal({
title: '归还成功',
content: '充电宝已归还成功,剩余押金将退还到您的账户',
confirmText: '查看详情',
success: (res) => {
if (res.confirm) {
// 跳转到归还成功页面查看详情
uni.redirectTo({
url: `/pages/order/return-success?orderId=${orderId}`
})
}
}
})
}, 500)
}
}
} catch (error) {
console.error(`检查订单 ${orderId} 状态出错:`, error)
}
}
}
// 导出单例实例
export const orderMonitor = new OrderMonitor()
// 监听页面切换事件
uni.onAppRoute((route) => {
const pagePath = route.path || ''
const pageSegments = pagePath.split('/')
const pageName = pageSegments[pageSegments.length - 1]
// 设置当前活跃页面
orderMonitor.setActivePage(pageName || null)
console.log('页面切换:', pagePath, '当前活跃页面:', pageName)
})
// 页面加载时自动恢复监控上次的活跃订单(如果有)
const initOrderMonitor = () => {
const lastActiveOrderId = uni.getStorageSync('activeOrderId')
if (lastActiveOrderId) {
const lastOrderData = { orderId: lastActiveOrderId }
orderMonitor.addOrder(lastOrderData, 'return')
}
}
// 初始化
import { queryById } from '@/config/user.js'
/**
* 订单监控服务
* 用于在后台监控订单状态变化特别是归还完成状态
*/
class OrderMonitor {
constructor() {
this.activeOrders = new Map() // 存储活跃订单 Map<orderId, {orderData, pageName}>
this.timer = null
this.checkInterval = 10000 // 10秒检查一次
this.isRunning = false
this.currentPage = null // 当前活跃页面
}
/**
* 添加订单到监控队列
* @param {Object} orderData 订单数据对象必须包含orderId字段
* @param {String} pageName 关联的页面名称默认为'return'
*/
addOrder(orderData, pageName = 'return') {
if (!orderData || !orderData.orderId) {
console.error('添加订单监控失败:无效的订单数据')
return
}
console.log(`添加订单到监控队列: ${orderData.orderId}, 页面: ${pageName}`)
this.activeOrders.set(orderData.orderId, {
...orderData,
pageName
})
// 如果监控服务尚未启动,则启动
if (!this.isRunning) {
this.start()
}
}
/**
* 移除订单的监控
* @param {Object} params 包含orderId或pageName的对象
*/
removeOrder(params) {
if (!params) return
// 如果提供了orderId,直接删除该订单
if (params.orderId && this.activeOrders.has(params.orderId)) {
console.log('从监控队列移除订单:', params.orderId)
this.activeOrders.delete(params.orderId)
}
// 如果提供了pageName,删除该页面关联的所有订单
else if (params.pageName) {
console.log('从监控队列移除页面相关订单:', params.pageName)
for (const [orderId, data] of this.activeOrders.entries()) {
if (data.pageName === params.pageName) {
this.activeOrders.delete(orderId)
}
}
}
// 如果没有订单需要监控了,停止服务
if (this.activeOrders.size === 0) {
this.stop()
}
}
/**
* 设置当前活跃页面
* @param {String} pageName 页面名称
*/
setActivePage(pageName) {
this.currentPage = pageName
console.log('设置当前活跃页面:', pageName)
}
/**
* 启动监控服务
*/
start() {
if (this.isRunning) return
console.log('启动订单监控服务')
this.isRunning = true
this.checkOrders()
this.timer = setInterval(() => {
this.checkOrders()
}, this.checkInterval)
}
/**
* 停止监控服务
*/
stop() {
if (!this.isRunning) return
console.log('停止订单监控服务')
this.isRunning = false
if (this.timer) {
clearInterval(this.timer)
this.timer = null
}
}
/**
* 检查所有活跃订单的状态
*/
async checkOrders() {
if (this.activeOrders.size === 0) return
console.log(`检查 ${this.activeOrders.size} 个活跃订单状态, 当前页面: ${this.currentPage}`)
// 只检查当前活跃页面关联的订单,或无页面关联的订单
for (const [orderId, data] of this.activeOrders.entries()) {
try {
// 只在归还页面(或页面未指定时)才执行轮询
if (!data.pageName || data.pageName === 'return') {
if (this.currentPage === 'return' || this.currentPage === null) {
await this.checkOrderStatus(orderId)
} else {
console.log(`跳过订单状态检查: ${orderId}, 当前不在归还页面`)
}
}
} catch (error) {
console.error(`检查订单状态失败: ${orderId}`, error)
}
}
}
/**
* 检查单个订单的状态
* @param {String} orderId 订单ID
*/
async checkOrderStatus(orderId) {
try {
console.log(`检查订单 ${orderId} 的状态`)
const result = await queryById(orderId)
if (result.code === 200 && result.data) {
const orderData = result.data
const existingData = this.activeOrders.get(orderId)
const pageName = existingData ? existingData.pageName : null
// 更新本地存储的订单数据,保留页面关联信息
this.activeOrders.set(orderId, {
...orderData,
pageName
})
// 检查订单是否已完成
if (orderData.orderStatus === 'used_done' || orderData.orderStatus === 'used_down') {
console.log(`订单 ${orderId} 已完成!`)
// 触发全局事件
uni.$emit('orderCompleted', orderData)
// 显示全局通知
uni.showToast({
title: '充电宝归还成功',
icon: 'success',
duration: 2000
})
// 播放通知声音(如果需要)
const innerAudioContext = uni.createInnerAudioContext()
innerAudioContext.src = '/static/audio/return_success.mp3'
innerAudioContext.play()
// 完成的订单不再需要监控
this.removeOrder({orderId})
// 如果用户不在归还页面,则显示归还成功弹窗
setTimeout(() => {
uni.showModal({
title: '归还成功',
content: '充电宝已归还成功,剩余押金将退还到您的账户',
confirmText: '查看详情',
success: (res) => {
if (res.confirm) {
// 跳转到归还成功页面查看详情
uni.redirectTo({
url: `/pages/order/return-success?orderId=${orderId}`
})
}
}
})
}, 500)
}
}
} catch (error) {
console.error(`检查订单 ${orderId} 状态出错:`, error)
}
}
}
// 导出单例实例
export const orderMonitor = new OrderMonitor()
// 监听页面切换事件
uni.onAppRoute((route) => {
const pagePath = route.path || ''
const pageSegments = pagePath.split('/')
const pageName = pageSegments[pageSegments.length - 1]
// 设置当前活跃页面
orderMonitor.setActivePage(pageName || null)
console.log('页面切换:', pagePath, '当前活跃页面:', pageName)
})
// 页面加载时自动恢复监控上次的活跃订单(如果有)
const initOrderMonitor = () => {
const lastActiveOrderId = uni.getStorageSync('activeOrderId')
if (lastActiveOrderId) {
const lastOrderData = { orderId: lastActiveOrderId }
orderMonitor.addOrder(lastOrderData, 'return')
}
}
// 初始化
initOrderMonitor()