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.

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