Commit 26584006 by 冷斌

fix bug

parent 51e90d44
...@@ -29,205 +29,190 @@ ...@@ -29,205 +29,190 @@
<div class="scimgBox"> <div class="scimgBox">
<div class="imgItem" @click="addImg('front_view')"> <div class="imgItem" @click="addImg('front_view')">
<img :src="form.front_view ? form.front_view : upload_image" <div class="imgItem" @click="addImg('front_view')" v-model="form.front_view">
:class="[form.front_view ? 'zhengjz' : 'addTipsimg']" v-model="form.front_view"> <img :src="form.front_view ? form.front_view : upload_image"
<div v-show="form.front_view ? false : true" class="addTips_wz">上传证件人像面</div> :class="[form.front_view ? 'zhengjz' : 'addTipsimg']">
<img :src="front_view ? front_view : upload_image" <div v-show="form.front_view ? false : true" class="addTips_wz">上传证件人像面</div>
:class="[front_view ? 'zhengjz' : 'addTipsimg']" v-model="front_view"> </div>
<div v-show="front_view ? false : true" class="addTips_wz">上传证件人像面</div> <div class="imgItem" @click="addImg('back_view')">
</div> <div class="imgItem" @click="addImg('back_view')" v-model="form.back_view">
<div class="imgItem" @click="addImg('back_view')"> <img :src="form.back_view ? form.back_view : upload_image"
<img :src="form.back_view ? form.back_view : upload_image" :class="[form.back_view ? 'zhengjz' : 'addTipsimg']">
:class="[form.back_view ? 'zhengjz' : 'addTipsimg']" v-model="form.back_view"> <div v-show="form.back_view ? false : true" class="addTips_wz">上传证件国徽面</div>
<div v-show="form.back_view ? false : true" class="addTips_wz">上传证件国徽面</div> </div>
<img :src="back_view ? back_view : upload_image" <div class="imgItem" @click="addImg('handset_view')">
:class="[back_view ? 'zhengjz' : 'addTipsimg']" v-model="back_view"> <div class="imgItem" @click="addImg('handset_view')" v-model="form.handset_view">
<div v-show="back_view ? false : true" class="addTips_wz">上传证件国徽面</div> <img :src="form.handset_view ? form.handset_view : upload_image"
</div> :class="[form.handset_view ? 'zhengjz' : 'addTipsimg']">
<div class="imgItem" @click="addImg('handset_view')"> <div v-show="form.handset_view ? false : true" class="addTips_wz">手持证件照</div>
<img :src="form.handset_view ? form.handset_view : upload_image" </div>
:class="[form.handset_view ? 'zhengjz' : 'addTipsimg']" v-model="form.handset_view"> <input id="file" name="image" type="file" v-show="false" class="upload" accept="image/*" @change="upload"/>
<div v-show="form.handset_view ? false : true" class="addTips_wz">手持证件照</div> <input id="file2" name="image" type="file" v-show="false" class="upload" accept="image/*" @change="upload"/>
<img :src="handset_view ? handset_view : upload_image" <input id="file3" name="image" type="file" v-show="false" class="upload" accept="image/*" @change="upload"/>
:class="[handset_view ? 'zhengjz' : 'addTipsimg']" v-model="form.handset_view"> </div>
<div v-show="handset_view ? false : true" class="addTips_wz">手持证件照</div>
</div>
<!-- <input id="file" name="image" type="file" v-show="false" class="upload" accept="image/*" @change="upload"/>
<input id="file2" name="image" type="file" v-show="false" class="upload" accept="image/*" @change="upload"/>
<input id="file3" name="image" type="file" v-show="false" class="upload" accept="image/*" @change="upload"/> -->
<input id="file" name="image" type="file" style="display: none;" class="upload" accept="image/*" @change="upload"/>
<input id="file2" name="image" type="file" style="display: none;" class="upload" accept="image/*" @change="upload"/>
<input id="file3" name="image" type="file" style="display: none;" class="upload" accept="image/*" @change="upload"/>
</div>
<!-- 按钮 --> <!-- 按钮 -->
<div class="btnBox"> <div class="btnBox">
<button type="button" :class="[isSubmit ? 'btnOne' : 'btnTwo']" @click="submit" :disabled="isSubmit">申请认证 <button type="button" :class="[isSubmit ? 'btnOne' : 'btnTwo']" @click="submit" :disabled="isSubmit">申请认证
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<script> <script>
var uid = '{$uid}'; var uid = '{$uid}';
var token = '{$token}'; var token = '{$token}';
var vm = new Vue({ var vm = new Vue({
el: '#app', el: '#app',
data: { data: {
//数据集 //数据集
form: { form: {
uid: uid, uid: uid,
token: token, token: token,
real_name: '', real_name: '',
cer_no: '', cer_no: '',
mobile: '', mobile: '',
front_view: '', front_view: '',
back_view: '', back_view: '',
handset_view: '' handset_view: ''
}, },
front_view: '', uploadName: '',
back_view: '', isSubmit: true,
handset_view: '', upload_image: '__PUBLIC__/appapi/img/add_r@2x.png',
uploadName: '',
isSubmit: true,
upload_image: '__PUBLIC__/appapi/img/add_r@2x.png',
},
methods: {
//事件
checkSubmit: function () {
let status = false;
for (let i in this.form) {
if (this.form[i] === '') {
status = true;
break;
}
}
this.isSubmit = status;
},
checkName: function () {
if (this.form.real_name === '') {
layer.msg("真实姓名不能为空");
return;
}
var reg_realName = /^(?=.*\d.*\b)/;
if (reg_realName.test(this.form.real_name)) {
layer.msg("请正确填写真实姓名");
return;
}
this.checkSubmit();
},
checkNo: function () {
if (this.form.cer_no === '') {
layer.msg("身份证号不能为空");
return;
}
var reg_identity = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
if (!reg_identity.test(this.form.cer_no)) {
layer.msg("请正确填写身份证号");
return;
}
this.checkSubmit();
},
checkMobile: function () {
if (this.form.mobile === '') {
layer.msg("手机号码不能为空");
return;
}
var reg_phone = /^(\d{5}|\d{6}|\d{7}|\d{8}|\d{9}|\d{10}|\d{11}|\d{12}|\d{13}|\d{14}|\d{15}|\d{16}|\d{17}|\d{18}|\d{19}|\d{20}|\d{21})$/;
if (!reg_phone.test(this.form.mobile)) {
layer.msg("请正确输入手机号码");
return;
}
this.checkSubmit();
},
addImg: function (name) {
this.uploadName = name;
if (this.uploadName === 'front_view') {
$("#file").click();
}
if (this.uploadName === 'back_view') {
$("#file2").click();
}
if (this.uploadName === 'handset_view') {
$("#file3").click();
}
},
upload: function () {
let _this = this;
let saveName, id = '';
if (_this.uploadName === 'front_view') {
id = 'file';
saveName = 'auth_' + uid + '_1';
}
if (_this.uploadName === 'back_view') {
id = 'file2';
saveName = 'auth_' + uid + '_2';
}
if (_this.uploadName === 'handset_view') {
id = 'file3';
saveName = 'auth_' + uid + '_3';
}
var loadingIndex = layer.load(2);
$.ajaxFileUpload({
url: './index.php?g=Appapi&m=Auth&a=upload',
secureuri: false,
fileElementId: id,
data: {saveName: saveName},
dataType: 'html',
success: function (data) {
data = data.replace(/<[^>]+>/g, "");
var str = JSON.parse(data);
if (_this.uploadName === 'front_view') {
_this.form.front_view = str.data.url;
_this.front_view = str.data.url;
}
if (_this.uploadName === 'back_view') {
_this.form.back_view = str.data.url;
_this.back_view = str.data.url;
}
if (_this.uploadName === 'handset_view') {
_this.form.handset_view = str.data.url;
_this.handset_view = str.data.url;
}
_this.checkSubmit();
layer.close(loadingIndex);
}, },
error: function (data) { methods: {
layer.msg("上传失败"); //事件
console.log(data); checkSubmit: function () {
} let status = false;
}); for (let i in this.form) {
}, if (this.form[i] === '') {
submit: function () { status = true;
let data = this.form; break;
$.ajax({url:"./index.php?g=Appapi&m=Auth&a=authsave", }
dataType:"json", }
data: data, this.isSubmit = status;
type:"POST", },
success:function(data){ checkName: function () {
//console.log(data); if (this.form.real_name === '') {
if(data.ret==200){ layer.msg("真实姓名不能为空");
window.location.href="./index.php?g=Appapi&m=Auth&a=success&uid="+uid; return;
}else{ }
layer.msg(data.msg); var reg_realName = /^(?=.*\d.*\b)/;
if (reg_realName.test(this.form.real_name)) {
layer.msg("请正确填写真实姓名");
return;
}
this.checkSubmit();
},
checkNo: function () {
if (this.form.cer_no === '') {
layer.msg("身份证号不能为空");
return;
}
var reg_identity = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
if (!reg_identity.test(this.form.cer_no)) {
layer.msg("请正确填写身份证号");
return;
}
this.checkSubmit();
},
checkMobile: function () {
if (this.form.mobile === '') {
layer.msg("手机号码不能为空");
return;
}
var reg_phone = /^(\d{5}|\d{6}|\d{7}|\d{8}|\d{9}|\d{10}|\d{11}|\d{12}|\d{13}|\d{14}|\d{15}|\d{16}|\d{17}|\d{18}|\d{19}|\d{20}|\d{21})$/;
if (!reg_phone.test(this.form.mobile)) {
layer.msg("请正确输入手机号码");
return;
}
this.checkSubmit();
},
addImg: function (name) {
this.uploadName = name;
if (this.uploadName === 'front_view') {
$("#file").click();
}
if (this.uploadName === 'back_view') {
$("#file2").click();
}
if (this.uploadName === 'handset_view') {
$("#file3").click();
}
},
upload: function () {
let _this = this;
let saveName, id = '';
if (_this.uploadName === 'front_view') {
id = 'file';
saveName = 'auth_' + uid + '_1';
}
if (_this.uploadName === 'back_view') {
id = 'file2';
saveName = 'auth_' + uid + '_2';
}
if (_this.uploadName === 'handset_view') {
id = 'file3';
saveName = 'auth_' + uid + '_3';
}
var loadingIndex = layer.load(2);
$.ajaxFileUpload({
url: './index.php?g=Appapi&m=Auth&a=upload',
secureuri: false,
fileElementId: id,
data: {saveName: saveName},
dataType: 'html',
success: function (data) {
data = data.replace(/<[^>]+>/g, "");
var str = JSON.parse(data);
if (_this.uploadName === 'front_view') {
_this.form.front_view = str.data.url;
}
if (_this.uploadName === 'back_view') {
_this.form.back_view = str.data.url;
}
if (_this.uploadName === 'handset_view') {
_this.form.handset_view = str.data.url;
}
_this.checkSubmit();
layer.close(loadingIndex);
},
error: function (data) {
layer.msg("上传失败");
console.log(data);
}
});
},
submit: function () {
let data = this.form;
$.ajax({url:"./index.php?g=Appapi&m=Auth&a=authsave",
dataType:"json",
data: data,
type:"POST",
success:function(data){
//console.log(data);
if(data.ret==200){
window.location.href="./index.php?g=Appapi&m=Auth&a=success&uid="+uid;
}else{
layer.msg(data.msg);
}
},
error:function(e){
layer.msg(e.msg);
}
})
} }
}, },
error:function(e){ watch: {
layer.msg(e.msg); //数据监测函数
},
created: function () {
//加载触发函数
} }
}) });
} </script>
},
watch: {
//数据监测函数
},
created: function () {
//加载触发函数
}
});
</script>
</body> </body>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment