coupon.vue 4.1 KB

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