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.

646 lines
17 KiB

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