certificateList.vue 4.9 KB

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