welfare.vue 9.8 KB

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