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.

664 lines
19 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <view class="service-new container">
  3. <view class="order-type-select" v-if="!buyInfo.teacher">
  4. <view class="order-type-title">
  5. <image style="width: 40rpx; height: 40rpx;margin-right: 10rpx;" slot='cover'
  6. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/OrderIcon.png">
  7. </image>
  8. <!-- <image style="width: 32rpx; height: 32rpx; margin-right: 10rpx;" src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/SystemOrderCircle.png"></image> -->
  9. 下单方式系统派单 <text style="color: #999;font-size: 26rpx;">(需先选择伴宠师等级)</text>
  10. </view>
  11. <view class="order-type-options">
  12. <view class="order-type-option"
  13. v-for="item in teacherLevelList"
  14. :key="item.id"
  15. :class="{active: item.id == companionLevel.id}"
  16. @click="selectCompanionLevel(item)">
  17. <image style="width: 40rpx; height: 40rpx; margin-right: 10rpx;"
  18. :src="item.paramValueImage || 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png'"></image>
  19. {{ item.paramValue }}
  20. <view class="info-icon" @click.stop="showCompanionInfo(item)">
  21. <uni-icons type="info" size="20" color="#FFB13F"></uni-icons>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="order-type-select"
  27. style="padding-bottom: 0rpx;"
  28. v-if="buyInfo.teacher">
  29. <view class="order-type-title order-type-title-custom"
  30. style="border-radius: 10rpx;">
  31. <view class="order-type-title-main"
  32. style="padding-left: 10rpx;">
  33. <image style="width: 40rpx; height: 40rpx; margin-right: 10rpx;" src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/OrderIcon.png"></image>
  34. <view class="main-title">
  35. 下单方式指定喂养员 - {{buyInfo.teacher.userName}}
  36. </view>
  37. </view>
  38. <view class="sub-title">
  39. 若伴宠师1小时内无响应或拒绝单则系统派单
  40. </view>
  41. </view>
  42. </view>
  43. <uni-popup ref="companionInfoPopup" type="center">
  44. <view class="companion-info-popup">
  45. <view class="companion-info-title">
  46. <text>{{ showLevelInfo.paramValue }}</text>
  47. </view>
  48. <view class="companion-info-content">
  49. <view class="companion-info-item">
  50. <text class="companion-info-label">等级:</text>
  51. <text class="companion-info-value">{{ showLevelInfo.paramValue }}</text>
  52. </view>
  53. <view class="companion-info-item">
  54. <text class="companion-info-label">价格:</text>
  55. <text class="companion-info-value">{{ companionLevelPrice() }}</text>
  56. </view>
  57. <view class="companion-info-item">
  58. <text class="companion-info-label">分类标准:</text>
  59. <text class="companion-info-value"
  60. v-html="showLevelInfo.paramValueArea"
  61. >
  62. </text>
  63. </view>
  64. </view>
  65. <view class="companion-info-close" @click="closeCompanionInfo">
  66. <uni-icons type="close" size="24" color="#fff"></uni-icons>
  67. </view>
  68. </view>
  69. </uni-popup>
  70. <view class="service-new-address">
  71. <uni-card padding=0 :is-shadow="false">
  72. <view class="service-new-title" slot="title">
  73. <view class="service-new-title-left">
  74. <view class="service-new-flag"></view>
  75. <view>服务地址</view>
  76. </view>
  77. </view>
  78. <view class="split-line"></view>
  79. <view class="service-new-address-content">
  80. <view v-if="isAddressSelected" class="service-new-address-selected" >
  81. <view class="personal-address-info">
  82. <view class="personal-address-text">
  83. {{currentAddress.province}} {{currentAddress.city}} {{currentAddress.detailAddress}}
  84. </view>
  85. <view class="personal-address-people">
  86. <view>
  87. {{currentAddress.name}}
  88. </view>
  89. <view style="border: solid #7D8196 1px; margin: 0 10px; height: 12px;"> </view>
  90. <view>
  91. {{currentAddress.phone}}
  92. </view>
  93. </view>
  94. </view>
  95. <view>
  96. <uni-icons type="right" size="28rpx" color="#AAA" @click="selectAddress"></uni-icons>
  97. </view>
  98. </view>
  99. <view v-else class="service-new-unselect">
  100. <view style="width: 50%;">
  101. <u-button color="#FFBF60" icon="plus-circle-fill" text="添加地址" shape="circle" plain @click="selectAddress">
  102. </u-button>
  103. </view>
  104. </view>
  105. </view>
  106. </uni-card>
  107. </view>
  108. <view class="service-new-pet">
  109. <uni-card padding=0 :is-shadow="false">
  110. <view class="service-new-title" slot="title">
  111. <view class="service-new-title-left">
  112. <view class="service-new-flag">
  113. </view>
  114. <view class="service-new-title-text">
  115. 服务宠物
  116. </view>
  117. </view>
  118. <view v-if="isPetSelected" class="add-pet" @click="selectPet">
  119. <u-icon name="plus-circle-fill" color="#FFBF60" size="28rpx" style="margin-right: 10rpx;"></u-icon>
  120. 添加宠物
  121. </view>
  122. </view>
  123. <view class="split-line"></view>
  124. <view class="service-new-pet-content">
  125. <view v-if="isPetSelected" class="personal-pet-list">
  126. <view v-for="(item,index) in currentPets" :key="index">
  127. <view class="personal-pet-list-item">
  128. <view class="personal-pet-info">
  129. <!-- 左侧头像 -->
  130. <view class="pet-avatar">
  131. <u-avatar :src="item.photo?item.photo:defaultPhoto" size="60" shape="circle"></u-avatar>
  132. </view>
  133. <!-- 中间内容 -->
  134. <view class="pet-info" style="flex: 1; margin: 0 20rpx; max-width: 50%;">
  135. <view class="pet-name-gender" style="display: flex; align-items: center;">
  136. <view>{{item.name}}</view>
  137. <view class="pet-gender" style="margin-left: 10rpx; display: flex;align-items: center;">
  138. <img :src="item.gender=='男生'?'../../static/images/details/boy.svg':'../../static/images/details/girl.svg'" alt="sex"
  139. style="width: 16px;height: 16px;"/>
  140. </view>
  141. </view>
  142. <view class="pet-dates ellipsis" >
  143. {{ getSelectedDateString(item.selectedDate) }}
  144. </view>
  145. </view>
  146. <!-- 右侧天数统计 -->
  147. <view class="date-total" style="margin-left: auto;width: 140rpx;text-align: end;">
  148. {{item.selectedDate.length}}
  149. <uni-icons type="right" size="28rpx" color="#AAA" @click="selectPet"></uni-icons>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. <view v-else class="service-new-unselect">
  156. <view style="width: 50%;">
  157. <u-button color="#FFBF60" icon="plus-circle-fill" text="添加宠物" shape="circle" plain @click="selectPet">
  158. </u-button>
  159. </view>
  160. </view>
  161. </view>
  162. </uni-card>
  163. </view>
  164. <view class="service-new-pet">
  165. <uni-card padding=0 :is-shadow="false">
  166. <view class="service-new-title" slot="title">
  167. <view class="service-new-title-left">
  168. <view class="service-new-flag">
  169. </view>
  170. <view class="service-new-title-text">
  171. 服务细则
  172. </view>
  173. </view>
  174. </view>
  175. <view class="split-line"></view>
  176. <view class="service-new-details-content">
  177. <view style="margin: 30rpx 0;">
  178. <u-checkbox-group
  179. v-model="needPreFamiliarize"
  180. iconPlacement="right"
  181. placement="column">
  182. <u-checkbox activeColor="#FFBF60" label="是否提前熟悉" name="是否提前熟悉" shape="circle"></u-checkbox>
  183. </u-checkbox-group>
  184. </view>
  185. <view class="split-line"></view>
  186. <view class="service-new-details-desc">
  187. <view style="display: flex;">
  188. <text style="width: 20rpx;">*</text>
  189. <text style="flex: 1;">价格{{ price_config.preFamiliarize.price }}/</text>
  190. </view>
  191. <view style="display: flex; margin: 20rpx 0;">
  192. <text style="width: 20rpx;">*</text>
  193. <text style="flex: 1;">服务内容: 购买此服务后伴宠师将在您离家前按照约定日期提前上门沟通熟悉喂养要求及宠物</text>
  194. </view>
  195. <view style="display: flex;">
  196. <text style="width: 20rpx;">*</text>
  197. <text style="flex: 1;">服务保障: 购买此服务后平台支持在提前熟悉后上门服务第一天前无理由免费更换伴宠师1次</text>
  198. </view>
  199. </view>
  200. </view>
  201. </uni-card>
  202. </view>
  203. <view class="details-subscribe">
  204. <button class="details-btn" @click="goNext">下一步</button>
  205. </view>
  206. </view>
  207. </template>
  208. <script>
  209. import {
  210. getProductList,
  211. getOpenId
  212. } from "@/api/system/user"
  213. import { setToken,getToken,getOpenIdKey,setOpenIdKey } from '@/utils/auth'
  214. import { mapState } from 'vuex'
  215. export default {
  216. data()
  217. {
  218. return {
  219. isAddressSelected:false,
  220. currentAddress:{},
  221. isPetSelected:false,
  222. currentPets:[],
  223. needPreFamiliarize:[],
  224. defaultPhoto:'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png',
  225. companionLevel: {}, // 默认选择初级伴宠师
  226. showLevelInfo : {},
  227. }
  228. },
  229. computed: {
  230. ...mapState(['teacherLevelList'])
  231. },
  232. onLoad: function(option) {
  233. },
  234. onShow() {
  235. if (!getToken() || !getOpenIdKey()) {
  236. this.login()
  237. }
  238. if(this.$globalData.mainSku.length < 1 || !this.$globalData.mainSku[0].price){
  239. // 获取主产品
  240. this.getProductList()
  241. }
  242. this.currentAddress = this.$globalData.newOrderData.currentAddress
  243. if(this.currentAddress&&this.currentAddress.name){
  244. this.isAddressSelected=true
  245. }
  246. this.currentPets = this.$globalData.newOrderData.currentPets
  247. if(this.currentPets&&this.currentPets.length>0){
  248. this.isPetSelected=true
  249. }
  250. this.needPreFamiliarize = this.$globalData.newOrderData.needPreFamiliarize
  251. // 初始化伴宠师等级
  252. if(this.$globalData.newOrderData.companionLevel) {
  253. this.companionLevel = this.$globalData.newOrderData.companionLevel
  254. }else{
  255. this.companionLevel = this.teacherLevelList[0]
  256. this.$globalData.newOrderData.companionLevel = this.companionLevel
  257. }
  258. this.$store.commit('getUserInfo')
  259. },
  260. methods:{
  261. companionLevelPrice(){
  262. let price = Number(this.showLevelInfo.paramValueText) * this.isAddPrice()
  263. return price * this.$store.state.memberRate
  264. },
  265. //判断当前选中的地址是否加价
  266. isAddPrice(){
  267. let currentAddress = this.$globalData.newOrderData.currentAddress || {}
  268. let defaultPrice = 1
  269. try{
  270. defaultPrice = this.price_config.cityConfig.priceRates.default
  271. }catch(e){
  272. defaultPrice = 1
  273. }
  274. if(!this.price_config.cityConfig || !currentAddress.province || !currentAddress.city){
  275. return defaultPrice
  276. }
  277. let addressList = this.price_config.cityConfig.priceRates || []
  278. for(let key in addressList){
  279. if((currentAddress.province + currentAddress.city).includes(key)){
  280. return addressList[key]
  281. }
  282. }
  283. return defaultPrice
  284. },
  285. selectAddress(){
  286. uni.navigateTo({
  287. url: "/pages/newOrder/addressList"
  288. });
  289. },
  290. selectPet(){
  291. uni.navigateTo({
  292. url: "/pages/newOrder/petList"
  293. });
  294. },
  295. selectCompanionLevel(level) {
  296. this.companionLevel = level;
  297. // 将选择的伴宠师等级保存到全局数据
  298. this.$globalData.newOrderData.companionLevel = level;
  299. },
  300. showCompanionInfo(level) {
  301. this.showLevelInfo = level
  302. this.$refs.companionInfoPopup.open();
  303. },
  304. closeCompanionInfo() {
  305. this.$refs.companionInfoPopup.close();
  306. },
  307. getProductList() {
  308. getProductList({
  309. "publishStatus": 1,
  310. "categoryId": 76,
  311. "needSku": true
  312. }).then(response => {
  313. if (response && response.content && response.content.length > 0) {
  314. const skus = response && response.content[0].skus
  315. if(skus && skus.length>0){
  316. let price = this.price_config.basePrice.normal || skus[0].price
  317. let productSku = {
  318. "skuId": skus[0].id,
  319. // "price":(price * this.$store.state.memberRate).toFixed(2),
  320. "price":(skus[0].price).toFixed(2),
  321. "name":response.content[0].name,
  322. "quantity": 1,
  323. "isMainProduct":true
  324. }
  325. this.$globalData.mainSku = [productSku]
  326. }
  327. }else {
  328. uni.showToast('获取主产品失败,请联系管理员')
  329. }
  330. console.log(response);
  331. })
  332. },
  333. login() {
  334. uni.login({
  335. provider: 'weixin',
  336. success: (loginRes) => {
  337. this.getOpenId(loginRes.code)
  338. },
  339. fail: function(error) {
  340. // 授权失败处理
  341. uni.showToast('授权失败,请授权后再试')
  342. }
  343. });
  344. },
  345. getOpenId(code) {
  346. getOpenId(code).then(res => {
  347. if (res.code == 200 && res.data) {
  348. let resData = JSON.parse(res.data)
  349. let token = resData.token;
  350. let openId = resData.openId;
  351. setOpenIdKey(openId)
  352. if(token){
  353. setToken(token)
  354. }
  355. }
  356. })
  357. },
  358. goNext(){
  359. console.log('this.$globalData', this.$globalData)
  360. if(!this.isAddressSelected) {
  361. this.$modal.showToast('请选择服务地址');
  362. return;
  363. }
  364. if(!this.isPetSelected) {
  365. this.$modal.showToast('请选择宠物');
  366. return;
  367. }
  368. this.$globalData.newOrderData.needPreFamiliarize = this.needPreFamiliarize
  369. uni.navigateTo({
  370. url: "/pages/newOrder/serviceNew2"
  371. });
  372. console.log(this.$globalData.newOrderData)
  373. },
  374. getSelectedDateString(selectDate){
  375. //显示日期为01/01;01/02;
  376. if(!selectDate || selectDate.length === 0) return '';
  377. return selectDate.map(date => {
  378. // 从日期字符串中提取月和日
  379. const [,month, day] = date.date.split('-');
  380. return `${month}/${day}`;
  381. }).join(';');
  382. }
  383. }
  384. }
  385. </script>
  386. <style scoped lang="less">
  387. .container {
  388. position: relative;
  389. height: 100%;
  390. padding-bottom: 78px;
  391. .order-type-select {
  392. padding: 20rpx 30rpx;
  393. margin-bottom: 20rpx;
  394. .order-type-title {
  395. background-color: #FFF9F0;
  396. display: flex;
  397. align-items: center;
  398. font-size: 28rpx;
  399. color: #333;
  400. margin-bottom: 20rpx;
  401. padding: 20rpx;
  402. border-radius: 40rpx;
  403. }
  404. .order-type-options {
  405. display: flex;
  406. justify-content: space-between;
  407. margin-top: 20rpx;
  408. flex-wrap: wrap;
  409. gap: 20rpx;
  410. .order-type-option {
  411. display: flex;
  412. align-items: center;
  413. width: 48%;
  414. height: 80rpx;
  415. background-color: #FFFFFF;
  416. border-radius: 40rpx;
  417. padding: 0 20rpx;
  418. font-size: 28rpx;
  419. color: #666;
  420. position: relative;
  421. border: 2rpx solid transparent;
  422. &.active {
  423. border: 2rpx solid #FFB13F;
  424. background-color: #FFF5E5;
  425. }
  426. .info-icon {
  427. position: absolute;
  428. right: 20rpx;
  429. }
  430. }
  431. }
  432. }
  433. .companion-info-popup {
  434. width: 600rpx;
  435. background-color: #FFFFFF;
  436. border-radius: 20rpx;
  437. padding: 40rpx;
  438. position: relative;
  439. &::after {
  440. content: '';
  441. display: flex;
  442. position: absolute;
  443. top: 0rpx;
  444. left: 0;
  445. width: 100%;
  446. height: 100rpx;
  447. background-color: #FFB13F;
  448. }
  449. .companion-info-title {
  450. font-size: 32rpx;
  451. font-weight: bold;
  452. color: #fff;
  453. text-align: center;
  454. border-bottom: 1rpx solid #EFEFEF;
  455. position: relative;
  456. z-index: 2;
  457. height: 100rpx;
  458. }
  459. .companion-info-content {
  460. .companion-info-item {
  461. margin-bottom: 40rpx;
  462. .companion-info-label {
  463. font-size: 28rpx;
  464. color: #666;
  465. margin-right: 10rpx;
  466. }
  467. .companion-info-value {
  468. font-size: 28rpx;
  469. color: #333;
  470. }
  471. }
  472. }
  473. .companion-info-close {
  474. position: absolute;
  475. bottom: -80rpx;
  476. left: 50%;
  477. transform: translateX(-50%);
  478. width: 80rpx;
  479. height: 80rpx;
  480. border-radius: 50%;
  481. display: flex;
  482. align-items: center;
  483. justify-content: center;
  484. }
  485. }
  486. .details-subscribe {
  487. background-color: #FFFFFF;
  488. padding: 10px;
  489. width: 100%;
  490. height: 78px;
  491. position: fixed;
  492. bottom: 0;
  493. z-index: 100;
  494. .details-btn {
  495. width: 100%;
  496. border-radius: 6px;
  497. background: #FFB13F;
  498. font-size: 16px;
  499. color: #FFFFFF;
  500. }
  501. }
  502. }
  503. .service-new{
  504. .service-new-flag {
  505. width: 8rpx;
  506. height: 32rpx;
  507. background: #FFBF60;
  508. border-radius: 30rpx 30rpx 30rpx 30rpx;
  509. margin-right: 10rpx;
  510. }
  511. .split-line{
  512. width: 100%;
  513. height: 1rpx;
  514. background: #EFEFEF;
  515. }
  516. .service-new-title{
  517. display: flex;
  518. font-weight: 500;
  519. font-size: 28rpx;
  520. color: #333333;
  521. line-height: 33rpx;
  522. margin: 42rpx 0 30rpx;
  523. justify-content: space-between;
  524. .service-new-title-left{
  525. display: flex;
  526. align-items: center;
  527. }
  528. }
  529. .service-new-unselect{
  530. height: 156rpx;
  531. display: flex;
  532. justify-content: center;
  533. align-items: center;
  534. }
  535. .add-pet{
  536. font-weight: 400;
  537. font-size: 28rpx;
  538. color: #FFAA48;
  539. line-height: 40rpx;
  540. display: flex;
  541. align-items: center;
  542. }
  543. .service-new-details-desc{
  544. font-weight: 400;
  545. font-size: 24rpx;
  546. color: #A94F20;
  547. line-height: 28rpx;
  548. text-align: left;
  549. padding: 26rpx 0;
  550. }
  551. .personal-address-info{
  552. display: flex;
  553. align-items: center;
  554. justify-content: flex-start;
  555. flex-wrap: wrap;
  556. margin: 32rpx 0;
  557. width: 80%;
  558. .personal-address-text{
  559. color: #333;
  560. font-size: 28rpx;
  561. font-weight: bold;
  562. width: 100%;
  563. }
  564. .personal-address-people{
  565. color: #7D8196;
  566. font-size: 28rpx;
  567. font-weight: 400;
  568. display: flex;
  569. justify-content: flex-start;
  570. align-items: center;
  571. }
  572. }
  573. .service-new-address-selected{
  574. display: flex;
  575. justify-content: space-between;
  576. align-items: center;
  577. }
  578. }
  579. .personal-pet-list {
  580. margin-top: 20rpx;
  581. .personal-pet-list-item {
  582. margin-bottom: 20rpx;
  583. background-color: #F9F9F9;
  584. height: 172rpx;
  585. border-radius: 8rpx;
  586. .personal-pet-info {
  587. height: 100%;
  588. display: flex;
  589. align-items: center;
  590. padding: 0 20rpx;
  591. }
  592. }
  593. }
  594. .order-type-title-custom {
  595. background-color: #FFF9F0;
  596. font-size: 28rpx;
  597. color: #333;
  598. margin-bottom: 20rpx;
  599. padding: 20rpx;
  600. border-radius: 20rpx;
  601. display: flex;
  602. flex-direction: column;
  603. align-items: flex-start !important;
  604. }
  605. .order-type-title-main {
  606. display: flex;
  607. align-items: flex-start;
  608. }
  609. .main-title {
  610. font-size: 28rpx;
  611. font-weight: bold;
  612. line-height: 1.2;
  613. color: #D97B2B;
  614. }
  615. .sub-title {
  616. font-size: 24rpx;
  617. color: #D97B2B;
  618. margin-top: 6rpx;
  619. line-height: 1.2;
  620. }
  621. </style>