完善茶室订单
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
<route lang="jsonc" type="page">
|
||||
{
|
||||
// "needLogin": true,
|
||||
"needLogin": true,
|
||||
"layout": "default",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
@ -10,21 +10,21 @@
|
||||
|
||||
<template>
|
||||
<view class="pb-180rpx">
|
||||
<view>
|
||||
<view>
|
||||
<navbar title="优惠券" custom-class='!bg-[#F6F7F8]'></navbar>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<view class="coupon-tab">
|
||||
<wd-tabs v-model="tab" swipeable slidable="always" @click="myCoupon.handleChangeTab" :lazy="false">
|
||||
<wd-tabs v-model="tab" swipeable slidable="always" @click="MyCoupon.handleChangeTab" :lazy="false">
|
||||
<wd-tab title="茶室优惠券">
|
||||
<view class="mx-30rpx">
|
||||
<view class="flex">
|
||||
<view v-for="(item, index) in tag" :key="index"
|
||||
@click="myCoupon.handleChangeTag(item)"
|
||||
@click="MyCoupon.handleChangeTag(item.value)"
|
||||
class="font-400 text-28rpx leading-40rpx w-116rpx h-64rpx flex justify-center items-center border-2rpx border-solid rounded-12rpx mr-20rpx"
|
||||
:class="item === currentTag ? ' border-[#4C9F44] bg-[#F0F6EF] text-[#4C9F44]' : 'border-[#fff] bg-[#fff]'">
|
||||
{{ item }}
|
||||
:class="item.value === currentTag ? ' border-[#4C9F44] bg-[#F0F6EF] text-[#4C9F44]' : 'border-[#fff] bg-[#fff]'">
|
||||
{{ item.label }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
canUse
|
||||
:showChecked="false"
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="myCoupon.handleCouponCheck"
|
||||
:onCheck="MyCoupon.handleCouponCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
></coupon>
|
||||
</view>
|
||||
@ -46,10 +46,10 @@
|
||||
<view class="mx-30rpx">
|
||||
<view class="flex">
|
||||
<view v-for="(item, index) in tag" :key="index"
|
||||
@click="myCoupon.handleChangeTag(item)"
|
||||
@click="MyCoupon.handleChangeTag(item.value)"
|
||||
class="font-400 text-28rpx leading-40rpx w-116rpx h-64rpx flex justify-center items-center border-2rpx border-solid rounded-12rpx mr-20rpx"
|
||||
:class="item === currentTag ? ' border-[#4C9F44] bg-[#F0F6EF] text-[#4C9F44]' : 'border-[#fff] bg-[#fff]'">
|
||||
{{ item }}
|
||||
:class="item.value === currentTag ? ' border-[#4C9F44] bg-[#F0F6EF] text-[#4C9F44]' : 'border-[#fff] bg-[#fff]'">
|
||||
{{ item.label }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
canUse
|
||||
:showChecked="false"
|
||||
:checked="item.id === checkedId"
|
||||
:onCheck="myCoupon.handleCouponCheck"
|
||||
:onCheck="MyCoupon.handleCouponCheck"
|
||||
:class="index !== couponList.length - 1 ? 'mb-20rpx' : ''"
|
||||
></coupon>
|
||||
</view>
|
||||
@ -77,19 +77,22 @@
|
||||
import {ref} from 'vue'
|
||||
import Coupon from '@/components/coupon/Coupon.vue'
|
||||
import GroupCoupon from '@/components/coupon/GroupCoupon.vue'
|
||||
import { getMyCoupons } from '@/api/user'
|
||||
|
||||
//
|
||||
const tab = ref<number>(0)
|
||||
const tag = ref<Array<string>>(['全部', '快过期', '已使用'])
|
||||
const currentTag = ref<string>('全部')
|
||||
const tag = ref<Array<any>>([
|
||||
{label: '全部', value: 0 },
|
||||
{label: '已使用', value: 1 },
|
||||
{label: '快过期', value: 3 },
|
||||
])
|
||||
const currentTab = ref<number>(0)
|
||||
const currentTag = ref<number>(0)
|
||||
|
||||
const couponType = ref<number>(2) // couponType 1:优惠券 2:团购券
|
||||
const OSS = inject('OSS')
|
||||
|
||||
const couponList = ref([
|
||||
{ id: 1, amount: 20, limit: 100, expire: '2024.08.20' },
|
||||
{ id: 2, amount: 10, limit: 50, expire: '2024.08.25' }
|
||||
])
|
||||
const couponList = ref<any[]>([])
|
||||
const checkedId = ref<number>(0)
|
||||
|
||||
const unCouponList = ref([
|
||||
@ -101,22 +104,57 @@
|
||||
if (args.type) {
|
||||
couponType.value = args.type
|
||||
}
|
||||
|
||||
MyCoupon.handleInit()
|
||||
})
|
||||
|
||||
const myCoupon = {
|
||||
// 切换tab
|
||||
handleChangeTab: (index: number) => {
|
||||
tab.value = index
|
||||
currentTag.value = '全部'
|
||||
const MyCoupon = {
|
||||
/**
|
||||
* 初始化优惠券列表
|
||||
*/
|
||||
handleInit: async () => {
|
||||
const res: any = await getMyCoupons({status: currentTag.value, type_id: currentTab.value == 0 ? 2 : 1})
|
||||
|
||||
if (Array.isArray(res)) {
|
||||
res.map((res) => {
|
||||
couponList.value.push({
|
||||
id: res.coupon_id,
|
||||
coupon_price: res.userCouponType[0].coupon_price,
|
||||
use_price: res.userCouponType[0].use_price,
|
||||
title: res.userCouponType[0].title,
|
||||
effect_time: res.userCouponType[0].effect_time,
|
||||
user_coupon_id: res.coupon_id,
|
||||
expire: res.expire
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 切换tag
|
||||
handleChangeTag: (item: string) => {
|
||||
/**
|
||||
* 切换tab
|
||||
* @param item 切换项
|
||||
*/
|
||||
handleChangeTab: (item: {index: number}) => {
|
||||
currentTab.value = item.index
|
||||
currentTag.value = 0
|
||||
couponList.value = []
|
||||
MyCoupon.handleInit()
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换tag
|
||||
* @param item 切换项
|
||||
*/
|
||||
handleChangeTag: (item: number) => {
|
||||
currentTag.value = item
|
||||
console.log("🚀 ~ currentTag.value :", currentTag.value )
|
||||
couponList.value = []
|
||||
MyCoupon.handleInit()
|
||||
},
|
||||
|
||||
// 选择优惠券-保留这个函数,暂时用不着
|
||||
/**
|
||||
* 选择优惠券-保留这个函数,暂时用不着
|
||||
* @param id 切换项
|
||||
*/
|
||||
handleCouponCheck: (id: number) => {
|
||||
checkedId.value = id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user