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.

578 lines
16 KiB

1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week 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. }
  234. },
  235. methods:{
  236. selectAddress(){
  237. uni.navigateTo({
  238. url: "/pages/newOrder/addressList"
  239. });
  240. },
  241. selectPet(){
  242. uni.navigateTo({
  243. url: "/pages/newOrder/petList"
  244. });
  245. },
  246. selectCompanionLevel(level) {
  247. this.companionLevel = level;
  248. // 将选择的伴宠师等级保存到全局数据
  249. this.$globalData.newOrderData.companionLevel = level;
  250. },
  251. showCompanionInfo(level) {
  252. if(level === 'junior') {
  253. this.popupTitle = '初级伴宠师';
  254. this.popupLevel = '初级伴宠师';
  255. } else {
  256. this.popupTitle = '高级伴宠师';
  257. this.popupLevel = '高级伴宠师';
  258. }
  259. this.$refs.companionInfoPopup.open();
  260. },
  261. closeCompanionInfo() {
  262. this.$refs.companionInfoPopup.close();
  263. },
  264. getProductList() {
  265. getProductList({
  266. "publishStatus": 1,
  267. "categoryId": 76,
  268. "needSku": true
  269. }).then(response => {
  270. if (response && response.content && response.content.length > 0) {
  271. const skus = response && response.content[0].skus
  272. if(skus && skus.length>0){
  273. let productSku = {
  274. "skuId": skus[0].id,
  275. "price":skus[0].price,
  276. "name":response.content[0].name,
  277. "quantity": 1,
  278. "isMainProduct":true
  279. }
  280. this.$globalData.mainSku = [productSku]
  281. }
  282. }else {
  283. uni.showToast('获取主产品失败,请联系管理员')
  284. }
  285. console.log(response);
  286. })
  287. },
  288. login() {
  289. uni.login({
  290. provider: 'weixin',
  291. success: (loginRes) => {
  292. this.getOpenId(loginRes.code)
  293. },
  294. fail: function(error) {
  295. // 授权失败处理
  296. uni.showToast('授权失败,请授权后再试')
  297. }
  298. });
  299. },
  300. getOpenId(code) {
  301. getOpenId(code).then(res => {
  302. if (res.code == 200 && res.data) {
  303. let resData = JSON.parse(res.data)
  304. let token = resData.token;
  305. let openId = resData.openId;
  306. setOpenIdKey(openId)
  307. if(token){
  308. setToken(token)
  309. }
  310. }
  311. })
  312. },
  313. goNext(){
  314. console.log(this.needPreFamiliarize)
  315. if(!this.isAddressSelected) {
  316. this.$modal.showToast('请选择服务地址');
  317. return;
  318. }
  319. if(!this.isPetSelected) {
  320. this.$modal.showToast('请选择宠物');
  321. return;
  322. }
  323. this.$globalData.newOrderData.needPreFamiliarize = this.needPreFamiliarize
  324. uni.navigateTo({
  325. url: "/pages/newOrder/serviceNew2"
  326. });
  327. console.log(this.$globalData.newOrderData)
  328. },
  329. getSelectedDateString(selectDate){
  330. //显示日期为01/01;01/02;
  331. if(!selectDate || selectDate.length === 0) return '';
  332. return selectDate.map(date => {
  333. // 从日期字符串中提取月和日
  334. const [,month, day] = date.date.split('-');
  335. return `${month}/${day}`;
  336. }).join(';');
  337. }
  338. }
  339. }
  340. </script>
  341. <style scoped lang="less">
  342. .container {
  343. position: relative;
  344. height: 100%;
  345. padding-bottom: 78px;
  346. .order-type-select {
  347. padding: 20rpx 30rpx;
  348. margin-bottom: 20rpx;
  349. .order-type-title {
  350. background-color: #FFF9F0;
  351. display: flex;
  352. align-items: center;
  353. font-size: 28rpx;
  354. color: #333;
  355. margin-bottom: 20rpx;
  356. padding: 20rpx;
  357. border-radius: 40rpx;
  358. }
  359. .order-type-options {
  360. display: flex;
  361. justify-content: space-between;
  362. margin-top: 20rpx;
  363. .order-type-option {
  364. display: flex;
  365. align-items: center;
  366. width: 48%;
  367. height: 80rpx;
  368. background-color: #FFFFFF;
  369. border-radius: 40rpx;
  370. padding: 0 20rpx;
  371. font-size: 28rpx;
  372. color: #666;
  373. position: relative;
  374. border: 2rpx solid transparent;
  375. &.active {
  376. border: 2rpx solid #FFB13F;
  377. background-color: #FFF5E5;
  378. }
  379. .info-icon {
  380. position: absolute;
  381. right: 20rpx;
  382. }
  383. }
  384. }
  385. }
  386. .companion-info-popup {
  387. width: 600rpx;
  388. background-color: #FFFFFF;
  389. border-radius: 20rpx;
  390. padding: 40rpx;
  391. position: relative;
  392. &::after {
  393. content: '';
  394. display: flex;
  395. position: absolute;
  396. top: 0rpx;
  397. left: 0;
  398. width: 100%;
  399. height: 100rpx;
  400. background-color: #FFB13F;
  401. }
  402. .companion-info-title {
  403. font-size: 32rpx;
  404. font-weight: bold;
  405. color: #fff;
  406. text-align: center;
  407. border-bottom: 1rpx solid #EFEFEF;
  408. position: relative;
  409. z-index: 2;
  410. height: 100rpx;
  411. }
  412. .companion-info-content {
  413. .companion-info-item {
  414. margin-bottom: 40rpx;
  415. .companion-info-label {
  416. font-size: 28rpx;
  417. color: #666;
  418. margin-right: 10rpx;
  419. }
  420. .companion-info-value {
  421. font-size: 28rpx;
  422. color: #333;
  423. }
  424. }
  425. }
  426. .companion-info-close {
  427. position: absolute;
  428. bottom: -80rpx;
  429. left: 50%;
  430. transform: translateX(-50%);
  431. width: 80rpx;
  432. height: 80rpx;
  433. border-radius: 50%;
  434. display: flex;
  435. align-items: center;
  436. justify-content: center;
  437. }
  438. }
  439. .details-subscribe {
  440. background-color: #FFFFFF;
  441. padding: 10px;
  442. width: 100%;
  443. height: 78px;
  444. position: fixed;
  445. bottom: 0;
  446. z-index: 100;
  447. .details-btn {
  448. width: 100%;
  449. border-radius: 6px;
  450. background: #FFB13F;
  451. font-size: 16px;
  452. color: #FFFFFF;
  453. }
  454. }
  455. }
  456. .service-new{
  457. .service-new-flag {
  458. width: 8rpx;
  459. height: 32rpx;
  460. background: #FFBF60;
  461. border-radius: 30rpx 30rpx 30rpx 30rpx;
  462. margin-right: 10rpx;
  463. }
  464. .split-line{
  465. width: 100%;
  466. height: 1rpx;
  467. background: #EFEFEF;
  468. }
  469. .service-new-title{
  470. display: flex;
  471. font-weight: 500;
  472. font-size: 28rpx;
  473. color: #333333;
  474. line-height: 33rpx;
  475. margin: 42rpx 0 30rpx;
  476. justify-content: space-between;
  477. .service-new-title-left{
  478. display: flex;
  479. align-items: center;
  480. }
  481. }
  482. .service-new-unselect{
  483. height: 156rpx;
  484. display: flex;
  485. justify-content: center;
  486. align-items: center;
  487. }
  488. .add-pet{
  489. font-weight: 400;
  490. font-size: 28rpx;
  491. color: #FFAA48;
  492. line-height: 40rpx;
  493. display: flex;
  494. align-items: center;
  495. }
  496. .service-new-details-desc{
  497. font-weight: 400;
  498. font-size: 24rpx;
  499. color: #A94F20;
  500. line-height: 28rpx;
  501. text-align: left;
  502. padding: 26rpx 0;
  503. }
  504. .personal-address-info{
  505. display: flex;
  506. align-items: center;
  507. justify-content: flex-start;
  508. flex-wrap: wrap;
  509. margin: 32rpx 0;
  510. width: 80%;
  511. .personal-address-text{
  512. color: #333;
  513. font-size: 28rpx;
  514. font-weight: bold;
  515. width: 100%;
  516. }
  517. .personal-address-people{
  518. color: #7D8196;
  519. font-size: 28rpx;
  520. font-weight: 400;
  521. display: flex;
  522. justify-content: flex-start;
  523. align-items: center;
  524. }
  525. }
  526. .service-new-address-selected{
  527. display: flex;
  528. justify-content: space-between;
  529. align-items: center;
  530. }
  531. }
  532. .personal-pet-list {
  533. margin-top: 20rpx;
  534. .personal-pet-list-item {
  535. margin-bottom: 20rpx;
  536. background-color: #F9F9F9;
  537. height: 172rpx;
  538. border-radius: 8rpx;
  539. .personal-pet-info {
  540. height: 100%;
  541. display: flex;
  542. align-items: center;
  543. padding: 0 20rpx;
  544. }
  545. }
  546. }
  547. </style>