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 @@
-
-
-
-
-
-
- 设备续费
-
- 套餐ID:
-
-
-
- 应用ID:
-
-
-
- 支付金额:
-
-
-
- 渠道ID:
-
-
-
- 设备ID:
-
-
-
-
-
-
-
- 创建订单
-
- 设备类型:
-
-
-
- 租赁周期:
-
-
-
- 金额:
-
-
-
-
-
-
-
- 获取订单列表
-
- 页码:
-
-
-
- 每页数量:
-
-
-
-
-
-
-
- API返回结果:
- {{ JSON.stringify(result, null, 2) }}
-
-
-
-
-
-
-
\ 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,
},
}
}