index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <up-popup :show="showPopup" :closeOnClickOverlay="true" @close="close">
  3. <view class="coupon-list-window">
  4. <view v-if="!orderShow" class="nav acea-row row-around">
  5. <view
  6. :class="['acea-row', 'row-middle', type === 1 ? 'on' : '']"
  7. @click="setType(1)"
  8. >通用券</view
  9. >
  10. <view
  11. :class="['acea-row', 'row-middle', type === 2 ? 'on' : '']"
  12. @click="setType(2)"
  13. >商品券</view
  14. >
  15. <view
  16. :class="['acea-row', 'row-middle', type === 3 ? 'on' : '']"
  17. @click="setType(3)"
  18. >品类券</view
  19. >
  20. <view
  21. :class="['acea-row', 'row-middle', type === 4 ? 'on' : '']"
  22. @click="setType(4)"
  23. >折扣券</view
  24. >
  25. </view>
  26. <view class="coupon-box">
  27. <view
  28. class="coupon-list"
  29. :style="{ 'margin-top': !orderShow ? '0' : '50rpx' }"
  30. >
  31. <scroll-view
  32. class="scroll-box"
  33. v-if="coupon.list.length"
  34. scroll-y="true"
  35. >
  36. <block v-if="coupon.list.length">
  37. <!-- <view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list" :key='index'> -->
  38. <view
  39. class="item acea-row row-center-wrapper"
  40. v-for="(item, index) in coupon.list"
  41. @click="getCouponUser(index, item.id)"
  42. :key="index"
  43. >
  44. <view
  45. class="money acea-row row-column row-center-wrapper"
  46. :class="item.isUse ? 'moneyGray' : ''"
  47. >
  48. <view
  49. >¥<text class="num">{{
  50. item.money ? Number(item.money) : ""
  51. }}</text></view
  52. >
  53. <view class="pic-num">满{{ item.minPrice }}元可用</view>
  54. </view>
  55. <view class="text">
  56. <view class="condition line2">
  57. <span
  58. class="line-title"
  59. :class="item.isUse ? 'gray' : ''"
  60. v-if="item.useType === 1"
  61. >通用</span
  62. >
  63. <span
  64. class="line-title"
  65. :class="item.isUse ? 'gray' : ''"
  66. v-else-if="item.useType === 3"
  67. >品类</span
  68. >
  69. <span
  70. class="line-title"
  71. :class="item.isUse ? 'gray' : ''"
  72. v-else
  73. >商品</span
  74. >
  75. <span>{{ item.name }}</span>
  76. </view>
  77. <view class="tip-row">注: 工费一次性抵扣</view>
  78. <view class="data acea-row row-between-wrapper">
  79. <view v-if="item.day > 0"
  80. >领取后{{ item.day }}天内可用</view
  81. >
  82. <view v-else>
  83. {{
  84. item.useStartTimeStr && item.useEndTimeStr
  85. ? item.useStartTimeStr + " - " + item.useEndTimeStr
  86. : ""
  87. }}
  88. </view>
  89. <view class="bnt gray" v-if="item.isUse">{{
  90. item.use_title || "已领取"
  91. }}</view>
  92. <view class="bnt bg-color" v-else>{{
  93. coupon.statusTile || "立即领取"
  94. }}</view>
  95. </view>
  96. </view>
  97. </view>
  98. </block>
  99. </scroll-view>
  100. <!-- 无优惠券 -->
  101. <view class="pictrue" v-else>
  102. <image src="/static/images/noCoupon.png"></image>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </up-popup>
  108. </template>
  109. <script setup>
  110. import { ref } from "vue";
  111. import { setCouponReceive } from "@/api/api.js";
  112. import { useToast } from "@/hooks/useToast";
  113. const props = defineProps({
  114. showPopup: {
  115. type: Boolean,
  116. default: false,
  117. },
  118. openType: {
  119. type: Number,
  120. default: 0,
  121. },
  122. coupon: {
  123. type: Object,
  124. default: () => ({}),
  125. },
  126. orderShow: {
  127. type: String,
  128. default: "",
  129. },
  130. });
  131. const { Toast } = useToast();
  132. const emit = defineEmits([
  133. "close",
  134. "ChangCouponsUseState",
  135. "ChangCoupons",
  136. "tabCouponType",
  137. ]);
  138. const type = ref(1);
  139. function close() {
  140. type.value = 1;
  141. emit("close");
  142. }
  143. function getCouponUser(index, id) {
  144. console.log({index, id}, props.openType)
  145. const list = props.coupon.list;
  146. if (list && list[index] && list[index].isUse === true && props.openType === 0)
  147. return true;
  148. switch (props.openType) {
  149. case 0:
  150. setCouponReceive(id).then(() => {
  151. emit("ChangCouponsUseState", index);
  152. Toast({ title: "领取成功" });
  153. emit("ChangCoupons", list[index]);
  154. });
  155. break;
  156. case 1:
  157. emit("ChangCoupons", index);
  158. break;
  159. }
  160. }
  161. function setType(val) {
  162. type.value = val;
  163. emit("tabCouponType", val);
  164. }
  165. </script>
  166. <style scoped lang="scss">
  167. .coupon-list-window {
  168. width: 100%;
  169. background-color: #f5f5f5;
  170. border-radius: 16rpx 16rpx 0 0;
  171. }
  172. .coupon-list-window .title {
  173. height: 124rpx;
  174. width: 100%;
  175. text-align: center;
  176. line-height: 124rpx;
  177. font-size: 32rpx;
  178. font-weight: bold;
  179. position: relative;
  180. }
  181. .coupon-list-window .iconfont {
  182. position: absolute;
  183. right: 30rpx;
  184. top: 50%;
  185. transform: translateY(-50%);
  186. font-size: 35rpx;
  187. color: #8a8a8a;
  188. font-weight: normal;
  189. }
  190. .coupon-list {
  191. height: 823rpx;
  192. overflow: auto;
  193. padding: 30rpx 0;
  194. }
  195. .pictrue {
  196. width: 414rpx;
  197. height: 336rpx;
  198. margin: 208rpx auto;
  199. image {
  200. width: 100%;
  201. height: 100%;
  202. }
  203. }
  204. .pic-num {
  205. color: #fff;
  206. font-size: 24rpx;
  207. }
  208. .line-title {
  209. width: 90rpx;
  210. padding: 0 10rpx;
  211. box-sizing: border-box;
  212. background: rgba(255, 247, 247, 1);
  213. border: 1px solid rgba(232, 51, 35, 1);
  214. opacity: 1;
  215. border-radius: 20rpx;
  216. font-size: 20rpx;
  217. color: #e83323;
  218. margin-right: 12rpx;
  219. &.gray {
  220. border-color: #bbb;
  221. color: #bbb;
  222. background-color: #f5f5f5;
  223. }
  224. }
  225. .tip-row {
  226. font-size: 26rpx;
  227. // color: #ccc;
  228. }
  229. .nav {
  230. width: 100%;
  231. height: 96rpx;
  232. border-bottom: 2rpx solid #f5f5f5;
  233. border-top-left-radius: 16rpx;
  234. border-top-right-radius: 16rpx;
  235. background-color: #ffffff;
  236. font-size: 30rpx;
  237. color: #999999;
  238. .acea-row {
  239. border-top: 5rpx solid transparent;
  240. border-bottom: 5rpx solid transparent;
  241. &.on {
  242. border-bottom-color: #e93323;
  243. color: #282828;
  244. }
  245. &:only-child {
  246. border-bottom-color: transparent;
  247. }
  248. }
  249. }
  250. .occupy {
  251. height: 106rpx;
  252. }
  253. .coupon-box {
  254. }
  255. .coupon-list {
  256. .scroll-box {
  257. height: 100%;
  258. .scroll-Y {
  259. height: 300rpx;
  260. }
  261. .scroll-view_H {
  262. white-space: nowrap;
  263. width: 100%;
  264. }
  265. .scroll-view-item {
  266. height: 300rpx;
  267. line-height: 300rpx;
  268. text-align: center;
  269. font-size: 36rpx;
  270. }
  271. .scroll-view-item_H {
  272. display: inline-block;
  273. width: 100%;
  274. height: 300rpx;
  275. line-height: 300rpx;
  276. text-align: center;
  277. font-size: 36rpx;
  278. }
  279. }
  280. .item {
  281. margin-bottom: 20rpx;
  282. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  283. .money {
  284. font-weight: normal;
  285. }
  286. }
  287. }
  288. </style>