myCouponList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <u-tabs
  5. :current="status"
  6. :scrollable="false"
  7. :list="tabs"
  8. lineColor="#C39A58"
  9. @change="statusChange">
  10. </u-tabs>
  11. </view>
  12. <mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  13. <view class="coupon-box" >
  14. <view class="item" v-for="(item) in dataList">
  15. <view class="left" >
  16. <image v-if="item.status==0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/0fdd75d89db84458886d38e615011048.png" mode="widthFix"></image>
  17. <image v-if="item.status!=0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/d950e4c7af1e4464be1a7777e9dca576.png" mode="widthFix"></image>
  18. <view style="z-index: 999;">
  19. ¥<span class="num" v-if="item.price!=null">{{item.price.toFixed(2)}}</span>
  20. </view>
  21. <view class="pic-num" v-if="item.minPrice!=null" >满{{item.minPrice.toFixed(2)}}元可用</view>
  22. </view>
  23. <view class="right">
  24. <view class="title">
  25. {{item.title}}
  26. </view>
  27. <view class="btns">
  28. <view v-if="item.status==0||item.status==2" >{{item.limitTime}} 到期</view>
  29. <view v-if="item.status==1">使用时间 {{item.useTime}}</view>
  30. <view class="bnt gray" v-if="item.status==1" >已使用</view>
  31. <view class="bnt gray" v-if="item.status==2" >已过期</view>
  32. <view class="btn" v-if="item.status==0" >可使用</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </mescroll-body>
  38. </view>
  39. </template>
  40. <script>
  41. import { getMyCouponList } from '@/api/user.js'
  42. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  43. export default {
  44. name: 'UserCoupon',
  45. props: {},
  46. mixins: [MescrollMixin], // 使用mixin
  47. data: function() {
  48. return {
  49. tabs:[
  50. {
  51. id:0,
  52. name:'待使用'
  53. },
  54. {
  55. id:1,
  56. name:'已使用'
  57. },
  58. {
  59. id:2,
  60. name:'已过期'
  61. }
  62. ],
  63. status:0,
  64. mescroll:null,
  65. downOption: { //下拉刷新
  66. use:true,
  67. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  68. },
  69. upOption: {
  70. onScroll:false,
  71. use: true, // 是否启用上拉加载; 默认true
  72. page: {
  73. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  74. size: 10 // 每页数据的数量,默认10
  75. },
  76. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  77. textNoMore:"已经到底了",
  78. empty: {
  79. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  80. tip: '暂无数据'
  81. }
  82. },
  83. dataList: []
  84. }
  85. },
  86. watch: {
  87. },
  88. onShow() {
  89. },
  90. methods: {
  91. statusChange(item){
  92. console.log(item)
  93. this.status=item.id
  94. this.mescroll.resetUpScroll()
  95. },
  96. navTo(url){
  97. uni.navigateTo({
  98. url: url
  99. })
  100. },
  101. mescrollInit(mescroll) {
  102. this.mescroll = mescroll;
  103. },
  104. /*下拉刷新的回调 */
  105. downCallback() {
  106. this.mescroll.resetUpScroll()
  107. },
  108. /*上拉加载的回调*/
  109. upCallback(page) {
  110. //联网加载数据
  111. var that = this;
  112. var data = {
  113. status:this.status,
  114. pageNum: page.num,
  115. pageSize: page.size
  116. };
  117. getMyCouponList(data).then(res => {
  118. if(res.code==200){
  119. if (page.num == 1) {
  120. that.dataList = res.data.list;
  121. } else {
  122. that.dataList = that.dataList.concat(res.data.list);
  123. }
  124. that.mescroll.endBySize(res.data.list.length, res.data.total);
  125. }else{
  126. uni.showToast({
  127. icon:'none',
  128. title: "请求失败",
  129. });
  130. that.dataList = null;
  131. that.mescroll.endErr();
  132. }
  133. });
  134. },
  135. },
  136. }
  137. </script>
  138. <style lang="less" scoped>
  139. .content{
  140. height: 100%;
  141. .top-fixed{
  142. width: 100%;
  143. position: fixed;
  144. top: 0;
  145. left: 0;
  146. z-index: 10;
  147. height: 88upx;
  148. background-color: #fff;
  149. }
  150. .coupon-box{
  151. width: 100%;
  152. padding: 15rpx;
  153. display: flex;
  154. flex-direction: column;
  155. align-items: flex-start;
  156. justify-content: flex-start;
  157. box-sizing: border-box;
  158. .item{
  159. width: 100%;
  160. display: flex;
  161. align-items: center;
  162. justify-content: flex-start;
  163. margin-bottom: 16rpx;
  164. height:170rpx;
  165. &:last-child{
  166. margin-bottom: 0rpx;
  167. }
  168. .left{
  169. color: #fff;
  170. font-size: 36rpx;
  171. font-weight: bold;
  172. text-align: center;
  173. display: flex;
  174. flex-direction: column;
  175. align-items: center;
  176. justify-content: center;
  177. position: relative;
  178. width: 230rpx;
  179. image{
  180. position: absolute;
  181. width: 230rpx;
  182. height:170rpx;
  183. color: #fff;
  184. }
  185. .num{
  186. font-size: 40rpx;
  187. }
  188. .pic-num{
  189. font-size: 20rpx;
  190. z-index: 99;
  191. }
  192. }
  193. .right{
  194. display: flex;
  195. flex-direction: column;
  196. align-items: flex-start;
  197. justify-content: flex-start;
  198. height:170rpx;
  199. width: calc(100% - 230rpx);
  200. padding: 0 17rpx 0 24rpx;
  201. background-color: #fff;
  202. box-sizing: border-box;
  203. .title{
  204. width: 100%;
  205. font-size: 0.3 * 100rpx;
  206. color: #282828;
  207. height: 0.93 * 100rpx;
  208. line-height: 0.93 * 100rpx;
  209. border-bottom: 1px solid #f0f0f0;
  210. }
  211. .btns{
  212. display: flex;
  213. align-items: center;
  214. justify-content: space-between;
  215. width: 100%;
  216. font-size: 0.2 * 100rpx;
  217. color: #999;
  218. height: 0.76 * 100rpx;
  219. .btn{
  220. width: 1.36 * 100rpx;
  221. height: 0.44 * 100rpx;
  222. border-radius: 0.22 * 100rpx;
  223. font-size: 0.22 * 100rpx;
  224. color: #fff;
  225. text-align: center;
  226. line-height: 0.44 * 100rpx;
  227. background-color: #C39A58;
  228. .gray{
  229. background-color: #ccc;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. }
  237. </style>