Browse Source

feat: 接口对接;

pull/7/head
fox 1 week ago
parent
commit
ffa1529641
8 changed files with 109 additions and 62 deletions
  1. +8
    -1
      api/model/product.js
  2. +3
    -4
      components/couponList/couponList.vue
  3. +20
    -5
      pages/index/center.vue
  4. +12
    -9
      pages_order/components/voucher/voucherCard.vue
  5. +28
    -16
      pages_order/mine/verifyVoucher.vue
  6. +2
    -0
      pages_order/mine/voucher.vue
  7. +2
    -2
      pages_order/order/orderDetail.vue
  8. +34
    -25
      pages_order/order/verifyOrder.vue

+ 8
- 1
api/model/product.js View File

@ -31,12 +31,19 @@ const api = {
method: 'GET',
},
/**
* 获取优惠券信息
* 优惠券-可使用门店列表
*/
queryVoucherShopList: {
url: '/vouchers/queryShopList',
method: 'GET',
},
/**
* 代金券-根据id查看代金券详情
*/
queryVouchersById: {
url: '/vouchers/queryVouchersById',
method: 'GET',
},
}
export default api

+ 3
- 4
components/couponList/couponList.vue View File

@ -17,8 +17,8 @@
<image class="list-item-bg" src="@/pages_order/static/coupon/coupon-bg-overtime.png" ></image>
</template>
<text class="list-item-count">{{ item.money }}</text>
<text class="list-item-deadline">{{ `有效期至${item.endTime}` }}</text>
<text class="list-item-count">{{ item.discountAmount }}</text>
<text class="list-item-deadline">{{ `有效期至${item.validTime ? $dayjs(item.validTime).format('YYYY-MM-DD') : '-'}` }}</text>
</view>
</view>
@ -49,8 +49,7 @@
}
},
watch: {
status: function(newValue) {
console.log('--watch--status', newValue)
status: function() {
this.getCouponList()
}
},


+ 20
- 5
pages/index/center.vue View File

@ -71,17 +71,15 @@
<view class="account-label">我的余额</view>
</view>
<view class="flex flex-column">
<!-- todo: 字段对接 -->
<view class="account-value">{{ userCenterData.score || 0 }}</view>
<view class="account-label">我的积分</view>
</view>
<view class="flex flex-column">
<view class="account-value">{{ riceInfo.canWithdraw || 0 }}<text class="account-unit"></text></view>
<view class="account-value">{{ userInfo.recommendAmount || 0 }}<text class="account-unit"></text></view>
<view class="account-label">推广佣金</view>
</view>
<view class="flex flex-column">
<!-- todo: 字段对接 -->
<view class="account-value">{{ riceInfo.balance || 0 }}<text class="account-unit"></text></view>
<view class="account-value">{{ couponCount || 0 }}<text class="account-unit"></text></view>
<view class="account-label">优惠券</view>
</view>
</view>
@ -178,6 +176,7 @@
},
data() {
return {
couponCount: 0,
}
},
onShow() {
@ -185,6 +184,7 @@
this.$store.commit('getUserInfo')
this.$store.commit('getUserCenterInfo')
this.$store.commit('getRiceInfo')
this.fetchCouponData()
}
},
methods: {
@ -214,10 +214,16 @@
console.log(res);
if (res.result) {
//
const [id, type] = res.result.split(',')
console.log('扫码结果:', res.result);
console.log('--overOrder', {
orderId : id,
type, // type0- 1-
})
this.$fetch('overOrder', {
orderId : res.result
orderId : id,
type, // type0- 1-
}).then(() => {
uni.showToast({
title: '核销成功',
@ -236,6 +242,15 @@
}
});
},
async fetchCouponData() {
try {
const { total } = await this.$fetch('queryVouchersList', { type: 0 })
this.couponCount = total
} catch (err) {
}
},
}
}
</script>


+ 12
- 9
pages_order/components/voucher/voucherCard.vue View File

