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.

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