index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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
  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 (more.value === 'noMore') {
  94. return
  95. }
  96. more.value = 'loading'
  97. pageInfo.value.pageNo++
  98. getList()
  99. }
  100. function handleUse () {
  101. // wx.navigateToMiniProgram({
  102. // appId: 'wx6decdf12f9e7a061', // 目标小程序的 appId
  103. // // envVersion: 'develop',
  104. // success(res) {
  105. // // 打开成功
  106. // console.log('成功跳转至小程序:', res);
  107. // },
  108. // fail(err) {
  109. // // 打开失败
  110. // uni.showToast({
  111. // title: '打开商城失败',
  112. // icon: 'none'
  113. // })
  114. // }
  115. // })
  116. inputDialog.value.open()
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .box {
  121. height: 100vh;
  122. }
  123. .scrollBox {
  124. width: 100vw;
  125. // padding: 20rpx;
  126. box-sizing: border-box;
  127. .panel {
  128. position: sticky;
  129. z-index: 2;
  130. top: 0;
  131. width: 100%;
  132. padding: 20rpx;
  133. margin-bottom: 20rpx;
  134. box-sizing: border-box;
  135. background: #FFF;
  136. display: flex;
  137. justify-content: space-between;
  138. align-items: flex-end;
  139. box-shadow: 0px 0px 10px 0px rgb(0, 0, 0, 0.25);
  140. .text {
  141. color: #F30;
  142. font-size: 54rpx;
  143. }
  144. .btn {
  145. width: 180rpx;
  146. height: 60rpx;
  147. line-height: 60rpx;
  148. font-size: 28rpx;
  149. text-align: center;
  150. background: #00B760;
  151. color: #FFF;
  152. border-radius: 30rpx;
  153. }
  154. }
  155. .list {
  156. // padding: 20rpx;
  157. }
  158. }
  159. .shareQrCodePopupContent {
  160. width: 75vw;
  161. padding: 40rpx;
  162. margin-bottom: 20rpx;
  163. text-align: center;
  164. background-color: #fff;
  165. }
  166. </style>