mycoupon.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view class="pages">
  3. <u-navbar
  4. title="我的优惠券"
  5. :placeholder="true"
  6. :autoBack="false"
  7. @leftClick="leftClick"
  8. :safeAreaInsetTop="true"
  9. >
  10. </u-navbar>
  11. <view class="tabs-wrap">
  12. <view class="inner">
  13. <u-tabs
  14. :list="tabsArr"
  15. @click="tabsClick"
  16. lineColor="#ED0000"
  17. lineWidth="82rpx"
  18. :activeStyle="{color: '#2D2D2D',fontWeight: 'bold'}"
  19. itemStyle="width:33%; height: 46px;box-sizing:border-box"
  20. >
  21. </u-tabs>
  22. </view>
  23. </view>
  24. <view class="page-wrap">
  25. <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  26. <!-- :down="downOption" :up="upOption" -->
  27. <view class="list">
  28. <view v-for="(item,index) in dataList" class="list-item u-flex" :class="{hotel:index==1}" :key="item.id" :style="{backgroundImage:`url(${staticUrl}/img/coupon-bg.png)`}">
  29. <view class="left u-flex u-row-center u-col-top">
  30. <text class="icon">¥</text>
  31. <text class="num">30</text>
  32. </view>
  33. <view class="right u-flex u-row-between">
  34. <view class="text">
  35. <view class="name">演出购票折扣券</view>
  36. <view class="time">有限期:2023.10.22-2023.10.22</view>
  37. <view class="rule u-flex">
  38. 使用规则
  39. <u-icon name="arrow-right" color="#D56442" size="30rpx"></u-icon>
  40. </view>
  41. </view>
  42. <view class="btn">去使用</view>
  43. </view>
  44. </view>
  45. </view>
  46. </mescroll-body>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. // 引入mescroll-mixins.js
  52. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  53. export default {
  54. mixins: [MescrollMixin], // 使用mixin
  55. components: {
  56. },
  57. data() {
  58. return {
  59. staticUrl:this.$commonConfig.staticUrl,
  60. // // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  61. // downOption: {
  62. // },
  63. // // 上拉加载的配置(可选, 绝大部分情况无需配置)
  64. // upOption: {
  65. // page: {
  66. // size: 10 // 每页数据的数量,默认10
  67. // },
  68. // noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  69. // empty: {
  70. // tip: '暂无相关数据'
  71. // }
  72. // },
  73. params:{
  74. },
  75. dataList:[
  76. {name:'路线推荐',pic:`${this.$commonConfig.staticUrl}/img/indexnav-luxian.png`,id:1},
  77. {name:'路线推荐',pic:`${this.$commonConfig.staticUrl}/img/indexnav-luxian.png`,id:1},
  78. ],
  79. tabsArr:[
  80. {name:'待使用',status:0},
  81. {name:'已使用',status:1},
  82. {name:'已过期',status:2}
  83. ],
  84. status:0,
  85. }
  86. },
  87. onShow() {
  88. },
  89. onLoad() {
  90. },
  91. methods: {
  92. leftClick(e){
  93. let pages = getCurrentPages();
  94. if(pages.length==1){
  95. uni.$u.route('/pages/index/index')
  96. }else{
  97. uni.navigateBack()
  98. };
  99. },
  100. /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
  101. downCallback(){
  102. this.mescroll.resetUpScroll();
  103. },
  104. /*上拉加载的回调*/
  105. upCallback(page) {
  106. // 此处可以继续请求其他接口
  107. // if(page.num == 1){
  108. // // 请求其他接口...
  109. // }
  110. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  111. // if(!this.hasTypeId){
  112. // this.mescroll.endErr();//没有接口暂时不调用
  113. // return // 此处return,先获取xx
  114. // }
  115. let pageNum = page.num; // 页码, 默认从1开始
  116. let pageSize = page.size; // 页长, 默认每页10条
  117. let params = {
  118. pageNum : page.num,
  119. pageSize : page.size,
  120. status:this.status
  121. }
  122. // console.log('this.params',params);
  123. this.$u.api.orderList(params).then(data => {
  124. this.hasfetch = true;
  125. console.log('data',JSON.parse(JSON.stringify(data)));
  126. // 接口返回的当前页数据列表 (数组)
  127. let curPageData = data.data.rows;
  128. // console.log('curPageData',JSON.parse(JSON.stringify(curPageData)));
  129. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  130. let curPageLen = curPageData.length;
  131. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  132. // let totalPage = data.data.data.totalPage;
  133. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  134. let totalSize = data.data.total;
  135. // 接口返回的是否有下一页 (true/false)
  136. // let hasNext = data.xxx;
  137. // console.log('totalPage',totalPage,'curPageLen',curPageLen);
  138. //设置列表数据
  139. if(page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
  140. this.dataList = this.dataList.concat(curPageData); //追加新数据
  141. // 请求成功,隐藏加载状态
  142. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  143. // this.mescroll.endByPage(curPageLen, totalPage);
  144. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  145. this.mescroll.endBySize(curPageLen, totalSize);
  146. }).catch(err => {
  147. this.mescroll.endErr()
  148. console.log(err)
  149. });
  150. },
  151. /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
  152. reloadList() {
  153. this.mescroll.resetUpScroll();
  154. },
  155. search(e){
  156. this.reloadList();
  157. },
  158. tabsClick(e){
  159. console.log('tabsClick',e);
  160. this.status = e.status;
  161. this.reloadList();
  162. // this.tabsIndex = e.index;
  163. },
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .tabs-wrap{
  169. position: relative;
  170. margin-bottom: 24rpx;
  171. box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(226,226,226,0.5);
  172. }
  173. .list{
  174. .list-item{
  175. width: 100%;
  176. height: 158rpx;
  177. background-repeat: no-repeat;
  178. background-size: 100% 100%;
  179. margin-bottom: 24rpx;
  180. .left{
  181. width: 190rpx;
  182. .icon{
  183. width: 26rpx;
  184. height: 26rpx;
  185. line-height: 26rpx;
  186. text-align: center;
  187. font-size: 10px;
  188. color: #fff;
  189. border-radius: 50%;
  190. background: linear-gradient(360deg, #ED0000 0%, #F27C7D 100%);
  191. }
  192. .num{
  193. font-size: 100rpx;
  194. font-family: Helvetica, Helvetica;
  195. font-weight: bold;
  196. color: #000000;
  197. background: linear-gradient(180deg, #F28082 0%, #ED0000 100%);
  198. -webkit-background-clip: text;
  199. -webkit-text-fill-color: transparent;
  200. }
  201. }
  202. .right{
  203. flex: 1;
  204. padding: 32rpx 20rpx;
  205. .text{
  206. padding-left: 10rpx;
  207. color: #D56442;
  208. font-size: 20rpx;
  209. font-weight: 400;
  210. }
  211. .name{
  212. font-size: 28rpx;
  213. font-weight: bold;
  214. color: #C5412B;
  215. margin-bottom: 16rpx;
  216. }
  217. .time{
  218. margin-bottom: 16rpx;
  219. }
  220. .btn{
  221. height: 50rpx;
  222. line-height: 50rpx;
  223. background: #ED0000;
  224. border-radius: 25rpx;
  225. font-size: 24rpx;
  226. font-weight: bold;
  227. color: #FFFFFF;
  228. padding: 0 24rpx;
  229. }
  230. }
  231. &.hotel{
  232. .num{
  233. background: linear-gradient(180deg, #F77941 0%, #E84816 100%);
  234. background: linear-gradient(180deg, #F77941 0%, #E84816 100%);
  235. -webkit-background-clip: text;
  236. -webkit-text-fill-color: transparent;
  237. }
  238. .icon{
  239. background: linear-gradient(360deg, #E84917 0%, #F97E45 100%);
  240. }
  241. }
  242. }
  243. }
  244. </style>