index.vue 3.9 KB

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