mall.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="pages">
  3. <view class="custom-nav">
  4. <view class="custom-nav-left" @click="$api.goback"><text class="iconfont icon-jiantou"></text></view>
  5. <view class="custom-nav-center"></view>
  6. </view>
  7. <view class="hold-status-bar">
  8. <!-- 占据了状态栏位置 -->
  9. </view>
  10. <view class="top-img mall">
  11. <image :src="$getimg + 'usercenter-bg.png'" class="img" mode="scaleToFill"></image>
  12. <view class="integral">
  13. <view class="integral-til">我的积分</view>
  14. <view class="integral-num">
  15. <text class="num">9</text>
  16. <text class="num">9</text>
  17. <text class="num">9</text>
  18. <text class="num">9</text>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="integral-content">
  23. <view class="integral-content-til">积分兑换</view>
  24. <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  25. <view class="product">
  26. <view v-for="(item,index) in productList" :key="index" class="product-item" @click="goCertDetails(item.fkOrderId)">
  27. </view>
  28. </view>
  29. </mescroll-body>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. // 引入mescroll-mixins.js
  35. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  36. // 引入mescroll-body组件 (如已在main.js注册全局组件,则省略此步骤)
  37. import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"; // 注意.vue后缀不能省
  38. export default {
  39. mixins: [MescrollMixin], // 使用mixin
  40. components: {
  41. MescrollBody,
  42. },
  43. data() {
  44. return {
  45. mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
  46. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  47. downOption: {
  48. // ...
  49. },
  50. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  51. upOption: {
  52. page: {
  53. size: 10 // 每页数据的数量,默认10
  54. },
  55. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  56. empty: {
  57. tip: '暂无相关数据'
  58. }
  59. },
  60. token:'',
  61. $getimg:this.$getimg,
  62. productList:[],
  63. params:{
  64. }
  65. }
  66. },
  67. onShow() {
  68. this.token = this.$store.state.token;
  69. },
  70. onLoad() {
  71. },
  72. methods: {
  73. /*mescroll组件初始化的回调,可获取到mescroll对象 (此处可删,mixins已默认)*/
  74. mescrollInit(mescroll) {
  75. this.mescroll = mescroll;
  76. },
  77. /*下拉刷新的回调, 有三种处理方式:*/
  78. downCallback(){
  79. // 第2种: 下拉刷新和上拉加载调同样的接口, 那么不用第1种方式, 直接mescroll.resetUpScroll()即可
  80. this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
  81. },
  82. /*上拉加载的回调*/
  83. upCallback(page) {
  84. let pageNum = page.num; // 页码, 默认从1开始
  85. let pageSize = page.size; // 页长, 默认每页10条
  86. this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
  87. let thetoken = this.tokenhead + ' ' + this.token;
  88. // console.log('thetoken',thetoken);
  89. // this.$api.http.post(this.config.apiBaseurl+'/carbon-h5/wap/order/searchCredentialList',{params:this.params,header: {Authorization:thetoken}})
  90. this.$api.http.post(this.config.apiBaseurl + '/carbon-h5/wap/order/searchCredentialList',this.params,{
  91. header: {
  92. Accept:'application/json',
  93. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  94. },
  95. }).then(data => {
  96. // 接口返回的当前页数据列表 (数组)
  97. let curPageData = data.data.retBody;
  98. // console.log('curPageData',curPageData);
  99. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  100. let curPageLen = curPageData.length;
  101. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  102. // let totalPage = data.xxx;
  103. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  104. let totalSize = data.data.retHead.total;
  105. // this.mescrollList = curPageData;
  106. // 接口返回的是否有下一页 (true/false)
  107. // let hasNext = data.xxx;
  108. //设置列表数据
  109. if(page.num == 1) this.certificateList = []; //如果是第一页需手动置空列表
  110. this.certificateList = this.certificateList.concat(curPageData); //追加新数据
  111. // console.log('page.num',page.num);
  112. console.log('this.certificateList',JSON.parse(JSON.stringify(this.certificateList)));
  113. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  114. this.mescroll.endBySize(curPageLen, totalSize);
  115. // setTimeout(()=>{
  116. // this.mescroll.endSuccess(curPageLen)
  117. // },20)
  118. }).catch(err => {
  119. this.mescroll.endErr()
  120. console.log(err)
  121. });
  122. }
  123. // goIndex(){
  124. // uni.switchTab({
  125. // url:'../index/index'
  126. // })
  127. // }
  128. }
  129. }
  130. </script>
  131. <style>
  132. @import url("./mall.css");
  133. </style>