@ -5,7 +5,7 @@
<view class="voucher-info">
<view class="voucher-row voucher-title">{{ data.vouchersId_dictText }}</view>
<!-- todo -->
<view class="voucher-row voucher-time">{{ `${data.startTime}-${data.endTime}` }}</view>
<view class="voucher-row voucher-time">{{ validRange }}</view>
<view class="voucher-row voucher-desc">{{ data.desc ||'' }}</view>
</view>
@ -17,20 +17,13 @@
</template>
<script>
const TEST_DATA = {
id: '001',
name: '【会员礼】50元代金券',
startTime: '2025.03.12',
endTime: '2025.09.12',
desc: '只可在线下门店使用',
}
export default {
props: {
data: {
type: Object,
default() {
return TEST_DATA
return {}
}
},
readonly: {
@ -38,6 +31,16 @@ export default {
default: false,
}
},
computed: {
validRange() {
const { createTime, validDate } = this.data || {}
let startTime = createTime ? this.$dayjs(createTime).format('YYYY.MM.DD') : '-'
let endTime = validDate ? this.$dayjs(validDate).format('YYYY.MM.DD') : '-'
return `${startTime}-${endTime}`
},
},
methods: {
onClick() {
this.$utils.navigateTo(`/pages_order/mine/verifyVoucher?id=${this.data.id}`)


+ 28
- 16
pages_order/mine/verifyVoucher.vue View File

@ -12,8 +12,10 @@
<view class="card info">
<view class="info-header">代金券核销</view>
<view class="flex flex-column info-content">
<image class="info-qr" :src="voucherDetail.qrCodeImgUrl" mode="widthFix"></image>
<view class="info-desc">{{ `有效时间:${voucherDetail.startTime}${voucherDetail.endTime}` }}</view>
<view class="info-qr">
<uv-qrcode ref="qrcode" size="279rpx" :value="`${voucherDetail.id},1`"></uv-qrcode>
</view>
<view class="info-desc">{{ `有效时间:${validRange}` }}</view>
</view>
</view>
</view>
@ -30,27 +32,37 @@
},
data() {
return {
// todo: fetch
voucherDetail: {
id: '001',
name: '【会员礼】50元代金券',
startTime: '2025.03.12',
endTime: '2025.09.12',
desc: '只可在线下门店使用',
orderNo: 'da123567',
qrCodeImgUrl: '../static/verifyOrder/temp-qrcode.png',
startTime: '2025-03-14',
endTime: '2025-04-14',
rights: ['过期退', '随时退']
},
id: null,
voucherDetail: {},
}
},
computed: {
validRange() {
const { createTime, validDate } = this.voucherDetail || {}
let startTime = createTime ? this.$dayjs(createTime).format('YYYY.MM.DD') : '-'
let endTime = validDate ? this.$dayjs(validDate).format('YYYY.MM.DD') : '-'
return `${startTime}${endTime}`
},
},
onLoad(option) {
const { id } = option
// todo: fetch voucher data by voucher id
this.id = id
this.fetchVoucherInfo()
},
methods: {
async fetchVoucherInfo() {
try {
const res = await this.$fetch('queryVouchersById', { userVouchersId: this.id })
res.vouchersId_dictText = res.title
this.voucherDetail =res
} catch (err) {
}
},
},
}
</script>


+ 2
- 0
pages_order/mine/voucher.vue View File

@ -105,6 +105,8 @@
}
}
this.list = []
this.getData()
}
},


+ 2
- 2
pages_order/order/orderDetail.vue View File

@ -20,11 +20,11 @@
</view>
<view class="flex info-row">
<text>付款时间</text>
<text>{{ orderDetail.payTime }}</text>
<text>{{ orderDetail.payTime || '-' }}</text>
</view>
<view class="flex info-row">
<text>核销时间</text>
<text>{{ orderDetail.validTime }}</text>
<text>{{ orderDetail.useTime || '-' }}</text>
</view>
</view>
</view>


+ 34
- 25
pages_order/order/verifyOrder.vue View File

@ -23,22 +23,18 @@
<view class="card info">
<view class="info-header">核销信息</view>
<view class="flex flex-column info-content">
<!-- <image class="info-qr" :src="orderDetail.qrCodeImgUrl" mode="widthFix"></image> -->
<view class="" style="margin: 20rpx;">
<!-- <uv-qrcode ref="qrcode" size="300rpx" value="https://h5.uvui.cn"></uv-qrcode> -->
<uv-qrcode ref="qrcode" size="300px" :value="orderDetail.id"></uv-qrcode>
<uv-qrcode ref="qrcode" size="300px" :value="`${orderDetail.id},0`"></uv-qrcode>
</view>
<view class="info-no">{{ `订单号:${orderDetail.id}` }}</view>
<view class="info-desc">{{ `有效时间:${orderDetail.startTime}${orderDetail.endTime}` }}</view>
<view class="info-desc">{{ `有效时间:${validRange}` }}</view>
</view>
</view>
</view>
<!-- 下单 -->
<view class="flex bar">
<button plain class="btn btn-plain" @click="overOrder">核销</button>
<button plain class="btn btn-plain" @click="onRefund">申请退款</button>
<button plain class="btn" @click="onBuyAgain">再次购买</button>
</view>
@ -58,6 +54,16 @@
orderDetail: {},
}
},
computed: {
validRange() {
const { createTime, validTime } = this.orderDetail || {}
let startTime = createTime ? this.$dayjs(createTime).format('YYYY-MM-DD') : '-'
let endTime = validTime ? this.$dayjs(validTime).format('YYYY-MM-DD') : '-'
return `${startTime}${endTime}`
},
},
onLoad(args) {
this.id = args.id
this.fetchOrderDetail()
@ -79,32 +85,35 @@
uni.stopPullDownRefresh()
},
overOrder() {
uni.showModal({
title: '确认核销订单吗?',
success: e => {
if (e.confirm) {
this.$api('overOrder', {
orderId: this.orderDetail.id,
}, res => {
this.$emit('done')
//
uni.navigateBack()
})
}
async fetchRefund() {
try {
const res = await this.$fetch('refundOrder', { orderId: this.orderDetail.id }, false)
if (res.code == 200) {
uni.showToast({
title: '退款成功',
icon: 'none'
})
setTimeout(uni.navigateBack, 800, -1)
} else {
uni.showToast({
title: res.data,
icon: 'none'
})
}
})
} catch (err) {
}
},
onRefund() {
uni.showModal({
title: '确认申请订单退款嘛?',
success: e => {
if (e.confirm) {
this.$api('refundOrder', {
orderId: this.orderDetail.id,
}, res => {
this.$emit('done')
this.fetchRefund()
uni.showToast({
title: '已提交申请,请耐心等候',
icon: 'none'
})
}
}


Loading…
Cancel
Save