代码提交

This commit is contained in:
黄少君
2023-11-14 17:21:03 +08:00
parent d0b337c596
commit dcab74274f
567 changed files with 22414 additions and 7375 deletions

View File

@ -0,0 +1,59 @@
/**
* @name: index.utli
* @author: kahu4
* @date: 2023-10-31 11:19
* @descriptionindex.utli
* @update: 2023-10-31 11:19
* */
import { ref, computed } from "vue";
import { onShow } from '@dcloudio/uni-app'
import {getCouponList} from "@/api/coupon";
import { tabList } from "@/pages/discountCoupon/index.data";
export function useDiscountCoupon(){
const tabCurrent = ref(0) // tab选中
const couponType = ref(1) // 1、可使用2、已使用3、已失效
const couponListLoading = ref(false)
const couponList = ref([])
const showEmpty = computed(() => couponList.value.length <= 0)
/**
* tab发生改变
* @param e
*/
async function handleTabsChange(e){
console.log(e)
couponList.value = []
tabCurrent.value = e.index
couponType.value = e.value
await doGetCouponList()
}
/**
* 获取购物车列表
* @returns {Promise<void>}
*/
async function doGetCouponList() {
try {
couponListLoading.value = true
const res = await getCouponList(couponType.value)
couponList.value = res
} finally {
couponListLoading.value = false
}
}
onShow(async () => {
await doGetCouponList()
})
return {
tabList,
tabCurrent,
handleTabsChange,
showEmpty,
couponListLoading,
couponList,
doGetCouponList
}
}