guhongwei 4 år sedan
förälder
incheckning
00fa5724a9

+ 9 - 1
src/layout/common/login.vue

@@ -32,7 +32,15 @@ export default {
   created() {},
   methods: {
     // 个人登录
-    grLogin() {},
+    grLogin() {
+      let openid = sessionStorage.getItem('openid');
+      if (openid) {
+        this.$toast({ type: 'success', message: '登录成功' });
+        this.$router.push({ path: '/perCenter/index' });
+      } else {
+        this.$toast({ type: 'error', message: '登录失败' });
+      }
+    },
     // 机构登录
     jgLogin() {
       this.$router.push({ path: '/login' });

+ 30 - 0
src/router/index.js

@@ -197,6 +197,20 @@ const mechCenter = [
     component: () => import('../views/mechCenter/service/index.vue'),
   },
 ];
+const perCenter = [
+  {
+    path: '/perCenter/index',
+    name: 'perCenter_index',
+    meta: { title: '个人中心' },
+    component: () => import('../views/perCenter/index.vue'),
+  },
+  {
+    path: '/perCenter/service/index',
+    name: 'perCenter_service_index',
+    meta: { title: '预约服务' },
+    component: () => import('../views/perCenter/service/index.vue'),
+  },
+];
 const web = [
   {
     path: '/',
@@ -215,6 +229,7 @@ const web = [
   ...research,
   ...userCenter,
   ...mechCenter,
+  ...perCenter,
 ];
 const routes = [...web];
 const router = new VueRouter({
@@ -225,6 +240,21 @@ const router = new VueRouter({
 router.beforeEach((to, from, next) => {
   document.title = `${to.meta.title} `;
   const token = localStorage.getItem('token');
+  // if (to.name == 'mechCenter_index') {
+  //   if (!token) {
+  //     next(`/login?path=${to.path}`);
+  //   } else {
+  //     let user = jwt.decode(token);
+  //     store.commit('setUser', user, { root: true });
+  //     next();
+  //   }
+  // } else if (to.name == 'login') {
+  //   next(`/login?path=${to.path}`);
+  // } else {
+  //   let user = jwt.decode(token);
+  //   store.commit('setUser', user, { root: true });
+  //   next();
+  // }
   if (to.name == 'mechCenter_index') {
     if (!token) {
       next(`/login?path=${to.path}`);

+ 7 - 14
src/views/login.vue

@@ -6,14 +6,13 @@
           <top topType="2" :leftArrow="false"></top>
         </el-col>
         <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
-          <el-col :span="24" class="one"> 科教之旅 </el-col>
-          <el-col :span="24" class="two">
-            <van-form>
+          <el-col :span="24" class="one">
+            <van-form label-width="4.2em">
               <van-field v-model="form.phone" name="账号" label="账号" :rules="[{ required: true, message: '请填写账号' }]" />
               <van-field v-model="form.password" type="password" name="密码" label="密码" :rules="[{ required: true, message: '请填写密码' }]" />
               <van-col span="24" class="btn">
-                <van-button type="danger" round @click="back">取消保存</van-button>
-                <van-button type="primary" round @click="onSubmit">提交保存</van-button>
+                <van-button type="danger" round @click="back">取消登录</van-button>
+                <van-button type="primary" round @click="onSubmit">提交登录</van-button>
               </van-col>
             </van-form>
           </el-col>
@@ -52,7 +51,9 @@ export default {
         this.$router.push({ path: '/mechCenter/index' });
       }
     },
-    back() {},
+    back() {
+      window.history.go(-1);
+    },
   },
   computed: {
     ...mapState(['user']),
@@ -80,16 +81,8 @@ export default {
   .info {
     overflow-x: hidden;
     overflow-y: auto;
-    background-color: #f9f9f9;
     padding: 8px;
     .one {
-      text-align: center;
-      font-size: 18px;
-      padding: 30px 0;
-      font-weight: bold;
-    }
-    .two {
-      background-color: #fff;
       .btn {
         text-align: center;
         margin: 10px 0;

+ 126 - 0
src/views/perCenter/index.vue

@@ -0,0 +1,126 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="top">
+          <top topType="2" :leftArrow="false"></top>
+        </el-col>
+        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
+          <el-col :span="24" class="one">
+            微信用户
+            <!-- <el-col :span="5" class="image">
+              <el-image :src="icon"></el-image>
+            </el-col>
+            <el-col :span="19" class="info">
+              <el-col :span="24" class="name textOver">
+                {{ user.name ? user.name : '游客' }}
+              </el-col>
+              <el-col :span="24" class="other">
+                <el-col :span="24" class="other_info textOver">
+                  电话:<span>{{ user.phone ? user.phone : '未知' }}</span>
+                </el-col>
+                <el-col :span="24" class="other_info textOver">
+                  地址:<span>{{ user.addr ? user.addr : '未知' }}</span>
+                </el-col>
+              </el-col>
+            </el-col> -->
+          </el-col>
+          <el-col :span="24" class="two">
+            <per-btn></per-btn>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import perBtn from './parts/per.vue';
+import top from '@/layout/common/top.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    top,
+    perBtn,
+  },
+  data: function () {
+    return {
+      clientHeight: '',
+      icon: require('@a/news1.jpg'),
+    };
+  },
+  async created() {
+    console.log(this.user);
+  },
+  mounted() {
+    let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 40;
+    this.$set(this, `clientHeight`, clientHeight);
+  },
+  methods: {},
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .top {
+    height: 40px;
+    overflow: hidden;
+    border-bottom: 1px solid #f1f1f1;
+  }
+  .info {
+    overflow-x: hidden;
+    overflow-y: auto;
+    background-color: #f9f9f9;
+    .one {
+      background-color: #fff;
+      margin: 0 0 10px 0;
+      padding: 10px;
+      .image {
+        text-align: center;
+        .el-image {
+          width: 60px;
+          height: 60px;
+          border-radius: 90px;
+        }
+      }
+      .info {
+        background-color: #fff;
+        padding: 0 10px;
+        .name {
+          font-size: 16px;
+          font-weight: bold;
+          margin: 0 0 5px 0;
+        }
+        .other {
+          .other_info {
+            font-size: 14px;
+            color: #666;
+            margin: 0 0 2px 0;
+            span {
+              color: #000;
+            }
+          }
+        }
+      }
+    }
+    .two {
+      background-color: #fff;
+    }
+  }
+}
+</style>

+ 52 - 0
src/views/perCenter/parts/per.vue

@@ -0,0 +1,52 @@
+<template>
+  <div id="jg">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="one">
+          <van-cell title="预约服务" @click="btn('/service/index')" is-link />
+          <van-cell title="退出登录" @click="logout" is-link />
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'jg',
+  props: {},
+  components: {},
+  data: function () {
+    return {};
+  },
+  created() {},
+  methods: {
+    btn(to) {
+      this.$router.push({ path: `/perCenter${to}` });
+    },
+    logout() {
+      let key = localStorage.removeItem('token');
+      if (key == undefined) {
+        this.$toast({ type: 'success', message: '修改成功' });
+        this.$router.push({ path: '/login' });
+      }
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 178 - 0
src/views/perCenter/service/index.vue

@@ -0,0 +1,178 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="top">
+          <top topType="2" @back="back"></top>
+        </el-col>
+        <el-col :span="24" class="info" :style="{ height: clientHeight + 'px' }">
+          <el-col :span="24" class="list" v-for="(item, index) in list" :key="index">
+            <el-col :span="24" class="name">
+              {{ item.project }}
+            </el-col>
+            <el-col :span="24" class="other">
+              <el-col :span="12" class="other_info textOver">
+                联系人:<span>{{ item.contact || '暂无' }}</span>
+              </el-col>
+              <el-col :span="12" class="other_info textOver">
+                联系电话:<span>{{ item.phone || '暂无' }}</span>
+              </el-col>
+              <el-col :span="12" class="other_info textOver">
+                电子邮箱:<span>{{ item.email || '暂无' }}</span>
+              </el-col>
+              <el-col :span="12" class="other_info textOver">
+                服务时间:<span>{{ item.server_time || '暂无' }}</span>
+              </el-col>
+            </el-col>
+            <el-col :span="24" class="staBtn">
+              <el-col :span="18" class="status">
+                状态:<span>{{ item.status == '0' ? '预约' : '完成' }}</span>
+              </el-col>
+              <el-col :span="6" class="btn">
+                <el-button type="primary" size="mini">查看详情</el-button>
+              </el-col>
+            </el-col>
+          </el-col>
+        </el-col>
+        <el-col :span="24" class="foot">
+          <page :limit="limit" :total="total" @search="search"></page>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import top from '@/layout/common/top.vue';
+import page from '@/layout/common/page.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: Order } = createNamespacedHelpers('Order');
+const { mapActions: Medium } = createNamespacedHelpers('Medium');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    top,
+    page,
+  },
+  data: function () {
+    return {
+      clientHeight: '',
+      list: [],
+      total: 0,
+      limit: '10',
+    };
+  },
+  async created() {
+    this.search();
+  },
+
+  methods: {
+    ...Order(['query']),
+    ...Medium(['fetch']),
+    async search({ skip = 0, limit = this.limit, ...info } = {}) {
+      let openid = sessionStorage.getItem('openid');
+      if (openid) info.openid = openid;
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        for (const val of res.data) {
+          this.searchPro(val);
+        }
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    // 获取项目/设备名称
+    async searchPro(data) {
+      let res = await this.fetch(data.medium_id);
+      if (this.$checkRes(res)) {
+        let arr = res.data.project.find((i) => i.id == data.project);
+        if (arr) {
+          data.project = arr.name;
+        } else {
+          let arr = res.data.equipment.find((i) => i.id == data.project);
+          if (arr) {
+            data.project = arr.name;
+          }
+        }
+      }
+    },
+    back() {
+      this.$router.push({ path: '/perCenter/index' });
+    },
+  },
+  mounted() {
+    let clientHeight = (document.documentElement.clientHeight || document.body.clientHeight) - 80;
+    this.$set(this, `clientHeight`, clientHeight);
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .top {
+    height: 40px;
+    overflow: hidden;
+    border-bottom: 1px solid #f1f1f1;
+  }
+  .info {
+    overflow-x: hidden;
+    overflow-y: auto;
+    background-color: #f9f9f9;
+    padding: 8px;
+    .list {
+      background-color: #fff;
+      padding: 8px;
+      margin: 0 0 10px 0;
+      border-radius: 10px;
+      .name {
+        font-size: 16px;
+        margin: 0 0 5px 0;
+        font-weight: bold;
+      }
+      .other {
+        .other_info {
+          font-size: 14px;
+          color: #666;
+          margin: 0 0 5px 0;
+          span {
+            color: #000;
+          }
+        }
+      }
+      .staBtn {
+        .status {
+          font-size: 14px;
+          color: #666;
+          padding: 4px 0;
+          span {
+            color: #ff0000;
+            font-weight: bold;
+          }
+        }
+        .btn {
+          text-align: center;
+        }
+      }
+    }
+  }
+  .foot {
+    height: 40px;
+    overflow: hidden;
+    border-top: 1px solid #f1f1f1;
+  }
+}
+</style>