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.

702 lines
18 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week 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">
  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. }
  230. },
  231. onShow() {
  232. if (!getToken() || !getOpenIdKey()) {
  233. this.login()
  234. } else{
  235. this.getPersonalInfo()
  236. // this.initVisitor()
  237. }
  238. },
  239. methods: {
  240. onGetPhoneNumber(e){
  241. if(e.detail.errMsg=="getPhoneNumber:fail user deny"){ //用户拒绝授权
  242. //拒绝授权后弹出一些提示
  243. }else{ //允许授权
  244. if(getOpenIdKey()){
  245. this.getPhoneNumber({"openId":getOpenIdKey(),"code":e.detail.code})
  246. }
  247. // debugger
  248. // console.log(e.detail.encryptedData)
  249. // e.detail.encryptedData //加密的用户信息
  250. // e.detail.iv //加密算法的初始向量 时要用到
  251. }
  252. },
  253. getPhoneNumber(data){
  254. getPhoneNumber(data).then(res=>{
  255. if(res&&res.code==200){
  256. let token = res.data.token
  257. setToken(token)
  258. this.isMember=true
  259. } else{
  260. uni.showToast({
  261. icon:'error',
  262. title:'获取手机号失败'
  263. })
  264. }
  265. })
  266. },
  267. login() {
  268. uni.login({
  269. provider: 'weixin',
  270. success: (loginRes) => {
  271. this.getOpenId(loginRes.code)
  272. },
  273. fail: function(error) {
  274. // 授权失败处理
  275. uni.showToast('授权失败,请授权后再试')
  276. }
  277. });
  278. },
  279. getOpenId(code) {
  280. getOpenId(code).then(res => {
  281. if (res.code == 200 && res.data) {
  282. let resData = JSON.parse(res.data)
  283. let token = resData.token;
  284. let openId = resData.openId;
  285. setOpenIdKey(openId)
  286. if(token){
  287. setToken(token)
  288. this.getPersonalInfo()
  289. }else{
  290. this.initVisitor()
  291. }
  292. }
  293. })
  294. },
  295. getPersonalInfo(){
  296. this.isMember=true
  297. getPersonalInfo().then(res=>{
  298. if(res&&(res.id || res.id === 0)){
  299. this.userLevel=res.level
  300. this.userName=res.nickname
  301. this.consumption=res.consumption
  302. this.promotion=res.promotion
  303. this.process=res.process*100
  304. this.point=res.integral
  305. this.collect=`${res.centralPoint}/10`
  306. this.coupon=res.coupon
  307. this.promotionDate=res.promotionDate
  308. this.nextLevel=res.nextLevel
  309. this.amountNeeded=res.amountNeeded
  310. if(res.h5OrderVO){
  311. let orderInfo= res.h5OrderVO
  312. if(orderInfo.status) {
  313. if(orderInfo.status==1){
  314. this.active = 0
  315. }else if(orderInfo.status==2){
  316. let date = new Date();
  317. let currentDate = `${date.getFullYear()}-${("0" + (date.getMonth() + 1)).slice(-2)}-${("0" + date.getDate()).slice(-2)}`;
  318. let serviceDate= orderInfo.orderServiceList[0]?.serviceDate
  319. if(serviceDate.indexOf(currentDate)>-1){
  320. this.active=2
  321. }else{
  322. this.active=1
  323. }
  324. }else if(orderInfo.status==3){
  325. this.active = 3
  326. }
  327. this.setOrderInfo(orderInfo)
  328. }else{
  329. this.active = 0
  330. this.amount=0
  331. this.service='专业喂养'
  332. this.days=0
  333. }
  334. }
  335. }
  336. console.log(res)
  337. })
  338. },
  339. initVisitor(){
  340. let currentYear = new Date().getFullYear()
  341. this.userLevel='游客'
  342. this.userName='游客'
  343. this.consumption=`累计消费 0 元( ${currentYear}-01-01起至今)`
  344. this.promotion='注册后即可享受会员权益'
  345. this.process=0
  346. this.point=0
  347. this.collect=`0/10`
  348. this.coupon=0
  349. this.active = 0
  350. this.amount=0
  351. this.service='专业喂养'
  352. this.days=0
  353. },
  354. setOrderInfo(orderInfo){
  355. this.amount=orderInfo.totalAmount
  356. this.service=orderInfo.orderItemList[0]?.productName
  357. let serviceDate= orderInfo.orderServiceList[0]?.serviceDate
  358. this.days = JSON.parse(serviceDate).length
  359. },
  360. toRegister(){
  361. this.$modal.showToast('敬请期待');
  362. },
  363. handleStepClick(orderInfo = {}) {
  364. // if(!this.isMember){
  365. // this.$modal.showToast('暂未匹配到您的会员信息,请先注册成为会员!');
  366. // return;
  367. // }
  368. // 如果点击的是服务中状态(索引为2)且当前订单状态也是服务中
  369. // if (e.index === 2 && this.active === 2) {
  370. // 跳转到订单详情页面
  371. uni.navigateTo({
  372. url: `/pages/personalCenter/orderDetailImage?orderId=${orderInfo.id}`
  373. });
  374. // }
  375. },
  376. openOtherPage(type){
  377. if(!this.isMember){
  378. this.$modal.showToast('暂未匹配到您的会员信息,请先注册成为会员!');
  379. return;
  380. }
  381. switch(type){
  382. case 'member':{
  383. // this.$modal.showToast('页面开发中');
  384. uni.navigateTo({
  385. url: `/pages/personalCenter/member`
  386. });
  387. break;
  388. }
  389. case 'point':{
  390. uni.navigateTo({
  391. url: `/pages/personalCenter/point`
  392. });
  393. break;
  394. }
  395. case 'collect':{
  396. uni.navigateTo({
  397. url: `/pages/personalCenter/collect`
  398. });
  399. break;
  400. }
  401. case 'coupon':{
  402. // uni.showToast({
  403. // title: '敬请期待',
  404. // duration: 3000,
  405. // icon:"none"
  406. // })
  407. // this.$modal.showToast('敬请期待');
  408. uni.navigateTo({
  409. url: `/pages/personalCenter/coupon`
  410. });
  411. break;
  412. }
  413. case 'order':{
  414. uni.navigateTo({
  415. // url: `/pages/details/order`
  416. url: `/pages_order/order/orderList`
  417. });
  418. break;
  419. }
  420. case 'pet':{
  421. uni.navigateTo({
  422. url: `/pages/personalCenter/pet`
  423. });
  424. break;
  425. }
  426. case 'lock':{
  427. uni.navigateTo({
  428. url: `/pages/personalCenter/lock`
  429. });
  430. break;
  431. }
  432. case 'service':{
  433. uni.navigateTo({
  434. url: `/pages/personalCenter/service`
  435. });
  436. break;
  437. }
  438. case 'address':{
  439. uni.navigateTo({
  440. url: `/pages/personalCenter/address`
  441. });
  442. break;
  443. }
  444. case 'taskList':{
  445. uni.navigateTo({
  446. url: `/pages_order/task/taskList`
  447. });
  448. break;
  449. }
  450. case 'userInfo':{
  451. uni.navigateTo({
  452. url: `/pages/personalCenter/userInfo`
  453. });
  454. break;
  455. }
  456. default:this.$modal.showToast('页面开发中');
  457. }
  458. }
  459. }
  460. }
  461. </script>
  462. <style lang="scss">
  463. .personal-index{
  464. .personal-base-info{
  465. display: flex;
  466. justify-content: center;
  467. flex-wrap: wrap;
  468. align-content:flex-start;
  469. width: 100%;
  470. height: 200px;
  471. flex-shrink: 0;
  472. background: linear-gradient(0deg, #F5F5F7 0%, #FFBF60 99.41%);
  473. .personal-user{
  474. display: flex;
  475. justify-content: center;
  476. align-items: center;
  477. margin-top: 10px;
  478. .personal-user-name{
  479. text-align: center;
  480. color: #111;
  481. font-size: 20px;
  482. font-style: normal;
  483. font-weight: blod;
  484. height: 28px;
  485. }
  486. .personal-user-level{
  487. width: 62px;
  488. height: 22px;
  489. line-height: 22px;
  490. background-color: #ffaa48;
  491. color: #FFF;
  492. text-align: center;
  493. font-size: 12px;
  494. font-style: normal;
  495. font-weight: 500;
  496. border-radius: 20px;
  497. border: #FFF solid 1.5px;
  498. margin-right: 15px;
  499. }
  500. }
  501. .personal-progress{
  502. width: 100%;
  503. height: 80px;
  504. flex-shrink: 0;
  505. border-radius: 8px;
  506. border: 1.5px solid #FFF;
  507. padding: 10px;
  508. background: linear-gradient(107deg, #FFE0BF 8.09%, #FFECD7 21.18%, #FFF4E8 32.78%, #FFEFDE 44.88%, #FEEEDB 57.48%);
  509. .progress-text{
  510. color: #B78B43;
  511. text-align: center;
  512. font-size: 12px;
  513. font-style: normal;
  514. font-weight: 400;
  515. line-height: 20px;
  516. }
  517. .progress{
  518. margin: 5px 0;
  519. }
  520. }
  521. }
  522. .personal-stat{
  523. display: flex;
  524. justify-content: space-between;
  525. align-items: center;
  526. padding: 10px 15px;
  527. .personal-stat-box{
  528. width: 30%;
  529. height: 90px;
  530. flex-shrink: 0;
  531. border-radius: 8px;
  532. background: #FFF;
  533. display: flex;
  534. flex-wrap: wrap;
  535. padding: 10px;
  536. .personal-stat-box-right{
  537. width: 50%;
  538. height: 45px;
  539. text-align: right;
  540. .personal-stat-box-img{
  541. width: 34px;
  542. height: 34px;
  543. }
  544. }
  545. .personal-stat-box-left{
  546. width: 50%;
  547. height: 45px;
  548. display:flex;
  549. flex-flow: column; //垂直排列
  550. justify-content: space-between;//两端对齐
  551. .personal-stat-box-label{
  552. color: #111;
  553. font-size: 14px;
  554. font-style: normal;
  555. font-weight: 400;
  556. line-height: 16px;
  557. }
  558. .personal-stat-box-value{
  559. color: #333;
  560. font-size: 16px;
  561. font-style: normal;
  562. font-weight: 500;
  563. line-height: 14px;
  564. }
  565. }
  566. .personal-stat-box-bottom{
  567. width: 100%;
  568. color: #AAA;
  569. font-size: 12px;
  570. font-style: normal;
  571. font-weight: 400;
  572. line-height: normal;
  573. display: flex;
  574. align-items: flex-end;
  575. }
  576. }
  577. }
  578. .uni-steps-btns{
  579. display: flex;
  580. justify-content: center;
  581. .u-button{
  582. width: 160rpx;
  583. height: 55rpx;
  584. margin-right: 155rpx;
  585. .u-button__text{
  586. font-size: 22rpx !important;
  587. }
  588. }
  589. }
  590. .personal-order{
  591. width: 100%;
  592. .personal-order-title{
  593. width: 100%;
  594. display: flex;
  595. justify-content: space-between;
  596. align-items: center;
  597. border-bottom: 1px solid #efefef;
  598. height: 36px;
  599. .personal-order-title-text{
  600. color: #333;
  601. font-size: 15px;
  602. font-style: normal;
  603. font-weight: 500;
  604. line-height: 16px;
  605. }
  606. .personal-order-title-link{
  607. color: #AAA;
  608. font-size: 13px;
  609. font-style: normal;
  610. font-weight: 400;
  611. line-height: 16px;
  612. }
  613. }
  614. .personal-order-footer{
  615. width: 100%;
  616. display: flex;
  617. justify-content: space-between;
  618. align-items: center;
  619. border-top: 1px solid #efefef;
  620. padding-top: 10px;
  621. .personal-order-footer-text{
  622. display: flex;
  623. color: #333;
  624. font-size: 13px;
  625. font-style: normal;
  626. font-weight: 400;
  627. line-height: normal;
  628. }
  629. }
  630. .personal-order-login-btn{
  631. height: 100px;
  632. display: flex;
  633. justify-content: center;
  634. align-items: center;
  635. }
  636. }
  637. }
  638. .personal-functions{
  639. width: 100%;
  640. .personal-function-title{
  641. width: 100%;
  642. display: flex;
  643. justify-content: space-between;
  644. align-items: center;
  645. border-bottom: 1px solid #efefef;
  646. height: 36px;
  647. .personal-function-title-text{
  648. color: #333;
  649. font-size: 15px;
  650. font-style: normal;
  651. font-weight: 500;
  652. line-height: 16px;
  653. }
  654. }
  655. .personal-functions-content{
  656. width: 100%;
  657. display: flex;
  658. justify-content: space-between;
  659. align-items: center;
  660. flex-wrap: wrap;
  661. gap: 30rpx 0;
  662. .personal-function{
  663. width: 24%;
  664. display: flex;
  665. justify-content: center;
  666. flex-wrap: wrap;
  667. .personal-function-name{
  668. color: #333;
  669. font-size: 14px;
  670. font-style: normal;
  671. font-weight: 400;
  672. line-height: normal;
  673. margin-top: 5px;
  674. }
  675. }
  676. }
  677. }
  678. </style>