index.vue 7.1 KB

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