You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

680 lines
18 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <view class="personal-index">
  3. <view class="personal-base-info">
  4. <view style="width: 100%;height: 140px; margin-top: 10px;">
  5. <view style="width: 100%;text-align: center;" @click="openOtherPage('userInfo')">
  6. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/avatar_1.png"
  7. style="width: 66px; height: 66px;" mode="widthFix"></img>
  8. </view>
  9. <!-- <view style="width: 100%;text-align: center;">
  10. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/cmdf_text.png"style="width:55px;height: 16px;" mode="widthFix"></img>
  11. </view>
  12. -->
  13. <view class="personal-user">
  14. <view class="personal-user-level">
  15. {{userLevel}}
  16. </view>
  17. <view class="personal-user-name" @click="openOtherPage('userInfo')">
  18. {{userName}}
  19. </view>
  20. <view style="width: 62px;margin-left: 15px;"> </view>
  21. </view>
  22. </view>
  23. <view style="padding: 0 15px; width: 100%;">
  24. <view class="personal-progress" @click="openOtherPage('member')">
  25. <view class="progress-text">
  26. {{consumption}}
  27. <!-- 累计消费{{spent}}{{startDate}}起至今 -->
  28. </view>
  29. <view class="progress">
  30. <view class="progress-box">
  31. <progress :percent="process" activeColor="#FFAA48" backgroundColor="#ffffff" border-radius="28px" stroke-width="5" />
  32. </view>
  33. </view>
  34. <view class="progress-text" v-if="userLevel!='金卡会员'">
  35. {{promotionDate}}
  36. <text style="font-weight: bold;font-size: 14px;">
  37. 再消费{{amountNeeded}}
  38. </text>即可升级至
  39. <text style="font-weight: bold;font-size: 14px;">{{nextLevel}}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="personal-stat">
  44. <view class="personal-stat-box">
  45. <view class="personal-stat-box-left" @click="openOtherPage('point')">
  46. <view class="personal-stat-box-label">
  47. 积分
  48. </view>
  49. <view class="personal-stat-box-value">
  50. {{point}}
  51. </view>
  52. </view>
  53. <view class="personal-stat-box-right">
  54. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/point.png" alt="point" class="personal-stat-box-img" mode="widthFix"/>
  55. </view>
  56. <view class="personal-stat-box-bottom">
  57. 查看历史明细
  58. </view>
  59. </view>
  60. <view class="personal-stat-box" @click="openOtherPage('collect')">
  61. <view class="personal-stat-box-left">
  62. <view class="personal-stat-box-label">
  63. 集点
  64. </view>
  65. <view class="personal-stat-box-value">
  66. {{collect}}
  67. </view>
  68. </view>
  69. <view class="personal-stat-box-right">
  70. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/collect.png" alt="collect" class="personal-stat-box-img" mode="widthFix"/>
  71. </view>
  72. <view class="personal-stat-box-bottom">
  73. 下单获得好礼
  74. </view>
  75. </view>
  76. <view class="personal-stat-box" @click="openOtherPage('coupon')">
  77. <view class="personal-stat-box-left">
  78. <view class="personal-stat-box-label">
  79. 卡券
  80. </view>
  81. <view class="personal-stat-box-value">
  82. {{coupon}}
  83. </view>
  84. </view>
  85. <view class="personal-stat-box-right">
  86. <img src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/coupon.png" alt="coupon" class="personal-stat-box-img" mode="widthFix"/>
  87. </view>
  88. <view class="personal-stat-box-bottom">
  89. 我的卡券数量
  90. </view>
  91. </view>
  92. </view>
  93. <view class="personal-order">
  94. <uni-card margin="0 15px 10px" :is-shadow="false">
  95. <view class="personal-order-title" slot="title">
  96. <view class="personal-order-title-text">
  97. 订单状态
  98. </view>
  99. <view class="personal-order-title-link" @click="openOtherPage('order')">
  100. 全部订单 <uni-icons type="right" size="14px" color="#AAA"></uni-icons>
  101. </view>
  102. </view>
  103. <view v-if="isMember">
  104. <view style="padding-bottom: 10px;">
  105. <view style="color: #AAA;
  106. font-size: 14px;
  107. text-align: center;
  108. margin-bottom: 10px;">
  109. 当前订单
  110. </view>
  111. <uni-steps :options="orderStatus" active-icon="checkbox" :active="active" active-color='#ffaa48'
  112. @clickStep="handleStepClick" />
  113. </view>
  114. <view class="personal-order-footer" slot="actions">
  115. <view class="personal-order-footer-text">
  116. {{service}}
  117. <view style="color: #AAA;font-size: 12px;"> (本次服务共{{days}}) </view>
  118. </view>
  119. <view class="personal-order-footer-text">
  120. {{amount}}
  121. </view>
  122. </view>
  123. </view>
  124. <view v-else class="personal-order-login-btn" >
  125. <u-button type="primary"
  126. open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber"
  127. shape="circle" :plain="true"
  128. :hairline="true" color="#FFAA48"
  129. text="登录后方可预约"
  130. @click="toRegister"></u-button>
  131. </view>
  132. </uni-card>
  133. </view>
  134. <view class="personal-functions">
  135. <uni-card margin="0 15px 10px" :is-shadow="false">
  136. <view class="personal-function-title" slot="title">
  137. <view class="personal-function-title-text">
  138. 常用功能
  139. </view>
  140. </view>
  141. <view class="personal-functions-content">
  142. <view v-for="(item,index) in functions" :key="index" class="personal-function" @click="openOtherPage(item.path)">
  143. <img :src="item.icon" alt="item.label" style="width: 30px; height: 30px;" mode="widthFix" />
  144. <view class="personal-function-name">{{item.label}}</view>
  145. </view>
  146. </view>
  147. </uni-card>
  148. </view>
  149. </view>
  150. </view>
  151. </template>
  152. <script>
  153. import {getOpenId,getPhoneNumber} from "@/api/system/user.js"
  154. import { setToken,getToken,getOpenIdKey,setOpenIdKey } from '@/utils/auth'
  155. import {getPersonalInfo} from "@/api/system/personal.js"
  156. export default{
  157. data(){
  158. return{
  159. userName:'',
  160. userLevel:'',
  161. process:0,
  162. spent:0,
  163. cost:0,
  164. consumption:'',
  165. promotion:'',
  166. point:0,
  167. collect:'0/10',
  168. coupon:0,
  169. active: 0,
  170. isMember:false,
  171. orderStatus: [{
  172. activeImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/sentedOrder.png',
  173. deactiveImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/sentOrder.png',
  174. title: '待派单'
  175. }, {
  176. activeImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/ordered.png',
  177. deactiveImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/order.png',
  178. title: '已派单'
  179. }, {
  180. activeImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/serviced.png',
  181. deactiveImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/service.png',
  182. title: '服务中'
  183. }, {
  184. activeImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/overed.png',
  185. deactiveImg:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/over.png',
  186. title: '已完成'
  187. }],
  188. service:'专业喂养',
  189. days:0,
  190. amount:0,
  191. promotionDate:'2025年01月01日',
  192. nextLevel:'普卡会员',
  193. amountNeeded:'0',
  194. functions:[
  195. {
  196. icon:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/pet.png',
  197. label: '宠物档案',
  198. path:'pet'
  199. },
  200. {
  201. icon:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/serviceFile.png',
  202. label: '服务档案',
  203. path:'service'
  204. },
  205. {
  206. icon:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/address.png',
  207. label: '地址电话',
  208. path:'address'
  209. },
  210. {
  211. icon:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/lock.png',
  212. label: '门锁信息',
  213. path:'lock'
  214. },
  215. {
  216. icon:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/index/lock.png',
  217. label: '任务中心',
  218. path:'taskList'
  219. },
  220. ]
  221. }
  222. },
  223. onShow() {
  224. if (!getToken() || !getOpenIdKey()) {
  225. this.login()
  226. } else{
  227. this.getPersonalInfo()
  228. // this.initVisitor()
  229. }
  230. },
  231. methods: {
  232. onGetPhoneNumber(e){
  233. if(e.detail.errMsg=="getPhoneNumber:fail user deny"){ //用户拒绝授权
  234. //拒绝授权后弹出一些提示
  235. }else{ //允许授权
  236. if(getOpenIdKey()){
  237. this.getPhoneNumber({"openId":getOpenIdKey(),"code":e.detail.code})
  238. }
  239. // debugger
  240. // console.log(e.detail.encryptedData)
  241. // e.detail.encryptedData //加密的用户信息
  242. // e.detail.iv //加密算法的初始向量 时要用到
  243. }
  244. },
  245. getPhoneNumber(data){
  246. getPhoneNumber(data).then(res=>{
  247. if(res&&res.code==200){
  248. let token = res.data.token
  249. setToken(token)
  250. this.isMember=true
  251. } else{
  252. uni.showToast({
  253. icon:'error',
  254. title:'获取手机号失败'
  255. })
  256. }
  257. })
  258. },
  259. login() {
  260. uni.login({
  261. provider: 'weixin',
  262. success: (loginRes) => {
  263. this.getOpenId(loginRes.code)
  264. },
  265. fail: function(error) {
  266. // 授权失败处理
  267. uni.showToast('授权失败,请授权后再试')
  268. }
  269. });
  270. },
  271. getOpenId(code) {
  272. getOpenId(code).then(res => {
  273. if (res.code == 200 && res.data) {
  274. let resData = JSON.parse(res.data)
  275. let token = resData.token;
  276. let openId = resData.openId;
  277. setOpenIdKey(openId)
  278. if(token){
  279. setToken(token)
  280. this.getPersonalInfo()
  281. }else{
  282. this.initVisitor()
  283. }
  284. }
  285. })
  286. },
  287. getPersonalInfo(){
  288. this.isMember=true
  289. getPersonalInfo().then(res=>{
  290. if(res&&(res.id || res.id === 0)){
  291. this.userLevel=res.level
  292. this.userName=res.nickname
  293. this.consumption=res.consumption
  294. this.promotion=res.promotion
  295. this.process=res.process*100
  296. this.point=res.integral
  297. this.collect=`${res.centralPoint}/10`
  298. this.coupon=res.coupon
  299. this.promotionDate=res.promotionDate
  300. this.nextLevel=res.nextLevel
  301. this.amountNeeded=res.amountNeeded
  302. if(res.h5OrderVO){
  303. let orderInfo= res.h5OrderVO
  304. if(orderInfo.status) {
  305. if(orderInfo.status==1){
  306. this.active = 0
  307. }else if(orderInfo.status==2){
  308. let date = new Date();
  309. let currentDate = `${date.getFullYear()}-${("0" + (date.getMonth() + 1)).slice(-2)}-${("0" + date.getDate()).slice(-2)}`;
  310. let serviceDate= orderInfo.orderServiceList[0]?.serviceDate
  311. if(serviceDate.indexOf(currentDate)>-1){
  312. this.active=2
  313. }else{
  314. this.active=1
  315. }
  316. }else if(orderInfo.status==3){
  317. this.active = 3
  318. }
  319. this.setOrderInfo(orderInfo)
  320. }else{
  321. this.active = 0
  322. this.amount=0
  323. this.service='专业喂养'
  324. this.days=0
  325. }
  326. }
  327. }
  328. console.log(res)
  329. })
  330. },
  331. initVisitor(){
  332. let currentYear = new Date().getFullYear()
  333. this.userLevel='游客'
  334. this.userName='游客'
  335. this.consumption=`累计消费 0 元( ${currentYear}-01-01起至今)`
  336. this.promotion='注册后即可享受会员权益'
  337. this.process=0
  338. this.point=0
  339. this.collect=`0/10`
  340. this.coupon=0
  341. this.active = 0
  342. this.amount=0
  343. this.service='专业喂养'
  344. this.days=0
  345. },
  346. setOrderInfo(orderInfo){
  347. this.amount=orderInfo.totalAmount
  348. this.service=orderInfo.orderItemList[0]?.productName
  349. let serviceDate= orderInfo.orderServiceList[0]?.serviceDate
  350. this.days = JSON.parse(serviceDate).length
  351. },
  352. toRegister(){
  353. this.$modal.showToast('敬请期待');
  354. },
  355. handleStepClick(e) {
  356. // if(!this.isMember){
  357. // this.$modal.showToast('暂未匹配到您的会员信息,请先注册成为会员!');
  358. // return;
  359. // }
  360. // 如果点击的是服务中状态(索引为2)且当前订单状态也是服务中
  361. // if (e.index === 2 && this.active === 2) {
  362. // 跳转到订单详情页面
  363. uni.navigateTo({
  364. url: `/pages/personalCenter/orderDetail`
  365. });
  366. // }
  367. },
  368. openOtherPage(type){
  369. if(!this.isMember){
  370. this.$modal.showToast('暂未匹配到您的会员信息,请先注册成为会员!');
  371. return;
  372. }
  373. switch(type){
  374. case 'member':{
  375. // this.$modal.showToast('页面开发中');
  376. uni.navigateTo({
  377. url: `/pages/personalCenter/member`
  378. });
  379. break;
  380. }
  381. case 'point':{
  382. uni.navigateTo({
  383. url: `/pages/personalCenter/point`
  384. });
  385. break;
  386. }
  387. case 'collect':{
  388. uni.navigateTo({
  389. url: `/pages/personalCenter/collect`
  390. });
  391. break;
  392. }
  393. case 'coupon':{
  394. // uni.showToast({
  395. // title: '敬请期待',
  396. // duration: 3000,
  397. // icon:"none"
  398. // })
  399. // this.$modal.showToast('敬请期待');
  400. uni.navigateTo({
  401. url: `/pages/personalCenter/coupon`
  402. });
  403. break;
  404. }
  405. case 'order':{
  406. uni.navigateTo({
  407. url: `/pages/details/order`
  408. });
  409. break;
  410. }
  411. case 'pet':{
  412. uni.navigateTo({
  413. url: `/pages/personalCenter/pet`
  414. });
  415. break;
  416. }
  417. case 'lock':{
  418. uni.navigateTo({
  419. url: `/pages/personalCenter/lock`
  420. });
  421. break;
  422. }
  423. case 'service':{
  424. uni.navigateTo({
  425. url: `/pages/personalCenter/service`
  426. });
  427. break;
  428. }
  429. case 'address':{
  430. uni.navigateTo({
  431. url: `/pages/personalCenter/address`
  432. });
  433. break;
  434. }
  435. case 'taskList':{
  436. uni.navigateTo({
  437. url: `/pages/personalCenter/taskList`
  438. });
  439. break;
  440. }
  441. case 'userInfo':{
  442. uni.navigateTo({
  443. url: `/pages/personalCenter/userInfo`
  444. });
  445. break;
  446. }
  447. default:this.$modal.showToast('页面开发中');
  448. }
  449. }
  450. }
  451. }
  452. </script>
  453. <style lang="scss">
  454. .personal-index{
  455. .personal-base-info{
  456. display: flex;
  457. justify-content: center;
  458. flex-wrap: wrap;
  459. align-content:flex-start;
  460. width: 100%;
  461. height: 200px;
  462. flex-shrink: 0;
  463. background: linear-gradient(0deg, #F5F5F7 0%, #FFBF60 99.41%);
  464. .personal-user{
  465. display: flex;
  466. justify-content: center;
  467. align-items: center;
  468. margin-top: 10px;
  469. .personal-user-name{
  470. text-align: center;
  471. color: #111;
  472. font-size: 20px;
  473. font-style: normal;
  474. font-weight: blod;
  475. height: 28px;
  476. }
  477. .personal-user-level{
  478. width: 62px;
  479. height: 22px;
  480. line-height: 22px;
  481. background-color: #ffaa48;
  482. color: #FFF;
  483. text-align: center;
  484. font-size: 12px;
  485. font-style: normal;
  486. font-weight: 500;
  487. border-radius: 20px;
  488. border: #FFF solid 1.5px;
  489. margin-right: 15px;
  490. }
  491. }
  492. .personal-progress{
  493. width: 100%;
  494. height: 80px;
  495. flex-shrink: 0;
  496. border-radius: 8px;
  497. border: 1.5px solid #FFF;
  498. padding: 10px;
  499. background: linear-gradient(107deg, #FFE0BF 8.09%, #FFECD7 21.18%, #FFF4E8 32.78%, #FFEFDE 44.88%, #FEEEDB 57.48%);
  500. .progress-text{
  501. color: #B78B43;
  502. text-align: center;
  503. font-size: 12px;
  504. font-style: normal;
  505. font-weight: 400;
  506. line-height: 20px;
  507. }
  508. .progress{
  509. margin: 5px 0;
  510. }
  511. }
  512. }
  513. .personal-stat{
  514. display: flex;
  515. justify-content: space-between;
  516. align-items: center;
  517. padding: 10px 15px;
  518. .personal-stat-box{
  519. width: 30%;
  520. height: 90px;
  521. flex-shrink: 0;
  522. border-radius: 8px;
  523. background: #FFF;
  524. display: flex;
  525. flex-wrap: wrap;
  526. padding: 10px;
  527. .personal-stat-box-right{
  528. width: 50%;
  529. height: 45px;
  530. text-align: right;
  531. .personal-stat-box-img{
  532. width: 34px;
  533. height: 34px;
  534. }
  535. }
  536. .personal-stat-box-left{
  537. width: 50%;
  538. height: 45px;
  539. display:flex;
  540. flex-flow: column; //垂直排列
  541. justify-content: space-between;//两端对齐
  542. .personal-stat-box-label{
  543. color: #111;
  544. font-size: 14px;
  545. font-style: normal;
  546. font-weight: 400;
  547. line-height: 16px;
  548. }
  549. .personal-stat-box-value{
  550. color: #333;
  551. font-size: 16px;
  552. font-style: normal;
  553. font-weight: 500;
  554. line-height: 14px;
  555. }
  556. }
  557. .personal-stat-box-bottom{
  558. width: 100%;
  559. color: #AAA;
  560. font-size: 12px;
  561. font-style: normal;
  562. font-weight: 400;
  563. line-height: normal;
  564. display: flex;
  565. align-items: flex-end;
  566. }
  567. }
  568. }
  569. .personal-order{
  570. width: 100%;
  571. .personal-order-title{
  572. width: 100%;
  573. display: flex;
  574. justify-content: space-between;
  575. align-items: center;
  576. border-bottom: 1px solid #efefef;
  577. height: 36px;
  578. .personal-order-title-text{
  579. color: #333;
  580. font-size: 15px;
  581. font-style: normal;
  582. font-weight: 500;
  583. line-height: 16px;
  584. }
  585. .personal-order-title-link{
  586. color: #AAA;
  587. font-size: 13px;
  588. font-style: normal;
  589. font-weight: 400;
  590. line-height: 16px;
  591. }
  592. }
  593. .personal-order-footer{
  594. width: 100%;
  595. display: flex;
  596. justify-content: space-between;
  597. align-items: center;
  598. border-top: 1px solid #efefef;
  599. padding-top: 10px;
  600. .personal-order-footer-text{
  601. display: flex;
  602. color: #333;
  603. font-size: 13px;
  604. font-style: normal;
  605. font-weight: 400;
  606. line-height: normal;
  607. }
  608. }
  609. .personal-order-login-btn{
  610. height: 100px;
  611. display: flex;
  612. justify-content: center;
  613. align-items: center;
  614. }
  615. }
  616. }
  617. .personal-functions{
  618. width: 100%;
  619. .personal-function-title{
  620. width: 100%;
  621. display: flex;
  622. justify-content: space-between;
  623. align-items: center;
  624. border-bottom: 1px solid #efefef;
  625. height: 36px;
  626. .personal-function-title-text{
  627. color: #333;
  628. font-size: 15px;
  629. font-style: normal;
  630. font-weight: 500;
  631. line-height: 16px;
  632. }
  633. }
  634. .personal-functions-content{
  635. width: 100%;
  636. display: flex;
  637. justify-content: space-between;
  638. align-items: center;
  639. flex-wrap: wrap;
  640. gap: 30rpx 0;
  641. .personal-function{
  642. width: 24%;
  643. display: flex;
  644. justify-content: center;
  645. flex-wrap: wrap;
  646. .personal-function-name{
  647. color: #333;
  648. font-size: 14px;
  649. font-style: normal;
  650. font-weight: 400;
  651. line-height: normal;
  652. margin-top: 5px;
  653. }
  654. }
  655. }
  656. }
  657. </style>