welfare.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. }
  137. })
  138. onShow(() => {
  139. const currentPage = getCurrentPages()[0]; // 获取当前页面实例
  140. const currentTabBar = currentPage?.getTabBar?.();
  141. // 设置当前tab页的下标index
  142. currentTabBar?.setData({ selected: 2 });
  143. init()
  144. })
  145. function init () {
  146. // 获取余额积分
  147. getBalance()
  148. // 获取积分规则列表
  149. getTask()
  150. }
  151. // 获取积分余额
  152. async function getBalance() {
  153. const { data } = await getAccountBalance()
  154. const { data: _data } = await getUserAccount()
  155. balance.value = {
  156. ...data,
  157. point: _data?.point
  158. }
  159. }
  160. function handleLogin () {
  161. if (!useUserStore.isLogin) {
  162. showAuthModal()
  163. return
  164. }
  165. }
  166. function handleTo (page) {
  167. if (!useUserStore.isLogin) {
  168. showAuthModal()
  169. return
  170. }
  171. if (showNecessaryInfoPopup()) {
  172. uni.showToast({
  173. title: '请先完善基本信息',
  174. icon: 'none'
  175. })
  176. showAuthModal('necessaryInfo')
  177. return
  178. }
  179. uni.navigateTo({
  180. url: `/pagesA/${page}/index`
  181. })
  182. }
  183. </script>
  184. <style scoped lang="scss">
  185. .enterAvatar {
  186. width: 100rpx;
  187. height: 100rpx;
  188. border-radius: 50%;
  189. margin: 0 auto;
  190. }
  191. .avatar-tips {
  192. position: absolute;
  193. bottom: 3rpx;
  194. left: 50%;
  195. transform: translateX(-50%);
  196. width: 60rpx;
  197. height: 38rpx;
  198. line-height: 38rpx;
  199. color: #fff;
  200. text-align: center;
  201. font-family: MiSans-Medium;
  202. background-color: #00B760;
  203. border-radius: 20rpx;
  204. }
  205. .septal-line {
  206. height: 60rpx;
  207. border-left: 3px dashed #DDDDDD;
  208. }
  209. .shareQrCodePopupContent {
  210. width: 75vw;
  211. padding: 40rpx;
  212. margin-bottom: 20rpx;
  213. text-align: center;
  214. background-color: #fff;
  215. border-radius: 20rpx;
  216. }
  217. .box {
  218. height: 100vh;
  219. padding: 20rpx 0 0 0;
  220. box-sizing: border-box;
  221. .scrollBox{
  222. height: 100%;
  223. padding-bottom: 120rpx;
  224. box-sizing: border-box;
  225. }
  226. .content {
  227. padding-bottom: 24rpx;
  228. box-sizing: border-box;
  229. }
  230. .wallet {
  231. box-sizing: border-box;
  232. &-content {
  233. display: flex;
  234. height: 100%;
  235. border-radius: 10rpx;
  236. align-items: center;
  237. &-member {
  238. width: 20%;
  239. .name {
  240. margin-left: 50rpx;
  241. }
  242. }
  243. &-item {
  244. width: 40%;
  245. display: flex;
  246. flex-direction: column;
  247. align-items: center;
  248. justify-content: center;
  249. .title {
  250. font-size: .85em;
  251. }
  252. }
  253. }
  254. }
  255. .points {
  256. height: 282rpx;
  257. margin: 30rpx;
  258. padding: 30rpx;
  259. background-color: #fff;
  260. border-radius: 20rpx;
  261. &-item {
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. height: 90rpx;
  266. line-height: 90rpx;
  267. border-radius: 20rpx;
  268. padding: 0 20rpx;
  269. margin-bottom: 20rpx;
  270. &:last-child {
  271. margin-bottom: 0;
  272. }
  273. &-text {
  274. font-family: MiSans-Medium;
  275. font-size: 28rpx;
  276. }
  277. .icon-img {
  278. width: 50rpx;
  279. height: 50rpx;
  280. margin-right: 20rpx;
  281. }
  282. }
  283. }
  284. .goods {
  285. padding: 30rpx;
  286. margin: 0 30rpx 30rpx 30rpx;
  287. background-color: #fff;
  288. border-radius: 20rpx;
  289. .goods-box {
  290. display: flex;
  291. flex-wrap: wrap;
  292. justify-content: space-between;
  293. &-item {
  294. width: 48%;
  295. margin: 10upx 0;
  296. box-sizing: border-box;
  297. border-radius: 20rpx;
  298. box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  299. &-img {
  300. width: 100%;
  301. height: 305rpx;
  302. display: block;
  303. margin: auto;
  304. border-radius: 20rpx 20rpx 0 0;
  305. }
  306. &-price {
  307. color: #00B760;
  308. font-size: 26rpx;
  309. font-family: MiSans-Semibold;
  310. margin-left: 20rpx;
  311. }
  312. &-name {
  313. font-family: MiSans-Medium;
  314. font-size: 26rpx;
  315. padding: 20rpx 30rpx;
  316. height: 65rpx;
  317. overflow:hidden;
  318. text-overflow:ellipsis;
  319. -webkit-box-orient:vertical;
  320. -webkit-line-clamp:2;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. </style>