CouponList.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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: "coupon/lists",
  90. data: {
  91. token: uni.getStorageSync('token'),
  92. page: this.page,
  93. limit: 15,
  94. status:1
  95. },
  96. }).then(res => {
  97. console.log(res, "res")
  98. if (res.data.list.length == 0) {
  99. this.is_load = true,
  100. this.is_load_more = true,
  101. setTimeout(() => {
  102. this.is_load_more = false
  103. }, 1e3);
  104. return
  105. }
  106. this.is_load = false;
  107. this.CouponList = this.CouponList.concat(res.data.list);
  108. }).catch((res) => {
  109. uni.showToast({
  110. title: res.message,
  111. icon: 'none'
  112. })
  113. });
  114. },
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. page {
  120. background: #fff;
  121. }
  122. .no-more {
  123. font-size: 28rpx;
  124. color: #999999;
  125. text-align: center;
  126. padding: 20rpx 0;
  127. }
  128. .CouponList {
  129. margin: 0 40rpx;
  130. margin-top: 20rpx;
  131. border-radius: 8rpx;
  132. height: 180rpx;
  133. overflow: hidden;
  134. .CouponL {
  135. text-align: left;
  136. padding: 10rpx 20rpx;
  137. border: 1rpx solid #F1F1F1;
  138. .CouponContenttitle {
  139. font-size: 34rpx;
  140. padding-top: 15rpx;
  141. }
  142. .CouponContentC {
  143. color: #999;
  144. font-size: 24rpx;
  145. padding-top: 15rpx;
  146. }
  147. }
  148. .CouponR {
  149. background: linear-gradient(0deg, rgba(2, 126, 251, 1) 0%, rgba(0, 172, 238, 1) 100%);
  150. color: #FFFFFF;
  151. width: 200rpx;
  152. text-align: center;
  153. position: relative;
  154. .coupon-center {
  155. position: absolute;
  156. left: -16rpx;
  157. top: 0;
  158. width: 30rpx;
  159. .rund {
  160. width: 24rpx;
  161. height: 24rpx;
  162. background: #FFFFFF;
  163. border-radius: 50%;
  164. position: absolute;
  165. }
  166. .top {
  167. top: -15rpx;
  168. }
  169. .bottom {
  170. bottom: -15rpx;
  171. }
  172. .line {
  173. width: 1rpx;
  174. height: 180rpx;
  175. }
  176. }
  177. .CouponLmoney {
  178. font-size: 47rpx;
  179. padding-top: 15rpx;
  180. .unit {
  181. font-size: 28rpx;
  182. }
  183. }
  184. .CouponRtext {
  185. font-size: 22rpx;
  186. border: 1rpx solid #FFFFFF;
  187. text-align: center;
  188. border-radius: 50px;
  189. display: inline-block;
  190. padding: 4rpx 18rpx;
  191. }
  192. .CouponLmoneys {
  193. font-size: 20rpx;
  194. margin-bottom: 10rpx;
  195. }
  196. }
  197. }
  198. </style>