CouponList.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view>
  3. <no-none v-if='CouponList.length<=0'></no-none>
  4. <block v-else>
  5. <view class="CouponList flex" @click="CouponUse" :data-num="item.num" :data-title="item.title" v-for=" (item,index) in CouponList" :key="index" :data-id="item.id">
  6. <view class="CouponL flex-grow-1">
  7. <view class="CouponContenttitle text-1">{{item.title}}</view>
  8. <view class="CouponContentC">
  9. <text>有效期:</text>
  10. <text>{{item.start_time}}-{{item.end_time}}</text>
  11. </view>
  12. </view>
  13. <view class="CouponR flex-grow-0">
  14. <view class="coupon-center">
  15. <view class="rund top">
  16. </view>
  17. <view class="line">
  18. </view>
  19. <view class="rund bottom">
  20. </view>
  21. </view>
  22. <view class="CouponLmoney"> <text class="unit">¥</text>{{ Number(item.cut_price) }}</view>
  23. <view class="CouponLmoneys">满{{ Number(item.full_price)}}可用</view>
  24. <view class="CouponRtext">立即查看</view>
  25. </view>
  26. </view>
  27. <loading :is_load="is_load" :is_load_more='is_load_more'></loading>
  28. </block>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. token: '', //获取用户的token
  36. page: 1,
  37. limit: 10,
  38. CouponList: [], //优惠券列表
  39. page: 1,
  40. is_load: false,
  41. is_load_more: false,
  42. }
  43. },
  44. onLoad() {
  45. this.token = uni.getStorageSync('token'); //读取缓存手机号码
  46. },
  47. onShow() {
  48. this.page = 1;
  49. this.CouponList = [];
  50. this.Coupon();
  51. },
  52. onPullDownRefresh() {
  53. console.log("下拉")
  54. this.page = 1;
  55. this.CouponList = [];
  56. this.Coupon();
  57. setTimeout(() => {
  58. uni.stopPullDownRefresh();
  59. }, 1000)
  60. },
  61. onReachBottom() {
  62. if (!this.is_load) {
  63. this.page = this.page + 1;
  64. this.Coupon();
  65. }
  66. },
  67. methods: {
  68. CouponUse(e) {
  69. console.log(e.currentTarget.dataset.id)
  70. let {id,title,num} = e.currentTarget.dataset;
  71. // let title = e.currentTarget.dataset.title;
  72. // let title = e.currentTarget.dataset.num;
  73. uni.$emit("handleFun",{title:title,coupon_id:id,num:num});
  74. uni.navigateBack();
  75. },
  76. loginOut() {
  77. uni.removeStorageSync("token")
  78. uni.removeStorage({
  79. key: 'login',
  80. success: (res) => {
  81. uni.reLaunch({
  82. url: "../login/login"
  83. })
  84. }
  85. })
  86. },
  87. Coupon() {
  88. this.request({
  89. url: "lottery/coupon",
  90. data: {
  91. token: uni.getStorageSync('token'),
  92. page: this.page,
  93. limit: 15,
  94. status:1
  95. },
  96. showLoading:true,
  97. }).then(res => {
  98. console.log(res, "res")
  99. if (res.data.list.length == 0) {
  100. this.is_load = true,
  101. this.is_load_more = true,
  102. setTimeout(() => {
  103. this.is_load_more = false
  104. }, 1e3);
  105. return
  106. }
  107. this.is_load = false;
  108. this.CouponList = this.CouponList.concat(res.data.list);
  109. }).catch((res) => {
  110. uni.showToast({
  111. title: res.message,
  112. icon: 'none'
  113. })
  114. });
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="scss">
  120. page {
  121. background: #fff;
  122. }
  123. .no-more {
  124. font-size: 28rpx;
  125. color: #999999;
  126. text-align: center;
  127. padding: 20rpx 0;
  128. }
  129. .CouponList {
  130. margin: 0 40rpx;
  131. margin-top: 20rpx;
  132. border-radius: 8rpx;
  133. height: 180rpx;
  134. overflow: hidden;
  135. .CouponL {
  136. text-align: left;
  137. padding: 10rpx 20rpx;
  138. border: 1rpx solid #F1F1F1;
  139. .CouponContenttitle {
  140. font-size: 34rpx;
  141. padding-top: 15rpx;
  142. }
  143. .CouponContentC {
  144. color: #999;
  145. font-size: 24rpx;
  146. padding-top: 15rpx;
  147. }
  148. }
  149. .CouponR {
  150. background: linear-gradient(0deg, rgba(2, 126, 251, 1) 0%, rgba(0, 172, 238, 1) 100%);
  151. color: #FFFFFF;
  152. width: 200rpx;
  153. text-align: center;
  154. position: relative;
  155. .coupon-center {
  156. position: absolute;
  157. left: -16rpx;
  158. top: 0;
  159. width: 30rpx;
  160. .rund {
  161. width: 24rpx;
  162. height: 24rpx;
  163. background: #FFFFFF;
  164. border-radius: 50%;
  165. position: absolute;
  166. }
  167. .top {
  168. top: -15rpx;
  169. }
  170. .bottom {
  171. bottom: -15rpx;
  172. }
  173. .line {
  174. width: 1rpx;
  175. height: 180rpx;
  176. }
  177. }
  178. .CouponLmoney {
  179. font-size: 47rpx;
  180. padding-top: 15rpx;
  181. .unit {
  182. font-size: 28rpx;
  183. }
  184. }
  185. .CouponRtext {
  186. font-size: 22rpx;
  187. border: 1rpx solid #FFFFFF;
  188. text-align: center;
  189. border-radius: 50px;
  190. display: inline-block;
  191. padding: 4rpx 18rpx;
  192. }
  193. .CouponLmoneys {
  194. font-size: 20rpx;
  195. margin-bottom: 10rpx;
  196. }
  197. }
  198. }
  199. </style>