snow 1 gadu atpakaļ
vecāks
revīzija
9235f65a75
5 mainītis faili ar 78 papildinājumiem un 89 dzēšanām
  1. 0 0
      dist/app.js
  2. 7 0
      dist/chunk-libs.js
  3. 1 1
      dist/runtime.js
  4. 66 88
      src/components/binding/index.vue
  5. 4 0
      src/main.js

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
dist/app.js


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 7 - 0
dist/chunk-libs.js


+ 1 - 1
dist/runtime.js

@@ -113,7 +113,7 @@
 /******/
 /******/
 /******/ 	var hotApplyOnUpdate = true;
 /******/ 	var hotApplyOnUpdate = true;
 /******/ 	// eslint-disable-next-line no-unused-vars
 /******/ 	// eslint-disable-next-line no-unused-vars
-/******/ 	var hotCurrentHash = "27e3c5048330480d42a7";
+/******/ 	var hotCurrentHash = "8de56e54463f35c510b8";
 /******/ 	var hotRequestTimeout = 10000;
 /******/ 	var hotRequestTimeout = 10000;
 /******/ 	var hotCurrentModuleData = {};
 /******/ 	var hotCurrentModuleData = {};
 /******/ 	var hotCurrentChildModule;
 /******/ 	var hotCurrentChildModule;

+ 66 - 88
src/components/binding/index.vue

@@ -1,69 +1,39 @@
 <template>
 <template>
   <div class="binding-container">
   <div class="binding-container">
-    <el-alert title="您的微信号未绑定过系统,请先绑定一个账号" :closable="false" type="warning" center show-icon />
-    <el-form label-width="80px" size="mini" style="margin-top:10px" ref="formRef" :model="formData" :rules="rules">
-      <!-- <el-form-item label="用户名:" prop="id">
-        <el-select
-          remote 
-          style="width:100%" 
-          v-model="formData.id" 
-          :loading="ol" 
-          :filterable="true" 
-          :remote-method="requestUserList"
-          @change="handleChange"
-          >
-          <el-option 
-            v-for="item in accounts" 
-            :key="item.value" 
-            :value="item.value" 
-            :disabled="Number(item.status) === 0"
-            :label="item.label">
-            <span style="float: left;">{{item.label}}</span>
-            <span v-if="Number(item.is_wx) === 1 || Number(item.status) === 0" style="float: right;color:#F56C6C">{{Number(item.is_wx) === 1 ? '已绑定' : '已禁用'}}</span>
-          </el-option>
-        </el-select>
-      </el-form-item> -->
+    <div v-if="isMobile">
+      <el-alert title="您的微信号未绑定过系统,请先绑定一个账号" :closable="false" type="warning" center show-icon />
+      <el-form label-width="80px" size="mini" style="margin-top:10px" ref="formRef" :model="formData" :rules="rules">
+        <el-form-item label="账号:" prop="username">
+          <el-input v-model="formData.username" placeholder="账号" />
+        </el-form-item>
 
 
-      <!-- {"openid":"oOpc26KiZFBKIm7SB8knFGvov1qg","username":"17531816886","password":"lxh971219"} -->
 
 
-      <el-form-item label="账号:" prop="username">
-        <el-input v-model="formData.username" placeholder="账号" />
-      </el-form-item>
+        <el-form-item label="密码:" prop="password">
+          <el-input type="password" v-model="formData.password" placeholder="密码" />
+        </el-form-item>
 
 
+        <el-form-item style="display: flex;justify-content: flex-end;">
+          <wx-open-subscribe :template="template" id="subscribe-btn" @success="handleSuccess" @error="handleError">
+            <script type="text/wxtag-template">
+              <style>
+              .sub-btn{
+                border:none;
+                background:#409EFF;
+                color:#fff;
+                padding:5px 10px;
+                border-radius:8px;
+              }
+            </style>
+          </script>
+            <script type="text/wxtag-template">
+              <button class="sub-btn">登 录</button>
+          </script>
+          </wx-open-subscribe>
+        </el-form-item>
+      </el-form>
+    </div>
 
 
-      <el-form-item label="密码:" prop="password">
-        <el-input type="password" v-model="formData.password" placeholder="密码" />
-      </el-form-item>
-
-      <!-- <el-form-item label-width="140px" label="验证手机号后四位:" prop="lastCode">
-        <el-input :disabled="!formData.id" placeholder="手机号后四位" maxlength="4" v-model="formData.lastCode" @input="handleLastValue" />
-      </el-form-item> -->
-
-      <el-form-item style="display: flex;justify-content: flex-end;">
-        <!-- <el-button type="primary" @click="submit">绑定</el-button> -->
-        <wx-open-subscribe 
-          :template="template"
-          id="subscribe-btn" 
-          @success="handleSuccess" 
-          @error="handleError" 
-        >
-        <script type="text/wxtag-template">
-          <style>
-            .sub-btn{
-              border:none;
-              background:#409EFF;
-              color:#fff;
-              padding:5px 10px;
-              border-radius:8px;
-            }
-          </style>
-        </script>
-        <script type="text/wxtag-template">
-          <button class="sub-btn">登 录</button>
-        </script>
-      </wx-open-subscribe>
-      </el-form-item>
-    </el-form>
+    <el-alert v-else title="请使用手机端绑定账号" :closable="false" type="error" center show-icon />
   </div>
   </div>
 </template>
 </template>
 
 
