From 896aff0e00e177a7de1ccf6e4d34ea1cb957e79a Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Fri, 22 Aug 2025 11:47:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=8E=A5=E6=94=B6=E4=BC=A0?= =?UTF-8?q?=E5=8F=82=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/dev.js | 2 +- examples/order-api-usage.js | 252 -------------------------- examples/order-api-usage.vue | 320 ---------------------------------- pages/agents/requestAgent.vue | 4 +- pages/login/login.vue | 28 ++- pages/profile/profile.vue | 10 +- 6 files changed, 31 insertions(+), 585 deletions(-) delete mode 100644 examples/order-api-usage.js delete mode 100644 examples/order-api-usage.vue diff --git a/config/dev.js b/config/dev.js index de0e72f..896e4c2 100644 --- a/config/dev.js +++ b/config/dev.js @@ -2,7 +2,7 @@ export const DEV_CONFIG = { // 临时token,用于开发测试 TEMP_TOKEN: - 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjJlYmJhZjZiLTA4OGMtNDFiZi1iOTZiLTM2OTg3ZGE4YWRkNiJ9.1DbS4tyDkcL12E1rMh3J3aIdjzqffrqnHg9ya-1kwRjkEQKvGE5lwNsRQve0hFveD3p33lxccVIzZxD3AbpAtw', + 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImEwMmVhNzAyLTU5Y2MtNDgyMS1hZGIzLTRjYWY0NzNjYjFhZSJ9.LNW_DJufVd4KfvQWNSH2MbLbVKAMMOcykOybK2Yrngg_IpepeDmlX1e26HQr3PFMpmXy6AYEtObIjjSQEqS61g', // 是否使用临时token USE_TEMP_TOKEN: true, diff --git a/examples/order-api-usage.js b/examples/order-api-usage.js deleted file mode 100644 index 371aee3..0000000 --- a/examples/order-api-usage.js +++ /dev/null @@ -1,252 +0,0 @@ -import { - renewDevice, - createLeaseOrder, - getOrderList, - getOrderDetail, - cancelOrder, - confirmReceive, - applyRefund -} from '@/api/order/order.js' - -/** - * 设备续费示例 - */ -export async function renewDeviceExample() { - try { - const renewData = { - suitId: "3", // 套餐ID - appId: "1", // 应用ID - payAmount: "365", // 支付金额 - channelId: "2", // 渠道ID - devId: "1" // 设备ID - } - - const response = await renewDevice(renewData) - - if (response.code === 200) { - console.log('续费成功:', response.data) - uni.showToast({ - title: '续费成功', - icon: 'success' - }) - } else { - throw new Error(response.message || '续费失败') - } - } catch (error) { - console.error('续费失败:', error) - uni.showToast({ - title: error.message || '续费失败', - icon: 'error' - }) - } -} - -/** - * 创建租赁订单示例 - */ -export async function createLeaseOrderExample(formData) { - try { - const orderData = { - name: formData.name, - phone: formData.phone, - address: formData.address, - detailAddress: formData.detailAddress, - equipmentId: formData.equipmentId, - periodId: formData.periodId, - amount: formData.amount - } - - const response = await createLeaseOrder(orderData) - - if (response.code === 200) { - console.log('订单创建成功:', response.data) - uni.showToast({ - title: '订单创建成功', - icon: 'success' - }) - return response.data - } else { - throw new Error(response.message || '订单创建失败') - } - } catch (error) { - console.error('订单创建失败:', error) - uni.showToast({ - title: error.message || '订单创建失败', - icon: 'error' - }) - throw error - } -} - -/** - * 获取订单列表示例 - */ -export async function getOrderListExample() { - try { - const params = { - page: 1, - size: 10, - status: 'all' // 可选: pending, paid, shipped, completed, cancelled - } - - const response = await getOrderList(params) - - if (response.code === 200) { - console.log('订单列表:', response.data) - return response.data - } else { - throw new Error(response.message || '获取订单列表失败') - } - } catch (error) { - console.error('获取订单列表失败:', error) - uni.showToast({ - title: error.message || '获取订单列表失败', - icon: 'error' - }) - throw error - } -} - -/** - * 获取订单详情示例 - */ -export async function getOrderDetailExample(orderId) { - try { - const response = await getOrderDetail(orderId) - - if (response.code === 200) { - console.log('订单详情:', response.data) - return response.data - } else { - throw new Error(response.message || '获取订单详情失败') - } - } catch (error) { - console.error('获取订单详情失败:', error) - uni.showToast({ - title: error.message || '获取订单详情失败', - icon: 'error' - }) - throw error - } -} - -/** - * 取消订单示例 - */ -export async function cancelOrderExample(orderId) { - try { - const response = await cancelOrder(orderId) - - if (response.code === 200) { - console.log('订单取消成功:', response.data) - uni.showToast({ - title: '订单取消成功', - icon: 'success' - }) - return response.data - } else { - throw new Error(response.message || '订单取消失败') - } - } catch (error) { - console.error('订单取消失败:', error) - uni.showToast({ - title: error.message || '订单取消失败', - icon: 'error' - }) - throw error - } -} - -/** - * 确认收货示例 - */ -export async function confirmReceiveExample(orderId) { - try { - const response = await confirmReceive(orderId) - - if (response.code === 200) { - console.log('确认收货成功:', response.data) - uni.showToast({ - title: '确认收货成功', - icon: 'success' - }) - return response.data - } else { - throw new Error(response.message || '确认收货失败') - } - } catch (error) { - console.error('确认收货失败:', error) - uni.showToast({ - title: error.message || '确认收货失败', - icon: 'error' - }) - throw error - } -} - -/** - * 申请退款示例 - */ -export async function applyRefundExample(orderId, reason, amount) { - try { - const refundData = { - orderId: orderId, - reason: reason, - amount: amount - } - - const response = await applyRefund(refundData) - - if (response.code === 200) { - console.log('退款申请成功:', response.data) - uni.showToast({ - title: '退款申请成功', - icon: 'success' - }) - return response.data - } else { - throw new Error(response.message || '退款申请失败') - } - } catch (error) { - console.error('退款申请失败:', error) - uni.showToast({ - title: error.message || '退款申请失败', - icon: 'error' - }) - throw error - } -} - -/** - * 在租赁页面中使用API的示例 - */ -export function useInLeasePage() { - // 在租赁页面的支付按钮点击事件中调用 - async function handlePayment() { - try { - // 1. 创建租赁订单 - const orderResult = await createLeaseOrderExample({ - name: '张三', - phone: '13800138000', - address: '北京市朝阳区', - detailAddress: '某某小区1号楼101室', - equipmentId: '1', - periodId: '3', - amount: '365.00' - }) - - // 2. 如果订单创建成功,可以进行支付 - if (orderResult) { - console.log('订单创建成功,订单号:', orderResult.orderId) - // 这里可以调用支付接口 - } - - } catch (error) { - console.error('支付流程失败:', error) - } - } - - return { - handlePayment - } -} \ No newline at end of file diff --git a/examples/order-api-usage.vue b/examples/order-api-usage.vue deleted file mode 100644 index fff7481..0000000 --- a/examples/order-api-usage.vue +++ /dev/null @@ -1,320 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/agents/requestAgent.vue b/pages/agents/requestAgent.vue index e3d0e0e..6f0c616 100644 --- a/pages/agents/requestAgent.vue +++ b/pages/agents/requestAgent.vue @@ -60,11 +60,11 @@ export default { const userId = getLocalUserId() if (userId) { // 构建包含登录页面链接和用户ID的二维码内容 - this.qrcodeValue = `https://wx.ccttiot.com/cf/i?agentId=${userId}` + this.qrcodeValue = `https://wx.ccttiot.com/cf/i/?agentId=${userId}` console.log('二维码内容:', this.qrcodeValue) } else { // 如果没有用户ID,使用默认值 - this.qrcodeValue = 'https://wx.ccttiot.com/cf/i?agentId=123456' + this.qrcodeValue = 'https://wx.ccttiot.com/cf/i?/agentId=123456' console.warn('未找到用户ID,使用默认二维码内容') } }, diff --git a/pages/login/login.vue b/pages/login/login.vue index 952048b..be9c260 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -99,11 +99,29 @@ export default { return commonEnum }, }, - onLoad() { - this.pageLoading = new AutoLoadingManager() - this.agentId = this.$Route.query.agentId || '' // 获取路由参数 - console.log('登录页面接收到的agentId:', this.agentId) + onLoad: async function (options) { + if (options && options.q) { + const q = decodeURIComponent(options.q) // 解码二维码链接 + console.log('解析后的链接:', q) // 示例: https://wx.ccttiot.com/cf/i/?agentId=63 + + // 提取agentId参数 + const agentId = this.getUrlParam('agentId', q) + if (agentId) { + this.setData({ agentId }) // 存入data(用于界面显示) + this.agentId = agentId // 存入实例属性 + console.log('成功存入agentId:', this.agentId) + } else { + console.log('获取id失败') + } + } }, + + getUrlParam: function (key, url) { + const regex = new RegExp(`[?&]${key}=([^&#]*)`) + const match = url.match(regex) + return match ? decodeURIComponent(match[1]) : null + }, + onUnload() { forceHideLoading() if (this.pageLoading) { @@ -242,7 +260,7 @@ export default { loginCode: res.code, agentId: this.agentId, // 携带agentId } - + console.log('登录请求携带的agentId:', this.agentId) console.log('登录请求数据:', data) diff --git a/pages/profile/profile.vue b/pages/profile/profile.vue index c186ecc..78c9922 100644 --- a/pages/profile/profile.vue +++ b/pages/profile/profile.vue @@ -237,7 +237,7 @@ export default { code: 200, data: { nickName: '昵称', - phonenumber: '123****8912', + phonenumber: '123****1234', avatar: '', userId: '1', }, @@ -256,7 +256,7 @@ export default { return { code: 200, data: { - balance: 10000.0, + balance: 0, waitBalance: 0, withdrawBalance: 0, withdrawedBalance: 0, @@ -276,9 +276,9 @@ export default { return { code: 200, data: { - userNum: 4, - deviceNum: 1, - rentAmount: 2, + userNum: 0, + deviceNum: 0, + rentAmount: 0, }, } }