index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <app-view class="credit-signin">
  3. <template #header>
  4. <app-navbar title="我的任务" @ready="onReady" />
  5. </template>
  6. <div ref="headerRef" class="credit-signin__header">
  7. <div class="credit-signin__header-wrapper g-block--bg">
  8. <div class="integral">
  9. <div class="integral-balance">
  10. {{ userAccount.curscore ?? 0 }}
  11. </div>
  12. <div class="integral-title">
  13. <img src="@mobile/assets/icons/gold.png" />
  14. <span>积分余额</span>
  15. </div>
  16. </div>
  17. <div class="iconbar">
  18. <ul>
  19. <li @click="userSignin">
  20. <img src="@mobile/assets/icons/schedule.svg" />
  21. <span v-if="userAccount.issigned">已签到</span>
  22. <span v-else>签到</span>
  23. </li>
  24. <li>
  25. <img src="@mobile/assets/icons/red-envelope.svg" @click="routerTo('credit-lottery')" />
  26. <span>积分红包</span>
  27. </li>
  28. <li>
  29. <img src="@mobile/assets/icons/statement.svg" @click="routerTo('credit-statement')" />
  30. <span>积分流水</span>
  31. </li>
  32. </ul>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="credit-signin__task">
  37. <dl class="list">
  38. <dt class="list-title">积分任务</dt>
  39. <dd class="list-item">
  40. <div class="list-item__title">
  41. <div class="title-icon">
  42. <img src="@mobile/assets/icons/signin.png" />
  43. </div>
  44. <div class="title-content">
  45. <span>每日签到</span>
  46. <span>积分+{{ getScoreConfig(2) }}</span>
  47. </div>
  48. </div>
  49. </dd>
  50. <dd class="list-item">
  51. <div class="list-item__title">
  52. <div class="title-icon">
  53. <img src="@mobile/assets/icons/friend.png" />
  54. </div>
  55. <div class="title-content">
  56. <span>好友下单每次</span>
  57. <span>积分+{{ getScoreConfig(4) }}</span>
  58. </div>
  59. </div>
  60. </dd>
  61. <dd class="list-item">
  62. <div class="list-item__title">
  63. <div class="title-icon">
  64. <img src="@mobile/assets/icons/useradd.png" />
  65. </div>
  66. <div class="title-content">
  67. <span>邀请新人注册</span>
  68. <span>积分+{{ getScoreConfig(3) }}</span>
  69. </div>
  70. </div>
  71. <div class="list-item__button">
  72. <Button type="primary" @click="showQRCode = true" round>去完成</Button>
  73. </div>
  74. </dd>
  75. <dd class="list-item">
  76. <div class="list-item__title">
  77. <div class="title-icon">
  78. <img src="@mobile/assets/icons/cart.png" />
  79. </div>
  80. <div class="title-content">
  81. <span>采购下单每次</span>
  82. <span>积分+{{ getScoreConfig(5) }}</span>
  83. </div>
  84. </div>
  85. <div class="list-item__button">
  86. <Button type="primary" round @click="navigationBack(1)">去完成</Button>
  87. </div>
  88. </dd>
  89. <dd class="list-item">
  90. <div class="list-item__title">
  91. <div class="title-icon">
  92. <img src="@mobile/assets/icons/goods.png" />
  93. </div>
  94. <div class="title-content">
  95. <span>现货下单每次</span>
  96. <span>积分+{{ getScoreConfig(6) }}</span>
  97. </div>
  98. </div>
  99. <div class="list-item__button">
  100. <Button type="primary" round @click="navigationBack(2)">去完成</Button>
  101. </div>
  102. </dd>
  103. </dl>
  104. </div>
  105. <app-register-code v-model:show="showQRCode" :text="userAccount.refernum" />
  106. </app-view>
  107. </template>
  108. <script lang="ts" setup>
  109. import { shallowRef, onActivated } from 'vue'
  110. import { showSuccessToast, showFailToast, Button } from 'vant'
  111. import { fullloading } from '@/utils/vant'
  112. import { useLoginStore } from '@/stores'
  113. import { queryUserAccount } from '@/services/api/account'
  114. import { queryTHJScoreConfig } from '@/services/api/credit'
  115. import { signin } from '@/services/api/common'
  116. import { useNavigation } from '@/hooks/navigation'
  117. import AppRegisterCode from '@mobile/components/modules/register-code/index.vue'
  118. const { routerTo, routerBack } = useNavigation()
  119. const loginStore = useLoginStore()
  120. const headerRef = shallowRef<HTMLDivElement>()
  121. const userAccount = shallowRef<Partial<Model.UserAccount>>({})
  122. const scoreConfig = shallowRef<Model.THJScoreConfigRsp[]>([])
  123. const showQRCode = shallowRef(false)
  124. const onReady = (el: HTMLDivElement) => {
  125. // 设置背景图位置
  126. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  127. }
  128. // 获取积分配置
  129. const getScoreConfig = (value: number) => {
  130. const item = scoreConfig.value.find((e) => e.scoreconfigtype === value)
  131. return item?.parma1 ?? 0
  132. }
  133. // 页面返回
  134. const navigationBack = (index: number) => {
  135. routerBack({ tabIndex: index })
  136. }
  137. const userSignin = () => {
  138. fullloading(() => {
  139. signin({
  140. userid: loginStore.userId
  141. }).then((res) => {
  142. if (res.data.signinstatus === 1) {
  143. getUserAccount()
  144. showSuccessToast('签到成功')
  145. } else {
  146. showFailToast('今日已签到')
  147. }
  148. }).catch(() => {
  149. showFailToast('签到失败')
  150. })
  151. }, '签到中...')
  152. }
  153. const getUserAccount = () => {
  154. queryUserAccount({
  155. userID: loginStore.userId
  156. }).then((res) => {
  157. userAccount.value = res.data
  158. })
  159. }
  160. queryTHJScoreConfig().then((res) => {
  161. scoreConfig.value = res.data
  162. })
  163. onActivated(() => getUserAccount())
  164. </script>
  165. <style lang="less">
  166. @import './index.less';
  167. </style>