index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <!-- 签到 -->
  3. <view>
  4. <view class='sign-record'>
  5. <view class='list' v-for="(item,index) in signList" :key="index">
  6. <view class='item'>
  7. <view class='data'>{{item.month}}</view>
  8. <view class='listn'>
  9. <view class='itemn acea-row row-between-wrapper' v-for="(itemn,indexn) in item.list" :key="indexn">
  10. <view>
  11. <view class='name line1'>{{itemn.title}}</view>
  12. <view>{{itemn.add_time}}</view>
  13. </view>
  14. <view class='num font-color'>+{{itemn.number}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class='loadingicon acea-row row-center-wrapper' v-if="signList.length > 0">
  20. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadtitle}}
  21. </view>
  22. <view v-if="signList.length == 0"><emptyPage title="暂无签到记录~"></emptyPage></view>
  23. </view>
  24. <!-- #ifdef MP -->
  25. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  26. <!-- #endif -->
  27. </view>
  28. </template>
  29. <script>
  30. import { getSignMonthList } from '@/api/user.js';
  31. import { toLogin } from '@/libs/login.js';
  32. import { mapGetters } from "vuex";
  33. import emptyPage from '@/components/emptyPage';
  34. export default {
  35. components: {
  36. emptyPage
  37. },
  38. data() {
  39. return {
  40. loading:false,
  41. loadend:false,
  42. loadtitle:'加载更多',
  43. page:1,
  44. limit:8,
  45. signList:[],
  46. isAuto: false, //没有授权的不会自动授权
  47. isShowAuth: false //是否隐藏授权
  48. };
  49. },
  50. computed: mapGetters(['isLogin']),
  51. watch:{
  52. isLogin:{
  53. handler:function(newV,oldV){
  54. if(newV){
  55. // #ifdef H5 || APP-PLUS
  56. this.getSignMoneList();
  57. // #endif
  58. }
  59. },
  60. deep:true
  61. }
  62. },
  63. onLoad(){
  64. if(this.isLogin){
  65. this.getSignMoneList();
  66. }else{
  67. // #ifdef H5 || APP-PLUS
  68. toLogin()
  69. // #endif
  70. // #ifdef MP
  71. this.isShowAuth = true;
  72. // #endif
  73. }
  74. },
  75. onShow() {
  76. uni.removeStorageSync('form_type_cart');
  77. },
  78. onReachBottom: function () {
  79. this.getSignMoneList();
  80. },
  81. methods: {
  82. /**
  83. *
  84. * 授权回调
  85. */
  86. onLoadFun:function(){
  87. this.getSignMoneList();
  88. this.isShowAuth = false;
  89. },
  90. // 授权关闭
  91. authColse:function(e){
  92. this.isShowAuth = e
  93. },
  94. /**
  95. * 获取签到记录列表
  96. */
  97. getSignMoneList:function(){
  98. let that=this;
  99. if(that.loading) return;
  100. if(that.loadend) return;
  101. that.loading = true;
  102. that.loadtitle = "";
  103. getSignMonthList({ page: that.page, limit: that.limit }).then(res=>{
  104. let list = res.data;
  105. let loadend = list.length < that.limit;
  106. that.signList = that.$util.SplitArray(list, that.signList);
  107. that.$set(that,'signList',that.signList);
  108. that.loadend = loadend;
  109. that.loading = false;
  110. that.loadtitle = loadend ? "没有更多内容啦~" : "加载更多"
  111. }).catch(err=>{
  112. that.loading = false;
  113. that.loadtitle = '加载更多';
  114. });
  115. },
  116. }
  117. }
  118. </script>
  119. <style>
  120. </style>