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.

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