liyongli před 3 roky
rodič
revize
416d9230b8
4 změnil soubory, kde provedl 159 přidání a 59 odebrání
  1. 10 0
      src/utils/isTerminal.js
  2. 38 4
      src/views/Apply.vue
  3. 3 2
      src/views/Applyreal.vue
  4. 108 53
      src/views/Appointment.vue

+ 10 - 0
src/utils/isTerminal.js

@@ -0,0 +1,10 @@
+const ua = window.navigator.userAgent;
+
+const isAndroid = /(Android);?[\s/]+([\d.]+)?/i.test(ua);
+const isIpad = /(iPad).*OS\s([\d_]+)/i.test(ua);
+const isIpod = /(iPod)(.*OS\s([\d_]+))?/i.test(ua);
+const isIphone = !isIpad && /(iPhone\sOS)\s([\d_]+)/i.test(ua);
+const isWechat = /micromessenger/i.test(ua);
+const isAlipay = /alipayclient/i.test(ua);
+
+export { isIphone, isWechat, isAlipay, isAndroid, isIpad, isIpod };

+ 38 - 4
src/views/Apply.vue

@@ -5,7 +5,7 @@
         v-model="username"
         label="名称"
         placeholder="名称"
-        :rules="[{ required: true, message: '请填写名' }]"
+        :rules="[{ required: true, message: '请填写名' }]"
       />
       <van-field label="套餐">
         <template #input>
@@ -39,7 +39,17 @@
           type="info"
           native-type="submit"
         >
-          提交
+          预约
+        </van-button>
+        <br />
+        <van-button
+          color="#2a7ef4"
+          round
+          block
+          type="info"
+          @click="toAppointment"
+        >
+          查看预约
         </van-button>
       </div>
     </van-form>
@@ -76,6 +86,7 @@ import "vant/lib/popup/style/index";
 import "vant/lib/picker/style/index";
 
 import { goodsList, apply, applyrang } from "../api/index";
