discount.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="content">
  3. <view class="top-nav flex">
  4. <view class="nav-item" v-for="(item,index) in navList" :key="index" :class="{'action': currentIndex == index}" @click="tabChange(index)">
  5. {{item.tit}}
  6. </view>
  7. <view class="jg"></view>
  8. </view>
  9. <scroll-view scroll-y="true" class="swiper-box" :style="{'height': height}">
  10. <empty v-if="navList[currentIndex].loaded === true && navList[currentIndex].list.length === 0"></empty>
  11. <view class="itemt" v-for="(navItem , index) in navList[currentIndex].list">
  12. <image :src="currentIndex == 0 ? '../../static/img/act-dis.png': '../../static/img/no-dis.png'" mode=""></image>
  13. <view class="price" :class="{'price1': currentIndex == 1}">
  14. {{parseFloat(navItem.coupon_price)}}
  15. </view>
  16. <view class="tit">
  17. {{navItem.coupon_title}}
  18. </view>
  19. <view class="time" :class="{'time1': currentIndex == 1}">
  20. {{navItem._add_time + ' - ' + navItem._end_time}}
  21. </view>
  22. <view class="status" :class="{'status1': currentIndex == 1 || navItem.is_fail != 0 }">
  23. {{navItem.is_fail != 0? '已过期' : currentIndex == 0? '未使用': '已使用'}}
  24. </view>
  25. <view class="condition">
  26. {{parseFloat(navItem.use_min_price) == 0 ? '无门槛': '满' + parseFloat(navItem.use_min_price) + '使用'}}
  27. </view>
  28. </view>
  29. <uni-load-more :status="navList[currentIndex].loadingType"></uni-load-more>
  30. </scroll-view>
  31. </view>
  32. </template>
  33. <script>
  34. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  35. import empty from '@/components/empty';
  36. import { getMyCoupons } from '../../api/index.js'
  37. export default {
  38. components: {
  39. uniLoadMore,
  40. empty
  41. },
  42. data() {
  43. return {
  44. currentIndex: 0,
  45. navList: [
  46. {
  47. tit: '未使用',
  48. status: 1,
  49. list: [],
  50. page: 1,
  51. limit: 10,
  52. loadingType: 'more'
  53. },
  54. {
  55. tit: '已使用',
  56. status: 2,
  57. list: [],
  58. page: 1,
  59. limit: 10,
  60. loadingType: 'more'
  61. }
  62. ],
  63. height: '',
  64. }
  65. },
  66. onReady() {
  67. var _this = this;
  68. uni.getSystemInfo({
  69. success: resu => {
  70. const query = uni.createSelectorQuery();
  71. query.select('.swiper-box').boundingClientRect();
  72. query.exec(function(res) {
  73. console.log(res, 'ddddddddddddd');
  74. _this.height = resu.windowHeight - res[0].top + 'px';
  75. console.log('打印页面的剩余高度', _this.height);
  76. });
  77. },
  78. fail: res => {}
  79. });
  80. },
  81. onShow() {
  82. this.loadData()
  83. },
  84. methods: {
  85. tabChange(index) {
  86. this.currentIndex = index
  87. this.loadData()
  88. },
  89. loadData() {
  90. let obj = this
  91. let index = obj.currentIndex
  92. let navItem = obj.navList[index]
  93. if(navItem.loadingType == 'noMore' || navItem.loadingType == 'loading') {
  94. return
  95. }
  96. navItem.loadingType = 'loading'
  97. getMyCoupons({
  98. page: 1,
  99. limit: 10
  100. },navItem.status).then(({data}) => {
  101. console.log(data,'++++++')
  102. navItem.list = data
  103. navItem.page++
  104. if(data.length == navItem.limit) {
  105. navItem.loadingType = 'more'
  106. }else {
  107. navItem.loadingType = 'noMore'
  108. }
  109. obj.$set(navItem,'loaded',true)
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss" scoped>
  116. .top-nav {
  117. height: 100rpx;
  118. width: 100%;
  119. background-color: #fff;
  120. border-top: 1px solid #e7e7e7;
  121. position: relative;
  122. .nav-item {
  123. text-align: center;
  124. width: 50%;
  125. line-height: 100rpx;
  126. font-size: 32rpx;
  127. }
  128. .action {
  129. color: #901b21;
  130. font-weight: bold;
  131. }
  132. .jg {
  133. position: absolute;
  134. top: 0;
  135. left: 0;
  136. right: 0;
  137. bottom: 0;
  138. margin: auto;
  139. height: 58rpx;
  140. width: 2rpx;
  141. background-color: #e7e7e7;
  142. }
  143. }
  144. .swiper-box {
  145. // background-color: red;
  146. padding-top: 30rpx;
  147. .itemt {
  148. width: 701rpx;
  149. height: 199rpx;
  150. margin: 0 auto 30rpx;
  151. position: relative;
  152. image {
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .price {
  157. width: 190rpx;
  158. line-height: 50rpx;
  159. color: #901b21;
  160. font-size: 50rpx;
  161. font-weight: bold;
  162. position: absolute;
  163. top: 43rpx;
  164. left: 21rpx;
  165. text-align: center;
  166. }
  167. .price1 {
  168. color: #d8d8d8;
  169. }
  170. .condition {
  171. width: 190rpx;
  172. line-height: 50rpx;
  173. font-size: 24rpx;
  174. position: absolute;
  175. top: 100rpx;
  176. left: 21rpx;
  177. text-align: center;
  178. color: #9a9a9a;
  179. }
  180. .tit {
  181. width: 490rpx;
  182. line-height: 45rpx;
  183. position: absolute;
  184. right: 0;
  185. top: 40rpx;
  186. font-size: 30rpx;
  187. font-weight: 500;
  188. padding-left: 20rpx;
  189. color: #1b1b1b;
  190. }
  191. .time {
  192. width: 490rpx;
  193. line-height: 30rpx;
  194. position: absolute;
  195. right: 0;
  196. top: 90rpx;
  197. font-size: 20rpx;
  198. font-weight: 500;
  199. padding-left: 20rpx;
  200. color: #1b1b1b;
  201. }
  202. .time1 {
  203. color: #d8d8d8;
  204. }
  205. .status {
  206. width: 123rpx;
  207. line-height: 50rpx;
  208. border-radius: 25rpx;
  209. font-size: 24rpx;
  210. border: 1px solid #1b1b1b;
  211. color: #1b1b1b;
  212. text-align: center;
  213. position: absolute;
  214. top: 124rpx;
  215. left: 234rpx;
  216. }
  217. .status1 {
  218. color: #d8d8d8;
  219. border: 1px solid #d8d8d8;
  220. }
  221. }
  222. }
  223. </style>