@@ -71,7 +41,7 @@
 import asyncRequest from "@/api"
 import asyncRequest from "@/api"
 import { isnumber, isAlphanumeric, validAlphabets, isMobile } from '@/utils/validate'
 import { isnumber, isAlphanumeric, validAlphabets, isMobile } from '@/utils/validate'
 export default {
 export default {
-  props: ["openid","template"],
+  props: ["openid", "template"],
   data() {
   data() {
 
 
     const validateUsername = (rule, value, callback) => {
     const validateUsername = (rule, value, callback) => {
@@ -104,45 +74,52 @@ export default {
     }
     }
 
 
     return {
     return {
-      visible:false,
-      template:"",
-      ol:false,
+      visible: false,
+      template: "",
+      isMobile: true,
+      ol: false,
       maxHeight: null,
       maxHeight: null,
-      loading_wx:true,
+      loading_wx: true,
       loading: false,
       loading: false,
       currentAccount: {},
       currentAccount: {},
+      isMobile:false,
       formData: {
       formData: {
         username: "",
         username: "",
         password: ""
         password: ""
       },
       },
-      rules:{
-        username:[{required:true,trigger:'change',validator:validateUsername}],
-        password:[{required:true,trigger:'change',validator:validatePassword}],
+      rules: {
+        username: [{ required: true, trigger: 'change', validator: validateUsername }],
+        password: [{ required: true, trigger: 'change', validator: validatePassword }],
       }
       }
     }
     }
   },
   },
   created() {
   created() {
+    if (/Mobi|Android|iPhone/i.test(navigator.userAgent)) {
+      this.isMobile = true
+    }
     document.title = "绑定采销账号"
     document.title = "绑定采销账号"
   },
   },
   beforeDestory() {
   beforeDestory() {
     document.title = ""
     document.title = ""
   },
   },
   methods: {
   methods: {
-    handleSuccess(res){
-        this.submit();
+    handleSuccess(res) {
+      console.log('success:',res)
+      this.submit();
     },
     },
-    handleError(){
+    handleError(err) {
+      console.lof('error:',err)
       this.submit();
       this.submit();
       // this.$message.warning("订阅失败,请重试!")
       // this.$message.warning("订阅失败,请重试!")
     },
     },
-    handleLastValue(value){
-      this.formData.lastCode = value.replace(/[^\d]/g,'');
+    handleLastValue(value) {
+      this.formData.lastCode = value.replace(/[^\d]/g, '');
       let { lastCode = "", phone } = this.formData
       let { lastCode = "", phone } = this.formData
       let phoneLastCode = []
       let phoneLastCode = []
-      for(let i = 0;i < 4;i ++){ phoneLastCode[i] = lastCode[i] || "*" }
-      const phonePreCode = phone.slice(0, 7) 
+      for (let i = 0; i < 4; i++) { phoneLastCode[i] = lastCode[i] || "*" }
+      const phonePreCode = phone.slice(0, 7)
       console.log(phonePreCode)
       console.log(phonePreCode)
-      this.formData.phone= phonePreCode + phoneLastCode.join("");
+      this.formData.phone = phonePreCode + phoneLastCode.join("");
     },
     },
     handleChange(value) {
     handleChange(value) {
       const item = this.accounts.find(({ value: oV }) => oV === value)
       const item = this.accounts.find(({ value: oV }) => oV === value)
@@ -153,20 +130,20 @@ export default {
         lastCode: ""
         lastCode: ""
       }
       }
     },
     },
-    async submit(){
-      try{
+    async submit() {
+      try {
         await this.$refs.formRef.validate();
         await this.$refs.formRef.validate();
-        const { username,password } = this.formData;
+        const { username, password } = this.formData;
         this.loading = true
         this.loading = true
-        const result = await asyncRequest.login({ password, username, openId:this.openid })
+        const result = await asyncRequest.login({ password, username, openId: this.openid })
         this.loading = false;
         this.loading = false;
-        if(result.code === 0){
-          this.$emit("bind",result.data.token);
-        }else{
+        if (result.code === 0) {
+          this.$emit("bind", result.data.token);
+        } else {
           this.$message.error(result.message)
           this.$message.error(result.message)
         }
         }
 
 
-      }catch(err){
+      } catch (err) {
         console.log(err)
         console.log(err)
       }
       }
     },
     },
@@ -178,7 +155,7 @@ export default {
       const { code, data } = result;
       const { code, data } = result;
       if (code === 0) {
       if (code === 0) {
         const { list } = data;
         const { list } = data;
-        this.accounts = list.map(({ id, nickname, mobile,is_wx,status }) => ({
+        this.accounts = list.map(({ id, nickname, mobile, is_wx, status }) => ({
           value: id,
           value: id,
           label: nickname,
           label: nickname,
           mobile,
           mobile,
@@ -199,10 +176,11 @@ export default {
 .binding-container {
 .binding-container {
   display: flex;
   display: flex;
   flex-direction: column;
   flex-direction: column;
-  align-items:center;
+  align-items: center;
+
   /deep/.el-form {
   /deep/.el-form {
-    width:95%;
-    max-width:500px;
+    width: 95%;
+    max-width: 500px;
   }
   }
 }
 }
 </style>
 </style>

+ 4 - 0
src/main.js

@@ -3,6 +3,8 @@ import Components from "./components/reports";
 import * as filters from './filters' // global filters
 import * as filters from './filters' // global filters
 import router from "./router"
 import router from "./router"
 
 
+import VConsole from "vconsole";
+
 import {
 import {
   Table,
   Table,
   Select,
   Select,
@@ -12,6 +14,8 @@ import {
 import 'element-ui/lib/theme-chalk/index.css';
 import 'element-ui/lib/theme-chalk/index.css';
 
 
 
 
+new VConsole();
+
 Vue.component(Table.name, Table);
 Vue.component(Table.name, Table);
 Vue.component(Select.name, Select);
 Vue.component(Select.name, Select);
 Vue.component(Option.name, Option);
 Vue.component(Option.name, Option);

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels