Browse Source

feat: 接口对接;

pull/1/head
fox 2 months ago
parent
commit
bf1fb80323
5 changed files with 57 additions and 98 deletions
  1. +11
    -9
      components/order/orderCard.vue
  2. +4
    -1
      pages.json
  3. +2
    -2
      pages/index/category.vue
  4. +17
    -53
      pages_order/order/orderDetail.vue
  5. +23
    -33
      pages_order/order/verifyOrder.vue

+ 11
- 9
components/order/orderCard.vue View File

@ -1,13 +1,14 @@
<template>
<view class="card order order-card__view" @click="onClick">
<view class="flex overview">
<text class="title">{{ data.title }}</text>
<text class="title">{{ data.itemId_dictText }}</text>
<text class="status">{{ statusCodeAndDescFieldsMapping[data.status] }}</text>
</view>
<view class="flex detail">
<image class="img" :src="data.massageItem.image"></image>
<view class="info">
<view class="flex flex-column desc">
<!-- todo: check -->
<view class="row">{{ `服务内容:${data.massageItem.title || '-'}` }}</view>
<view class="row">{{ `下单时间:${$dayjs(data.createTime).format('YYYY-MM-DD HH:mm:ss')}` }}</view>
<view class="row">{{ `订单号:${data.id || '-'}` }}</view>
@ -15,14 +16,14 @@
<view class="price">
总价格<text class="unit">¥</text><text class="count">{{ data.amount }}</text>
</view>
<view class="btns" v-if="[0, 1].includes(data.status)">
<view class="btns">
<!-- 待付款 -->
<template v-if="data.status === 0">
<template v-if="data.status == 0">
<button plain class="btn btn-plain" @click="onCancel">取消订单</button>
<button plain class="btn" @click="onPay">立即付款</button>
</template>
<!-- 待核销 -->
<template v-if="data.status === 1">
<template v-if="data.status == 1">
<button plain class="btn" @click="onVerify">去核销</button>
</template>
</view>
@ -56,8 +57,8 @@
},
methods: {
onClick() {
if (this.data.status === 2) { //
// todo: check
// todo: check
if (this.data.status == 2) { //
this.$utils.navigateTo(`/pages_order/order/orderDetail?id=${this.data.id}`)
}
},
@ -176,14 +177,14 @@
}
.btns {
margin-top: 16rpx;
margin-bottom: 9rpx;
text-align: right;
font-size: 0;
}
}
.btn {
margin-top: 16rpx;
margin-bottom: 9rpx;
display: inline-block;
width: auto;
min-width: 145rpx;
@ -192,7 +193,7 @@
box-sizing: border-box;
border: none;
border-radius: 29rpx;
margin: 0;
// margin: 0;
font-size: 22rpx;
line-height: 1;
@ -204,6 +205,7 @@
}
&-plain {
padding: 12rpx 26rpx;
border: 2rpx solid #999999;
color: #999999;
background: none;


+ 4
- 1
pages.json View File

@ -50,7 +50,10 @@
"path": "order/createOrder"
},
{
"path": "order/verifyOrder"
"path": "order/verifyOrder",
"style": {
"enablePullDownRefresh": true
}
},
{
"path": "order/orderDetail",


+ 2
- 2
pages/index/category.vue View File

@ -137,14 +137,14 @@
methods: {
async fetchCategoryList() {
try {
return (await this.$fetch('getCategoryList'))?.records?.map(item => ({ id: item.id, name: item.name, childrens: [] }))
return (await this.$fetch('getCategoryList', { pageSize: 1000 }))?.records?.map(item => ({ id: item.id, name: item.name, childrens: [] }))
} catch(err) {
return []
}
},
async queryProductList(categoryId) {
try {
return (await this.$fetch('queryProductList', { categoryId }))?.records || []
return (await this.$fetch('queryProductList', { categoryId, pageSize: 1000 }))?.records || []
} catch (err) {
return []
}


+ 17
- 53
pages_order/order/orderDetail.vue View File

@ -5,18 +5,18 @@
<view class="page-content">
<view class="page-label">订单详情</view>
<!-- 商品详情 -->
<productCard :data="productDetail" size="medium" :readonly="true"></productCard>
<productCard :data="orderDetail.massageItem" size="medium" :readonly="true"></productCard>
<view class="info">
<view class="info-header">订单信息</view>
<view class="info-content">
<view class="flex info-row">
<text>实付款</text>
<text class="price"><text class="price-unit">¥</text>{{ orderDetail.price }}</text>
<text class="price"><text class="price-unit">¥</text>{{ orderDetail.amount }}</text>
</view>
<view class="flex info-row">
<text>订单号</text>
<text>{{ orderDetail.orderNo }}</text>
<text>{{ orderDetail.id }}</text>
</view>
<view class="flex info-row">
<text>付款时间</text>
@ -24,7 +24,7 @@
</view>
<view class="flex info-row">
<text>核销时间</text>
<text>{{ orderDetail.verifyTime }}</text>
<text>{{ orderDetail.validTime }}</text>
</view>
</view>
</view>
@ -39,8 +39,6 @@
mapState
} from 'vuex'
const TEMP_BANNER_IMG_URL = 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280'
export default {
components: {
productCard
@ -48,62 +46,28 @@
computed: {},
data() {
return {
// todo: fetch
productDetail: {
id: '001',
imgUrl: TEMP_BANNER_IMG_URL,
price: 99,
num: 1,
sales: 235,
title: '60分钟肩颈推拿按摩',
desc: '疏通经络 放松肌肉',
tags: ['专业技师', '舒适环境', '深度放松'],
details: '<p>这里是商品详情..............<br/>这里是商品详情..............</p>'
},
orderDetail: {
id: '001',
orderNo: 'da123567',
price: 99,
payTime: '2024-12-24 18:45:23',
verifyTime: '2024-12-24 18:45:23',
},
id: 0,
id: null,
orderDetail: {},
}
},
onLoad(args) {
this.id = args.id
},
onShow() {
this.getOrderDetail()
this.fetchOrderDetail()
},
onPullDownRefresh() {
this.getOrderDetail()
this.fetchOrderDetail()
},
methods: {
getOrderDetail() {
// todo: delete test code
return
this.$api('getOrderDetail', {
id: this.id
}, res => {
uni.stopPullDownRefresh()
if (res.code == 200) {
this.order = res.result
}
})
},
async fetchOrderDetail() {
try {
this.orderDetail = await this.$fetch('queryOrderById', { id: this.id })
} catch (err) {
}
//
copy(content) {
uni.setClipboardData({
data: content,
success: () => {
uni.showToast({
title: '复制成功',
icon: 'none'
})
}
})
uni.stopPullDownRefresh()
},
}
}


+ 23
- 33
pages_order/order/verifyOrder.vue View File

@ -10,9 +10,9 @@
<view class="page-content">
<!-- 商品详情 -->
<productCard :data="productDetail" size="medium" :readonly="true"></productCard>
<productCard :data="orderDetail.massageItem" size="medium" :readonly="true"></productCard>
<view class="card rights">
<view class="card rights" v-if="orderDetail.rights && orderDetail.rights.length">
<view class="flex rights-item" v-for="item in orderDetail.rights" :key="item">
<image class="rights-icon" src="@/pages_order/static/verifyOrder/icon-checked.png" mode="widthFix"></image>
<text>{{ item }}</text>
@ -23,14 +23,12 @@
<view class="info-header">核销信息</view>
<view class="flex flex-column info-content">
<image class="info-qr" :src="orderDetail.qrCodeImgUrl" mode="widthFix"></image>
<view class="info-no">{{ `订单号:${orderDetail.orderNo}` }}</view>
<view class="info-no">{{ `订单号:${orderDetail.id}` }}</view>
<view class="info-desc">{{ `有效时间:${orderDetail.startTime}${orderDetail.endTime}` }}</view>
</view>
</view>
</view>
<!-- 下单 -->
<view class="flex bar">
<button plain class="btn btn-plain" @click="onRefund">申请退款</button>
@ -43,48 +41,40 @@
<script>
import productCard from '@/components/product/productCard.vue'
const TEMP_BANNER_IMG_URL = 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280'
export default {
components: {
productCard,
},
data() {
return {
// todo: fetch
productDetail: {
id: '001',
imgUrl: TEMP_BANNER_IMG_URL,
price: 99,
num: 1,
sales: 235,
title: '60分钟肩颈推拿按摩',
desc: '疏通经络 放松肌肉',
tags: ['专业技师', '舒适环境', '深度放松'],
details: '<p>这里是商品详情..............<br/>这里是商品详情..............</p>'
},
orderDetail: {
id: '001',
orderNo: 'da123567',
qrCodeImgUrl: '../static/verifyOrder/temp-qrcode.png',
startTime: '2025-03-14',
endTime: '2025-04-14',
rights: ['过期退', '随时退']
},
orderDetail: {},
}
},
onLoad(option) {
const { id } = option
// todo: fetch order data & product data by order id
},
onLoad(args) {
this.id = args.id
this.fetchOrderDetail()
},
onPullDownRefresh() {
this.fetchOrderDetail()
},
methods: {
async fetchOrderDetail() {
try {
this.orderDetail = await this.$fetch('queryOrderById', { id: this.id })
} catch (err) {
}
uni.stopPullDownRefresh()
},
onRefund() {
// todo
},
onBuyAgain() {
// todo: check
this.$utils.navigateTo(`/pages_order/product/productDetail?id=${this.productDetail.id}`)
this.$utils.navigateTo(`/pages_order/product/productDetail?id=${this.orderDetail.massageItem.id}`)
},
},
}


Loading…
Cancel
Save