myCoupon.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view class="container">
  3. <tui-tabs :top="0" :tabs="tabs" :currentTab="currentTab" selectedColor="#E41F19" sliderBgColor="#E41F19" @change="change"
  4. itemWidth="33.33333%" :isFixed="scrollTop>=0"></tui-tabs>
  5. <view class="tui-coupon-list" :class="{'tui-mtop':scrollTop>=0}">
  6. <view class="tui-coupon-item tui-top20" v-for="(item,index) in couponList" :key="index">
  7. <image src="/static/images/mall/coupon/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix">
  8. </image>
  9. <image v-if="currentTab==0" src="/static/images/mall/coupon/img_couponcentre_received_3x.png" class="tui-coupon-sign"></image>
  10. <image v-if="currentTab==1" src="/static/images/mall/coupon/img_coupon_beused_3x.png" class="tui-coupon-sign"></image>
  11. <image v-if="currentTab==2" src="/static/images/mall/coupon/img_coupon_failure_3x.png" class="tui-coupon-sign"></image>
  12. <view class="tui-coupon-item-left">
  13. <view class="tui-coupon-price-box" :class="{'tui-color-grey':i>0}">
  14. <view class="tui-coupon-price-sign" v-if="item.coupon_type==10">¥</view>
  15. <view class="tui-coupon-price" v-if="item.coupon_type==10"
  16. :class="{'tui-price-small':item.reduce_price.toString().length>4}">{{item.reduce_price}}
  17. </view>
  18. <view class="tui-coupon-price" v-if="item.coupon_type==20">{{item.discount}}</view>
  19. <view class="tui-coupon-price-sign" v-if="item.coupon_type==20">折</view>
  20. </view>
  21. <view class="tui-coupon-intro">满{{item.min_price}}元可用</view>
  22. </view>
  23. <view class="tui-coupon-item-right">
  24. <view class="tui-coupon-content">
  25. <view class="tui-coupon-title-box">
  26. <view v-if="item.sid==0" class="tui-coupon-btn" :class="{'tui-bg-grey':i>0}">全场券</view>
  27. <view v-if="item.use_goods==0" class="tui-coupon-title">全部商品可用</view>
  28. <view v-if="item.use_goods==1" class="tui-coupon-title">{{item.cat_ids_name}}类目可用</view>
  29. <view v-if="item.use_goods==2" class="tui-coupon-title">{{item.goods_ids_name}}可用</view>
  30. </view>
  31. <view class="tui-coupon-rule">
  32. <view class="tui-rule-box tui-padding-btm">
  33. <view class="tui-coupon-circle"></view>
  34. <view class="tui-coupon-text">不可叠加使用</view>
  35. </view>
  36. <view class="tui-rule-box">
  37. <view class="tui-coupon-circle"></view>
  38. <view v-if="item.expire_type==10" class="tui-coupon-text">自领取之日起{{item.expire_day}}天有效
  39. </view>
  40. <view v-if="item.expire_type==20" class="tui-coupon-text">
  41. {{item.start_time}}至{{item.end_time}}
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="tui-btn-box" v-if="currentTab==0">
  48. <tui-button @click="goindex" type="danger" width="152rpx" height="52rpx" :size="24" shape="circle" plain>立即使用
  49. </tui-button>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. export default {
  57. data() {
  58. return {
  59. tabs: [{
  60. name: "未使用"
  61. }, {
  62. name: "已使用"
  63. }, {
  64. name: "已过期"
  65. }],
  66. currentTab: 0,
  67. scrollTop: 0,
  68. couponList:[]
  69. }
  70. },
  71. onLoad() {
  72. this.getCoupons();
  73. },
  74. methods: {
  75. goindex: function() {
  76. this.sam.navigateTo('/pages/index/index');
  77. },
  78. change(e) {
  79. this.currentTab = e.index;
  80. this.getCoupons();
  81. },
  82. getCoupons: function() { // 读取可领取券列表
  83. var _this = this;
  84. _this.$request.get('couponreceive.mylist', {
  85. ptype: _this.currentTab,
  86. samkey: (new Date()).valueOf()
  87. }).then(res => {
  88. if (res.errno == 0) {
  89. _this.couponList = res.data;
  90. }
  91. })
  92. }
  93. },
  94. onPullDownRefresh() {
  95. let index = this.currentTab
  96. this.getCoupons()
  97. },
  98. onReachBottom() {
  99. let index = this.currentTab
  100. if (!this.couponList[index].pullUpOn) return;
  101. this.getCoupons()
  102. },
  103. onPageScroll(e) {
  104. this.scrollTop = e.scrollTop;
  105. }
  106. }
  107. </script>
  108. <style>
  109. .container {
  110. padding-bottom: env(safe-area-inset-bottom);
  111. }
  112. .tui-mtop {
  113. margin-top: 80rpx;
  114. }
  115. .tui-coupon-list {
  116. width: 100%;
  117. padding: 0 25rpx;
  118. box-sizing: border-box;
  119. }
  120. .tui-coupon-banner {
  121. width: 100%;
  122. }
  123. .tui-coupon-item {
  124. width: 100%;
  125. height: 210rpx;
  126. position: relative;
  127. display: flex;
  128. align-items: center;
  129. padding-right: 30rpx;
  130. box-sizing: border-box;
  131. overflow: hidden;
  132. }
  133. .tui-coupon-bg {
  134. width: 100%;
  135. height: 210rpx;
  136. position: absolute;
  137. left: 0;
  138. top: 0;
  139. z-index: 1;
  140. }
  141. .tui-coupon-sign {
  142. height: 110rpx;
  143. width: 110rpx;
  144. position: absolute;
  145. z-index: 999;
  146. top: -30rpx;
  147. right: 40rpx;
  148. }
  149. .tui-coupon-item-left {
  150. width: 218rpx;
  151. height: 210rpx;
  152. position: relative;
  153. z-index: 2;
  154. display: flex;
  155. align-items: center;
  156. justify-content: center;
  157. flex-direction: column;
  158. flex-shrink: 0;
  159. }
  160. .tui-coupon-price-box {
  161. display: flex;
  162. color: #e41f19;
  163. align-items: flex-end;
  164. }
  165. .tui-coupon-price-sign {
  166. font-size: 30rpx;
  167. }
  168. .tui-coupon-price {
  169. font-size: 70rpx;
  170. line-height: 68rpx;
  171. font-weight: bold;
  172. }
  173. .tui-price-small {
  174. font-size: 58rpx !important;
  175. line-height: 56rpx !important;
  176. }
  177. .tui-coupon-intro {
  178. background: #F7F7F7;
  179. padding: 8rpx 10rpx;
  180. font-size: 26rpx;
  181. line-height: 26rpx;
  182. font-weight: 400;
  183. color: #666;
  184. margin-top: 18rpx;
  185. }
  186. .tui-coupon-item-right {
  187. flex: 1;
  188. height: 210rpx;
  189. position: relative;
  190. z-index: 2;
  191. display: flex;
  192. align-items: center;
  193. justify-content: space-between;
  194. padding-left: 24rpx;
  195. box-sizing: border-box;
  196. overflow: hidden;
  197. }
  198. .tui-coupon-content {
  199. width: 82%;
  200. display: flex;
  201. flex-direction: column;
  202. justify-content: center;
  203. }
  204. .tui-coupon-title-box {
  205. display: flex;
  206. align-items: center;
  207. font-size: 28rpx;
  208. }
  209. .tui-coupon-title {
  210. width: 100%;
  211. font-size: 26rpx;
  212. color: #333;
  213. }
  214. .tui-coupon-btn {
  215. padding: 6rpx;
  216. background: #FFEBEB;
  217. color: #e41f19;
  218. font-size: 25rpx;
  219. line-height: 25rpx;
  220. display: flex;
  221. align-items: center;
  222. justify-content: center;
  223. transform: scale(0.9);
  224. transform-origin: 0 center;
  225. border-radius: 4rpx;
  226. flex-shrink: 0;
  227. }
  228. .tui-color-grey {
  229. color: #888 !important;
  230. }
  231. .tui-bg-grey {
  232. background: #F0F0F0 !important;
  233. color: #888 !important;
  234. }
  235. .tui-coupon-rule {
  236. padding-top: 22rpx;
  237. }
  238. .tui-rule-box {
  239. display: flex;
  240. align-items: center;
  241. transform: scale(0.8);
  242. transform-origin: 0 100%;
  243. }
  244. .tui-padding-btm {
  245. padding-bottom: 6rpx;
  246. }
  247. .tui-coupon-circle {
  248. width: 8rpx;
  249. height: 8rpx;
  250. background: rgb(160, 160, 160);
  251. border-radius: 50%;
  252. }
  253. .tui-coupon-text {
  254. font-size: 28rpx;
  255. line-height: 28rpx;
  256. font-weight: 400;
  257. color: #666;
  258. padding-left: 8rpx;
  259. white-space: nowrap;
  260. }
  261. .tui-top20 {
  262. margin-top: 20rpx;
  263. }
  264. .tui-btn-box {
  265. position: absolute;
  266. width: 146rpx;
  267. height: 52rpx;
  268. right: 20rpx;
  269. bottom: 40rpx;
  270. z-index: 10;
  271. }
  272. </style>