+import { isIphone, isAndroid } from "@/utils/isTerminal.js";
 
 export default {
   name: "Apply",
@@ -97,8 +108,18 @@ export default {
     };
   },
   mounted() {
-    this.userphone = this.$route.query.phone || "";
-    this.username = this.$route.query.userName || "";
+    let user = {};
+    var payload = {
+      type: "JSbridge",
+      functionName: "getUserInfo",
+      arguments: {},
+    };
+    if (isAndroid && window.H5Listener && window.H5Listener.getUserInfo)
+      user = JSON.parse(window.H5Listener.getUserInfo());
+    if (isIphone) user = window.prompt(JSON.stringify(payload)) || {};
+    console.log(user);
+    this.userphone = user.realName || "";
+    this.username = user.phone || "";
     goodsList().then(res => {
       this.goodsLi = res || [];
       this.radio = (this.goodsLi[0] || {}).id;
@@ -133,6 +154,15 @@ export default {
     },
   },
   methods: {
+    toAppointment() {
+      this.$router.push({
+        name: "Appointment",
+        query: {
+          userName: this.username,
+          phone: this.userphone,
+        },
+      });
+    },
     filter(type, options) {
       if (type === "minute") {
         return options.filter(option => option % 5 === 0);
@@ -148,6 +178,10 @@ export default {
       }).then(() => {
         this.$router.push({
           name: "Appointment",
+          query: {
+            userName: this.username,
+            phone: this.userphone,
+          },
         });
       });
     },

+ 3 - 2
src/views/Applyreal.vue

@@ -6,7 +6,7 @@
         v-model="username"
         label="名称"
         placeholder="名称"
-        :rules="[{ required: true, message: '请填写名' }]"
+        :rules="[{ required: true, message: '请填写名' }]"
       />
       <van-field label="套餐">
         <template #input>
@@ -88,12 +88,13 @@ export default {
       return options;
     },
     onSubmit() {
+
       applyreal({
         userName: this.username,
         userPhone: this.userphone,
         goodsId: this.radio,
       }).then(() => {
-        this.$router.go(-1);
+        this.$router.push('/');
       });
     },
   },

+ 108 - 53
src/views/Appointment.vue

@@ -4,13 +4,19 @@
       <van-cell title="已预约" />
       <van-cell v-for="(item, i) in mainList" :key="i" :title="item.userName">
         <template #default>
-          {{ item.orderTime }}
-          <van-icon
-            name="close"
-            color="#fb5f5c"
-            @click="() => removequeue(item.id, i)"
+          <div>
+            {{ item.orderTime }}
+          </div>
+        </template>
+        <template #label>
+          <van-button
             v-if="item.self"
-          />
+            @click="() => removequeue(item.id)"
+            type="danger"
+            size="mini"
+          >
+            取消预约
+          </van-button>
         </template>
       </van-cell>
     </div>
@@ -48,25 +54,26 @@ import {
   Sidebar as vanSidebar,
   SidebarItem as vanSidebarItem,
   Cell as vanCell,
-  Icon as vanIcon,
   Button as vanButton,
   Dialog,
+  Toast,
 } from "vant";
 import "vant/lib/sidebar/style/index";
 import "vant/lib/button/style/index";
 import "vant/lib/cell/style/index";
 import "vant/lib/icon/style/index";
+import "vant/lib/toast/style/index";
 import "vant/lib/dialog/style/index";
 import "vant/lib/sidebar-item/style/index";
 
 import {
   orderList,
   cancel,
-  getAPPUser,
-  getAPPToken,
-  getAPPUserDetail,
+  //   getAPPUser,
+  //   getAPPToken,
+  //   getAPPUserDetail,
 } from "../api/index";
-import { urlSearchData } from "../utils/tool";
+// import { urlSearchData } from "../utils/tool";
 
 export default {
   name: "Appointment",
@@ -81,61 +88,86 @@ export default {
     };
   },
   mounted() {
+    this.phone = this.$route.query.phone || "";
+    this.name = this.$route.query.userName || "";
     localStorage.token = "";
-    let search = urlSearchData();
+    // let search = urlSearchData();
     document.title = "美发预约系统";
     const that = this;
-    getAPPUser({
-      ticket: search.ticket,
-    }).then(r => {
-      getAPPToken("rest/63bada00-7d01-4acc-ab2b-df8061eeeb8f").then(res => {
-        const t = JSON.parse(res || "{}");
-        localStorage.token = t.id;
-        getAPPUserDetail({
-          loginName: r,
-        }).then(detail => {
-          const obj = JSON.parse(detail || "{}");
-          console.log(obj);
-          that.phone = obj.telNumber;
-          that.name = obj.name;
-          orderList({
-            userPhone: that.phone || "",
-          }).then(res => {
-            const li = res || [];
-            let l = [];
-            li.sort((a, b) => {
-              return new Date(a.orderTime) - new Date(b.orderTime);
-            });
-            for (let i = 0; i < li.length; i++) {
-              const v = li[i];
-              v.orderTime = v.orderTime.replace(/:00$/, "");
-              let key = v.orderTime.split(" ")[0];
-              if (that.group[key]) {
-                that.group[key].push(v);
-              } else {
-                l.push(key);
-                that.group[key] = [v];
-              }
-            }
-            that.dataList = l;
-            that.onChange();
-          });
-        });
+    orderList({
+      userPhone: that.phone || "",
+    }).then(res => {
+      const li = res || [];
+      let l = [];
+      li.sort((a, b) => {
+        return new Date(a.orderTime) - new Date(b.orderTime);
       });
+      for (let i = 0; i < li.length; i++) {
+        const v = li[i];
+        v.orderTime = v.orderTime.replace(/:00$/, "");
+        let key = v.orderTime.split(" ")[0];
+        if (that.group[key]) {
+          that.group[key].push(v);
+        } else {
+          l.push(key);
+          that.group[key] = [v];
+        }
+      }
+      that.dataList = l;
+      that.onChange();
     });
+    // getAPPUser({
+    //   ticket: search.ticket,
+    // }).then(r => {
+    //   getAPPToken("rest/63bada00-7d01-4acc-ab2b-df8061eeeb8f").then(res => {
+    //     const t = JSON.parse(res || "{}");
+    //     localStorage.token = t.id;
+    //     getAPPUserDetail({
+    //       loginName: r,
+    //     }).then(detail => {
+    //       const obj = JSON.parse(detail || "{}");
+    //       console.log(obj);
+    //       that.phone = obj.telNumber;
+    //       that.name = obj.name;
+    //       orderList({
+    //         userPhone: that.phone || "",
+    //       }).then(res => {
+    //         const li = res || [];
+    //         let l = [];
+    //         li.sort((a, b) => {
+    //           return new Date(a.orderTime) - new Date(b.orderTime);
+    //         });
+    //         for (let i = 0; i < li.length; i++) {
+    //           const v = li[i];
+    //           v.orderTime = v.orderTime.replace(/:00$/, "");
+    //           let key = v.orderTime.split(" ")[0];
+    //           if (that.group[key]) {
+    //             that.group[key].push(v);
+    //           } else {
+    //             l.push(key);
+    //             that.group[key] = [v];
+    //           }
+    //         }
+    //         that.dataList = l;
+    //         that.onChange();
+    //       });
+    //     });
+    //   });
+    // });
   },
   computed: {},
   methods: {
     toAppointment() {
       this.$router.push({
         name: "Apply",
-        params: { name: this.name, phone: this.phone } 
+        params: { name: this.name, phone: this.phone },
       });
     },
     onChange() {
       this.mainList = this.group[this.dataList[this.activeKey]];
     },
-    removequeue(id, i) {
+    removequeue(id) {
+      let that = this;
       Dialog.confirm({
         title: "取消预约",
         message: "确定要取消该预约?",
@@ -145,7 +177,31 @@ export default {
         cancel({
           id,
         }).then(() => {
-          this.group[this.dataList[this.activeKey]].splice(i, 1);
+          orderList({
+            userPhone: that.phone || "",
+          }).then(res => {
+            Toast("已取消预约");
+            const li = res || [];
+            let l = [],
+              group = {};
+            li.sort((a, b) => {
+              return new Date(a.orderTime) - new Date(b.orderTime);
+            });
+            for (let i = 0; i < li.length; i++) {
+              const v = li[i];
+              v.orderTime = v.orderTime.replace(/:00$/, "");
+              let key = v.orderTime.split(" ")[0];
+              if (group[key]) {
+                group[key].push(v);
+              } else {
+                l.push(key);
+                group[key] = [v];
+              }
+            }
+            that.dataList = l;
+            that.group = group;
+            that.onChange();
+          });
         });
       });
     },
@@ -157,7 +213,6 @@ export default {
     vanSidebar,
     vanCell,
     vanSidebarItem,
-    vanIcon,
     vanButton,
   },
 };
@@ -165,7 +220,7 @@ export default {
 
 <style>
 .Appointment {
-  height: 120%;
+  height: 100%;
   box-sizing: border-box;
   background-color: #f7f8fa;
 }