登录接收传参待测试

This commit is contained in:
WindowBird 2025-08-22 11:47:54 +08:00
parent 31f8a6a5da
commit 896aff0e00
6 changed files with 31 additions and 585 deletions

View File

@ -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,

View File

@ -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
}
}

View File

@ -1,320 +0,0 @@
<template>
<view class="order-api-demo">
<view class="header">
<text class="title">订单API使用示例</text>
</view>
<!-- 设备续费示例 -->
<view class="section">
<text class="section-title">设备续费</text>
<view class="form-item">
<text class="label">套餐ID:</text>
<input v-model="renewData.suitId" placeholder="请输入套餐ID" />
</view>
<view class="form-item">
<text class="label">应用ID:</text>
<input v-model="renewData.appId" placeholder="请输入应用ID" />
</view>
<view class="form-item">
<text class="label">支付金额:</text>
<input v-model="renewData.payAmount" placeholder="请输入支付金额" />
</view>
<view class="form-item">
<text class="label">渠道ID:</text>
<input v-model="renewData.channelId" placeholder="请输入渠道ID" />
</view>
<view class="form-item">
<text class="label">设备ID:</text>
<input v-model="renewData.devId" placeholder="请输入设备ID" />
</view>
<button @click="handleRenew" class="btn">设备续费</button>
</view>
<!-- 创建订单示例 -->
<view class="section">
<text class="section-title">创建订单</text>
<view class="form-item">
<text class="label">设备类型:</text>
<input v-model="orderData.deviceType" placeholder="请输入设备类型" />
</view>
<view class="form-item">
<text class="label">租赁周期:</text>
<input v-model="orderData.period" placeholder="请输入租赁周期" />
</view>
<view class="form-item">
<text class="label">金额:</text>
<input v-model="orderData.amount" placeholder="请输入金额" />
</view>
<button @click="handleCreateOrder" class="btn">创建订单</button>
</view>
<!-- 获取订单列表示例 -->
<view class="section">
<text class="section-title">获取订单列表</text>
<view class="form-item">
<text class="label">页码:</text>
<input v-model="listParams.page" placeholder="请输入页码" />
</view>
<view class="form-item">
<text class="label">每页数量:</text>
<input v-model="listParams.size" placeholder="请输入每页数量" />
</view>
<button @click="handleGetOrderList" class="btn">获取订单列表</button>
</view>
<!-- 结果显示 -->
<view class="result-section" v-if="result">
<text class="result-title">API返回结果:</text>
<text class="result-content">{{ JSON.stringify(result, null, 2) }}</text>
</view>
</view>
</template>
<script>
import {
renewDevice,
createOrder,
getOrderList,
getOrderDetail,
cancelOrder,
payOrder
} from '@/api/order/order.js'
export default {
name: 'OrderApiDemo',
data() {
return {
//
renewData: {
suitId: '3',
appId: '1',
payAmount: '365',
channelId: '2',
devId: '1'
},
//
orderData: {
deviceType: '',
period: '',
amount: ''
},
//
listParams: {
page: 1,
size: 10,
status: ''
},
// API
result: null
}
},
methods: {
//
async handleRenew() {
try {
console.log('🔍 发送续费请求:', this.renewData)
const response = await renewDevice(this.renewData)
this.result = response
console.log('✅ 续费成功:', response)
uni.showToast({
title: '续费成功',
icon: 'success'
})
} catch (error) {
console.error('❌ 续费失败:', error)
this.result = { error: error.message }
uni.showToast({
title: error.message || '续费失败',
icon: 'error'
})
}
},
//
async handleCreateOrder() {
try {
console.log('🔍 发送创建订单请求:', this.orderData)
const response = await createOrder(this.orderData)
this.result = response
console.log('✅ 创建订单成功:', response)
uni.showToast({
title: '创建订单成功',
icon: 'success'
})
} catch (error) {
console.error('❌ 创建订单失败:', error)
this.result = { error: error.message }
uni.showToast({
title: error.message || '创建订单失败',
icon: 'error'
})
}
},
//
async handleGetOrderList() {
try {
console.log('🔍 发送获取订单列表请求:', this.listParams)
const response = await getOrderList(this.listParams)
this.result = response
console.log('✅ 获取订单列表成功:', response)
uni.showToast({
title: '获取订单列表成功',
icon: 'success'
})
} catch (error) {
console.error('❌ 获取订单列表失败:', error)
this.result = { error: error.message }
uni.showToast({
title: error.message || '获取订单列表失败',
icon: 'error'
})
}
},
//
async getOrderDetail(orderId) {
try {
const response = await getOrderDetail(orderId)
console.log('✅ 获取订单详情成功:', response)
return response
} catch (error) {
console.error('❌ 获取订单详情失败:', error)
throw error
}
},
//
async cancelOrder(orderId) {
try {
const response = await cancelOrder(orderId)
console.log('✅ 取消订单成功:', response)
return response
} catch (error) {
console.error('❌ 取消订单失败:', error)
throw error
}
},
//
async payOrder(orderId, payMethod) {
try {
const response = await payOrder({
orderId,
payMethod
})
console.log('✅ 支付订单成功:', response)
return response
} catch (error) {
console.error('❌ 支付订单失败:', error)
throw error
}
}
}
}
</script>
<style lang="scss" scoped>
.order-api-demo {
padding: 30rpx;
background: #f5f5f5;
min-height: 100vh;
}
.header {
text-align: center;
margin-bottom: 40rpx;
.title {
font-size: 36rpx;
font-weight: bold;
color: #333;
}
}
.section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
.section-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 30rpx;
display: block;
}
}
.form-item {
display: flex;
align-items: center;
margin-bottom: 20rpx;
.label {
width: 160rpx;
font-size: 28rpx;
color: #666;
}
input {
flex: 1;
height: 70rpx;
padding: 0 20rpx;
border: 2rpx solid #e0e0e0;
border-radius: 10rpx;
font-size: 28rpx;
&:focus {
border-color: #007aff;
}
}
}
.btn {
width: 100%;
height: 80rpx;
background: #007aff;
color: #fff;
border: none;
border-radius: 10rpx;
font-size: 30rpx;
font-weight: bold;
margin-top: 20rpx;
&:active {
background: #0056cc;
}
}
.result-section {
background: #fff;
border-radius: 20rpx;
padding: 30rpx;
margin-top: 30rpx;
.result-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
display: block;
}
.result-content {
font-size: 24rpx;
color: #666;
line-height: 1.6;
word-break: break-all;
white-space: pre-wrap;
}
}
</style>

View File

@ -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使用默认二维码内容')
}
},

View File

@ -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) {

View File

@ -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,
},
}
}