1 line
8.5 KiB
Plaintext
1 line
8.5 KiB
Plaintext
|
{"version":3,"file":"list.js","sources":["../../../../../../src/modules/mall/coupon/list.vue","../../../../../../uniPage:/bW9kdWxlc1xtYWxsXGNvdXBvblxsaXN0LnZ1ZQ"],"sourcesContent":["<!-- 优惠券中心 -->\r\n<template>\r\n <s-layout title=\"优惠券\" :bgStyle=\"{ color: '#f2f2f2' }\">\r\n <su-sticky bgColor=\"#fff\">\r\n <su-tabs\r\n :list=\"tabMaps\"\r\n :scrollable=\"false\"\r\n @change=\"onTabsChange\"\r\n :current=\"state.currentTab\"\r\n />\r\n </su-sticky>\r\n <s-empty\r\n v-if=\"state.pagination.total === 0\"\r\n icon=\"/static/coupon-empty.png\"\r\n text=\"暂无优惠券\"\r\n />\r\n <!-- 情况一:领劵中心 -->\r\n <template v-if=\"state.currentTab === 0\">\r\n <view v-for=\"item in state.pagination.list\" :key=\"item.id\">\r\n <s-coupon-list\r\n :data=\"item\"\r\n @tap=\"sheep.$router.go('/modules/mall/coupon/detail', { id: item.id })\"\r\n >\r\n <template #default>\r\n <button\r\n class=\"ss-reset-button card-btn ss-flex ss-row-center ss-col-center\"\r\n :class=\"!item.canTake ? 'border-btn' : ''\"\r\n @click.stop=\"getBuy(item.id)\"\r\n :disabled=\"!item.canTake\"\r\n >\r\n {{ item.canTake ? '立即领取' : '已领取' }}\r\n </button>\r\n </template>\r\n </s-coupon-list>\r\n </view>\r\n </template>\r\n <!-- 情况二:我的优惠劵 -->\r\n <template v-else>\r\n <view v-for=\"item in state.pagination.list\" :key=\"item.id\">\r\n <s-coupon-list\r\n :data=\"item\"\r\n type=\"user\"\r\n @tap=\"sheep.$router.go('/modules/mall/coupon/detail', { couponId: item.id })\"\r\n >\r\n <template #default>\r\n <button\r\n class=\"ss-reset-button card-btn ss-flex ss-row-center ss-col-center\"\r\n :class=\"item.status !== 1 ? 'disabled-btn' : ''\"\r\n :disabled=\"item.status !== 1\"\r\n @click.stop=\"sheep.$router.go('/modules/mall/coupon/detail', { couponId: item.id })\"\r\n >\r\n {{ item.status === 1 ? '立即使用' : item.status === 2 ? '已使用' : '已过期' }}\r\n </button>\r\n </template>\r\n </s-coupon-list>\r\n </view>\r\n </template>\r\n\r\n <uni-load-more\r\n v-if=\"state.pagination.total > 0\"\r\n :status=\"state.loadStatus\"\r\n :content-text=\"{\r\n contentdown: '上拉加载更多',\r\n }\"\r\n @tap=\"loadMore\"\r\n />\r\n </s-layout>\r\n</template>\r\n\r\n<script setup>\r\nimport sheep from '@/sheep'\r\nimport { onLoad, onReachBottom } from '@dcloudio/uni-app'\r\nimport { reactive } from 'vue'\r\nimport _ from 'lodash-es'\r\nimport { resetPagination } from '@/sheep/util'\r\nimport CouponApi from '@/sheep/api/promotion/coupon'\r\n\r\n// 数据\r\nconst state = reactive({\r\n currentTab: 0, // 当前 tab\r\n type: '1',\r\n pagination: {\r\n list: [],\r\n total: 0,\r\n pageNo: 1,\r\n pageSize: 5,\r\n },\r\n loadStatus: '',\r\n})\r\n\r\nconst tabMaps = [\r\n {\r\n name: '领券中心',\r\n value: 'all',\r\n },\r\n {\r\n name: '已领取',\r\n value: '1',\r\n },\r\n {\r\n name: '已使用',\r\n value: '2',\r\n },\r\n {\r\n name: '已失效',\r\n value: '3',\r\n },\r\n]\r\n\r\n// TODO yunai:\r\nfunction onTabsChange(e) {\r\n state.currentTab = e.index\r\n state.type = e.value\r\n resetPagination(state.pagination)\r\n if (state.currentTab === 0) {\r\n getData()\r\n } else {\r\n getCoupon()\r\n }\r\n}\r\n\r\n// 获得优惠劵模版列表\r\nasync function getData() {\r\n state.loadStatus = 'loading'\r\n const { data, code } = await CouponApi.getCouponTemplatePage({\r\n pageNo: state.pagination.pageNo,\r\n pageSize: state.pagination.pageSize,\r\n })\r\n if (code !== 0) {\r\n return\r\n }\r\n state.pagination.list = _.concat(state.pagination.list, data.list)\r\n state.pag
|