myCouponList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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="#FF5C03"
  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. onLoad(option) {
  89. this.status=option.type;
  90. },
  91. onShow() {
  92. },
  93. methods: {
  94. statusChange(item){
  95. console.log(item)
  96. this.status=item.id
  97. this.mescroll.resetUpScroll()
  98. },
  99. navTo(url){
  100. uni.navigateTo({
  101. url: url
  102. })
  103. },
  104. mescrollInit(mescroll) {
  105. this.mescroll = mescroll;
  106. },
  107. /*下拉刷新的回调 */
  108. downCallback() {
  109. this.mescroll.resetUpScroll()
  110. },
  111. /*上拉加载的回调*/
  112. upCallback(page) {
  113. //联网加载数据
  114. var that = this;
  115. var data = {
  116. status:this.status,
  117. pageNum: page.num,
  118. pageSize: page.size
  119. };
  120. getMyCouponList(data).then(res => {
  121. if(res.code==200){
  122. if (page.num == 1) {
  123. that.dataList = res.data.list;
  124. } else {
  125. that.dataList = that.dataList.concat(res.data.list);
  126. }
  127. that.mescroll.endBySize(res.data.list.length, res.data.total);
  128. }else{
  129. uni.showToast({
  130. icon:'none',
  131. title: "请求失败",
  132. });
  133. that.dataList = null;
  134. that.mescroll.endErr();
  135. }
  136. });
  137. },
  138. },
  139. }
  140. </script>
  141. <style lang="less" scoped>
  142. .content{
  143. height: 100%;
  144. .top-fixed{
  145. width: 100%;
  146. position: absolute;
  147. top: 0;
  148. left: 0;
  149. z-index: 10;
  150. height: 88upx;
  151. background-color: #fff;
  152. }
  153. .coupon-box{
  154. width: 100%;
  155. padding: 15rpx;
  156. display: flex;
  157. flex-direction: column;
  158. align-items: flex-start;
  159. justify-content: flex-start;
  160. box-sizing: border-box;
  161. .item{
  162. width: 100%;
  163. display: flex;
  164. align-items: center;
  165. justify-content: flex-start;
  166. margin-bottom: 16rpx;
  167. height:170rpx;
  168. &:last-child{
  169. margin-bottom: 0rpx;
  170. }
  171. .left{
  172. color: #fff;
  173. font-size: 36rpx;
  174. font-weight: bold;
  175. text-align: center;
  176. display: flex;
  177. flex-direction: column;
  178. align-items: center;
  179. justify-content: center;
  180. position: relative;
  181. width: 230rpx;
  182. image{
  183. position: absolute;
  184. width: 230rpx;
  185. height:170rpx;
  186. color: #fff;
  187. }
  188. .num{
  189. font-size: 40rpx;
  190. }
  191. .pic-num{
  192. font-size: 20rpx;
  193. z-index: 99;
  194. }
  195. }
  196. .right{
  197. display: flex;
  198. flex-direction: column;
  199. align-items: flex-start;
  200. justify-content: flex-start;
  201. height:170rpx;
  202. width: calc(100% - 230rpx);
  203. padding: 0 17rpx 0 24rpx;
  204. background-color: #fff;
  205. box-sizing: border-box;
  206. .title{
  207. width: 100%;
  208. font-size: 0.3 * 100rpx;
  209. color: #282828;
  210. height: 0.93 * 100rpx;
  211. line-height: 0.93 * 100rpx;
  212. border-bottom: 1px solid #f0f0f0;
  213. }
  214. .btns{
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. width: 100%;
  219. font-size: 0.2 * 100rpx;
  220. color: #999;
  221. height: 0.76 * 100rpx;
  222. .btn{
  223. width: 1.36 * 100rpx;
  224. height: 0.44 * 100rpx;
  225. border-radius: 0.22 * 100rpx;
  226. font-size: 0.22 * 100rpx;
  227. color: #fff;
  228. text-align: center;
  229. line-height: 0.44 * 100rpx;
  230. background-color: #FF5C03;
  231. .gray{
  232. background-color: #ccc;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }
  239. }
  240. </style>