index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <layout-page>
  3. <view class="box defaultBgc">
  4. <scroll-view class="scrollBox" scroll-y="true" @scrolltolower="loadingMore">
  5. <view>
  6. <view class="panel">
  7. <view>
  8. <!-- <uni-icons color="#f30" type="icon-renminbi1688" size="16" custom-prefix="iconfont"></uni-icons> -->
  9. <text class="text">{{ balance.point }}</text>
  10. </view>
  11. <!-- <view>
  12. <button class="btn" @tap="handleUse">积分兑换</button>
  13. </view> -->
  14. </view>
  15. <view class="list">
  16. <uni-list>
  17. <uni-list-item
  18. v-for="item in items"
  19. :key="item.id"
  20. :title="item.description"
  21. :rightText="item._createTime"
  22. />
  23. </uni-list>
  24. <uni-load-more :status="more" />
  25. </view>
  26. </view>
  27. </scroll-view>
  28. <uni-popup ref="inputDialog" type="dialog">
  29. <view class="shareQrCodePopupContent">
  30. <view class="ss-m-b-10">请前往网页版门墩儿商城查看</view>
  31. <uni-link href="https://www.menduner.com/mall" text="点击复制网页地址" color="#00B760" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  32. </view>
  33. </uni-popup>
  34. </view>
  35. </layout-page>
  36. </template>
  37. <!-- balance 余额 -->
  38. <script setup>
  39. import { ref } from 'vue'
  40. import {
  41. getUserAccount,
  42. getEnterpriseAccountRecordPage
  43. } from '@/api/sign'
  44. import { timesTampChange } from '@/utils/date'
  45. const balance = ref({})
  46. const items = ref([])
  47. const pageInfo = ref({
  48. pageNo: 1,
  49. pageSize: 20
  50. })
  51. const total = ref(0)
  52. const more = ref('more')
  53. const inputDialog = ref()
  54. getBalance()
  55. getList()
  56. // 获取积分余额
  57. async function getBalance() {
  58. const { data } = await getUserAccount()
  59. if (!data) {
  60. return
  61. }
  62. balance.value = data
  63. }
  64. async function getList () {
  65. try {
  66. const { data } = await getEnterpriseAccountRecordPage({ ...pageInfo.value, type: 0 })
  67. if (!data || !data.list) {
  68. if (pageInfo.value.pageNo === 1) {
  69. return
  70. }
  71. pageInfo.value.pageNo--
  72. more.value = 'more'
  73. return
  74. }
  75. const _data = data.list.map(e => {
  76. return {
  77. ...e,
  78. _createTime: timesTampChange(e.createTime)
  79. }
  80. })
  81. items.value.push(..._data)
  82. total.value = +data.total || 0
  83. more.value = total.value <= items.value.length ? 'noMore' : 'more'
  84. } catch (error) {
  85. if (pageInfo.value.pageNo === 1) {
  86. return
  87. }
  88. pageInfo.value.pageNo--
  89. more.value = 'more'
  90. }
  91. }
  92. function loadingMore () {
  93. if (total.value <= 0) {
  94. return
  95. }
  96. if (more.value === 'noMore') {
  97. return
  98. }
  99. more.value = 'loading'
  100. pageInfo.value.pageNo++
  101. getList()
  102. }
  103. function handleUse () {
  104. // wx.navigateToMiniProgram({
  105. // appId: 'wx6decdf12f9e7a061', // 目标小程序的 appId
  106. // // envVersion: 'develop',
  107. // success(res) {
  108. // // 打开成功
  109. // console.log('成功跳转至小程序:', res);
  110. // },
  111. // fail(err) {
  112. // // 打开失败
  113. // uni.showToast({
  114. // title: '打开商城失败',
  115. // icon: 'none'
  116. // })
  117. // }
  118. // })
  119. inputDialog.value.open()
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .box {
  124. height: 100vh;
  125. }
  126. .scrollBox {
  127. width: 100vw;
  128. // padding: 20rpx;
  129. box-sizing: border-box;
  130. .panel {
  131. position: sticky;
  132. z-index: 2;
  133. top: 0;
  134. width: 100%;
  135. padding: 20rpx;
  136. margin-bottom: 20rpx;
  137. box-sizing: border-box;
  138. background: #FFF;
  139. display: flex;
  140. justify-content: space-between;
  141. align-items: flex-end;
  142. box-shadow: 0px 0px 10px 0px rgb(0, 0, 0, 0.25);
  143. .text {
  144. color: #F30;
  145. font-size: 54rpx;
  146. }
  147. .btn {
  148. width: 180rpx;
  149. height: 60rpx;
  150. line-height: 60rpx;
  151. font-size: 28rpx;
  152. text-align: center;
  153. background: #00B760;
  154. color: #FFF;
  155. border-radius: 30rpx;
  156. }
  157. }
  158. .list {
  159. // padding: 20rpx;
  160. }
  161. }
  162. .shareQrCodePopupContent {
  163. width: 75vw;
  164. padding: 40rpx;
  165. margin-bottom: 20rpx;
  166. text-align: center;
  167. background-color: #fff;
  168. }
  169. </style>