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.

623 lines
18 KiB

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