Skip to content

Commit

Permalink
代码格式化,统一风格
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeshuTT committed Aug 9, 2019
1 parent 8908d46 commit e515ce6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/common/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const toLogin = () => {
// 默认请求地址
Axios.defaults.baseURL = process.env.VUE_APP_BASE_API // url = base url + request url
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
Axios.defaults.timeout = 10000
Axios.defaults.timeout = 10*1000
// 请求(http request)拦截器 提前处理

// 响应(http response)拦截器 处理异常
Expand Down Expand Up @@ -48,6 +48,12 @@ Axios.interceptors.response.use(
if (response) {
// 请求已发出,但服务器响应的状态码不在 2xx 范围内
// console.warn(`web request ${response.config.url},status: ${response.status},statusText: ${response.statusText}`)
console.group('Ajax 错误')
console.log('request: ', `${response.config.url}`)
console.log('status: ', `${response.status}`)
console.log('status: ', `${response.statusText}`)
console.groupEnd()

return Promise.reject(response)
}else{
// 网络超时,断网,请求不存在等
Expand Down
1 change: 0 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ router.beforeEach((to, from, next) => {
next();
});


new Vue({
store,
router,
Expand Down
12 changes: 11 additions & 1 deletion src/pages/login/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
type="tel"
label="手机号"
placeholder="请输入手机号" />
<van-field v-model="nick"
type="text"
label="用户"
placeholder="请输入用户名" />
<van-field v-model="pwd"
type="password"
label="密码"
Expand Down Expand Up @@ -69,6 +73,7 @@ export default {
current:0, // 0登录,1注册
mobile: '',
pwd: '123456',
nick: '',
code: '',
vcodeSend: 0, // 0获取验证码,1验证码倒计时,
vcodeText: '获取验证码',
Expand All @@ -93,6 +98,11 @@ export default {
this.$toast('请输入正确的密码')
return;
}
// 用户名
if (this.current && isEmpty(this.nick)) {
this.$toast('请输入用户名')
return;
}
// 短信验证码4位数字
if (this.current && !/^\d{4}$/.test(this.code)) {
this.$toast('请输入正确的验证码')
Expand All @@ -110,10 +120,10 @@ export default {
mobileRegister() {
const params = {
mobile: this.mobile,
nick: this.nick || `用户${(new Date()).format('MM-dd')}`,
pwd: this.pwd,
code: this.code,
autoLogin: true, //该参数可以自动完成登录并返回token
nick:`用户${(new Date()).format('MM-dd')}`
}
this.$request.post('/user/m/register', params).then(res => {
if (res.code !== 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const store = new Vuex.Store({
},
defaultAddress: {},
userInfo:{
avatarUrl: `${require('@/assets/avatar_default.png')}`,
avatarUrl: '',
nick:'',
province:'',
city:'',
Expand Down

0 comments on commit e515ce6

Please sign in to comment.