ソースを参照

去掉默认账号和api地址

lfj 4 年 前
コミット
548251cdbd
2 ファイル変更65 行追加68 行削除
  1. 21 21
      src/config/index.config.js
  2. 44 47
      src/pages/public/login.vue

+ 21 - 21
src/config/index.config.js

@@ -1,22 +1,22 @@
 const CONFIG = {
-    //开发环境配置
-    development: {
-        assetsPath: '/static', // 静态资源路径
-        baseUrl: 'http://tyou.xiudo.cn/merch',  // 后台接口请求地址
-        // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
-        hostUrl: 'http://localhost:8080',        // H5地址(前端运行地址)
-        websocketUrl: '',        // websocket服务端地址
-        weixinAppId: '', // 微信公众号appid
-        uploadUrl: 'http://tyou.xiudo.cn/merch/common/upload/oss'
-    },
-    //生产环境配置
-    production: {
-        assetsPath: '/static', // 静态资源路径
-        baseUrl: 'https://tyou.xiudo.cn/merch',  // 后台接口请求地址
-        hostUrl: 'https://tyou.xiudo.cn',        // H5地址(前端运行地址)
-        websocketUrl: '',        // websocket服务端地址
-        weixinAppId: '', // 微信公众号appid
-        uploadUrl: 'https://you.xiudo.cn/merch/common/upload/oss'
-    }
-};
-export default CONFIG[process.env.NODE_ENV];
+  // 开发环境配置
+  development: {
+    assetsPath: '/static', // 静态资源路径
+    baseUrl: 'http://tyou.xiudo.cn/merch', // 后台接口请求地址
+    // baseUrl: 'http://192.168.100.135:83/merch',  // 后台接口请求地址
+    hostUrl: 'http://localhost:8080', // H5地址(前端运行地址)
+    websocketUrl: '', // websocket服务端地址
+    weixinAppId: '', // 微信公众号appid
+    uploadUrl: 'http://tyou.xiudo.cn/merch/common/upload/oss'
+  },
+  // 生产环境配置
+  production: {
+    assetsPath: '/static', // 静态资源路径
+    baseUrl: 'https://you.xiudo.cn/merch', // 后台接口请求地址
+    hostUrl: 'https://you.xiudo.cn', // H5地址(前端运行地址)
+    websocketUrl: '', // websocket服务端地址
+    weixinAppId: '', // 微信公众号appid
+    uploadUrl: 'https://you.xiudo.cn/merch/common/upload/oss'
+  }
+}
+export default CONFIG[process.env.NODE_ENV]

+ 44 - 47
src/pages/public/login.vue

@@ -60,16 +60,16 @@
   </view>
 </template>
 <script>
-import { authLogin, loginByPass, loginBySmsCode, smsCode } from '@/api/login';
-import moment from '@/common/moment';
+import { authLogin, loginByPass, loginBySmsCode, smsCode } from '@/api/login'
+import moment from '@/common/moment'
 export default {
-  data() {
+  data () {
     return {
       loginParams: {
-        username: 'xiudo',
+        username: '',
         code: '',
-        password: '123456',
-        uuid: null,
+        password: '',
+        uuid: null
       },
       codeImage: null,
       btnLoading: false,
@@ -78,90 +78,88 @@ export default {
       loginByPass: true,
       smsCodeBtnDisabled: true,
       userInfo: null
-    };
+    }
   },
 
-  onShow() {
+  onShow () {
     if (this.$mStore.getters.hasLogin) {
-      this.$mRouter.reLaunch({ route: '/pages/index/index' });
+      this.$mRouter.reLaunch({ route: '/pages/index/index' })
     }
   },
 
   // 页面生命周期 监听页面加载是否加载完成
-  onLoad() {
-    this.getCaptchaImage();
+  onLoad () {
+    this.getCaptchaImage()
 
     // #ifdef MP-WEIXIN
-    uni.hideHomeButton()  // 会话过期更改页面跳转到登录页的跳转方式,并隐藏小房子
+    uni.hideHomeButton() // 会话过期更改页面跳转到登录页的跳转方式,并隐藏小房子
     // #endif
   },
 
   methods: {
     // 统一跳转路由
-    navTo() {
-      this.$mRouter.redirectTo({ route: '/pages/public/resetpassword' });
+    navTo () {
+      this.$mRouter.redirectTo({ route: '/pages/public/resetpassword' })
     },
 
-
-		// 获取验证码
-    async getCaptchaImage() {
+    // 获取验证码
+    async getCaptchaImage () {
       await this.$http
         .get('/captchaImage', {})
         .then(async (r) => {
-          this.codeImage = 'data:image/gif;base64,' + r.data.img;
-          this.loginParams.uuid = r.data.uuid;
+          this.codeImage = 'data:image/gif;base64,' + r.data.img
+          this.loginParams.uuid = r.data.uuid
         })
         .catch(() => {
-          this.loading = false;
-        });
+          this.loading = false
+        })
     },
     // 提交表单
-    async toLogin() {
-      let cheRes, loginApi;
+    async toLogin () {
+      let cheRes, loginApi
       if (this.loginByPass) {
-        loginApi = loginByPass;
+        loginApi = loginByPass
         cheRes = this.$mGraceChecker.check(
           this.loginParams,
           this.$mFormRule.loginByPassRule
-        );
+        )
       }
-      //表单验证规则是否通过,否,终止登陆提示错误信息
+      // 表单验证规则是否通过,否,终止登陆提示错误信息
       if (!cheRes) {
-        this.$mHelper.toast(this.$mGraceChecker.error);
-        return;
+        this.$mHelper.toast(this.$mGraceChecker.error)
+        return
       }
-      this.handleLogin(this.loginParams, loginApi);
+      this.handleLogin(this.loginParams, loginApi)
     },
     // 登录
-    async handleLogin(params, loginApi) {
-      this.btnLoading = true;
+    async handleLogin (params, loginApi) {
+      this.btnLoading = true
       await this.$http
         .post(loginApi, params)
-        .then( async r => {
-          console.log(r);
-          let rolelist = r.data.pages
-          this.$mStore.commit('login', r.data);
+        .then(async r => {
+          console.log(r)
+          const rolelist = r.data.pages
+          this.$mStore.commit('login', r.data)
 
           // 商家信息
           await this.$http.get('/getUserInfo').then(async (res) => {
             if (res.data) {
-              console.log(res);
-              this.$mStore.commit('setScenic',res.data)
+              console.log(res)
+              this.$mStore.commit('setScenic', res.data)
             }
-          });
+          })
 
-          this.$mHelper.toast('恭喜您,登录成功!');
-
-          this.$mRouter.reLaunch({ route: `/pages/${rolelist[0].code}/${rolelist[0].code}`});
-          this.btnLoading = false;
+          this.$mHelper.toast('恭喜您,登录成功!')
 
+          this.$mRouter.reLaunch({ route: `/pages/${rolelist[0].code}/${rolelist[0].code}` })
+          this.btnLoading = false
         })
         .catch(() => {
-          this.btnLoading = false;
-        });
+          this.btnLoading = false
+        })
     }
-  },
-};
+  }
+}
 </script>
 <style lang="scss" scoped>
 
@@ -275,7 +273,6 @@ export default {
 	background-color: #fff;
 	border-bottom: 1px solid #e7e7e7;
 
-
   .tit {
     height: 50upx;
     line-height: 56upx;