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.

713 lines
19 KiB

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