Pārlūkot izejas kodu

Merge branch 'dev_zlx' into dev

zhaolianxi 3 gadi atpakaļ
vecāks
revīzija
f1d7155496

+ 1 - 1
index.html

@@ -3,7 +3,7 @@
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
-    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=610161977d2e2632eb34aff3e88a079f"></script>
+    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=5ae8644771ef9abf9cfb3ea23b1df6ca"></script>
     <title>猎豹AI</title>
   </head>
   <body>

+ 21 - 5
src/api/http.js

@@ -1,5 +1,6 @@
 import axios from 'axios';
 import qs from 'qs';
+import { message } from 'element-ui';
 const requestUrl = 'http://153.37.175.42:8086/'; // 测试内部接口
 // const requestUrl = 'http://121.4.100.145:8082/'; // 测试内部接口
 //const requestUrl = 'https://api.liebaoai.cn/'; // 统一正式接口
@@ -40,11 +41,26 @@ service.interceptors.response.use(
       }
     },
     error => {
-        if (error.response && error.response.code == 404) {
-            //跳转到xx页面
-            console.log("404错误")
-        }
-        return Promise.reject(error.response)
+      let status = error.response && error.response.status;
+      switch( status ) {
+        case 404:
+          message({
+            message: error.response.data.message,
+            type: 'error'
+          })
+        break;
+        case 500:
+          message({
+            message: error.response.data.message,
+            type: 'error'
+          })
+        break;
+        default:
+          // to do something
+        break;
+        
+      }
+      return Promise.reject(error.response)
     }
 )
 

+ 5 - 1
src/api/user.js

@@ -10,4 +10,8 @@ export const loginPassword = ( params ) => {
 
 export const loginVerification = ( params ) => {
   return post( 'app/login/verification', params )
-}
+}
+
+export const forgotPassword = ( params ) => {
+  return post( 'app/login/password/change', params )
+}

+ 1 - 1
src/components/Home.vue

@@ -36,7 +36,7 @@
         </div>
       </el-col>
     </el-row>
-    <!-- <order-map></order-map> -->
+    <order-map></order-map>
   </div>
 </template>
 

+ 36 - 12
src/components/orderComponents/orderAMap.vue

@@ -1,9 +1,11 @@
 <template>
   <el-dialog width="80%" :show-close="false" destroy-on-close :visible.sync="dialogTableVisible">
     <!-- <div id="container"></div> -->
+    <div>
+      <el-input v-model="searchKey" @change="searchMap($event)"/>
+    </div>
     <el-amap vid="container" style="height: 600px;" :center="center" :zoom="zoom" class="amap-demo">
-      <!-- <el-amap-marker v-for="(marker,index) in markers" :key="index" :position="marker.position"
-        :events="marker.events"></el-amap-marker> -->
+      <el-amap-marker v-for="(marker,index) in markers" :key="index" :position="marker.position" :icon="marker.icon"></el-amap-marker>
       <!-- <el-amap-info-window v-if="window" :position="window.position" :visible="window.visible"
         :content="window.content"></el-amap-info-window> -->
     </el-amap>
@@ -11,19 +13,25 @@
 </template>
 
 <script>
+  import qs from 'qs';
+  //var map = new AMap.Map('container');
   export default {
     data() {
       return {
+        searchKey: '',
         dialogTableVisible: true,
         order: {},
-        markers: [],
+        markers: [
+          { id:1, position: [120.629585, 31.269379], icon: '/static/image/map-fa.png' },
+          { id:2, position: [120.609585, 31.209379], icon: '/static/image/map-shou.png' },
+        ],
         srcList: [],
         windows: [],
         window: '',
         geocoder: '',
         defaultCity: '苏州',
-        zoom: 16,
-        center: [120.619585, 31.299379],
+        zoom: 12,
+        center: [120.619585, 31.239379],
         address: '',
         province: '',
         city: '',
@@ -35,14 +43,25 @@
         },
       }
     },
-    created() {
-      var map = new AMap.Map('container', {
-        zoom: 11, //级别
-        center: [116.397428, 39.90923], //中心点坐标
-      });
-      console.log(map, '地图')
-    },
+    created() {},
     methods: {
+      searchMap(e) {
+        console.log(e)
+        fetch('https://restapi.amap.com/v3/assistant/inputtips?key=5ae8644771ef9abf9cfb3ea23b1df6ca&keywords=苏州大学&city=0512&offset=20&types=keywords',{
+          methods: 'GET'
+        }).then( res => {
+          return res.json()
+        }).then( result => {
+          console.log(result);
+          fetch(`https://restapi.amap.com/v3/geocode/geo?key=4940f0a9fdc717ab27dd37fa0497c771&address=${ result.tips[0].district }${ result.tips[0].address }${ result.tips[0].name }`,{
+            methods: 'GET'
+          }).then( res1 => {
+            return res1.json()
+          }).then( rp => {
+            console.log(rp, '------------')
+          } )
+        } )
+      },
       setDialogStatus() {
         this.dialogTableVisible = true;
       }
@@ -51,6 +70,7 @@
 </script>
 
 <style lang="scss" scoped>
+  /* 图标大小修改 */
   /deep/ .el-dialog__header {
     display: none !important;
   }
@@ -58,4 +78,8 @@
     width: 100%;
     height: 400px;
   }
