index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. <template>
  2. <view class="preCarWash" style="padding-bottom: 240rpx;">
  3. <Card titles="附近门店" page="washCar" :data="carShopData"></Card>
  4. <Card titles="车辆信息" :data="cardMsg"></Card>
  5. <view class="card-view">
  6. <view class="classHead">
  7. <view class="classBorder">
  8. </view>
  9. <view class="classTitle">
  10. 选择服务
  11. </view>
  12. </view>
  13. <view class="classBody" style="padding: 36rpx 0;">
  14. <view v-for="(item, index) in carWashType" :key="index"
  15. style="padding-left: 24rpx;margin-bottom: 20rpx;">
  16. <button :class="chooseBtn==index?'chooseBtn':'btn'" @click="chooseBtn=index">{{item.name}}</button>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="card-view">
  21. <view class="classHead">
  22. <view class="classBorder">
  23. </view>
  24. <view class="classTitle">
  25. 服务方式
  26. </view>
  27. </view>
  28. <view class="radioView">
  29. <radio-group @change="radioChange">
  30. <div class="radioBody">
  31. <div class="radio">
  32. <radio style="transform:scale(0.7)" color="#0078FF" checked="true" :value="1" />在店洗车
  33. </div>
  34. <div class="radio">
  35. <radio style="transform:scale(0.7)" color="#0078FF" :value="2" />预约洗车
  36. </div>
  37. </div>
  38. </radio-group>
  39. </view>
  40. <view class="border" v-if="radioValue===2"></view>
  41. <view class="dataTimeBody" @tap="routerTo(dataTime)" v-if="radioValue===2">
  42. <view :class="dataTime?'dataTime':'dataNull'">
  43. {{dataTime || "请选择预约时间"}}
  44. </view>
  45. <view class="dataRight">
  46. <image class="classChoose" :src="require('../../static/choose.png')">
  47. </view>
  48. </view>
  49. </view>
  50. <view class="card-view" style="height: 186rpx;">
  51. <view class="classHead">
  52. <view class="classBorder">
  53. </view>
  54. <view class="classTitle">
  55. 可用套餐
  56. </view>
  57. </view>
  58. <view class="dataTimeBody" style="padding-top: 28rpx;" @tap="routerTo('套餐')">
  59. <view :class="setMeal.name?'dataTime':'dataNull'">
  60. {{setMeal.name || "请选择套餐"}}
  61. </view>
  62. <view class="dataRight">
  63. <span v-if="setMeal.name" class="unit">可用</span>
  64. <span v-if="setMeal.name" class="num">{{setMeal.surplusSum}}</span>
  65. <image class="classChoose" :src="require('../../static/choose.png')">
  66. </view>
  67. </view>
  68. </view>
  69. <view class="price">
  70. <view class="leftView">
  71. <view class="classBottomLeft">
  72. <view style="font-size: 26rpx;">
  73. </view>
  74. <view style="font-size: 56rpx;">
  75. {{carPrice}}
  76. </view>
  77. </view>
  78. <view class="classBottomRight">
  79. <view class="bottomSpan">
  80. 优惠价
  81. </view>
  82. <view class="bottomLaset">
  83. ¥{{carScrib}}
  84. </view>
  85. </view>
  86. </view>
  87. <view class="rightView" @click="plOrder">
  88. 立即预约
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. getSelectStore,
  96. getUserCar,
  97. getTimeList,
  98. carwashService
  99. } from "@/api/shop.js"
  100. import {
  101. getByTypeCode,
  102. getDefaultPrice,
  103. getMyPackage,
  104. carwashOrder
  105. } from "@/api/carWash.js"
  106. import Card from '@/components/Card'
  107. const app = getApp();
  108. export default {
  109. components: {
  110. Card
  111. },
  112. data: function() {
  113. return {
  114. requestStatus: false,
  115. loading: false,
  116. cardMsg: {},
  117. chooseBtn: 0,
  118. imgurl: require("../../static/logo.png"),
  119. dataTime: "",
  120. carShop: [],
  121. carShopData: {},
  122. setMeal: {},
  123. carWashType: [],
  124. setMealList: [],
  125. carPrice: "",
  126. carScrib: "",
  127. dataTimeList: [],
  128. startTime: "",
  129. radioValue: "1",
  130. carwashCode: "",
  131. pageType: '',
  132. btnStatus: false
  133. }
  134. },
  135. onBackPress(options) {
  136. console.log('11111');
  137. // 这里可以自定义返回逻辑,比如下面跳转其他页面
  138. if (!this.pageType) {
  139. // #ifdef APP-PLUS
  140. if (plus.os.name.toLowerCase() === 'android') {
  141. plus.runtime.quit();
  142. } else {
  143. plus.runtime.quit();
  144. }
  145. // #endif
  146. // return true 表示禁止默认返回
  147. return true;
  148. }
  149. },
  150. watch: {
  151. setMeal(val) {
  152. this.carPrice = 0
  153. },
  154. loading(val) {
  155. console.log(22222);
  156. if (this.cardMsg != "" && this.carShopData != undefined && this.carWashType != "" && val != undefined) {
  157. console.log(
  158. 'this.cardMsg != "" && this.carShopData != undefined && this.carWashType != "" && val != undefined',
  159. this.cardMsg);
  160. if (this.cardMsg.id != undefined) {
  161. this.getDefaultPrices(this.carWashType[0].name, this.carShopData.id, this.cardMsg.id)
  162. this.getMyPackages(this.carWashType[0].name, this.carShopData.id, this.cardMsg.id)
  163. }
  164. }
  165. },
  166. chooseBtn(val) {
  167. console.log(33333, val);
  168. if (this.cardMsg != "" && this.carShopData != undefined && this.carWashType != "" && val != undefined) {
  169. if (this.cardMsg.id != undefined) {
  170. console.log(this.carWashType[val], 'val');
  171. this.carwashCode = this.carWashType[val].id
  172. this.getDefaultPrices(this.carWashType[val].name, this.carShopData.id, this.cardMsg.id)
  173. this.getMyPackages(this.carWashType[val].name, this.carShopData.id, this.cardMsg.id)
  174. }
  175. }
  176. },
  177. cardMsg(val) {
  178. if (this.carShopData != undefined && this.carWashType != "" && val.id != undefined) {
  179. console.log(44444);
  180. console.log('val', val);
  181. this.getDefaultPrices(this.carWashType[0].name, this.carShopData.id, val.id)
  182. this.getMyPackages(this.carWashType[0].name, this.carShopData.id, val.id)
  183. }
  184. },
  185. carShopData(val) {
  186. console.log(55555);
  187. console.log('this.cardMsg.id', this.val);
  188. console.log(this.carWashType);
  189. if (this.cardMsg != "" && this.carWashType != "" && val != undefined) {
  190. if (this.cardMsg.id != undefined) {
  191. console.log(111);
  192. console.log(this.carWashType[0].id, val.id, this.cardMsg.id);
  193. // this.getDefaultPrices(this.carWashType[0].id, val.id, this.cardMsg.id)
  194. this.getMyPackages(this.carWashType[0].id, val.id, this.cardMsg.id)
  195. }
  196. }
  197. }
  198. },
  199. onLoad: function(e) { //option为object类型,会序列化上个页面传递的参数
  200. console.log('onLoad', e.token);
  201. this.pageType = e.type
  202. let that = this;
  203. app.globalData.requestToken = e.token;
  204. uni.setStorageSync('token', e.token)
  205. getSelectStore({
  206. pageNo: 1,
  207. pageSize: 20,
  208. type: 2,
  209. isCarwash: 1,
  210. longitude: app.globalData.longitude,
  211. latitude: app.globalData.latitude
  212. }).then(res => {
  213. that.carShop = res.data.rows;
  214. that.carShopData = that.carShop[0];
  215. console.log('that.carShop', that.carShop);
  216. console.log('that.carShop[0]', that.carShop[0]);
  217. console.log('shop====================>', uni.getStorageSync('shopData'));
  218. if (that.carShopData != undefined) {
  219. console.log(that.carShopData.id, 'that.carShopData.idthat.carShopData.id,');
  220. carwashService({
  221. id: that.carShopData.id
  222. }).then(res => {
  223. console.log(res, '参数12345');
  224. that.carWashType = res.data;
  225. that.carwashCode = that.carWashType[0].id
  226. if (that.carShop != "" && that.cardMsg != "" && that.carWashType != "") {
  227. that.loading = true;
  228. }
  229. })
  230. getTimeList({
  231. id: that.carShopData.id
  232. }).then(res => { //that.carShopData.id
  233. that.dataTimeList = res.data
  234. })
  235. if (that.carShop != "" && that.cardMsg != "" && that.carWashType != "") {
  236. that.loading = true;
  237. }
  238. } else {
  239. that.loading = true;
  240. }
  241. })
  242. getUserCar().then(res => {
  243. console.log(res);
  244. that.cardMsg = res.data;
  245. if (that.carShop != "" && that.cardMsg != "" && that.carWashType != "") {
  246. that.loading = true;
  247. }
  248. })
  249. /* getByTypeCode({
  250. dictTypeCode: "carWashType",
  251. }).then(res => {
  252. console.log(res.data,'dict');
  253. that.carWashType = res.data;
  254. that.carwashCode = that.carWashType[0].code
  255. if (that.carShop != "" && that.cardMsg != "" && that.carWashType != "") {
  256. that.loading = true;
  257. }
  258. }) */
  259. },
  260. onShow: function() { //option为object类型,会序列化上个页面传递的参数
  261. console.log('onShow');
  262. let that = this
  263. uni.$on('chooseData', function(data) {
  264. console.log('data===========================>', data);
  265. that.dataTime = data.data;
  266. that.startTime = data.startTime;
  267. })
  268. uni.$on('chooseCar', function(data) {
  269. that.cardMsg = data;
  270. })
  271. uni.$on('chooseShop', function(data) {
  272. console.log('datadddddd==================================>', data);
  273. that.carShopData = data;
  274. getTimeList({
  275. id: that.carShopData.id
  276. }).then(res => {
  277. console.log(res, 'resss');
  278. that.dataTimeList = res.data
  279. carwashService({
  280. id: that.carShopData.id
  281. }).then(res => {
  282. that.chooseBtn = 0
  283. console.log(res.data, '参数');
  284. that.carWashType = res.data;
  285. that.carwashCode = res.data[0].id
  286. console.log(that.carWashType[0].name, that.carShopData.id, tidhat
  287. .cardMsg
  288. .id,
  289. 'that.carWashType[0].name, that.carShopData.id, that.cardMsg.id'
  290. );
  291. that.getDefaultPrices(that.carWashType[0].name, that.carShopData.id,
  292. that.cardMsg.id)
  293. that.getMyPackages(that.carWashType[0].name, that.carShopData.id, that
  294. .cardMsg.id)
  295. if (that.carShop != "" && that.cardMsg != "" && that.carWashType !=
  296. "") {
  297. that.loading = true;
  298. }
  299. })
  300. })
  301. })
  302. uni.$on('setMeal', function(data) {
  303. that.setMeal = data;
  304. if (that.setMeal) {
  305. this.carPrice = 0
  306. }
  307. })
  308. },
  309. methods: {
  310. /* toPay(){
  311. uni.requestPayment({
  312. provider:"wxpay",
  313. })
  314. }, */
  315. plOrder() {
  316. if (this.requestStatus) {
  317. // 利用 return 终止函数继续运行
  318. return false;
  319. }
  320. this.requestStatus = true;
  321. setTimeout(() => {
  322. // 模拟执行完毕
  323. // 改变 requestStatus
  324. this.requestStatus = false;
  325. }, 1000);
  326. console.log(1);
  327. let data = {};
  328. if (this.cardMsg == "") {
  329. uni.showToast({
  330. title: "请选择车辆",
  331. icon: 'none',
  332. duration: 2000,
  333. })
  334. return
  335. } else {
  336. data.userCarId = this.cardMsg.id;
  337. }
  338. if (this.carShopData == "") {
  339. uni.showToast({
  340. title: "请选择店铺",
  341. icon: 'none',
  342. duration: 2000,
  343. })
  344. return;
  345. } else {
  346. data.shopId = this.carShopData.id;
  347. }
  348. if (this.carShopData == "") {
  349. uni.showToast({
  350. title: "请选择店铺",
  351. icon: 'none',
  352. duration: 2000,
  353. })
  354. return;
  355. } else {
  356. data.shopId = this.carShopData.id;
  357. }
  358. if (this.carwashCode == "") {
  359. uni.showToast({
  360. title: "请选择服务",
  361. // icon: 'none',
  362. duration: 2000,
  363. })
  364. return
  365. } else {
  366. data.shopServiceId = this.carwashCode
  367. }
  368. let type = 2
  369. if (data.payMoney == 0) type = 0;
  370. console.log(this.setMeal);
  371. data.payType = type;
  372. data.reserveTime = this.startTime;
  373. data.payMoney = this.carPrice;
  374. console.log(data.payMoney);
  375. data.upsId = this.setMeal.id
  376. data.upId = this.setMeal.upId
  377. data.serviceType = parseInt(this.radioValue);
  378. console.log('传参============>time', data);
  379. if (data.userCarId == null) {
  380. uni.showToast({
  381. icon: 'none',
  382. title: '请先添加车辆'
  383. })
  384. } else {
  385. if (data.upsId) {
  386. carwashOrder(data).then(() => {
  387. uni.showToast({
  388. icon: 'none',
  389. title: '下单成功'
  390. })
  391. setTimeout(() => {
  392. uni.navigateTo({
  393. url: '/pages/preCarWash/washOrder/index?token=' + uni
  394. .getStorageSync('token')
  395. })
  396. }, 1000)
  397. })
  398. } else {
  399. uni.navigateTo({
  400. url: '/pages/shop/cashierDesk/cashierDesk?page=carwash&params=' + JSON.stringify(data)
  401. })
  402. }
  403. }
  404. },
  405. getDefaultPrices(carwashCode, id, ucId) {
  406. let _this = this;
  407. console.log(carwashCode, id, ucId, 'carwashCode, id, ucId');
  408. getDefaultPrice({
  409. carwashName: carwashCode,
  410. id: id,
  411. ucId: ucId
  412. }).then((res) => {
  413. _this.carPrice = res.data.carPrice;
  414. _this.carScrib = res.data.carScrib;
  415. })
  416. },
  417. getMyPackages(carwashCode, id, ucId) {
  418. let _this = this;
  419. console.log(carwashCode, '店铺id');
  420. getMyPackage({
  421. carwashName: carwashCode,
  422. shopId: id,
  423. carId: ucId
  424. }).then((res) => {
  425. console.log(res, 'ressssss');
  426. _this.setMealList = res.data
  427. })
  428. },
  429. radioChange(e) {
  430. this.radioValue = e.detail.value
  431. },
  432. // 路由跳转
  433. routerTo(item) {
  434. if (item == "门店") {
  435. this.$yrouter.push({
  436. path: "/pages/preCarWash/chooseShop/index"
  437. });
  438. } else if (item == "套餐") {
  439. if (this.carShopData.id == null) {
  440. uni.showToast({
  441. title: "请选择店铺",
  442. icon: 'none',
  443. duration: 2000,
  444. })
  445. return;
  446. }
  447. if (this.cardMsg.id == null) {
  448. uni.showToast({
  449. title: "请选择车辆",
  450. icon: 'none',
  451. duration: 2000,
  452. })
  453. return;
  454. }
  455. let id = this.setMeal.id != undefined ? this.setMeal.id : "";
  456. this.$yrouter.push({
  457. path: "/pages/preCarWash/setMeal/index?id=" + id + "&setMealList=" + JSON.stringify(this
  458. .setMealList) + "&shopId=" + this.carShopData.id + "&carId=" + this.cardMsg.id +
  459. "&carWashType=" + this.carWashType[this.chooseBtn].dictCode
  460. });
  461. } else {
  462. this.$yrouter.push({
  463. path: "/pages/preCarWash/chooseTime/index?dataTime=" + item + "&shopId=" + this.carShop
  464. .id + "&dataTimeList=" + JSON.stringify(this.dataTimeList)
  465. });
  466. }
  467. }
  468. }
  469. }
  470. </script>
  471. <style>
  472. page {
  473. background: #F5F5F5;
  474. }
  475. .card-view {
  476. width: 94%;
  477. margin-left: 3%;
  478. background: #FFFFFF;
  479. border-radius: 10rpx;
  480. margin-top: 28rpx;
  481. }
  482. .classHead {
  483. display: flex;
  484. padding-top: 28rpx;
  485. width: 100%;
  486. height: 28rpx;
  487. }
  488. .classBorder {
  489. width: 5rpx;
  490. height: 28rpx;
  491. background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
  492. border-radius: 3rpx;
  493. }
  494. .classTitle {
  495. height: 25rpx;
  496. font-size: 26rpx;
  497. font-family: PingFang SC;
  498. font-weight: 500;
  499. color: #666666;
  500. padding-left: 28rpx;
  501. line-height: 28rpx;
  502. }
  503. .classBody {
  504. display: flex;
  505. justify-content: start;
  506. flex-wrap: wrap;
  507. }
  508. .classChoose {
  509. width: 15rpx;
  510. height: 23rpx;
  511. margin-left: 10rpx;
  512. }
  513. .chooseBtn {
  514. width: 204rpx;
  515. height: 86rpx;
  516. background: linear-gradient(0deg, #FF4800 0%, #FF9600 100%);
  517. border-radius: 10rpx;
  518. font-size: 32rpx;
  519. font-family: PingFang SC;
  520. font-weight: bold;
  521. color: #FFFFFF;
  522. line-height: 86rpx;
  523. }
  524. .btn {
  525. width: 204rpx;
  526. height: 86rpx;
  527. background: #FFFFFF;
  528. border: 1px solid #DBDBDB;
  529. border-radius: 10rpx;
  530. font-size: 32rpx;
  531. font-family: PingFang SC;
  532. font-weight: bold;
  533. color: #333333;
  534. line-height: 86rpx;
  535. }
  536. .radio {
  537. font-size: 28rpx;
  538. font-family: PingFang SC;
  539. font-weight: 500;
  540. color: #333333;
  541. line-height: 55rpx;
  542. width: 50%;
  543. }
  544. .radioBody {
  545. display: flex;
  546. padding: 28rpx;
  547. }
  548. .border {
  549. width: 650rpx;
  550. height: 1px;
  551. background: #EEEEEE;
  552. border-radius: 1px;
  553. margin-left: 4%;
  554. }
  555. .dataTimeBody {
  556. height: 100rpx;
  557. width: calc(100% - 56rpx);
  558. display: flex;
  559. padding: 0 28rpx;
  560. justify-content: space-between;
  561. }
  562. .dataTime {
  563. font-size: 32rpx;
  564. font-family: PingFang SC;
  565. font-weight: bold;
  566. color: #333333;
  567. line-height: 100rpx
  568. }
  569. .dataNull {
  570. font-size: 32rpx;
  571. font-family: PingFang SC;
  572. font-weight: 500;
  573. color: #A9A9A9;
  574. line-height: 100rpx;
  575. }
  576. .dataRight {
  577. /* margin-right: 56rpx; */
  578. line-height: 100rpx;
  579. }
  580. .price {
  581. width: 690rpx;
  582. height: 110rpx;
  583. background: #FFFFFF;
  584. border: 1px solid #EEEEEE;
  585. box-shadow: 0px 8rpx 17rpx 0px rgba(168, 165, 165, 0.09);
  586. border-radius: 55rpx;
  587. margin: 58rpx 0 58rpx 28rpx;
  588. position: fixed;
  589. bottom: 0rpx;
  590. }
  591. .leftView {
  592. float: left;
  593. display: flex;
  594. padding: 18rpx;
  595. }
  596. .rightView {
  597. float: right;
  598. width: 240rpx;
  599. height: 110rpx;
  600. text-align: center;
  601. background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
  602. border-radius: 0 55rpx 55rpx 0;
  603. font-size: 34rpx;
  604. font-family: PingFang SC;
  605. font-weight: 500;
  606. color: #FEFEFE;
  607. line-height: 110rpx
  608. }
  609. .classBottomLeft {
  610. display: flex;
  611. font-family: PingFang SC;
  612. font-weight: 500;
  613. color: #005EFF;
  614. align-items: baseline;
  615. }
  616. .bottomLaset {
  617. font-size: 26rpx;
  618. font-family: PingFang SC;
  619. font-weight: 500;
  620. text-decoration: line-through;
  621. color: #BCBCBC;
  622. line-height: 50rpx;
  623. }
  624. .bottomSpan {
  625. width: 78rpx;
  626. height: 28rpx;
  627. text-align: center;
  628. background: rgba(255, 181, 158, 0.4);
  629. box-shadow: 0px 3rpx 6rpx 0px rgba(212, 84, 24, 0.2);
  630. border-radius: 14rpx 14rpx 13rpx 0px;
  631. font-size: 20rpx;
  632. font-family: PingFang SC;
  633. font-weight: 500;
  634. color: #FF3C00;
  635. line-height: 31rpx;
  636. }
  637. .classBottomRight {
  638. padding-left: 18rpx;
  639. }
  640. .unit {
  641. font-size: 26rpx;
  642. font-family: PingFang SC;
  643. font-weight: 500;
  644. color: #666666;
  645. line-height: 31rpx;
  646. }
  647. .num {
  648. font-size: 26rpx;
  649. font-family: PingFang SC;
  650. font-weight: 500;
  651. color: #007DFF;
  652. line-height: 31rpx;
  653. }
  654. button::after {
  655. border: none;
  656. }
  657. </style>