index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="widthBox">
  3. <view v-for="item in data" :key="item.id" @click.stop="jumpDetails(item)">
  4. <image :src="item.url"
  5. style="width: 100%;height: 350rpx;border-radius: 10rpx;" mode="scaleToFill">
  6. </image>
  7. </view>
  8. <u-empty v-if="data.length == 0" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  9. <u-loadmore v-if="page.total !== 0 && data.length != 0" :status="status" />
  10. </view>
  11. </template>
  12. <script>
  13. // import {
  14. // activityList
  15. // } from '@/api/tabBar/activity.js'
  16. import {
  17. shoppingCartList
  18. } from '@/api/shoppingCart/index.js'
  19. export default {
  20. data() {
  21. return {
  22. page: {
  23. current: 1,
  24. size: 10,
  25. total: 0,
  26. },
  27. data: [],
  28. status: 'loadmore',
  29. }
  30. },
  31. onLoad() {
  32. uni.showToast({
  33. title: "开发中",
  34. icon: "none",
  35. });
  36. // this.activityListfun()
  37. },
  38. onShow() {
  39. // this.getUpdate()
  40. this.getBadge()
  41. this.data = [];
  42. this.page.current = 1;
  43. size: this.page.size = 10;
  44. // this.activityListfun()
  45. },
  46. onReachBottom() {
  47. this.status = 'loading'
  48. if (this.data.length < this.page.total) {
  49. this.page.current++
  50. this.activityListfun()
  51. } else {
  52. this.status = 'nomore'
  53. }
  54. },
  55. methods: {
  56. getBadge() {
  57. shoppingCartList().then(res => {
  58. let num = res.data.length
  59. uni.setTabBarBadge({
  60. index: 3, // tabIndex,tabBar的哪一项,从0开始
  61. text: num.toString() // 显示的文本,超过 99 显示成 “…”
  62. })
  63. })
  64. },
  65. // getUpdate() {
  66. // const updateManager = uni.getUpdateManager();
  67. // updateManager.onCheckForUpdate(function(res) {
  68. // // 请求完新版本信息的回调
  69. // if (res.hasUpdate) {
  70. // updateManager.onUpdateReady(function() {
  71. // uni.showModal({
  72. // title: '更新提示',
  73. // content: '新版本已经准备好,是否重启应用?',
  74. // success: function(res) {
  75. // if (res.confirm) {
  76. // // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  77. // updateManager.applyUpdate();
  78. // }
  79. // }
  80. // });
  81. // });
  82. // updateManager.onUpdateFailed(function() {
  83. // // 新的版本下载失败
  84. // uni.showModal({
  85. // title: '已经有新版本了哟~',
  86. // content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  87. // });
  88. // });
  89. // }
  90. // });
  91. // },
  92. // 跳转详情
  93. jumpDetails(row) {
  94. uni.navigateTo({
  95. url: '/pages/tabBar/activity/details?id=' + row.id
  96. })
  97. },
  98. // 获取列表数据
  99. activityListfun() {
  100. uni.showLoading({
  101. title: '加载中',
  102. mask: true
  103. });
  104. activityList({
  105. current: this.page.current,
  106. size: this.page.size,
  107. status: 1
  108. }).then(res => {
  109. this.data = this.data.concat(res.data.records)
  110. this.page.total = res.data.total
  111. if (this.data.length == res.data.total) {
  112. this.status = 'nomore'
  113. }
  114. uni.setTabBarBadge({
  115. index: 1, // tabIndex,tabBar的哪一项,从0开始
  116. text: res.data.total.toString() // 显示的文本,超过 99 显示成 “…”
  117. })
  118. uni.hideLoading();
  119. }).catch(err => {
  120. uni.hideLoading();
  121. })
  122. },
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .widthBox {
  128. background-color: #fff;
  129. padding: 32rpx;
  130. height: 100vh;
  131. }
  132. </style>