welfare.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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: '../../static/img/share-poster.jpg'
  118. }
  119. })
  120. onShareTimeline(() => {
  121. return {
  122. title: '门墩儿 专注顶尖招聘',
  123. path: '/pages/index/position',
  124. imageUrl: '../../static/img/share-poster.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. // getSummary()
  135. getBalance()
  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 toInfo () {
  167. uni.navigateTo({
  168. url: '/pagesA/info/index'
  169. })
  170. }
  171. function handleTo (page) {
  172. if (!useUserStore.isLogin) {
  173. showAuthModal()
  174. return
  175. }
  176. if (showNecessaryInfoPopup()) {
  177. uni.showToast({
  178. title: '请先完善基本信息',
  179. icon: 'none'
  180. })
  181. showAuthModal('necessaryInfo')
  182. return
  183. }
  184. uni.navigateTo({
  185. url: `/pagesA/${page}/index`
  186. })
  187. }
  188. </script>
  189. <style scoped lang="scss">
  190. .enterAvatar {
  191. width: 100rpx;
  192. height: 100rpx;
  193. border-radius: 50%;
  194. margin: 0 auto;
  195. }
  196. .avatar-tips {
  197. position: absolute;
  198. bottom: 3rpx;
  199. left: 50%;
  200. transform: translateX(-50%);
  201. width: 60rpx;
  202. height: 38rpx;
  203. line-height: 38rpx;
  204. color: #fff;
  205. text-align: center;
  206. font-family: MiSans-Medium;
  207. background-color: #00B760;
  208. border-radius: 20rpx;
  209. }
  210. .septal-line {
  211. height: 60rpx;
  212. border-left: 3px dashed #DDDDDD;
  213. }
  214. .shareQrCodePopupContent {
  215. width: 75vw;
  216. padding: 40rpx;
  217. margin-bottom: 20rpx;
  218. text-align: center;
  219. background-color: #fff;
  220. border-radius: 20rpx;
  221. }
  222. .box {
  223. height: 100vh;
  224. padding: 20rpx 0 0 0;
  225. box-sizing: border-box;
  226. .scrollBox{
  227. height: 100%;
  228. padding-bottom: 120rpx;
  229. box-sizing: border-box;
  230. }
  231. .content {
  232. padding-bottom: 24rpx;
  233. box-sizing: border-box;
  234. }
  235. .wallet {
  236. box-sizing: border-box;
  237. &-content {
  238. display: flex;
  239. height: 100%;
  240. border-radius: 10rpx;
  241. align-items: center;
  242. &-member {
  243. width: 20%;
  244. .name {
  245. margin-left: 50rpx;
  246. }
  247. }
  248. &-item {
  249. width: 40%;
  250. display: flex;
  251. flex-direction: column;
  252. align-items: center;
  253. justify-content: center;
  254. .title {
  255. font-size: .85em;
  256. }
  257. }
  258. }
  259. }
  260. .points {
  261. height: 282rpx;
  262. margin: 30rpx;
  263. padding: 30rpx;
  264. background-color: #fff;
  265. border-radius: 20rpx;
  266. &-item {
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. height: 90rpx;
  271. line-height: 90rpx;
  272. border-radius: 20rpx;
  273. padding: 0 20rpx;
  274. margin-bottom: 20rpx;
  275. &:last-child {
  276. margin-bottom: 0;
  277. }
  278. &-text {
  279. font-family: MiSans-Medium;
  280. font-size: 28rpx;
  281. }
  282. .icon-img {
  283. width: 50rpx;
  284. height: 50rpx;
  285. margin-right: 20rpx;
  286. }
  287. }
  288. }
  289. .goods {
  290. padding: 30rpx;
  291. margin: 0 30rpx 30rpx 30rpx;
  292. background-color: #fff;
  293. border-radius: 20rpx;
  294. .goods-box {
  295. display: flex;
  296. flex-wrap: wrap;
  297. justify-content: space-between;
  298. &-item {
  299. width: 48%;
  300. margin: 10upx 0;
  301. box-sizing: border-box;
  302. border-radius: 20rpx;
  303. box-shadow: 1px 2px 12px rgba(0, 0, 0, 0.17);
  304. &-img {
  305. width: 100%;
  306. height: 305rpx;
  307. display: block;
  308. margin: auto;
  309. border-radius: 20rpx 20rpx 0 0;
  310. }
  311. &-price {
  312. color: #00B760;
  313. font-size: 26rpx;
  314. font-family: MiSans-Semibold;
  315. margin-left: 20rpx;
  316. }
  317. &-name {
  318. font-family: MiSans-Medium;
  319. font-size: 26rpx;
  320. padding: 20rpx 30rpx;
  321. height: 65rpx;
  322. overflow:hidden;
  323. text-overflow:ellipsis;
  324. -webkit-box-orient:vertical;
  325. -webkit-line-clamp:2;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. </style>