index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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-title">积分明细</view>
  34. <view class="integral-detail-section" v-for="(item, index) in Data" :key="index">
  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" :style="{ color: item.isPointUsable === 0 ? '#53c21d' : '#e81a1a' }">{{ 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. // 将可用积分存储到本地
  94. uni.setStorageSync('totalPoint', res.data.totalPoint || 0)
  95. console.log(res)
  96. }
  97. // 积分明细
  98. const getList = async () => {
  99. // const params = {
  100. // totalPoint: 0,//总积分
  101. // availablePoint:0,//可兑换积分
  102. // }
  103. const res = await coreUserPointChangeData()
  104. Data.value = res.rows
  105. console.log(res)
  106. }
  107. onMounted(() => {
  108. getData()
  109. getList()
  110. getListSum()
  111. })
  112. </script>
  113. <style lang="scss" scoped>
  114. .integral-container {
  115. padding: 32rpx 24rpx 120rpx 24rpx;
  116. background: #fff;
  117. min-height: 100vh;
  118. padding-bottom: 120rpx;
  119. }
  120. .integral-header {
  121. background: #f8f8f8;
  122. border-radius: 20rpx;
  123. padding: 32rpx 24rpx 24rpx 24rpx;
  124. margin-bottom: 32rpx;
  125. }
  126. .integral-header-row {
  127. display: flex;
  128. justify-content: space-between;
  129. margin-bottom: 16rpx;
  130. }
  131. .integral-header-item {
  132. flex: 1;
  133. text-align: center;
  134. }
  135. .integral-header-label {
  136. color: #888;
  137. font-size: 28rpx;
  138. margin-bottom: 8rpx;
  139. }
  140. .integral-header-value {
  141. color: #333;
  142. font-size: 40rpx;
  143. font-weight: bold;
  144. }
  145. .integral-rate-row {
  146. display: flex;
  147. justify-content: space-between;
  148. align-items: center;
  149. }
  150. .integral-rate {
  151. color: #888;
  152. font-size: 24rpx;
  153. }
  154. .integral-desc {
  155. color: #1a73e8;
  156. font-size: 24rpx;
  157. display: flex;
  158. align-items: center;
  159. margin-left: 20rpx;
  160. }
  161. .integral-detail-section {
  162. margin-bottom: 32rpx;
  163. }
  164. .integral-detail-title {
  165. font-size: 32rpx;
  166. font-weight: bold;
  167. margin-bottom: 16rpx;
  168. }
  169. .integral-detail-list {
  170. background: #f8f8f8;
  171. border-radius: 16rpx;
  172. padding: 16rpx;
  173. }
  174. .integral-detail-item {
  175. display: flex;
  176. align-items: center;
  177. justify-content: space-between;
  178. padding: 16rpx 0;
  179. border-bottom: 1rpx solid #eee;
  180. font-size: 28rpx;
  181. }
  182. .integral-detail-item:last-child {
  183. border-bottom: none;
  184. }
  185. .integral-detail-type {
  186. color: #333;
  187. flex: 2;
  188. }
  189. .integral-detail-date {
  190. color: #aaa;
  191. flex: 3;
  192. font-size: 24rpx;
  193. text-align: center;
  194. }
  195. .integral-detail-value {
  196. flex: 1;
  197. text-align: right;
  198. font-weight: bold;
  199. }
  200. .integral-detail-value.add {
  201. color: #1a73e8;
  202. }
  203. .integral-detail-value.minus {
  204. color: #e81a1a;
  205. }
  206. .integral-tip-footer {
  207. position: fixed;
  208. left: 0;
  209. bottom: 30rpx;
  210. width: 100vw;
  211. background: #fffbe8;
  212. color: #b8860b;
  213. font-size: 24rpx;
  214. text-align: center;
  215. padding: 24rpx 0 32rpx 0;
  216. box-shadow: 0 -4rpx 24rpx rgba(0, 0, 0, 0.04);
  217. z-index: 99;
  218. }
  219. .popup-content {
  220. background: #fff;
  221. padding: 30rpx;
  222. border-radius: 12rpx;
  223. width: 600rpx;
  224. }
  225. .popup-title {
  226. font-size: 32rpx;
  227. font-weight: bold;
  228. text-align: center;
  229. margin-bottom: 30rpx;
  230. }
  231. .popup-text {
  232. font-size: 28rpx;
  233. color: #333;
  234. line-height: 1.6;
  235. margin-bottom: 20rpx;
  236. }
  237. .popup-close {
  238. text-align: center;
  239. color: #1a73e8;
  240. font-size: 28rpx;
  241. margin-top: 30rpx;
  242. padding: 20rpx;
  243. border-top: 1rpx solid #eee;
  244. }
  245. </style>