index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="integral-container">
  3. <!-- 积分总览 -->
  4. <view class="integral-header">
  5. <view class="integral-header-row">
  6. <view class="integral-header-item">
  7. <view class="integral-header-label">总积分</view>
  8. <view class="integral-header-value">{{ List.totalPoint }}</view>
  9. </view>
  10. <view class="integral-header-item">
  11. <view class="integral-header-label">可兑换积分</view>
  12. <view class="integral-header-value">{{ List.availablePoint }}</view>
  13. </view>
  14. </view>
  15. <view class="integral-rate-row">
  16. <view class="integral-rate">1积分=1人民币</view>
  17. <view class="integral-desc" @click="open" style="cursor: pointer;">收益说明
  18. <up-icon name="question-circle"></up-icon>
  19. </view>
  20. </view>
  21. <up-popup :show="show" mode="center" @close="close" @open="open">
  22. <view class="popup-content">
  23. <view class="popup-title">收益说明</view>
  24. <view class="popup-text">用户积分:用户通过平台生成的二维码进行分享,以拉取新用户或志愿者(服务者)并获得相应积分。</view>
  25. <view class="popup-text">积分规则:拉取一个新用户可获得1分,拉取一个新志愿者(服务者)可获得5分。</view>
  26. <view class="popup-text">积分兑换:所获积分可以兑换等价值的商品或购买各类居家服务。</view>
  27. <view class="popup-text">积分生效:用户积分的兑换,以所拉取用户在平台上产生交易为准,即产生了交易的用户或志愿者(服务者)其相应的积分才可实现兑换。</view>
  28. <view class="popup-close" @click="close">关闭</view>
  29. </view>
  30. </up-popup>
  31. </view>
  32. <!-- 积分明细 -->
  33. <view class="integral-detail-section" v-for="(item, index) in Data" :key="index">
  34. <view class="integral-detail-title">积分明细</view>
  35. <view class="integral-detail-list">
  36. <view class="integral-detail-item">
  37. <view class="integral-detail-type">
  38. {{ dictSortMap[item.changeType] || item.changeType }}
  39. </view>
  40. <view class="integral-detail-date">{{ item.createTime }}</view>
  41. <view class="integral-detail-value add">{{ item.changePoint }}积分</view>
  42. </view>
  43. <!-- 可循环渲染多条明细 -->
  44. </view>
  45. </view>
  46. <!-- 固定底部提示 -->
  47. <view class="integral-tip-footer">提示:用户推广积分需要用户所推广人员进行消费过后积分才可以使用</view>
  48. </view>
  49. </template>
  50. <script setup>
  51. import { onMounted, ref, computed } from 'vue'
  52. import { getUserPointInfoData, coreUserPointChangeData, syStemDictList } from '@/api/userPoints'
  53. const List = ref({})//可用积分
  54. const Data = ref([])//积分明细
  55. const dataList = ref([])
  56. // 创建响应式数据
  57. const show = ref(false);
  58. // 定义方法
  59. function open() {
  60. show.value = true;
  61. console.log('弹窗打开', show.value);
  62. }
  63. function close() {
  64. show.value = false;
  65. console.log('弹窗关闭', show.value);
  66. }
  67. const dictSortMap = computed(() => {
  68. let mapObj = {}
  69. dataList.value.forEach((item) => {
  70. mapObj[item.dictValue] = item.dictLabel
  71. })
  72. return mapObj
  73. })
  74. async function getListSum() {
  75. try {
  76. const res = await syStemDictList().catch((err) => {
  77. console.error('接口请求失败:', err)
  78. throw err // 重新抛出以进入 catch 块
  79. })
  80. dataList.value = res.rows
  81. } catch (e) {
  82. console.error('获取数据异常:', e) // 确保这里打印错误
  83. }
  84. }
  85. // 可用积分
  86. const getData = async () => {
  87. const params = {
  88. totalPoint: 0,//总积分
  89. availablePoint: 0,//可兑换积分
  90. }
  91. const res = await getUserPointInfoData(params)
  92. List.value = res.data
  93. console.log(res)
  94. }
  95. // 积分明细
  96. const getList = async () => {
  97. // const params = {
  98. // totalPoint: 0,//总积分
  99. // availablePoint:0,//可兑换积分
  100. // }
  101. const res = await coreUserPointChangeData()
  102. Data.value = res.rows
  103. console.log(res)
  104. }
  105. onMounted(() => {
  106. getData()
  107. getList()
  108. getListSum()
  109. })
  110. </script>
  111. <style lang="scss" scoped>
  112. .integral-container {
  113. padding: 32rpx 24rpx 120rpx 24rpx;
  114. background: #fff;
  115. min-height: 100vh;
  116. padding-bottom: 120rpx;
  117. }
  118. .integral-header {
  119. background: #f8f8f8;
  120. border-radius: 20rpx;
  121. padding: 32rpx 24rpx 24rpx 24rpx;
  122. margin-bottom: 32rpx;
  123. }
  124. .integral-header-row {
  125. display: flex;
  126. justify-content: space-between;
  127. margin-bottom: 16rpx;
  128. }
  129. .integral-header-item {
  130. flex: 1;
  131. text-align: center;
  132. }
  133. .integral-header-label {
  134. color: #888;
  135. font-size: 28rpx;
  136. margin-bottom: 8rpx;
  137. }
  138. .integral-header-value {
  139. color: #333;
  140. font-size: 40rpx;
  141. font-weight: bold;
  142. }
  143. .integral-rate-row {
  144. display: flex;
  145. justify-content: space-between;
  146. align-items: center;
  147. }
  148. .integral-rate {
  149. color: #888;
  150. font-size: 24rpx;
  151. }
  152. .integral-desc {
  153. color: #1a73e8;
  154. font-size: 24rpx;
  155. display: flex;
  156. align-items: center;
  157. margin-left: 20rpx;
  158. }
  159. .integral-detail-section {
  160. margin-bottom: 32rpx;
  161. }
  162. .integral-detail-title {
  163. font-size: 32rpx;
  164. font-weight: bold;
  165. margin-bottom: 16rpx;
  166. }
  167. .integral-detail-list {
  168. background: #f8f8f8;
  169. border-radius: 16rpx;
  170. padding: 16rpx;
  171. }
  172. .integral-detail-item {
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. padding: 16rpx 0;
  177. border-bottom: 1rpx solid #eee;
  178. font-size: 28rpx;
  179. }
  180. .integral-detail-item:last-child {
  181. border-bottom: none;
  182. }
  183. .integral-detail-type {
  184. color: #333;
  185. flex: 2;
  186. }
  187. .integral-detail-date {
  188. color: #aaa;
  189. flex: 3;
  190. font-size: 24rpx;
  191. text-align: center;
  192. }
  193. .integral-detail-value {
  194. flex: 1;
  195. text-align: right;
  196. font-weight: bold;
  197. }
  198. .integral-detail-value.add {
  199. color: #1a73e8;
  200. }
  201. .integral-detail-value.minus {
  202. color: #e81a1a;
  203. }
  204. .integral-tip-footer {
  205. position: fixed;
  206. left: 0;
  207. bottom: 30rpx;
  208. width: 100vw;
  209. background: #fffbe8;
  210. color: #b8860b;
  211. font-size: 24rpx;
  212. text-align: center;
  213. padding: 24rpx 0 32rpx 0;
  214. box-shadow: 0 -4rpx 24rpx rgba(0, 0, 0, 0.04);
  215. z-index: 99;
  216. }
  217. .popup-content {
  218. background: #fff;
  219. padding: 30rpx;
  220. border-radius: 12rpx;
  221. width: 600rpx;
  222. }
  223. .popup-title {
  224. font-size: 32rpx;
  225. font-weight: bold;
  226. text-align: center;
  227. margin-bottom: 30rpx;
  228. }
  229. .popup-text {
  230. font-size: 28rpx;
  231. color: #333;
  232. line-height: 1.6;
  233. margin-bottom: 20rpx;
  234. }
  235. .popup-close {
  236. text-align: center;
  237. color: #1a73e8;
  238. font-size: 28rpx;
  239. margin-top: 30rpx;
  240. padding: 20rpx;
  241. border-top: 1rpx solid #eee;
  242. }
  243. </style>