123
This commit is contained in:
parent
78b6267321
commit
6a1483e24e
|
|
@ -1,8 +1,8 @@
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
// import {getHeaders} from '../utils/token'
|
// import {getHeaders} from '../utils/token'
|
||||||
|
|
||||||
// const baseUrl = 'http://localhost:8083/api/'
|
const baseUrl = 'http://localhost:8083/api/'
|
||||||
const baseUrl = 'http://api.tomey.live/api/'
|
// const baseUrl = 'http://api.tomey.live/api/'
|
||||||
class HttpRequest {
|
class HttpRequest {
|
||||||
constructor (baseUrl) {
|
constructor (baseUrl) {
|
||||||
this.baseUrl = baseUrl
|
this.baseUrl = baseUrl
|
||||||
|
|
|
||||||
|
|
@ -41,30 +41,30 @@
|
||||||
import {gotoNewOrder} from './../../../assets/js/gotoNewOrder'
|
import {gotoNewOrder} from './../../../assets/js/gotoNewOrder'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data () {
|
||||||
let regexpPhoneNumber=(rule, value, callback) => {
|
let regexpPhoneNumber = (rule, value, callback) => {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
callback(new Error('请输入联系电话!'));
|
callback(new Error('请输入联系电话!'))
|
||||||
}else if(!/^1[3-8][0-9]{9}$/.test(value)){
|
} else if (!/^1[3-8][0-9]{9}$/.test(value)) {
|
||||||
callback(new Error('手机号码格式不正确!'));
|
callback(new Error('手机号码格式不正确!'))
|
||||||
}else{
|
} else {
|
||||||
callback();
|
callback()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
return {
|
return {
|
||||||
ruleForm: {
|
ruleForm: {
|
||||||
userName: '',
|
userName: '',
|
||||||
phoneNum:'',
|
phoneNum: '',
|
||||||
gender:1,
|
gender: 1,
|
||||||
address:''
|
address: ''
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
userName: [
|
userName: [
|
||||||
{ required: true, message: '请输入名字', trigger: 'blur' },
|
{ required: true, message: '请输入名字', trigger: 'blur' },
|
||||||
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'change' },
|
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'change' },
|
||||||
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'blur' },
|
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'blur' },
|
||||||
{ pattern:/\D/, message: '不能为纯数字', trigger: 'change' },
|
{ pattern: /\D/, message: '不能为纯数字', trigger: 'change' },
|
||||||
{ pattern:/\D/, message: '不能为纯数字', trigger: 'blur' }
|
{ pattern: /\D/, message: '不能为纯数字', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
phoneNum: [
|
phoneNum: [
|
||||||
{ required: true, message: '请输入您的联系方式'},
|
{ required: true, message: '请输入您的联系方式'},
|
||||||
|
|
@ -72,60 +72,59 @@ export default {
|
||||||
{ validator: regexpPhoneNumber, trigger: 'blur'}
|
{ validator: regexpPhoneNumber, trigger: 'blur'}
|
||||||
],
|
],
|
||||||
gender: [
|
gender: [
|
||||||
{ required: true, type:'number', message: '请选择性别', trigger: 'change' }
|
{ required: true, type: 'number', message: '请选择性别', trigger: 'change' }
|
||||||
],
|
],
|
||||||
address:[
|
address: [
|
||||||
{ required: true, message: '请输入联系地址', trigger: 'blur' }
|
{ required: true, message: '请输入联系地址', trigger: 'blur' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.ruleForm.phoneNum = this.$store.state.user.userInfo.userId;
|
this.ruleForm.phoneNum = this.$store.state.user.userInfo.userId
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitForm(formName) {
|
submitForm (formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
let addInfo = {
|
let addInfo = {
|
||||||
userName:this.ruleForm.userName,
|
userName: this.ruleForm.userName,
|
||||||
phoneNum:this.ruleForm.phoneNum,
|
phoneNum: this.ruleForm.phoneNum,
|
||||||
gender:this.ruleForm.gender,
|
gender: this.ruleForm.gender,
|
||||||
address:this.ruleForm.address
|
address: this.ruleForm.address
|
||||||
}
|
}
|
||||||
axios.post(`/users/addInformation`,addInfo).then(response=>{
|
axios.post(`/users/addInformation`, addInfo).then(response => {
|
||||||
let res = response.data;
|
let res = response.data
|
||||||
if(res.status=='0'){
|
if (res.status == '0') {
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '修改成功',
|
title: '修改成功',
|
||||||
message: '恭喜你! 修改成功!',
|
message: '恭喜你! 修改成功!',
|
||||||
duration:2000,
|
duration: 2000,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
})
|
||||||
gotoNewOrder.$emit('goNewOrder','userInformation');
|
gotoNewOrder.$emit('goNewOrder', 'userInformation')
|
||||||
this.$router.push({path:'userInformation'});
|
this.$router.push({path: 'userInformation'})
|
||||||
}else{
|
} else {
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '修改失败',
|
title: '修改失败',
|
||||||
message:res.msg,
|
message: res.msg,
|
||||||
duration:2000,
|
duration: 2000,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}).catch(err=>{
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err)
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
resetForm(formName) {
|
resetForm (formName) {
|
||||||
this.$refs[formName].resetFields();
|
this.$refs[formName].resetFields()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
|
|
|
||||||
|
|
@ -41,30 +41,30 @@
|
||||||
import {gotoNewOrder} from './../../../assets/js/gotoNewOrder'
|
import {gotoNewOrder} from './../../../assets/js/gotoNewOrder'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data () {
|
||||||
let regexpPhoneNumber=(rule, value, callback) => {
|
let regexpPhoneNumber = (rule, value, callback) => {
|
||||||
if (value === '') {
|
if (value === '') {
|
||||||
callback(new Error('请输入联系电话!'));
|
callback(new Error('请输入联系电话!'))
|
||||||
}else if(!/^1[3-8][0-9]{9}$/.test(value)){
|
} else if (!/^1[3-8][0-9]{9}$/.test(value)) {
|
||||||
callback(new Error('手机号码格式不正确!'));
|
callback(new Error('手机号码格式不正确!'))
|
||||||
}else{
|
} else {
|
||||||
callback();
|
callback()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
return {
|
return {
|
||||||
ruleForm: {
|
ruleForm: {
|
||||||
userName: '',
|
userName: '',
|
||||||
phoneNum:'',
|
phoneNum: '',
|
||||||
gender:1,
|
gender: 1,
|
||||||
address:''
|
address: ''
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
userName: [
|
userName: [
|
||||||
{ required: true, message: '请输入名字', trigger: 'blur' },
|
{ required: true, message: '请输入名字', trigger: 'blur' },
|
||||||
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'change' },
|
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'change' },
|
||||||
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'blur' },
|
{ min: 2, max: 6, message: '长度在 3 到 6 个字符', trigger: 'blur' },
|
||||||
{ pattern:/\D/, message: '不能为纯数字', trigger: 'change' },
|
{ pattern: /\D/, message: '不能为纯数字', trigger: 'change' },
|
||||||
{ pattern:/\D/, message: '不能为纯数字', trigger: 'blur' }
|
{ pattern: /\D/, message: '不能为纯数字', trigger: 'blur' }
|
||||||
],
|
],
|
||||||
phoneNum: [
|
phoneNum: [
|
||||||
{ required: true, message: '请输入您的联系方式'},
|
{ required: true, message: '请输入您的联系方式'},
|
||||||
|
|
@ -72,60 +72,59 @@ export default {
|
||||||
{ validator: regexpPhoneNumber, trigger: 'blur'}
|
{ validator: regexpPhoneNumber, trigger: 'blur'}
|
||||||
],
|
],
|
||||||
gender: [
|
gender: [
|
||||||
{ required: true, type:'number', message: '请选择性别', trigger: 'change' }
|
{ required: true, type: 'number', message: '请选择性别', trigger: 'change' }
|
||||||
],
|
],
|
||||||
address:[
|
address: [
|
||||||
{ required: true, message: '请输入联系地址', trigger: 'blur' }
|
{ required: true, message: '请输入联系地址', trigger: 'blur' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted () {
|
||||||
this.ruleForm.phoneNum = this.$store.state.user.userInfo.userId;
|
this.ruleForm.phoneNum = this.$store.state.user.userInfo.userId
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitForm(formName) {
|
submitForm (formName) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
let addInfo = {
|
let addInfo = {
|
||||||
userName:this.ruleForm.userName,
|
userName: this.ruleForm.userName,
|
||||||
phoneNum:this.ruleForm.phoneNum,
|
phoneNum: this.ruleForm.phoneNum,
|
||||||
gender:this.ruleForm.gender,
|
gender: this.ruleForm.gender,
|
||||||
address:this.ruleForm.address
|
address: this.ruleForm.address
|
||||||
}
|
}
|
||||||
axios.post(`/users/addInformation`,addInfo).then(response=>{
|
axios.post(`/users/addInformation`, addInfo).then(response => {
|
||||||
let res = response.data;
|
let res = response.data
|
||||||
if(res.status=='0'){
|
if (res.status == '0') {
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '修改成功',
|
title: '修改成功',
|
||||||
message: '恭喜你! 修改成功!',
|
message: '恭喜你! 修改成功!',
|
||||||
duration:2000,
|
duration: 2000,
|
||||||
type: 'success'
|
type: 'success'
|
||||||
});
|
})
|
||||||
gotoNewOrder.$emit('goNewOrder','userInformation');
|
gotoNewOrder.$emit('goNewOrder', 'userInformation')
|
||||||
this.$router.push({path:'userInformation'});
|
this.$router.push({path: 'userInformation'})
|
||||||
}else{
|
} else {
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '修改失败',
|
title: '修改失败',
|
||||||
message:res.msg,
|
message: res.msg,
|
||||||
duration:2000,
|
duration: 2000,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}).catch(err=>{
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err)
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
resetForm(formName) {
|
resetForm (formName) {
|
||||||
this.$refs[formName].resetFields();
|
this.$refs[formName].resetFields()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang='scss'>
|
<style lang='scss'>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue