mine.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <template>
  2. <layout>
  3. <view class="container">
  4. <view class="my-background">
  5. <view class="user-top">
  6. <view class="flex justify-between p-3 align-center">
  7. <view class="flex">
  8. <image :src="isLogin ? member.avatar ? member.avatar : '/static/images/logo.png' : '/static/images/logo.png'"
  9. class="rounded-circle avatar-img" @tap="serv({type:'pages',pages:'/pages/components/pages/mine/userinfo'})"></image>
  10. <view class="flex flex-column text-white justify-center align-cente ml-2" v-if="isLogin">
  11. <text class="nick-text">{{ member.nickname }}</text>
  12. <text class="id-text">用户id:{{ member.id }}</text>
  13. </view>
  14. <view class="flex flex-column justify-center align-cente ml-2" v-else @tap="login">
  15. <text class="nick-text"><text style="color:#059825;">去登录</text>获取更多会员权益</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="vip-box" v-if="isLogin">
  20. <view class="vip-box-content py-3 px-2 flex-column" v-if="member.cardId > 0">
  21. <view class=" flex justify-between align-center px-3 " @tap="goVip">
  22. <view class="flex align-center">
  23. <image src="/static/images/mine/vip.png" class="icon-img"></image>
  24. <view class="text-white font-size-smaller ml-1">{{ member.cardName }}</view>
  25. </view>
  26. <view class="text-white font-size-smaller"><view class="vip-btn2">查看详情</view></view>
  27. </view>
  28. </view>
  29. <view class="vip-box-content py-4 px-2" v-else>
  30. <view class="vip-box-left flex align-center justify-center">
  31. <view class="flex flex-column w-30 align-center ">
  32. <view style="width: 60rpx;height: 70rpx;"><image src="/static/images/c1.png" style="width: 58rpx;height: 58rpx;"></image> </view>
  33. <text class="font-size-smaller ">赠送积分</text>
  34. </view>
  35. <view class="flex flex-column w-30 align-center justify-center">
  36. <view style="width: 60rpx;height: 70rpx;"><image src="/static/images/c3.png" style="width: 60rpx;height: 58rpx;"></image></view>
  37. <text class="font-size-smaller ">享受折扣</text>
  38. </view>
  39. <view class="flex flex-column w-30 align-center">
  40. <view style="width: 60rpx;height: 70rpx;"><image src="/static/images/c2.png" style="width: 60rpx;height: 60rpx;"></image></view>
  41. <text class="font-size-smaller ">赠送余额</text>
  42. </view>
  43. </view>
  44. <view class="vip-box-right flex align-center justify-center " @tap="goVip">
  45. <view class="vip-btn">升级尊享</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="px-3 mt-1">
  51. <!-- user box begin -->
  52. <view class="d-flex flex-column bg-white user-box">
  53. <!-- user grid begin -->
  54. <view class="w-100 d-flex align-items-center just-content-center">
  55. <view class="user-grid" @tap="serv({type:'pages',pages:'/pages/components/pages/coupons/coupons'})">
  56. <view class="value font-size-extra-lg font-weight-bold text-color-base">
  57. {{ isLogin ? member.couponCount : 0}}
  58. </view>
  59. <view class="font-size-sm text-color-assist">优惠券</view>
  60. </view>
  61. <view><uv-line direction="col" length="50"></uv-line></view>
  62. <view class="user-grid" @tap="serv({type:'pages', pages: '/pages/components/pages/balance/bill?cate=1'})">
  63. <view class="value font-size-extra-lg font-weight-bold text-color-base">
  64. {{ isLogin ? member.integral : 0 }}
  65. </view>
  66. <view class="font-size-sm text-color-assist">积分</view>
  67. </view>
  68. <view><uv-line direction="col" length="50"></uv-line></view>
  69. <view class="user-grid" @tap="serv({type:'pages',pages:'/pages/components/pages/balance/balance'})">
  70. <view class="value font-size-extra-lg font-weight-bold text-color-base">
  71. {{ isLogin ? member.nowMoney : 0 }}
  72. </view>
  73. <view class="font-size-sm text-color-assist">余额</view>
  74. </view>
  75. </view>
  76. <!-- user grid end -->
  77. </view>
  78. <!-- user box end -->
  79. </view>
  80. <view class="px-3 mt-1">
  81. <!-- user box begin -->
  82. <view class="d-flex flex-column bg-white user-box">
  83. <!-- user grid begin -->
  84. <view class="w-100 d-flex align-items-center just-content-center py-2">
  85. <view class="w-50 flex justify-center align-center" @tap="toDetail('/pages/components/pages/orders/orders',99)">
  86. <view class="">
  87. <image src="/static/images/my_order.png" style="height: 80rpx;width: 70rpx;"></image>
  88. </view>
  89. <view class="flex flex-column justify-center align-center">
  90. <text>我的订单</text>
  91. <text class=" text-color-assist mt-1" style="font-size: 20rpx;">这里查看你的订单</text>
  92. </view>
  93. </view>
  94. <view><uv-line direction="col" length="50"></uv-line></view>
  95. <view class="w-50 flex justify-center align-center" @tap="toDetail('/pages/components/pages/coupons/coupons',4)">
  96. <view class="">
  97. <image src="/static/images/my_coupon.png" style="height: 70rpx;width: 75rpx;"></image>
  98. </view>
  99. <view class="flex flex-column justify-center align-center">
  100. <text>领劵中心</text>
  101. <text class=" text-color-assist mt-1" style="font-size: 20rpx;">用券购买更划算</text>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- user grid end -->
  106. </view>
  107. <!-- user box end -->
  108. </view>
  109. </view>
  110. <!-- service box begin -->
  111. <view class="service-box">
  112. <view class="font-size-lg text-color-base font-weight-bold" style="margin-bottom: 50rpx;">我的服务</view>
  113. <view class="u-m-t-20">
  114. <uv-grid :border="false" :col="4">
  115. <block v-for="(item,index) in services" :key="index">
  116. <uv-grid-item v-if="item.type == 'call'" v-on:click="makePhoneCall(item.phone)" :customStyle="{paddingBottom:50+'rpx'}">
  117. <image :src="item.image" style="width: 40rpx;height: 40rpx;" ></image>
  118. <text class="font-size-sm text-color-assist my-2">{{item.name}}</text>
  119. </uv-grid-item>
  120. <uv-grid-item v-else @tap="serv(item)" :customStyle="{paddingBottom:50+'rpx'}">
  121. <image :src="item.image" style="width: 40rpx;height: 40rpx;" ></image>
  122. <text class="font-size-sm text-color-assist my-2">{{item.name}}</text>
  123. </uv-grid-item>
  124. </block>
  125. </uv-grid>
  126. </view>
  127. </view>
  128. </view>
  129. </layout>
  130. </template>
  131. <script setup>
  132. import {
  133. ref,
  134. computed
  135. } from 'vue'
  136. import { useMainStore } from '@/store/store'
  137. import { storeToRefs } from 'pinia'
  138. import { onLoad,onShow} from '@dcloudio/uni-app'
  139. import { formatDateTime,kmUnit } from '@/utils/util'
  140. import {
  141. userGetUserInfo,
  142. mineService
  143. } from '@/api/user'
  144. import {
  145. check
  146. } from '@/api/merchant'
  147. const main = useMainStore()
  148. const { member,isLogin } = storeToRefs(main)
  149. const title = ref('个人中心')
  150. const services = ref([])
  151. const growthValue = computed(() => {
  152. if (!isLogin.value) return 0
  153. const {
  154. currentValue,
  155. needValue
  156. } = member.value
  157. return currentValue / (currentValue + needValue) * 100
  158. })
  159. onLoad(() => {
  160. getServices();
  161. })
  162. onShow(() => {
  163. getUserInfo();
  164. })
  165. const toDetail = (page,index) => {
  166. uni.navigateTo({
  167. url: page + '?current=' + index
  168. })
  169. }
  170. const getUserInfo = async() => {
  171. if (isLogin.value) {
  172. let data = await userGetUserInfo();
  173. if (data) {
  174. main.SET_MEMBER(data);
  175. }
  176. }
  177. }
  178. const getServices = async() => {
  179. let data = await mineService();
  180. if (data) {
  181. services.value = data;
  182. }
  183. }
  184. const makePhoneCall = (phoneNumber) => {
  185. uni.makePhoneCall({
  186. phoneNumber: phoneNumber,
  187. })
  188. }
  189. const login = () => {
  190. uni.navigateTo({
  191. url: '/pages/components/pages/login/login'
  192. })
  193. }
  194. // const packages = () => {
  195. // if (!isLogin.value) {
  196. // login()
  197. // return
  198. // }
  199. // uni.navigateTo({
  200. // url: '/pages/components/pages/packages/index'
  201. // })
  202. //}
  203. const serv = async(item) => {
  204. switch (item.type) {
  205. case 'pages':
  206. if(item.pages == 'no'){
  207. uni.showToast({
  208. title: '开发中......',
  209. icon: 'error'
  210. })
  211. return
  212. }
  213. if (!isLogin.value) {
  214. login()
  215. return
  216. }
  217. if(item.pages == '/pages/components/pages/merchant/index'){
  218. let res = await check()
  219. if(res == 9999){
  220. uni.showModal({
  221. title: '提示',
  222. content: '演示环境:进入默认yshop店铺商家,确定进入?',
  223. success: function (res) {
  224. if (res.confirm) {
  225. uni.navigateTo({
  226. url: item.pages
  227. })
  228. } else if (res.cancel) {
  229. return
  230. }
  231. }
  232. });
  233. return
  234. }
  235. if(!res){
  236. return
  237. }
  238. }
  239. uni.navigateTo({
  240. url: item.pages
  241. })
  242. break;
  243. case 'miniprogram':
  244. uni.navigateToMiniProgram({
  245. appId: item.app_id
  246. })
  247. break;
  248. case 'menu':
  249. uni.navigateTo({
  250. url: '/pages/components/pages/mine/service?id=' + item.id + '&name=' + item.name
  251. })
  252. break;
  253. case 'content':
  254. uni.navigateTo({
  255. url: '/pages/components/pages/mine/content?id=' + item.id + '&name=' + item.name
  256. })
  257. break;
  258. }
  259. }
  260. const goVip = () => {
  261. if(member.value.cardId > 0){
  262. uni.navigateTo({
  263. url: '/pages/components/pages/vip/detail?id=' + member.value.cardId
  264. })
  265. }else{
  266. uni.navigateTo({
  267. url: '/pages/components/pages/vip/vip'
  268. })
  269. }
  270. }
  271. </script>
  272. <style lang="scss" scoped>
  273. page {
  274. height: auto;
  275. min-height: 100%;
  276. }
  277. .user-top{
  278. padding-top: calc(30rpx + var(--status-bar-height));
  279. }
  280. .my-background {
  281. position: relative;
  282. width: 100%;
  283. background: linear-gradient(180deg, #b7edcb 0, #ffffff 100%, #ffffff 100%) !important
  284. }
  285. .avatar-img {
  286. width: 100rpx;
  287. height: 100rpx;
  288. }
  289. .nick-text {
  290. font-size: 24rpx;
  291. color: #333;
  292. //font-weight: bold;
  293. }
  294. .id-text {
  295. font-size: 22rpx;
  296. color: #333;
  297. }
  298. .icon-img {
  299. width: 50rpx;
  300. height: 50rpx;
  301. }
  302. .vip-box {
  303. padding: 0 30rpx;
  304. // position: relative;
  305. .vip-box-content {
  306. border-radius: 20rpx;
  307. background: linear-gradient(180deg, #25140a 0, #402b16 100%, #402b16 100%) !important;
  308. //height: 100rpx;
  309. display: flex;
  310. .vip-box-left{
  311. //position: absolute;top: 38rpx;left:60rpx;z-index: 2;
  312. width: 70%;
  313. color: #f4dba2;
  314. }
  315. .vip-box-right {
  316. width: 30%;
  317. color: #fff;
  318. //color: #ffffff;position: absolute;top: 45rpx;right:60rpx;z-index: 2;
  319. }
  320. }
  321. .vip-btn{
  322. background-color: #f4dba2;
  323. padding: 10rpx 30rpx;
  324. font-size: 22rpx;
  325. border-radius: 30rpx;
  326. color: #25140a;
  327. }
  328. .vip-btn2{
  329. background-color: #f4dba2;
  330. padding: 8rpx 25rpx;
  331. font-size: 20rpx;
  332. border-radius: 30rpx;
  333. color: #25140a;
  334. }
  335. }
  336. .font-size-26 {
  337. font-size: 28rpx;
  338. }
  339. .font-size-24 {
  340. font-size: 24rpx;
  341. }
  342. .vip-bg-img {
  343. position: absolute;
  344. top: 10rpx;
  345. left: 0;
  346. right:0;
  347. margin:auto;
  348. width:700rpx
  349. }
  350. .item-image {
  351. width: 40rpx;
  352. height: 40rpx;
  353. }
  354. .bg {
  355. width: 100%;
  356. height: calc(410 / 594 * 750rpx);
  357. }
  358. .hym-btn {
  359. position: absolute;
  360. top: 40rpx;
  361. right: 40rpx;
  362. color: $color-primary;
  363. display: flex;
  364. align-items: center;
  365. justify-content: center;
  366. border-radius: 50rem;
  367. font-size: $font-size-sm;
  368. box-shadow: 0 0 20rpx rgba(66, 66, 66, 0.1);
  369. &::after {
  370. border: 0;
  371. }
  372. image {
  373. width: 30rpx;
  374. height: 30rpx;
  375. margin-right: 10rpx;
  376. }
  377. }
  378. .user-box {
  379. position: relative;
  380. border-radius: 8rpx;
  381. margin-bottom: 10rpx;
  382. //margin-top: 40rpx;
  383. box-shadow: $box-shadow;
  384. }
  385. // .avatar {
  386. // position: relative;
  387. // margin-top: -35rpx;
  388. // margin-left: 35rpx;
  389. // margin-right: 35rpx;
  390. // width: 160rpx;
  391. // height: 160rpx;
  392. // border-radius: 20rpx;
  393. // display: flex;
  394. // align-items: center;
  395. // justify-content: center;
  396. // background-color: #FFFFFF;
  397. // box-shadow: 0 0 20rpx rgba($color: #000000, $alpha: 0.2);
  398. // image {
  399. // width: 140rpx;
  400. // height: 140rpx;
  401. // border-radius: 100%;
  402. // }
  403. // .badge {
  404. // position: absolute;
  405. // right: -10rpx;
  406. // bottom: -10rpx;
  407. // background-color: #FFFFFF;
  408. // border-radius: 50rem;
  409. // display: flex;
  410. // align-items: center;
  411. // justify-content: center;
  412. // color: $color-warning;
  413. // font-size: 24rpx;
  414. // padding: 8rpx 16rpx;
  415. // box-shadow: 0 0 20rpx rgba($color: #000000, $alpha: 0.2);
  416. // image {
  417. // width: 30rpx;
  418. // height: 30rpx;
  419. // }
  420. // }
  421. // }
  422. .level-benefit {
  423. margin-left: 35rpx;
  424. padding: 10rpx 0 10rpx 30rpx;
  425. border-radius: 50rem 0 0 50rem;
  426. }
  427. .user-grid {
  428. width: 33%;
  429. padding: 30rpx;
  430. display: flex;
  431. flex-direction: column;
  432. align-items: center;
  433. justify-content: center;
  434. .value {
  435. margin-bottom: 20rpx;
  436. }
  437. }
  438. .level-benefit-box {
  439. border-radius: 8rpx;
  440. margin-bottom: 30rpx;
  441. box-shadow: 0 10rpx 8rpx rgba($color: #878889, $alpha: 0.1);
  442. width: 100%;
  443. display: flex;
  444. padding: 30rpx;
  445. flex-direction: column;
  446. background-color: #FFFFFF;
  447. .row {
  448. display: flex;
  449. padding: 30rpx 0 20rpx;
  450. justify-content: space-around;
  451. align-items: center;
  452. .grid {
  453. width: 20%;
  454. display: flex;
  455. flex-direction: column;
  456. font-size: $font-size-sm;
  457. color: $text-color-assist;
  458. align-items: center;
  459. image {
  460. width: 80rpx;
  461. height: 80rpx;
  462. margin-bottom: 10rpx;
  463. }
  464. }
  465. }
  466. }
  467. .banner {
  468. width: 100%;
  469. border-radius: 8rpx;
  470. margin-bottom: 30rpx;
  471. }
  472. .service-box {
  473. width: 100%;
  474. background-color: #FFFFFF;
  475. padding: 32rpx 30rpx 10rpx;
  476. box-shadow: $box-shadow;
  477. // .row {
  478. // display: flex;
  479. // flex-wrap: wrap;
  480. // color: $text-color-assist;
  481. // font-size: $font-size-sm;
  482. // padding-bottom: -40rpx;
  483. // .grid {
  484. // display: flex;
  485. // flex-direction: column;
  486. // justify-content: center;
  487. // align-items: center;
  488. // margin-bottom: 40rpx;
  489. // width: 25%;
  490. // position: relative;
  491. // image {
  492. // width: 80rpx;
  493. // height: 80rpx;
  494. // margin-bottom: 20rpx;
  495. // }
  496. // }
  497. // .opacity-0 {
  498. // position: absolute;
  499. // width: 100%;
  500. // height: 100%;
  501. // opacity: 0;
  502. // z-index: 10;
  503. // }
  504. // }
  505. }
  506. </style>