welfare.vue 9.9 KB

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