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.

692 lines
20 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
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. <view class="companion-info-label">等级:</view>
  51. <view class="companion-info-value">{{ showLevelInfo.paramValue }}</view>
  52. </view>
  53. <view class="companion-info-item">
  54. <view class="companion-info-label">价格:</view>
  55. <view class="companion-info-value">{{ (companionLevelPrice() + basePrice()).toFixed(2) }}</view>
  56. </view>
  57. <view class="companion-info-item">
  58. <view class="companion-info-label">分类标准:</view>
  59. <view class="companion-info-value"
  60. v-html="showLevelInfo.paramValueArea"
  61. >
  62. </view>
  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', 'buyInfo', 'price_config'])
  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. // 计算并保存伴宠师等级价格
  259. this.$globalData.newOrderData.companionLevelPrice = this.calculateCompanionLevelPrice(this.companionLevel)
  260. // 保存城市倍率
  261. this.$globalData.newOrderData.cityPriceRate = this.isAddPrice()
  262. this.$store.commit('getUserInfo')
  263. },
  264. methods:{
  265. basePrice(){
  266. let priceConfig = this.$store.state.price_config
  267. let normal = priceConfig.basePrice && priceConfig.basePrice.normal
  268. let normalNumber = normal * this.$store.state.memberRate * this.isAddPrice()
  269. return isNaN(normalNumber) ? 0 : normalNumber
  270. },
  271. companionLevelPrice(){
  272. let price = Number(this.showLevelInfo.paramValueText) * this.isAddPrice()
  273. return price * this.$store.state.memberRate
  274. },
  275. // 计算伴宠师等级价格(用于保存到全局数据)
  276. calculateCompanionLevelPrice(level) {
  277. if (!level || !level.paramValueText) {
  278. return 0
  279. }
  280. let price = Number(level.paramValueText) * this.isAddPrice()
  281. return price * this.$store.state.memberRate
  282. },
  283. //判断当前选中的地址是否加价
  284. isAddPrice(){
  285. let currentAddress = this.$globalData.newOrderData.currentAddress || {}
  286. let defaultPrice = 1
  287. try{
  288. defaultPrice = this.price_config.cityConfig.priceRates.default
  289. }catch(e){
  290. defaultPrice = 1
  291. }
  292. if(!this.price_config.cityConfig || !currentAddress.province || !currentAddress.city){
  293. return defaultPrice
  294. }
  295. let addressList = this.price_config.cityConfig.priceRates || []
  296. for(let key in addressList){
  297. if((currentAddress.province + currentAddress.city).includes(key)){
  298. return addressList[key]
  299. }
  300. }
  301. return defaultPrice
  302. },
  303. selectAddress(){
  304. uni.navigateTo({
  305. url: "/pages/newOrder/addressList"
  306. });
  307. },
  308. selectPet(){
  309. uni.navigateTo({
  310. url: "/pages/newOrder/petList"
  311. });
  312. },
  313. selectCompanionLevel(level) {
  314. this.companionLevel = level;
  315. // 将选择的伴宠师等级保存到全局数据
  316. this.$globalData.newOrderData.companionLevel = level;
  317. // 计算并保存伴宠师等级价格
  318. this.$globalData.newOrderData.companionLevelPrice = this.calculateCompanionLevelPrice(level);
  319. },
  320. showCompanionInfo(level) {
  321. this.showLevelInfo = level
  322. this.$refs.companionInfoPopup.open();
  323. },
  324. closeCompanionInfo() {
  325. this.$refs.companionInfoPopup.close();
  326. },
  327. getProductList() {
  328. getProductList({
  329. "publishStatus": 1,
  330. "categoryId": 76,
  331. "needSku": true
  332. }).then(response => {
  333. if (response && response.content && response.content.length > 0) {
  334. const skus = response && response.content[0].skus
  335. if(skus && skus.length>0){
  336. let price = this.price_config.basePrice.normal || skus[0].price
  337. let productSku = {
  338. "skuId": skus[0].id,
  339. // "price":(price * this.$store.state.memberRate).toFixed(2),
  340. "price":(skus[0].price).toFixed(2),
  341. "name":response.content[0].name,
  342. "quantity": 1,
  343. "isMainProduct":true
  344. }
  345. this.$globalData.mainSku = [productSku]
  346. }
  347. }else {
  348. uni.showToast('获取主产品失败,请联系管理员')
  349. }
  350. console.log(response);
  351. })
  352. },
  353. login() {
  354. uni.login({
  355. provider: 'weixin',
  356. success: (loginRes) => {
  357. this.getOpenId(loginRes.code)
  358. },
  359. fail: function(error) {
  360. // 授权失败处理
  361. uni.showToast('授权失败,请授权后再试')
  362. }
  363. });
  364. },
  365. getOpenId(code) {
  366. getOpenId(code).then(res => {
  367. if (res.code == 200 && res.data) {
  368. let resData = JSON.parse(res.data)
  369. let token = resData.token;
  370. let openId = resData.openId;
  371. setOpenIdKey(openId)
  372. if(token){
  373. setToken(token)
  374. }
  375. }
  376. })
  377. },
  378. goNext(){
  379. console.log('this.$globalData', this.$globalData)
  380. if(!this.isAddressSelected) {
  381. this.$modal.showToast('请选择服务地址');
  382. return;
  383. }
  384. if(!this.isPetSelected) {
  385. this.$modal.showToast('请选择宠物');
  386. return;
  387. }
  388. this.$globalData.newOrderData.needPreFamiliarize = this.needPreFamiliarize
  389. // 保存城市倍率
  390. this.$globalData.newOrderData.cityPriceRate = this.isAddPrice()
  391. uni.navigateTo({
  392. url: "/pages/newOrder/serviceNew2"
  393. });
  394. console.log(this.$globalData.newOrderData)
  395. },
  396. getSelectedDateString(selectDate){
  397. //显示日期为01/01;01/02;
  398. if(!selectDate || selectDate.length === 0) return '';
  399. return selectDate.map(date => {
  400. // 从日期字符串中提取月和日
  401. const [,month, day] = date.date.split('-');
  402. return `${month}/${day}`;
  403. }).join(';');
  404. }
  405. }
  406. }
  407. </script>
  408. <style scoped lang="less">
  409. .container {
  410. position: relative;
  411. height: 100%;
  412. padding-bottom: 78px;
  413. .order-type-select {
  414. padding: 20rpx 30rpx;
  415. margin-bottom: 20rpx;
  416. .order-type-title {
  417. background-color: #FFF9F0;
  418. display: flex;
  419. align-items: center;
  420. font-size: 28rpx;
  421. color: #333;
  422. margin-bottom: 20rpx;
  423. padding: 20rpx;
  424. border-radius: 40rpx;
  425. }
  426. .order-type-options {
  427. display: flex;
  428. justify-content: space-between;
  429. margin-top: 20rpx;
  430. flex-wrap: wrap;
  431. gap: 20rpx;
  432. .order-type-option {
  433. display: flex;
  434. align-items: center;
  435. width: 48%;
  436. height: 80rpx;
  437. background-color: #FFFFFF;
  438. border-radius: 40rpx;
  439. padding: 0 20rpx;
  440. font-size: 28rpx;
  441. color: #666;
  442. position: relative;
  443. border: 2rpx solid transparent;
  444. &.active {
  445. border: 2rpx solid #FFB13F;
  446. background-color: #FFF5E5;
  447. }
  448. .info-icon {
  449. position: absolute;
  450. right: 20rpx;
  451. }
  452. }
  453. }
  454. }
  455. .companion-info-popup {
  456. width: 600rpx;
  457. background-color: #FFFFFF;
  458. border-radius: 20rpx;
  459. padding: 40rpx;
  460. position: relative;
  461. &::after {
  462. content: '';
  463. display: flex;
  464. position: absolute;
  465. top: 0rpx;
  466. left: 0;
  467. width: 100%;
  468. height: 100rpx;
  469. background-color: #FFB13F;
  470. }
  471. .companion-info-title {
  472. font-size: 32rpx;
  473. font-weight: bold;
  474. color: #fff;
  475. text-align: center;
  476. border-bottom: 1rpx solid #EFEFEF;
  477. position: relative;
  478. z-index: 2;
  479. height: 100rpx;
  480. }
  481. .companion-info-content {
  482. .companion-info-item {
  483. margin-bottom: 40rpx;
  484. display: flex;
  485. .companion-info-label {
  486. font-size: 28rpx;
  487. color: #666;
  488. width: 136rpx;
  489. flex-shrink: 0;
  490. }
  491. .companion-info-value {
  492. font-size: 28rpx;
  493. color: #333;
  494. }
  495. }
  496. }
  497. .companion-info-close {
  498. position: absolute;
  499. bottom: -80rpx;
  500. left: 50%;
  501. transform: translateX(-50%);
  502. width: 80rpx;
  503. height: 80rpx;
  504. border-radius: 50%;
  505. display: flex;
  506. align-items: center;
  507. justify-content: center;
  508. }
  509. }
  510. .details-subscribe {
  511. background-color: #FFFFFF;
  512. padding: 10px;
  513. width: 100%;
  514. height: 78px;
  515. position: fixed;
  516. bottom: 0;
  517. z-index: 100;
  518. .details-btn {
  519. width: 100%;
  520. border-radius: 6px;
  521. background: #FFB13F;
  522. font-size: 16px;
  523. color: #FFFFFF;
  524. }
  525. }
  526. }
  527. .service-new{
  528. .service-new-flag {
  529. width: 8rpx;
  530. height: 32rpx;
  531. background: #FFBF60;
  532. border-radius: 30rpx 30rpx 30rpx 30rpx;
  533. margin-right: 10rpx;
  534. }
  535. .split-line{
  536. width: 100%;
  537. height: 1rpx;
  538. background: #EFEFEF;
  539. }
  540. .service-new-title{
  541. display: flex;
  542. font-weight: 500;
  543. font-size: 28rpx;
  544. color: #333333;
  545. line-height: 33rpx;
  546. margin: 42rpx 0 30rpx;
  547. justify-content: space-between;
  548. .service-new-title-left{
  549. display: flex;
  550. align-items: center;
  551. }
  552. }
  553. .service-new-unselect{
  554. height: 156rpx;
  555. display: flex;
  556. justify-content: center;
  557. align-items: center;
  558. }
  559. .add-pet{
  560. font-weight: 400;
  561. font-size: 28rpx;
  562. color: #FFAA48;
  563. line-height: 40rpx;
  564. display: flex;
  565. align-items: center;
  566. }
  567. .service-new-details-desc{
  568. font-weight: 400;
  569. font-size: 24rpx;
  570. color: #A94F20;
  571. line-height: 28rpx;
  572. text-align: left;
  573. padding: 26rpx 0;
  574. }
  575. .personal-address-info{
  576. display: flex;
  577. align-items: center;
  578. justify-content: flex-start;
  579. flex-wrap: wrap;
  580. margin: 32rpx 0;
  581. width: 80%;
  582. .personal-address-text{
  583. color: #333;
  584. font-size: 28rpx;
  585. font-weight: bold;
  586. width: 100%;
  587. }
  588. .personal-address-people{
  589. color: #7D8196;
  590. font-size: 28rpx;
  591. font-weight: 400;
  592. display: flex;
  593. justify-content: flex-start;
  594. align-items: center;
  595. }
  596. }
  597. .service-new-address-selected{
  598. display: flex;
  599. justify-content: space-between;
  600. align-items: center;
  601. }
  602. }
  603. .personal-pet-list {
  604. margin-top: 20rpx;
  605. .personal-pet-list-item {
  606. margin-bottom: 20rpx;
  607. background-color: #F9F9F9;
  608. height: 172rpx;
  609. border-radius: 8rpx;
  610. .personal-pet-info {
  611. height: 100%;
  612. display: flex;
  613. align-items: center;
  614. padding: 0 20rpx;
  615. }
  616. }
  617. }
  618. .order-type-title-custom {
  619. background-color: #FFF9F0;
  620. font-size: 28rpx;
  621. color: #333;
  622. margin-bottom: 20rpx;
  623. padding: 20rpx;
  624. border-radius: 20rpx;
  625. display: flex;
  626. flex-direction: column;
  627. align-items: flex-start !important;
  628. }
  629. .order-type-title-main {
  630. display: flex;
  631. align-items: flex-start;
  632. }
  633. .main-title {
  634. font-size: 28rpx;
  635. font-weight: bold;
  636. line-height: 1.2;
  637. color: #D97B2B;
  638. }
  639. .sub-title {
  640. font-size: 24rpx;
  641. color: #D97B2B;
  642. margin-top: 6rpx;
  643. line-height: 1.2;
  644. }
  645. </style>