welfare.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <view>
  3. <Navbar title="会员福利" />
  4. <layout-page>
  5. <view :style="{'padding-top': navbarHeight + 'px'}">
  6. <view class="commonBackground"></view>
  7. <view class="box defaultBgc">
  8. <scroll-view class="scrollBox" scroll-y="true">
  9. <view class="content">
  10. <!-- 钱包 -->
  11. <view class="wallet">
  12. <view class="wallet-content">
  13. <view class="wallet-content-member">
  14. <view class="name">
  15. <view v-if="useUserStore.isLogin" style="position: relative;">
  16. <image class="enterAvatar"
  17. :src="getUserAvatar(useUserStore?.baseInfo?.avatar, useUserStore?.baseInfo?.sex)"
  18. ></image>
  19. <view class="avatar-tips">我</view>
  20. </view>
  21. <text v-else class="MiSans-Semibold default-text-color" style="font-size: 38rpx;" @tap="handleLogin">点击登录</text>
  22. </view>
  23. </view>
  24. <view class="wallet-content-integral wallet-content-item" @tap="handleTo('integral')">
  25. <text class="MiSans-Semibold" style="font-size: 40rpx;">{{ balance.point || 0 }}</text>
  26. <text class="title MiSans-Normal">积分</text>
  27. </view>
  28. <view class="septal-line"></view>
  29. <view class="wallet-content-cash wallet-content-item" @tap="handleTo('balance')">
  30. <text class="MiSans-Semibold" style="font-size: 40rpx;">{{ balance.balance > 0 ? (balance?.balance / 100.0).toFixed(2) : 0 }}</text>
  31. <text class="title MiSans-Normal">余额</text>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 积分规则 -->
  36. <view class="points">
  37. <view class="MiSans-Semibold default-text-color" style="font-size: 30rpx; margin-bottom: 30rpx;">积分规则</view>
  38. <view v-for="(k, i) in integralRules" :key="i" class="points-item list-item-bgc default-border">
  39. <view class="d-flex align-center">
  40. <image class="icon-img" src="https://minio.menduner.com/dev/112bdf67dea1505a8d063f22b560a21891631dc7294526488d7f82009d716229.png"></image>
  41. <text class="points-item-text">{{ k.title }}</text>
  42. </view>
  43. <view class="points-item-text color-primary">
  44. {{ k.point }}({{ k.complete ? '已完成' : '未完成' }})
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 积分兑换 -->
  49. <view class="goods">
  50. <view class="MiSans-Semibold default-text-color" style="font-size: 30rpx; margin-bottom: 30rpx;">积分兑换</view>
  51. <view class="goods-box">
  52. <view class="goods-box-item list-item-bgc" v-for="(item,index) in goodsList" :key="index" @tap.stop="handleClickGoods">
  53. <image :src="item.url" class="goods-box-item-img" mode="widthFix"></image>
  54. <view class="default-border" style="border-radius: 0 0 20rpx 20rpx; border-top: none;">
  55. <view class="goods-box-item-name">{{ item.name }}</view>
  56. <view style="padding: 0 30rpx 20rpx 30rpx;">
  57. <text class="MiSans-Normal color-666" style="font-size: 24rpx">消费积分</text>
  58. <text class="goods-box-item-price">{{ item.point }}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </scroll-view>
  66. </view>
  67. </view>
  68. </layout-page>
  69. <uni-popup ref="inputDialog" type="dialog">
  70. <view class="shareQrCodePopupContent">
  71. <view class="ss-m-b-10 MiSans-Normal">请前往网页版门墩儿商城兑换</view>
  72. <uni-link class="MiSans-Normal" href="https://www.menduner.com/mall" text="点击复制网页地址" color="#00B760" fontSize="16" copyTips="已复制,请在电脑端打开"></uni-link>
  73. </view>
  74. </uni-popup>
  75. </view>
  76. </template>
  77. <script setup>
  78. import { ref, watch } from 'vue'
  79. import layoutPage from '@/layout'
  80. import Navbar from '@/components/Navbar'
  81. import {
  82. getAccountBalance,
  83. getUserAccount,
  84. } from '@/api/sign'
  85. import { getTaskList } from '@/api/integral'
  86. import { onShow, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
  87. import { userStore } from '@/store/user'
  88. import { showAuthModal } from '@/hooks/useModal'
  89. import { showNecessaryInfoPopup } from '@/utils/request'
  90. import { getUserAvatar } from '@/utils/avatar'
  91. const navbarHeight = ref(uni.getStorageSync('navbarHeight'))
  92. const inputDialog = ref()
  93. const useUserStore = userStore()
  94. // 积分规则
  95. const integralRules = ref([])
  96. const getTask = async () => {
  97. const { data } = await getTaskList({ mark: '推荐任务', type: 0 })
  98. integralRules.value = data
  99. }
  100. // 商品列表
  101. const goodsList = [
  102. { name: '房券-高端酒店房券', point: 12000, url: 'https://minio.menduner.com/dev/menduner/hotalRoomVoucher.png' },
  103. { name: '门墩儿酒店英语学习年卡', point: 8000, url: 'https://minio.menduner.com/dev/menduner/englishCourses.jpg' },
  104. { name: '红酒-经典年份葡萄酒', point: 5000, url: 'https://minio.menduner.com/dev/menduner/redWine.png' },
  105. { name: '瑞幸咖啡券-瑞幸咖啡精致享受券', point: 2000, url: 'https://minio.menduner.com/dev/menduner/coffee.png' },
  106. { name: '减压捏捏乐', point: 500, url: 'https://minio.menduner.com/dev/menduner/pinchMusic.png' }
  107. ]
  108. onLoad(() => {
  109. wx.showShareMenu({
  110. withShareTicket: true,
  111. menus: ['shareAppMessage', 'shareTimeline']
  112. })
  113. onShareAppMessage(() => {
  114. return {
  115. title: '门墩儿 专注顶尖招聘',
  116. path: '/pages/index/position',
  117. imageUrl: 'https://minio.menduner.com/dev/89f171b91e3056a700d80b26a9dbb4cd6e9677b3f3b4f036a2127f5d5023e9d3.jpg'
  118. }
  119. })
  120. onShareTimeline(() => {
  121. return {
  122. title: '门墩儿 专注顶尖招聘',
  123. path: '/pages/index/position',
  124. imageUrl: 'https://minio.menduner.com/dev/89f171b91e3056a700d80b26a9dbb4cd6e9677b3f3b4f036a2127f5d5023e9d3.jpg'
  125. }
  126. })
  127. })
  128. const handleClickGoods = () => {
  129. inputDialog.value.open()
  130. }
  131. const balance = ref({})
  132. watch([() => useUserStore.refreshToken, () => useUserStore.isLogin], () => {
  133. if (useUserStore.isLogin) {
  134. getBalance()
  135. getTask()
  136. } else {
  137. integralRules.value = []
  138. }
  139. })
  140. onShow(() => {
  141. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  142. const currentTabBar = currentPage?.getTabBar?.();
  143. // 设置当前tab页的下标index
  144. currentTabBar?.setData({ selected: 2 });
  145. init()
  146. })
  147. function init () {
  148. // 获取余额积分
  149. getBalance()
  150. // 获取积分规则列表
  151. getTask()
  152. }
  153. // 获取积分余额
  154. async function getBalance() {
  155. const { data } = await getAccountBalance()
  156. const { data: _data } = await getUserAccount()
  157. balance.value = {
  158. ...data,
  159. point: _data?.point
  160. }
  161. }
  162. function handleLogin () {
  163. if (!useUserStore.isLogin) {
  164. showAuthModal()
  165. return
  166. }
  167. }
  168. function handleTo (page) {
  169. if (!useUserStore.isLogin) {
  170. showAuthModal()
  171. return
  172. }
  173. if (showNecessaryInfoPopup()) {
  174. uni.showToast({
  175. title: '请先完善基本信息',
  176. icon: 'none'
  177. })
  178. showAuthModal('necessaryInfo')
  179. return
  180. }
  181. uni.navigateTo({
  182. url: `/pagesA/${page}/index`
  183. })
  184. }
  185. </script>
  186. <style scoped lang="scss">
  187. .enterAvatar {
  188. width: 100rpx;
  189. height: 100rpx;
  190. border-radius: 50%;
  191. margin: 0 auto;
  192. }
  193. .avatar-tips {
  194. position: absolute;
  195. bottom: 3rpx;
  196. left: 50%;
  197. transform: translateX(-50%);
  198. width: 60rpx;
  199. height: 38rpx;
  200. line-height: 38rpx;
  201. color: #fff;
  202. text-align: center;
  203. font-family: MiSans-Medium;
  204. background-color: #00B760;
  205. border-radius: 20rpx;
  206. }
  207. .septal-line {
  208. height: 60rpx;
  209. border-left: 3px dashed #DDDDDD;
  210. }
  211. .shareQrCodePopupContent {
  212. width: 75vw;
  213. padding: 40rpx;
  214. margin-bottom: 20rpx;
  215. text-align: center;
  216. background-color: #fff;
  217. border-radius: 20rpx;
  218. }
  219. .box {
  220. height: 100vh;
  221. padding: 20rpx 0 0 0;
  222. box-sizing: border-box;
  223. .scrollBox{
  224. height: 100%;
  225. padding-bottom: 120rpx;
  226. box-sizing: border-box;
  227. }
  228. .content {
  229. padding-bottom: 24rpx;
  230. box-sizing: border-box;
  231. }
  232. .wallet {
  233. box-sizing: border-box;
  234. &-content {
  235. display: flex;
  236. height: 100%;
  237. border-radius: 10rpx;
  238. align-items: center;
  239. &-member {
  240. width: 20%;
  241. .name {
  242. margin-left: 50rpx;
  243. }
  244. }
  245. &-item {
  246. width: 40%;
  247. display: flex;
  248. flex-direction: column;
  249. align-items: center;
  250. justify-content: center;
  251. .title {
  252. font-size: .85em;
  253. }
  254. }
  255. }
  256. }
  257. .points {
  258. height: 282rpx;
  259. margin: 30rpx;
  260. padding: 30rpx;
  261. background-color: #fff;
  262. border-radius: 20rpx;
  263. &-item {
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. height: 90rpx;
  268. line-height: 90rpx;
  269. border-radius: 20rpx;
  270. padding: 0 20rpx;
  271. margin-bottom: 20rpx;
  272. &:last-child {
  273. margin-bottom: 0;
  274. }
  275. &-text {
  276. font-family: MiSans-Medium;
  277. font-size: 28rpx;
  278. }
  279. .icon-img {
  280. width: 50rpx;
  281. height: 50rpx;
  282. margin-right: 20rpx;
  283. }
  284. }
  285. }
  286. .goods {
  287. padding: 30rpx;
  288. margin: 0 30rpx 30rpx 30rpx;
  289. background-color: #fff;
  290. border-radius: 20rpx;
  291. .goods-box {
  292. display: flex;
  293. flex-wrap: wrap;
  294. justify-content: space-between;
  295. &-item {
  296. width: 48%;
  297. margin: 10upx 0;
  298. box-sizing: border-box;
  299. border-radius: 20rpx;
  300. box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  301. &-img {
  302. width: 100%;
  303. height: 305rpx;
  304. display: block;
  305. margin: auto;
  306. border-radius: 20rpx 20rpx 0 0;
  307. }
  308. &-price {
  309. color: #00B760;
  310. font-size: 26rpx;
  311. font-family: MiSans-Semibold;
  312. margin-left: 20rpx;
  313. }
  314. &-name {
  315. font-family: MiSans-Medium;
  316. font-size: 26rpx;
  317. padding: 20rpx 30rpx;
  318. height: 65rpx;
  319. overflow:hidden;
  320. text-overflow:ellipsis;
  321. -webkit-box-orient:vertical;
  322. -webkit-line-clamp:2;
  323. }
  324. }
  325. }
  326. }
  327. }
  328. </style>