myCoupon.vue 6.6 KB

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