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.

591 lines
17 KiB

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