index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="HTTP_REQUEST_URL_IMG+'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. import { HTTP_REQUEST_URL_IMG } from "@/config/app";
  114. const props = defineProps({
  115. showPopup: {
  116. type: Boolean,
  117. default: false,
  118. },
  119. openType: {
  120. type: Number,
  121. default: 0,
  122. },
  123. coupon: {
  124. type: Object,
  125. default: () => ({}),
  126. },
  127. orderShow: {
  128. type: String,
  129. default: "",
  130. },
  131. });
  132. const { Toast } = useToast();
  133. const emit = defineEmits([
  134. "close",
  135. "ChangCouponsUseState",
  136. "ChangCoupons",
  137. "tabCouponType",
  138. ]);
  139. const type = ref(1);
  140. function close() {
  141. type.value = 1;
  142. emit("close");
  143. }
  144. function getCouponUser(index, id) {
  145. console.log({index, id}, props.openType)
  146. const list = props.coupon.list;
  147. if (list && list[index] && list[index].isUse === true && props.openType === 0)
  148. return true;
  149. switch (props.openType) {
  150. case 0:
  151. setCouponReceive(id).then(() => {
  152. emit("ChangCouponsUseState", index);
  153. Toast({ title: "领取成功" });
  154. emit("ChangCoupons", list[index]);
  155. });
  156. break;
  157. case 1:
  158. emit("ChangCoupons", index);
  159. break;
  160. }
  161. }
  162. function setType(val) {
  163. type.value = val;
  164. emit("tabCouponType", val);
  165. }
  166. </script>
  167. <style scoped lang="scss">
  168. .coupon-list-window {
  169. width: 100%;
  170. background-color: #f5f5f5;
  171. border-radius: 16rpx 16rpx 0 0;
  172. }
  173. .coupon-list-window .title {
  174. height: 124rpx;
  175. width: 100%;
  176. text-align: center;
  177. line-height: 124rpx;
  178. font-size: 32rpx;
  179. font-weight: bold;
  180. position: relative;
  181. }
  182. .coupon-list-window .iconfont {
  183. position: absolute;
  184. right: 30rpx;
  185. top: 50%;
  186. transform: translateY(-50%);
  187. font-size: 35rpx;
  188. color: #8a8a8a;
  189. font-weight: normal;
  190. }
  191. .coupon-list {
  192. height: 823rpx;
  193. overflow: auto;
  194. padding: 30rpx 0;
  195. }
  196. .pictrue {
  197. width: 414rpx;
  198. height: 336rpx;
  199. margin: 208rpx auto;
  200. image {
  201. width: 100%;
  202. height: 100%;
  203. }
  204. }
  205. .pic-num {
  206. color: #fff;
  207. font-size: 24rpx;
  208. }
  209. .line-title {
  210. width: 90rpx;
  211. padding: 0 10rpx;
  212. box-sizing: border-box;
  213. background: rgba(255, 247, 247, 1);
  214. border: 1px solid rgba(232, 51, 35, 1);
  215. opacity: 1;
  216. border-radius: 20rpx;
  217. font-size: 20rpx;
  218. color: #e83323;
  219. margin-right: 12rpx;
  220. &.gray {
  221. border-color: #bbb;
  222. color: #bbb;
  223. background-color: #f5f5f5;
  224. }
  225. }
  226. .tip-row {
  227. font-size: 26rpx;
  228. // color: #ccc;
  229. }
  230. .nav {
  231. width: 100%;
  232. height: 96rpx;
  233. border-bottom: 2rpx solid #f5f5f5;
  234. border-top-left-radius: 16rpx;
  235. border-top-right-radius: 16rpx;
  236. background-color: #ffffff;
  237. font-size: 30rpx;
  238. color: #999999;
  239. .acea-row {
  240. border-top: 5rpx solid transparent;
  241. border-bottom: 5rpx solid transparent;
  242. &.on {
  243. border-bottom-color: #e93323;
  244. color: #282828;
  245. }
  246. &:only-child {
  247. border-bottom-color: transparent;
  248. }
  249. }
  250. }
  251. .occupy {
  252. height: 106rpx;
  253. }
  254. .coupon-box {
  255. }
  256. .coupon-list {
  257. .scroll-box {
  258. height: 100%;
  259. .scroll-Y {
  260. height: 300rpx;
  261. }
  262. .scroll-view_H {
  263. white-space: nowrap;
  264. width: 100%;
  265. }
  266. .scroll-view-item {
  267. height: 300rpx;
  268. line-height: 300rpx;
  269. text-align: center;
  270. font-size: 36rpx;
  271. }
  272. .scroll-view-item_H {
  273. display: inline-block;
  274. width: 100%;
  275. height: 300rpx;
  276. line-height: 300rpx;
  277. text-align: center;
  278. font-size: 36rpx;
  279. }
  280. }
  281. .item {
  282. margin-bottom: 20rpx;
  283. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
  284. .money {
  285. font-weight: normal;
  286. }
  287. }
  288. }
  289. </style>