|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="apply">
|
|
|
- <van-nav-bar title="预定" left-arrow />
|
|
|
+ <van-nav-bar title="预定" :left-arrow="back" @click-left="$router.go(-1)" />
|
|
|
<van-form @submit="onSubmit">
|
|
|
<van-field
|
|
|
v-model="username"
|
|
@@ -32,14 +32,6 @@
|
|
|
readonly
|
|
|
:rules="[{ required: true, message: '请选择预定时间' }]"
|
|
|
/>
|
|
|
- <!-- <van-field
|
|
|
- @click="() => (dateInput = true)"
|
|
|
- v-model="selectTime"
|
|
|
- label="预定时间"
|
|
|
- placeholder="预定时间"
|
|
|
- readonly
|
|
|
- :rules="[{ required: true, message: '请选择预定时间' }]"
|
|
|
- /> -->
|
|
|
<div style="margin: 16px">
|
|
|
<van-button
|
|
|
color="#2a7ef4"
|
|
@@ -52,7 +44,8 @@
|
|
|
</van-button>
|
|
|
</div>
|
|
|
</van-form>
|
|
|
- <div style="margin: 16px" v-if="back">
|
|
|
+ <div style="margin: 16px">
|
|
|
+ <!-- <div style="margin: 16px" v-if="!back"> -->
|
|
|
<van-button round block type="default" @click="toAppointment">
|
|
|
查看预约
|
|
|
</van-button>
|
|
@@ -60,15 +53,6 @@
|
|
|
|
|
|
<!-- #2a7ef4 -->
|
|
|
<van-popup v-model="dateInput" position="bottom">
|
|
|
- <!-- <van-datetime-picker
|
|
|
- :filter="filter"
|
|
|
- type="datetime"
|
|
|
- :min-date="minDate"
|
|
|
- :max-date="maxDate"
|
|
|
- title="选择预定时间"
|
|
|
- @cancel="dateInput = false"
|
|
|
- @confirm="onConfirm"
|
|
|
- /> -->
|
|
|
<van-picker
|
|
|
title="选择预约时间"
|
|
|
@cancel="dateInput = false"
|
|
@@ -102,9 +86,6 @@ import "vant/lib/picker/style/index";
|
|
|
|
|
|
import { goodsList, apply, applyrang } from "../api/index";
|
|
|
|
|
|
-// import { formatDate } from "../utils/tool";
|
|
|
-
|
|
|
-// let selecttime = null;
|
|
|
export default {
|
|
|
name: "Apply",
|
|
|
data() {
|
|
@@ -126,24 +107,38 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.back = !!location.href.split("?")[1];
|
|
|
+ this.userphone = this.$route.query.phone || "";
|
|
|
+ this.username = this.$route.query.userName || "";
|
|
|
+ this.back = !location.href.split("?")[1];
|
|
|
goodsList().then(res => {
|
|
|
this.goodsLi = res || [];
|
|
|
this.radio = (this.goodsLi[0] || {}).id;
|
|
|
});
|
|
|
- applyrang()
|
|
|
- .then(res => {
|
|
|
- console.log(res);
|
|
|
- this.tagList = res || [];
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ applyrang().then(res => {
|
|
|
+ let l = res || [],
|
|
|
+ nl = [],
|
|
|
+ o = {};
|
|
|
+ for (let i = 0; i < l.length; i++) {
|
|
|
+ const v = l[i];
|
|
|
+ let keys = v.startTime.split(" "),
|
|
|
+ key = keys[0],
|
|
|
+ val = keys[1];
|
|
|
+ v.startTime = val;
|
|
|
+ if (o[key] >= 0) {
|
|
|
+ nl[o[key]].children.push(v);
|
|
|
+ } else {
|
|
|
+ o[key] = nl.length;
|
|
|
+ nl[o[key]] = {
|
|
|
+ startTime: key,
|
|
|
+ children: [v],
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.tagList = nl;
|
|
|
+ });
|
|
|
},
|
|
|
computed: {
|
|
|
selectTime() {
|
|
|
- // if (!this.date.D || !this.date.D.length) return "";
|
|
|
- // return this.date.D.join("-") + " " + this.date.T.join(":");
|
|
|
return this.date;
|
|
|
},
|
|
|
},
|
|
@@ -155,26 +150,21 @@ export default {
|
|
|
return options;
|
|
|
},
|
|
|
toAppointment() {
|
|
|
- this.$router.push({ name: "Appointment", params: { a: 0 } });
|
|
|
+ this.$router.push({ name: "Appointment", query: { phone: this.userphone } });
|
|
|
},
|
|
|
onSubmit() {
|
|
|
apply({
|
|
|
userName: this.username,
|
|
|
userPhone: this.userphone,
|
|
|
goodsId: this.radio,
|
|
|
- orderTime: this.date
|
|
|
- // orderTime: this.date.D.join("-") + " " + this.date.T.join(":") + ":00",
|
|
|
- }).then(res => {
|
|
|
- console.log(res);
|
|
|
+ orderTime: this.date,
|
|
|
+ }).then(() => {
|
|
|
this.toAppointment();
|
|
|
});
|
|
|
},
|
|
|
onConfirm(date) {
|
|
|
this.dateInput = false;
|
|
|
- // selecttime = date;
|
|
|
- console.log(date);
|
|
|
- // this.date = formatDate(date);
|
|
|
- this.date = date.startTime;
|
|
|
+ this.date = date.join(" ");
|
|
|
},
|
|
|
},
|
|
|
beforeUnmount: function () {},
|