+  /deep/ .amap-container img {
+    width: 35px !important;
+    height: 45px !important;
+  }
 </style>

+ 3 - 0
src/main.js

@@ -7,6 +7,9 @@ import router from './router'
 import Elementui from 'element-ui'
 import store from './store/index.js';
 
+import axios from 'axios'
+Vue.prototype.$axios = axios    //全局注册,使用方法为:this.$axios
+
 import VueAMap from 'vue-amap';
 
 import {get, post, postJson} from './api/http'

+ 130 - 8
src/views/resetPassword.vue

@@ -12,40 +12,162 @@
         <div class="top-icon">
           重置密码
         </div>
-        <div>
+        <div v-loading="isLoading">
           <!-- 密码登录 -->
           <div class="login-password">
             <div class="pass-item">
               <img src="../../static/image/phone-icon.png" class="phone-icon" />
-              <el-input placeholder="请输入手机号" class="input-phone" :maxlength="11" />
+              <el-input placeholder="请输入手机号" v-model="mobile" class="input-phone" :maxlength="11" />
             </div>
             <div class="pass-item">
               <img src="../../static/image/code-icon.png" class="phone-icon" />
-              <el-input placeholder="验证码" class="input-phone" type="password" />
-              <div class="get-code">获取短信验证码</div>
+              <el-input placeholder="验证码" v-model="code" class="input-phone" :maxlength="4" />
+              <div class="get-code" v-if="!showCode" @click.stop="getCode">获取短信验证码</div>
+              <div class="get-code" v-else>{{ count }}秒</div>
             </div>
             <div class="pass-item">
               <img src="../../static/image/lock-icon.png" class="lock-icon" />
-              <el-input placeholder="新密码" class="input-phone" type="password" />
+              <el-input placeholder="新密码" v-model="password" class="input-phone" type="password" />
             </div>
             <div class="pass-item">
               <img src="../../static/image/lock-icon.png" class="lock-icon" />
-              <el-input placeholder="确认新密码" class="input-phone" type="password" />
+              <el-input placeholder="确认新密码" v-model="passwordAgian" class="input-phone" type="password" />
             </div>
           </div>
         </div>
-        <div class="login-btn">确认</div>
+        <div class="login-btn" @click.stop="commit">确认</div>
       </div>
     </div>
   </div>
 </template>
 
 <script>
+  import {
+    getPhoneCode,
+    forgotPassword
+  } from '../api/user.js';
   export default {
     data() {
       return {
-        activeIndex: 1
+        isLoading: false, // 请求解决展示loading
+        activeIndex: 1,
+        mobile: '',
+        code: '',
+        password: '',
+        passwordAgian: '',
+        showCode: false,
+        count: 60,
+        timer: null
       }
+    },
+    destroyed() {
+      clearInterval( this.timer );
+      this.timer = null;
+    },
+    methods: {
+      commit() {
+        if (!this.mobile.trim()) {
+          return this.$message({
+            message: '手机号码不能为空',
+            type: 'error'
+          })
+        }
+        if (!this.checkPhone(this.mobile)) {
+          return this.$message({
+            message: '请输入正确的手机号',
+            type: 'error'
+          })
+        }
+        if (!this.code.trim()) {
+          return this.$message({
+            message: '验证码不能为空',
+            type: 'error'
+          })
+        }
+        if (!this.password.trim()) {
+          return this.$message({
+            message: '密码不能为空',
+            type: 'error'
+          })
+        }
+        if (!this.passwordAgian.trim()) {
+          return this.$message({
+            message: '确认密码不能为空',
+            type: 'error'
+          })
+        }
+        if (this.password.trim() !== this.passwordAgian.trim()) {
+          return this.$message({
+            message: '两次密码不一致',
+            type: 'error'
+          })
+        }
+        let params = {
+          code: this.code,
+          mobile: this.mobile,
+          newPassword: this.password
+        }
+        forgotPassword( params ).then( res => {
+          if ( res.code == 200 ) {
+            this.$router.go(-1);
+          }else {
+            return this.$message({
+              message: res.msg,
+              type: 'error'
+            })
+          }
+        } )
+      },
+      checkPhone(phone) {
+        if (!(/^1\d{10}$/.test(phone))) {
+          return false;
+        } else {
+          return true
+        }
+      },
+      // 获取验证码
+      getCode() {
+        if (!this.mobile.trim()) {
+          return this.$message({
+            message: '手机号码不能为空',
+            type: 'error'
+          })
+        }
+        if (!this.checkPhone(this.mobile)) {
+          return this.$message({
+            message: '请输入正确的手机号',
+            type: 'error'
+          })
+        }
+        let params = {
+          mobile: this.mobile,
+          type: 1
+        };
+        this.isLoading = true;
+        getPhoneCode(params).then(res => {
+          if (res.code == 200) {
+            this.isLoading = false;
+            this.showCode = true;
+            this.$message({
+              message: '验证码发送成功',
+              type: 'success'
+            })
+            this.timer = setInterval(() => {
+              this.count--;
+              if (this.count <= 1) {
+                this.showCode = false;
+                clearInterval(this.timer);
+              }
+            }, 1000)
+          } else {
+            this.isLoading = false;
+            return this.$message({
+              message: res.msg,
+              type: 'error'
+            })
+          }
+        })
+      },
     }
   }
 </script>

BIN
static/image/map-fa.png


BIN
static/image/map-shou.png