index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <!-- 卡券组 -->
  3. <view class="diy-goods" :style="{ background: itemStyle.background }">
  4. <view class="goods-list" :class="[`display__${itemStyle.display}`, `column__${itemStyle.column}`]">
  5. <scroll-view :scroll-x="itemStyle.display === 'slide'">
  6. <view class="goods-item" v-for="(dataItem, index) in dataList" :key="index" @click="onTargetCoupon(dataItem.id, dataItem.type, dataItem.userCouponId)">
  7. <!-- 单列卡券 -->
  8. <block>
  9. <view class="dis-flex">
  10. <!-- 卡券图片 -->
  11. <view class="goods-item_left">
  12. <image class="image" :src="dataItem.image"></image>
  13. </view>
  14. <view class="goods-item_right">
  15. <!-- 卡券名称 -->
  16. <view class="goods-name twolist-hidden">
  17. <text>{{ dataItem.name }}</text>
  18. </view>
  19. <view class="goods-item_desc">
  20. <!-- 卡券卖点 -->
  21. <view class="desc-selling_point dis-flex">
  22. <text class="onelist-hidden">{{ dataItem.sellingPoint }}</text>
  23. </view>
  24. <view class="coupon-attr">
  25. <view class="attr-l">
  26. <!-- 参与人数 -->
  27. <view class="desc-goods_sales dis-flex">
  28. <text v-if="dataItem.type === 'C'">已领取{{ dataItem.gotNum }},剩余{{ dataItem.leftNum }}</text>
  29. <text v-if="dataItem.type === 'P'">已预存{{ dataItem.gotNum }},剩余{{ dataItem.leftNum }}</text>
  30. <text v-if="dataItem.type === 'T'">已领取{{ dataItem.gotNum }}</text>
  31. </view>
  32. <!-- 卡券面额 -->
  33. <view v-if="dataItem.amount > 0" class="desc_footer">
  34. <text class="price_x">¥{{ dataItem.amount }}</text>
  35. </view>
  36. </view>
  37. <view class="attr-r">
  38. <!--领券按钮-->
  39. <view class="receive" v-if="dataItem.type === 'C' && dataItem.isReceive === false">
  40. <text>立即领取</text>
  41. </view>
  42. <view class="receive state" v-if="dataItem.type === 'C' && dataItem.isReceive === true">
  43. <text>已领取</text>
  44. </view>
  45. <view class="receive" v-if="dataItem.type === 'P' && dataItem.isReceive === false">
  46. <text>立即预存</text>
  47. </view>
  48. <view v-if="dataItem.type === 'T' && dataItem.isReceive === false" class="receive">
  49. <text>领取次卡</text>
  50. </view>
  51. <view v-if="dataItem.type === 'T' && dataItem.isReceive === true" class="receive state">
  52. <text>已领取</text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </block>
  60. </view>
  61. </scroll-view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import * as couponApi from '@/api/coupon'
  67. import * as pageApi from '@/api/page'
  68. export default {
  69. name: "Coupon",
  70. /**
  71. * 组件的属性列表
  72. * 用于组件自定义设置
  73. */
  74. props: {
  75. itemIndex: String,
  76. itemStyle: Object,
  77. params: Object,
  78. dataList: Array
  79. },
  80. /**
  81. * 组件的方法列表
  82. * 更新属性和数据的方法与更新页面数据的方法类似
  83. */
  84. methods: {
  85. /**
  86. * 卡券详情页
  87. */
  88. onTargetCoupon(couponId, type, userCouponId) {
  89. if (type === 'P') {
  90. this.$navTo(`pages/prestore/buy`, { couponId })
  91. } else {
  92. if (type === 'C') {
  93. this.$navTo(`pages/coupon/detail`, { couponId: couponId, userCouponId: userCouponId })
  94. } else if(type === 'T') {
  95. this.$navTo(`pages/timer/detail`, { couponId: couponId, userCouponId: userCouponId })
  96. }
  97. }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .diy-goods {
  104. .goods-list {
  105. padding: 4rpx;
  106. box-sizing: border-box;
  107. .goods-item {
  108. box-sizing: border-box;
  109. padding: 6rpx;
  110. .goods-image {
  111. position: relative;
  112. width: 80rpx;
  113. height: 63rpx;
  114. border-radius: 5rpx;
  115. padding-bottom: 100%;
  116. overflow: hidden;
  117. background: #fff;
  118. &:after {
  119. content: '';
  120. display: block;
  121. margin-top: 100%;
  122. }
  123. .image {
  124. position: absolute;
  125. width: 80rpx;
  126. height: 63rpx;
  127. border-radius: 5rpx;
  128. top: 0;
  129. left: 0;
  130. -o-object-fit: cover;
  131. object-fit: cover;
  132. }
  133. }
  134. .detail {
  135. padding: 8rpx;
  136. background: #fff;
  137. .goods-name {
  138. height: 64rpx;
  139. line-height: 1.3;
  140. white-space: normal;
  141. color: #484848;
  142. font-size: 26rpx;
  143. }
  144. .detail-price {
  145. .goods-price {
  146. margin-right: 8rpx;
  147. }
  148. .line-price {
  149. text-decoration: line-through;
  150. }
  151. }
  152. }
  153. }
  154. &.display__slide {
  155. white-space: nowrap;
  156. font-size: 0;
  157. .goods-item {
  158. display: inline-block;
  159. }
  160. }
  161. &.display__list {
  162. .goods-item {
  163. float: left;
  164. }
  165. }
  166. &.column__2 {
  167. .goods-item {
  168. width: 50%;
  169. }
  170. }
  171. &.column__3 {
  172. .goods-item {
  173. width: 33.33333%;
  174. }
  175. }
  176. &.column__1 {
  177. .goods-item {
  178. width: 100%;
  179. height: 240rpx;
  180. margin-bottom: 12rpx;
  181. padding: 20rpx;
  182. box-sizing: border-box;
  183. background: #fff;
  184. line-height: 1.6;
  185. &:last-child {
  186. margin-bottom: 0;
  187. }
  188. }
  189. .goods-item_left {
  190. display: flex;
  191. width: 35%;
  192. background: #fff;
  193. align-items: center;
  194. .image {
  195. display: block;
  196. margin-top: 20rpx;
  197. width: 200rpx;
  198. height: 157rpx;
  199. border-radius: 6rpx;
  200. }
  201. }
  202. .goods-item_right {
  203. position: relative;
  204. width: 65%;
  205. .goods-name {
  206. margin-top: 20rpx;
  207. height: 40rpx;
  208. line-height: 1.0;
  209. white-space: normal;
  210. color: #484848;
  211. font-size: 30rpx;
  212. }
  213. }
  214. .goods-item_desc {
  215. margin-top: 0rpx;
  216. .coupon-attr {
  217. .attr-l {
  218. float:left;
  219. width: 70%;
  220. }
  221. .attr-r {
  222. margin-top:20rpx;
  223. float:left;
  224. }
  225. }
  226. }
  227. .desc-selling_point {
  228. width: 400rpx;
  229. font-size: 24rpx;
  230. color: #e49a3d;
  231. }
  232. .receive {
  233. height: 46rpx;
  234. width: 128rpx;
  235. line-height: 46rpx;
  236. text-align: center;
  237. border: 1px solid #f8df00;
  238. border-radius: 5rpx;
  239. color: #f86d48;
  240. background: #f8df98;
  241. font-size: 22rpx;
  242. &.state {
  243. border: none;
  244. color: #cccccc;
  245. background: #F5F5F5;
  246. }
  247. }
  248. .desc-goods_sales {
  249. color: #999;
  250. font-size: 24rpx;
  251. }
  252. .desc_footer {
  253. font-size: 24rpx;
  254. .price_x {
  255. margin-right: 16rpx;
  256. color: #f03c3c;
  257. font-size: 30rpx;
  258. }
  259. .price_y {
  260. text-decoration: line-through;
  261. }
  262. }
  263. }
  264. }
  265. }
  266. </style>