order.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view class="">
  3. <!-- <u-navbar
  4. title="我的业绩"
  5. :placeholder="true"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar> -->
  10. <view class="page-wrap">
  11. <img src="../static/img/order-banner.png" alt="">
  12. </view>
  13. <view class="tabs-wrap">
  14. <u-tabs
  15. :list="tabsList"
  16. lineColor="#009AEF"
  17. :activeStyle="{color:'#333','font-weight': '600','font-size':'30rpx'}"
  18. :inactiveStyle="{color:'#999'}"
  19. @click="tabsClick"></u-tabs>
  20. </view>
  21. <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  22. <view class="page-wrap" v-show="dataList.length>0" >
  23. <view class="list">
  24. <view class="item u-flex u-col-top" @click="goDetail(item)" v-for="item in dataList" :key="item.id">
  25. <img class="img" :src="item.mainImg" alt="">
  26. <view class="text">
  27. <view class="title ellipsis-2">{{item.goodsName}}</view>
  28. <view class="credit">{{item.credit}}积分</view>
  29. <view class="bottom u-flex u-row-between">
  30. <view class="quantity">兑换数量:{{item.quantity}}</view>
  31. <u-button v-if="item.status==0" @click.native.stop="viewCode(item)" type="primary" :customStyle="{height:'58rpx',width: 'auto','margin-right': 'unset'}" text="兑换码"></u-button>
  32. <u-button v-if="item.status==1" @click.native.stop="goDetail(item)" type="primary" :customStyle="{height:'58rpx',width: 'auto','margin-right': 'unset','background-color':'#CCEBFC','border-color':'#CCEBFC'}" text="详情"></u-button>
  33. <u-button v-if="item.status==2" @click.native.stop="goDetail(item)" type="primary" :customStyle="{height:'58rpx',width: 'auto','margin-right': 'unset','background-color':'#CCEBFC','border-color':'#CCEBFC'}" text="详情"></u-button>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </mescroll-body>
  40. <tabbar :tabbarIndexProps='1' />
  41. </view>
  42. </template>
  43. <script>
  44. import tabbar from "../components/tabbar.vue";
  45. // 引入mescroll-mixins.js
  46. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  47. export default {
  48. mixins: [MescrollMixin], // 使用mixin
  49. components:{
  50. tabbar,
  51. },
  52. data() {
  53. return {
  54. totalAmount:'',
  55. downOption: {},
  56. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  57. upOption: {
  58. page: {
  59. size: 10 // 每页数据的数量,默认10
  60. },
  61. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  62. empty: {
  63. tip: '暂无相关数据'
  64. }
  65. },
  66. tabsList:[{name:'未领取',status:'0'},{name:'已领取',status:1},{name:'已失效',status:2}],
  67. status:'',
  68. params:{
  69. },
  70. activeIndex:0,
  71. dataList: []
  72. }
  73. },
  74. onShow() {
  75. },
  76. onLoad() {
  77. this.params.status = this.tabsList[this.activeIndex].status;
  78. // console.log('1111', this.tabsList[this.activeIndex]);
  79. },
  80. methods: {
  81. /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
  82. downCallback(){
  83. this.mescroll.resetUpScroll();
  84. },
  85. /*上拉加载的回调*/
  86. upCallback(page) {
  87. // 此处可以继续请求其他接口
  88. // if(page.num == 1){
  89. // // 请求其他接口...
  90. // }
  91. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  92. // if(!this.params.id){
  93. // this.mescroll.endErr()
  94. // return // 此处return,先获取xx
  95. // }
  96. let pageNum = page.num; // 页码, 默认从1开始
  97. let pageSize = page.size; // 页长, 默认每页10条isAsc:0//时间排序 0:降序 1:升序 (默认星级降序排序)
  98. this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
  99. this.$u.api.memberExchangeRecord(this.params).then(data => {
  100. // console.log('data',JSON.parse(JSON.stringify(data)));
  101. // 接口返回的当前页数据列表 (数组)
  102. let curPageData = data.data.rows;
  103. this.totalAmount = data.data.total;
  104. // console.log('curPageData',JSON.parse(JSON.stringify(curPageData)));
  105. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  106. let curPageLen = curPageData.length;
  107. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  108. // let totalPage = data.data.data.totalPage;
  109. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  110. let totalSize = curPageData.total;
  111. // 接口返回的是否有下一页 (true/false)
  112. // let hasNext = data.xxx;
  113. // console.log('totalPage',totalPage,'curPageLen',curPageLen);
  114. //设置列表数据
  115. if(page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
  116. this.dataList = this.dataList.concat(curPageData); //追加新数据
  117. // 请求成功,隐藏加载状态
  118. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  119. // this.mescroll.endByPage(curPageLen, totalPage);
  120. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  121. this.mescroll.endBySize(curPageLen, totalSize);
  122. }).catch(err => {
  123. this.mescroll.endErr()
  124. console.log(err)
  125. });
  126. },
  127. /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
  128. reloadList() {
  129. this.mescroll.resetUpScroll();
  130. },
  131. tabsClick(item){
  132. this.params.status = item.status;
  133. this.reloadList()
  134. console.log('item',item);
  135. },
  136. viewCode(item){
  137. // console.log('viewCode',item);
  138. uni.$u.route('/center/paycode', {
  139. qrContent: item.exchangeCode,
  140. });
  141. },
  142. goDetail(item){
  143. // console.log('goDetail',item);
  144. uni.$u.route('/shopping/orderdetails', {
  145. id: item.id,
  146. });
  147. }
  148. }
  149. }
  150. </script>
  151. <style>
  152. page{
  153. background-color: #F5F9FC;
  154. }
  155. </style>
  156. <style lang="scss" scoped>
  157. .tabs-wrap{
  158. background-color: #fff;
  159. margin-bottom: 0;
  160. }
  161. .list{
  162. border-radius: 8rpx;
  163. padding: 0 20rpx;
  164. background-color: #fff;
  165. .item{
  166. padding: 28rpx 0;
  167. background-color: #fff;
  168. .img{
  169. width: 200rpx;
  170. height: 202rpx;
  171. }
  172. .text{
  173. flex: 1;
  174. margin-left: 40rpx;
  175. .title{
  176. font-size: 30rpx;
  177. font-family: PingFangSC-Regular, PingFang SC;
  178. font-weight: 400;
  179. color: #333333;
  180. line-height: 42rpx;
  181. margin-bottom: 20rpx;
  182. }
  183. .credit{
  184. font-size: 32rpx;
  185. font-family: PingFangSC-Semibold, PingFang SC;
  186. font-weight: 600;
  187. color: #FFB100;
  188. line-height: 44rpx;
  189. margin-bottom: 20rpx;
  190. }
  191. .quantity{
  192. font-size: 28rpx;
  193. font-family: PingFangSC-Regular, PingFang SC;
  194. font-weight: 400;
  195. color: #999999;
  196. line-height: 40rpx;
  197. }
  198. }
  199. &:not(:last-of-type){
  200. border-bottom: 0.5px solid #ddd;
  201. padding-bottom: 20rpx;
  202. }
  203. }
  204. }
  205. </style>