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.pagination.total = data.total\r\n state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'\r\n}\r\n\r\n// 获得我的优惠劵\r\nasync function getCoupon() {\r\n state.loadStatus = 'loading'\r\n const { data, code } = await CouponApi.getCouponPage({\r\n pageNo: state.pagination.pageNo,\r\n pageSize: state.pagination.pageSize,\r\n status: state.type,\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.pagination.total = data.total\r\n state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore'\r\n}\r\n\r\n// 领取优惠劵\r\nasync function getBuy(id) {\r\n const { code } = await CouponApi.takeCoupon(id)\r\n if (code !== 0) {\r\n return\r\n }\r\n uni.showToast({\r\n title: '领取成功',\r\n })\r\n setTimeout(() => {\r\n resetPagination(state.pagination)\r\n getData()\r\n }, 1000)\r\n}\r\n\r\n// 加载更多\r\nfunction loadMore() {\r\n if (state.loadStatus === 'noMore') {\r\n return\r\n }\r\n state.pagination.pageNo++\r\n if (state.currentTab === 0) {\r\n getData()\r\n } else {\r\n getCoupon()\r\n }\r\n}\r\n\r\nonLoad((Option) => {\r\n // 领劵中心\r\n if (Option.type === 'all' || !Option.type) {\r\n getData()\r\n // 我的优惠劵\r\n } else {\r\n Option.type === 'geted'\r\n ? (state.currentTab = 1)\r\n : Option.type === 'used'\r\n ? (state.currentTab = 2)\r\n : (state.currentTab = 3)\r\n state.type = state.currentTab\r\n getCoupon()\r\n }\r\n})\r\n\r\nonReachBottom(() => {\r\n loadMore()\r\n})\r\n</script>\r\n<style lang=\"scss\" scoped>\r\n \r\n.card-btn {\r\n height: 50rpx;\r\n // width: 144rpx;\r\n padding: 0 16rpx;\r\n font-size: 24rpx;\r\n font-weight: 400;\r\n color: #ffffff;\r\n background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));\r\n border-radius: 40rpx;\r\n}\r\n\r\n.border-btn {\r\n color: #fff !important;\r\n background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light));\r\n}\r\n\r\n.disabled-btn {\r\n color: #fff !important;\r\n background: #cccccc;\r\n background-color: #cccccc !important;\r\n}\r\n</style>\r\n","import MiniProgramPage from 'D:/App/Work/addr/acdr-ui/src/modules/mall/coupon/list.vue'\nwx.createPage(MiniProgramPage)"],"names":["reactive","resetPagination","CouponApi","_","uni","onLoad","onReachBottom"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,UAAA,QAAAA,cAAAA,SAAA;AAAA,MACA,YAAA;AAAA;AAAA,MACA,MAAA;AAAA,MACA,YAAA;AAAA,QACA,MAAA,CAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA,UAAA;AAAA,MACA;AAAA,MACA,YAAA;AAAA,IACA,CAAA;AAEA,UAAA,UAAA;AAAA,MACA;AAAA,QACA,MAAA;AAAA,QACA,OAAA;AAAA,MACA;AAAA,MACA;AAAA,QACA,MAAA;AAAA,QACA,OAAA;AAAA,MACA;AAAA,MACA;AAAA,QACA,MAAA;AAAA,QACA,OAAA;AAAA,MACA;AAAA,MACA;AAAA,QACA,MAAA;AAAA,QACA,OAAA;AAAA,MACA;AAAA,IACA;AAGA,aAAA,aAAA,GAAA;AACA,YAAA,aAAA,EAAA;AACA,YAAA,OAAA,EAAA;AACAC,uBAAA,gBAAA,MAAA,UAAA;AACA,UAAA,MAAA,eAAA,GAAA;AACA,gBAAA;AAAA,MACA,OAAA;AACA,kBAAA;AAAA,MACA;AAAA,IACA;AAGA,aAAA,UAAA;AAAA;AACA,cAAA,aAAA;AACA,cAAA,EAAA,MAAA,KAAA,IAAA,MAAAC,2BAAAA,UAAA,sBAAA;AAAA,UACA,QAAA,MAAA,WAAA;AAAA,UACA,UAAA,MAAA,WAAA;AAAA,QACA,CAAA;AACA,YAAA,SAAA,GAAA;AACA;AAAA,QACA;AACA,cAAA,WAAA,OAAAC,qBAAA,OAAA,MAAA,WAAA,MAAA,KAAA,IAAA;AACA,cAAA,WAAA,QAAA,KAAA;AACA,cAAA,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