welfare.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <layout-page>
  3. <view class="box defaultBgc">
  4. <scroll-view class="scrollBox" scroll-y="true">
  5. <view class="content">
  6. <!-- 钱包 -->
  7. <view class="wallet">
  8. <view class="wallet-content">
  9. <view class="wallet-content-member">
  10. <view class="iconBox">
  11. <view class="iconBox-line">
  12. <uni-icons type="vip-filled" size="20" color="#ffbc00"></uni-icons>
  13. </view>
  14. </view>
  15. <view class="name">
  16. <text v-if="useUserStore.isLogin" @tap="toInfo" class="active">
  17. {{ useUserStore?.baseInfo?.name || useUserStore?.userInfo?.phone }}
  18. </text>
  19. <text v-else @tap="handleLogin">点击登录</text>
  20. </view>
  21. </view>
  22. <view class="wallet-content-integral wallet-content-item" @tap="handleTo('integral')">
  23. <text>{{ balance.point || 0 }}</text>
  24. <text class="title">积分</text>
  25. </view>
  26. <view class="wallet-content-cash wallet-content-item" @tap="handleTo('balance')">
  27. <text>{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
  28. <text class="title">余额</text>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 签到 -->
  33. <!-- <view class="signIn">
  34. <view class="signIn-content">
  35. <view class="signIn-content-items">
  36. <view class="item" v-for="(sign, i) in SignItems" :key="sign.day">
  37. <view class="box" :class="{ active: i < continuousDay }">
  38. <uni-icons type="vip" size="30" color="#ffbc00" style="text-align: center;"></uni-icons>
  39. <text class="text">+{{ sign.point }}</text>
  40. </view>
  41. <view class="day">
  42. <text>{{ i === todayNumber ? '今' : '第' + sign.day }}天</text>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="tips">
  47. <button
  48. :disabled="todaySignIn"
  49. :class="{ disabled: todaySignIn }"
  50. @tap="handleSignIn"
  51. >
  52. {{ todaySignIn ? '已签到' : '签到'}}
  53. </button>
  54. </view>
  55. </view>
  56. </view> -->
  57. <!-- 积分规则、积分兑换 -->
  58. <view class="ss-m-t-20">
  59. <uni-section title="积分规则" type="line" style="background-color: #fff;">
  60. <uni-list>
  61. <uni-list-item v-for="(k, i) in integralRules" :key="i" :showArrow="false">
  62. <template v-slot:header>
  63. <text class="ss-m-t-10">{{ k.title }}</text>
  64. </template>
  65. <template v-slot:footer>
  66. <view class="d-flex align-center" style="width: 130px; text-align: start; position: relative;">
  67. <image src="/static/svg/integral.svg" style="width: 30px; height: 30px;"></image>
  68. <view class="color-primary ss-m-l-10">{{ k.point }}</view>
  69. <uni-tag :inverted="true" :text="k.complete ? '已完成' : '未完成'" :type="k.complete ? 'success' : 'error'" style="position: absolute; right: 0;" />
  70. </view>
  71. </template>
  72. </uni-list-item>
  73. </uni-list>
  74. </uni-section>
  75. <view class="ss-m-t-20">
  76. <uni-section title="积分兑换" type="line" style="background-color: #fff;">
  77. <view class="goods" >
  78. <view class="goods-item" v-for="(item,index) in goodsList" :key="index" @tap.stop="handleClickGoods">
  79. <image :src="item.url" class="goods-item-img" mode="widthFix"></image>
  80. <view class="goods-item-name">{{ item.name }}</view>
  81. <view>消耗积分<text class="goods-item-price">{{ item.point }}</text></view>
  82. </view>
  83. </view>
  84. </uni-section>
  85. </view>
  86. </view>
  87. </view>
  88. </scroll-view>
  89. </view>
  90. <uni-popup ref="inputDialog" type="dialog">
  91. <view class="shareQrCodePopupContent">
  92. <view class="ss-m-b-10">请前往网页版门墩儿商城兑换</view>
  93. <uni-link href="https://www.menduner.com/mall" text="点击复制网页地址" color="#00B760" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  94. </view>
  95. </uni-popup>
  96. </layout-page>
  97. </template>
  98. <script setup>
  99. import { ref, watch } from 'vue'
  100. import layoutPage from '@/layout'
  101. import {
  102. // getRewardSignInConfigList,
  103. // getRewardSignInRecordSummary,
  104. // createRewardSignInRecord,
  105. getAccountBalance,
  106. getUserAccount,
  107. } from '@/api/sign'
  108. import { getTaskList } from '@/api/integral'
  109. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  110. import { userStore } from '@/store/user'
  111. import { showAuthModal } from '@/hooks/useModal'
  112. import { showNecessaryInfoPopup } from '@/utils/request'
  113. const inputDialog = ref()
  114. const useUserStore = userStore()
  115. // 设置自定义tabBar选中值
  116. // const SignItems = ref([])
  117. // 积分规则
  118. const integralRules = ref([])
  119. const getTask = async () => {
  120. const { data } = await getTaskList({ mark: '推荐任务', type: 0 })
  121. integralRules.value = data
  122. }
  123. // 商品列表
  124. const goodsList = [
  125. { name: '房券-高端酒店房券', point: 12000, url: 'https://minio.menduner.com/dev/menduner/hotalRoomVoucher.png' },
  126. { name: '门墩儿酒店英语学习年卡', point: 8000, url: 'https://minio.menduner.com/dev/menduner/englishCourses.jpg' },
  127. { name: '红酒-经典年份葡萄酒', point: 5000, url: 'https://minio.menduner.com/dev/menduner/redWine.png' },
  128. { name: '瑞幸咖啡券-瑞幸咖啡精致享受券', point: 2000, url: 'https://minio.menduner.com/dev/menduner/coffee.png' },
  129. { name: '减压捏捏乐', point: 500, url: 'https://minio.menduner.com/dev/menduner/pinchMusic.png' }
  130. ]
  131. onLoad(() => {
  132. wx.showShareMenu({
  133. withShareTicket: true,
  134. menus: ['shareAppMessage', 'shareTimeline']
  135. })
  136. onShareAppMessage(() => {
  137. return {
  138. title: '门墩儿 专注顶尖招聘',
  139. path: '/pages/index/position',
  140. imageUrl: '../../static/img/share-poster.jpg'
  141. }
  142. })
  143. onShareTimeline(() => {
  144. return {
  145. title: '门墩儿 专注顶尖招聘',
  146. path: '/pages/index/position',
  147. imageUrl: '../../static/img/share-poster.jpg'
  148. }
  149. })
  150. })
  151. const handleClickGoods = () => {
  152. // uni.showToast({
  153. // icon: 'none',
  154. // title: '请前往网页版门墩儿商城兑换'
  155. // })
  156. inputDialog.value.open()
  157. }
  158. // 连续签到天数
  159. // const continuousDay = ref(0)
  160. // 今天有无签到
  161. // const todaySignIn = ref(false)
  162. // 今天
  163. // const todayNumber = ref()
  164. const balance = ref({})
  165. watch([() => useUserStore.refreshToken, () => useUserStore.isLogin], () => {
  166. if (useUserStore.isLogin) {
  167. // getSummary()
  168. getBalance()
  169. }
  170. })
  171. onShow(() => {
  172. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  173. const currentTabBar = currentPage?.getTabBar?.();
  174. // 设置当前tab页的下标index
  175. currentTabBar?.setData({ selected: 2 });
  176. init()
  177. })
  178. function init () {
  179. // 获取签到列表
  180. // getSignIn()
  181. // 获取签到信息
  182. // getSummary()
  183. // 获取余额积分
  184. getBalance()
  185. // 获取积分规则列表
  186. getTask()
  187. }
  188. // 获取积分余额
  189. async function getBalance() {
  190. const { data } = await getAccountBalance()
  191. const { data: _data } = await getUserAccount()
  192. balance.value = {
  193. ...data,
  194. point: _data?.point
  195. }
  196. }
  197. // 获取个人签到统计
  198. // async function getSummary() {
  199. // const { data } = await getRewardSignInRecordSummary()
  200. // if (!data) return
  201. // continuousDay.value = data.continuousDay // 连续签到第n天
  202. // todaySignIn.value = data.todaySignIn // 今天有无签到
  203. // todayNumber.value = todaySignIn.value ? continuousDay.value - 1 : continuousDay.value
  204. // }
  205. // 获取签到列表
  206. // async function getSignIn () {
  207. // try {
  208. // const { data } = await getRewardSignInConfigList()
  209. // SignItems.value = data
  210. // } catch (error) {
  211. // }
  212. // }
  213. // 签到
  214. // async function handleSignIn () {
  215. // uni.showLoading({
  216. // title: '正在签到'
  217. // })
  218. // try {
  219. // const { code } = await createRewardSignInRecord()
  220. // if (code !== 0) {
  221. // return
  222. // }
  223. // setTimeout(async () => {
  224. // const { code: _code } = await getSummary()
  225. // if (_code !== 0) {
  226. // return
  227. // }
  228. // uni.showToast({
  229. // title: '签到成功',
  230. // icon: 'success',
  231. // mask: true
  232. // })
  233. // // 更新积分
  234. // getBalance()
  235. // }, 1000)
  236. // } catch (error) {
  237. // } finally {
  238. // uni.hideLoading()
  239. // }
  240. // }
  241. function handleLogin () {
  242. if (!useUserStore.isLogin) {
  243. showAuthModal()
  244. return
  245. }
  246. }
  247. function toInfo () {
  248. uni.navigateTo({
  249. url: '/pagesA/info/index'
  250. })
  251. }
  252. function handleTo (page) {
  253. if (!useUserStore.isLogin) {
  254. showAuthModal()
  255. return
  256. }
  257. if (showNecessaryInfoPopup()) {
  258. uni.showToast({
  259. title: '请先完善基本信息',
  260. icon: 'none'
  261. })
  262. showAuthModal('necessaryInfo')
  263. return
  264. }
  265. uni.navigateTo({
  266. url: `/pagesA/${page}/index`
  267. })
  268. }
  269. </script>
  270. <style scoped lang="scss">
  271. .shareQrCodePopupContent {
  272. width: 75vw;
  273. padding: 40rpx;
  274. margin-bottom: 20rpx;
  275. text-align: center;
  276. background-color: #fff;
  277. }
  278. .box {
  279. overflow: hidden;
  280. height: 100vh;
  281. padding: 20rpx 0 0 0;
  282. box-sizing: border-box;
  283. .scrollBox{
  284. height: 100%;
  285. padding-bottom: 120rpx;
  286. box-sizing: border-box;
  287. }
  288. .content {
  289. padding-bottom: 24rpx;
  290. box-sizing: border-box;
  291. }
  292. .wallet {
  293. box-sizing: border-box;
  294. height: 200rpx;
  295. margin-bottom: 20rpx;
  296. &-content {
  297. display: flex;
  298. height: 100%;
  299. border-radius: 10rpx;
  300. background: #FFF;
  301. &-member {
  302. width: 50%;
  303. display: flex;
  304. align-items: center;
  305. position: relative;
  306. &:after {
  307. content: '';
  308. position: absolute;
  309. width: 4rpx;
  310. height: 30%;
  311. right: 0;
  312. top: 35%;
  313. background: #00B760;
  314. }
  315. .iconBox {
  316. width: 100rpx;
  317. height: 100%;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. &-line {
  322. border: 4rpx solid #ffbc00;
  323. border-radius: 180rpx;
  324. padding: 10rpx;
  325. }
  326. }
  327. .name {
  328. flex: 1;
  329. .actvie {
  330. color: #ffbc00;
  331. }
  332. }
  333. }
  334. &-item {
  335. width: 25%;
  336. display: flex;
  337. flex-direction: column;
  338. align-items: center;
  339. justify-content: center;
  340. .title {
  341. font-size: .85em;
  342. }
  343. }
  344. &-integral {
  345. }
  346. &-cash {
  347. }
  348. }
  349. }
  350. .signIn {
  351. // padding: 0 20rpx;
  352. box-sizing: border-box;
  353. &-content {
  354. border-radius: 10rpx;
  355. background: #FFF;
  356. &-items {
  357. padding: 20rpx 20rpx;
  358. display: flex;
  359. height: 220rpx;
  360. box-sizing: border-box;
  361. .item {
  362. height: 140rpx;
  363. width: 100%;
  364. align-items: center;
  365. justify-content: center;
  366. padding: 0 10rpx;
  367. .box {
  368. height: 100%;
  369. width: 100%;
  370. display: flex;
  371. flex-direction: column;
  372. background: #f2f4f7;
  373. border-radius: 10rpx;
  374. &.active {
  375. color: #fff;
  376. background: rgba(16,137,123, .66);
  377. }
  378. .text {
  379. font-size: .75em;
  380. text-align: center;
  381. }
  382. }
  383. .day {
  384. margin-top: 10rpx;
  385. height: 60rpx;
  386. text-align: center;
  387. font-size: .5em;
  388. }
  389. }
  390. }
  391. .tips {
  392. display: flex;
  393. align-items: center;
  394. justify-content: flex-end;
  395. height: 80rpx;
  396. font-size: .75em;
  397. color: #999;
  398. &-light {
  399. color: #00B760;
  400. padding: 0 10rpx;
  401. }
  402. button {
  403. width: 180rpx;
  404. height: 60rpx;
  405. font-size: 24rpx;
  406. margin: 0 10rpx;
  407. border: unset;
  408. background-color: #00B760;
  409. color: #FFF;
  410. &.disabled {
  411. // background-color: #a7a7a7 !important;
  412. opacity: .5;
  413. }
  414. }
  415. }
  416. }
  417. }
  418. .goods {
  419. padding: 0 15upx;
  420. display: flex;
  421. flex-wrap: wrap;
  422. justify-content: space-between;
  423. &-item {
  424. background: #FFFFFF;
  425. width: 48%;
  426. margin: 10upx 0;
  427. box-sizing: border-box;
  428. &-img {
  429. width: 100%;
  430. height: 250upx;
  431. display: block;
  432. margin: auto;
  433. }
  434. &-price {
  435. padding-top: 10upx;
  436. color: #00B760;
  437. font-size: 32upx;
  438. }
  439. &-name {
  440. width: 100%;
  441. white-space: nowrap;
  442. font-size: 28upx;
  443. line-height: 50upx;
  444. padding-bottom: 10upx;
  445. padding-top: 10upx;
  446. overflow:hidden;
  447. text-overflow:ellipsis;
  448. -webkit-box-orient:vertical;
  449. -webkit-line-clamp:2;
  450. }
  451. }
  452. }
  453. }
  454. :deep(.uni-section .uni-section-header__decoration) {
  455. background-color: #00B760 !important;
  456. }
  457. </style>