提交 5f5c8fe8e444f77f20365d0d7c173da978cd4c27

作者 wangyu
1 个父辈 0fa5fe64

优化

1 //app.js 1 //app.js
  2 +const appId = 'wxe91c67adba6ac02d';
2 App({ 3 App({
3 onLaunch: function () { 4 onLaunch: function () {
4 var that = this; 5 var that = this;
@@ -39,7 +40,7 @@ App({ @@ -39,7 +40,7 @@ App({
39 data: { 40 data: {
40 "grant_type": "wx_app_code", 41 "grant_type": "wx_app_code",
41 "code": code, 42 "code": code,
42 - "scope": "global_access:end_user,tenant:wxe91c67adba6ac02d" 43 + "scope": "global_access:end_user,tenant:" + appId
43 }, 44 },
44 method: "POST", 45 method: "POST",
45 header: { 46 header: {
@@ -89,6 +90,7 @@ App({ @@ -89,6 +90,7 @@ App({
89 }, 90 },
90 91
91 globalData: { 92 globalData: {
  93 + appId: appId,
92 onshow_count: 0, 94 onshow_count: 0,
93 baseUrl: "http://47.96.75.229:20000/", 95 baseUrl: "http://47.96.75.229:20000/",
94 // baseUrl: "https://api.workai.com.cn/", 96 // baseUrl: "https://api.workai.com.cn/",
1 // pages/main/addinfo/addinfo.js 1 // pages/main/addinfo/addinfo.js
2 var app = getApp(); 2 var app = getApp();
  3 +var format = require('../../../utils/util.js');
3 var baseUrl = app.globalData.baseUrl; 4 var baseUrl = app.globalData.baseUrl;
4 Page({ 5 Page({
5 6
@@ -54,7 +55,7 @@ Page({ @@ -54,7 +55,7 @@ Page({
54 isrequre: true, 55 isrequre: true,
55 label: '是否境外人员', 56 label: '是否境外人员',
56 bindtype: 'forigner', 57 bindtype: 'forigner',
57 - selected: '否', 58 + placeholder: '否',
58 disabled: true, 59 disabled: true,
59 values: ["否", "是"], 60 values: ["否", "是"],
60 onChange: 'onPickerSelect' 61 onChange: 'onPickerSelect'
@@ -376,7 +377,6 @@ Page({ @@ -376,7 +377,6 @@ Page({
376 birthDate: that.data.birthDate, 377 birthDate: that.data.birthDate,
377 card_number: id_info.id_card_number 378 card_number: id_info.id_card_number
378 }) 379 })
379 - console.log('-cardtypeData--', that.data.cardtypeData)  
380 380
381 } 381 }
382 }, 382 },
@@ -604,11 +604,17 @@ Page({ @@ -604,11 +604,17 @@ Page({
604 // var profession_datas = this.data.professionData.values[pro_index[pro_index[0]]][0] 604 // var profession_datas = this.data.professionData.values[pro_index[pro_index[0]]][0]
605 // console.log('profession_datas', profession_datas) 605 // console.log('profession_datas', profession_datas)
606 var regMobile = /^1[3|4|5|7|8][0-9]{9}$/; 606 var regMobile = /^1[3|4|5|7|8][0-9]{9}$/;
  607 + var regname = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/;
  608 + var regEmail = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
607 var formdata = e.detail.value; 609 var formdata = e.detail.value;
608 console.log("formdata", formdata); 610 console.log("formdata", formdata);
  611 + console.log('idnum', this.data.card_number.length < 1&&!format.isIDCardNum(formdata.id_card_no))
609 if (formdata.name.length < 1) { 612 if (formdata.name.length < 1) {
610 this.showtoast('请输入姓名'); 613 this.showtoast('请输入姓名');
611 return 614 return
  615 + } else if (!regname.test(formdata.name)) {
  616 + this.showtoast('请输入正确姓名');
  617 + return
612 } else if (this.data.relativeData.selected.length < 1) { 618 } else if (this.data.relativeData.selected.length < 1) {
613 this.showtoast('请选择成员关系'); 619 this.showtoast('请选择成员关系');
614 return 620 return
@@ -618,14 +624,17 @@ Page({ @@ -618,14 +624,17 @@ Page({
618 } else if (this.data.cardtypeData.selected.length < 1) { 624 } else if (this.data.cardtypeData.selected.length < 1) {
619 this.showtoast('请选择证照类型'); 625 this.showtoast('请选择证照类型');
620 return 626 return
621 - } else if (this.data.isIdCard && this.data.card_number.length < 1) {  
622 - this.showtoast('请上传有效证件照片'); 627 + } else if (this.data.isIdCard && (this.data.card_number.length < 1 && !format.isIDCardNum(formdata.id_card_no))) {
  628 + this.showtoast('请填写有效证件号');
623 return 629 return
624 } else if (!this.data.isIdCard && (!formdata.id_card_no || formdata.id_card_no.length < 1)) { 630 } else if (!this.data.isIdCard && (!formdata.id_card_no || formdata.id_card_no.length < 1)) {
625 this.showtoast('请输入证件号码'); 631 this.showtoast('请输入证件号码');
626 return 632 return
627 - } else if (formdata.mobile.length < 1 || !regMobile.test(formdata.mobile) ) {  
628 - this.showtoast('请输入有效手机号'); 633 + } else if (formdata.mobile.length < 1) {
  634 + this.showtoast('请输入手机号');
  635 + return
  636 + } else if (!regMobile.test(formdata.mobile)){
  637 + this.showtoast('请输入正确手机号');
629 return 638 return
630 } else if (this.data.investInfo.selected.length < 1) { 639 } else if (this.data.investInfo.selected.length < 1) {
631 this.showtoast('请选择是否股东投资者'); 640 this.showtoast('请选择是否股东投资者');
@@ -633,6 +642,9 @@ Page({ @@ -633,6 +642,9 @@ Page({
633 } else if (this.data.specificIndustryInfo.selected.length < 1) { 642 } else if (this.data.specificIndustryInfo.selected.length < 1) {
634 this.showtoast('请选择是否特定行业'); 643 this.showtoast('请选择是否特定行业');
635 return 644 return
  645 + } else if (formdata.email && formdata.email.length > 0 && !regEmail.test(formdata.email)){
  646 + this.showtoast('请输入正确的邮箱');
  647 + return
636 } 648 }
637 var new_card_num = '' 649 var new_card_num = ''
638 if (this.data.isIdCard && this.data.card_number.length > 0) { 650 if (this.data.isIdCard && this.data.card_number.length > 0) {
@@ -662,7 +674,7 @@ Page({ @@ -662,7 +674,7 @@ Page({
662 "name": that.data.name.length > 0 ? that.data.name : formdata.name, 674 "name": that.data.name.length > 0 ? that.data.name : formdata.name,
663 "family_ties": that.data.relativeData.selected, 675 "family_ties": that.data.relativeData.selected,
664 "native": "中国", 676 "native": "中国",
665 - "id_card_type": that.data.relativeData.selected, 677 + "id_card_type": that.data.cardtypeData.selected,
666 "id_card_no": that.data.card_number, 678 "id_card_no": that.data.card_number,
667 "gender": that.data.genderData.selected, 679 "gender": that.data.genderData.selected,
668 "birth_date": Date.parse(new Date(this.data.birthday)) / 1000, 680 "birth_date": Date.parse(new Date(this.data.birthday)) / 1000,
@@ -75,15 +75,16 @@ @@ -75,15 +75,16 @@
75 <template is="picker_cell_normal" data="{{...cardtypeData}}" /> 75 <template is="picker_cell_normal" data="{{...cardtypeData}}" />
76 <view class="divide_line"></view> 76 <view class="divide_line"></view>
77 77
78 - <view class='item_body' bindtap='getIdInfo'> 78 + <view class='item_body'>
79 <text style='color:red;font-size: 28rpx;line-height: 80rpx;float:left'>*</text> 79 <text style='color:red;font-size: 28rpx;line-height: 80rpx;float:left'>*</text>
80 <text class='text_black_28 float_left'>证照号码</text> 80 <text class='text_black_28 float_left'>证照号码</text>
81 - <view wx:if="{{isIdCard}}" >  
82 - <image class='image_camera float_right' src='/images/camera.png'></image>  
83 - <text class='text_333_28 float_right'>{{card_number}}</text> 81 + <view wx:if="{{isIdCard}}" >
  82 + <image class='image_camera float_right' src='/images/camera.png' bindtap='getIdInfo'></image>
  83 + <!-- <text class='text_333_28 float_right'>{{card_number}}</text> -->
  84 + <input class='input_wrap float_right' placeholder='请输入证件号码' placeholder-class='text_999_28' name='id_card_no' maxlength='24' value='{{card_number}}'></input>
84 </view> 85 </view>
85 <view wx:else> 86 <view wx:else>
86 - <input class='input_wrap float_right' placeholder='请输入证件号码' placeholder-class='text_999_28' name='id_card_no' maxlength='24'></input> 87 + <input class='input_wrap float_right' placeholder='请输入证件号码' placeholder-class='text_999_28' name='id_card_no' maxlength='24' value='{{card_number}}'></input>
87 </view> 88 </view>
88 </view> 89 </view>
89 <view class="divide_line"></view> 90 <view class="divide_line"></view>
@@ -313,7 +314,7 @@ @@ -313,7 +314,7 @@
313 <view class="divide_line"></view> 314 <view class="divide_line"></view>
314 <view class='item_body'> 315 <view class='item_body'>
315 <text class='text_666_28 float_left'>工号</text> 316 <text class='text_666_28 float_left'>工号</text>
316 - <input class='input_wrap float_right' name='employee_no' type='number' placeholder-class='text_999_28' placeholder='请输入工号' maxlength='24'></input> 317 + <input class='input_wrap float_right' name='employee_no' placeholder-class='text_999_28' placeholder='请输入工号' maxlength='24'></input>
317 </view> 318 </view>
318 <view class="divide_line"></view> 319 <view class="divide_line"></view>
319 <!-- <view class='item_body'> 320 <!-- <view class='item_body'>
@@ -322,8 +323,8 @@ @@ -322,8 +323,8 @@
322 <text class='text_333_28 float_right'></text> 323 <text class='text_333_28 float_right'></text>
323 </view> --> 324 </view> -->
324 <template is="picker_cell_normal" data="{{...investpersonalInfo}}" /> 325 <template is="picker_cell_normal" data="{{...investpersonalInfo}}" />
325 - <view class="divide_line" hidden="{{investpersonalInfo.selected!='是'}}"></view>  
326 - <view class='item_body' hidden="{{investpersonalInfo.selected!='是'}}"> 326 + <view class="divide_line" hidden="{{investpersonalInfo.selected=='否'}}"></view>
  327 + <view class='item_body' hidden="{{investpersonalInfo.selected=='否'}}">
327 <text class='text_666_28 float_left'>个人投资总额</text> 328 <text class='text_666_28 float_left'>个人投资总额</text>
328 <input class='input_wrap float_right' name='personal_equity_total' type='digit' placeholder-class='text_999_28' placeholder='请输入个人投资总额' maxlength='20'></input> 329 <input class='input_wrap float_right' name='personal_equity_total' type='digit' placeholder-class='text_999_28' placeholder='请输入个人投资总额' maxlength='20'></input>
329 </view> 330 </view>
@@ -33,7 +33,7 @@ Page({ @@ -33,7 +33,7 @@ Page({
33 isrequre: true, 33 isrequre: true,
34 label: '关系', 34 label: '关系',
35 bindtype: 'relative', 35 bindtype: 'relative',
36 - placeholder: '请选择关系', 36 + placeholder: '',
37 selected: '', 37 selected: '',
38 disabled: true, 38 disabled: true,
39 values: ["子女", "配偶"], 39 values: ["子女", "配偶"],
@@ -63,7 +63,7 @@ Page({ @@ -63,7 +63,7 @@ Page({
63 isrequre: true, 63 isrequre: true,
64 label: '是否境外人员', 64 label: '是否境外人员',
65 bindtype: 'forigner', 65 bindtype: 'forigner',
66 - selected: '否', 66 + placeholder: '否',
67 disabled: true, 67 disabled: true,
68 values: ["否", "是"], 68 values: ["否", "是"],
69 onChange: 'onPickerSelect' 69 onChange: 'onPickerSelect'
@@ -226,6 +226,7 @@ Page({ @@ -226,6 +226,7 @@ Page({
226 * 生命周期函数--监听页面加载 226 * 生命周期函数--监听页面加载
227 */ 227 */
228 onLoad: function(options) { 228 onLoad: function(options) {
  229 +
229 console.log('options.id', options.id) 230 console.log('options.id', options.id)
230 if (options.id && options.id.length > 0) { 231 if (options.id && options.id.length > 0) {
231 this.setData({ 232 this.setData({
@@ -269,13 +270,14 @@ Page({ @@ -269,13 +270,14 @@ Page({
269 }, 270 },
270 271
271 //对各参数初始赋值 272 //对各参数初始赋值
272 - handleDatas: function() { 273 + handleDatas: function() {
273 //todo 274 //todo
274 - // var curdate = format.getNowFormatDate()  
275 - console.log('curdate', curdate) 275 + var curdate = format.curDateTime()
  276 + console.log('curdate', curdate)
  277 +
276 var tax_info = this.data.taxInfo 278 var tax_info = this.data.taxInfo
277 this.data.name = tax_info.name 279 this.data.name = tax_info.name
278 - this.data.relativeData.selected = tax_info.family_ties 280 + this.data.relativeData.placeholder = tax_info.family_ties
279 this.data.personstatusData.selected = tax_info.taxpayer_status 281 this.data.personstatusData.selected = tax_info.taxpayer_status
280 282
281 this.data.cardtypeData.selected = tax_info.id_card_type 283 this.data.cardtypeData.selected = tax_info.id_card_type
@@ -288,7 +290,9 @@ Page({ @@ -288,7 +290,9 @@ Page({
288 this.data.birthDate.selected = format.yearFormString(tax_info.birth_date) + '-' + format.monthFormString(tax_info.birth_date) + '-' + format.dayFormString(tax_info.birth_date) 290 this.data.birthDate.selected = format.yearFormString(tax_info.birth_date) + '-' + format.monthFormString(tax_info.birth_date) + '-' + format.dayFormString(tax_info.birth_date)
289 this.data.professionData.selected = tax_info.profession.three_level_name 291 this.data.professionData.selected = tax_info.profession.three_level_name
290 this.data.startDate.selected = format.yearFormString(tax_info.join_date) + '-' + format.monthFormString(tax_info.join_date) + '-' + format.dayFormString(tax_info.join_date) 292 this.data.startDate.selected = format.yearFormString(tax_info.join_date) + '-' + format.monthFormString(tax_info.join_date) + '-' + format.dayFormString(tax_info.join_date)
  293 + this.data.startDate.end = curdate
291 this.data.endDate.selected = format.yearFormString(tax_info.separate_date) + '-' + format.monthFormString(tax_info.separate_date) + '-' + format.dayFormString(tax_info.separate_date) 294 this.data.endDate.selected = format.yearFormString(tax_info.separate_date) + '-' + format.monthFormString(tax_info.separate_date) + '-' + format.dayFormString(tax_info.separate_date)
  295 + this.data.endDate.end = curdate
292 this.data.degreeData.selected = tax_info.education 296 this.data.degreeData.selected = tax_info.education
293 this.data.disabilityInfo.selected = tax_info.is_disability 297 this.data.disabilityInfo.selected = tax_info.is_disability
294 this.data.lieshuInfo.selected = tax_info.is_martyr_family 298 this.data.lieshuInfo.selected = tax_info.is_martyr_family
@@ -737,17 +741,19 @@ Page({ @@ -737,17 +741,19 @@ Page({
737 741
738 formSubmit: function(e) { 742 formSubmit: function(e) {
739 console.log("date", Date.parse(new Date(this.data.birthday)) / 1000) 743 console.log("date", Date.parse(new Date(this.data.birthday)) / 1000)
740 - 744 + var regEmail = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
741 var formdata = e.detail.value; 745 var formdata = e.detail.value;
742 console.log("formdata", formdata) 746 console.log("formdata", formdata)
743 console.log("card_number", this.data.card_number) 747 console.log("card_number", this.data.card_number)
744 if (this.data.name && this.data.name.length < 1 && formdata.name.length < 1) { 748 if (this.data.name && this.data.name.length < 1 && formdata.name.length < 1) {
745 this.showtoast('请输入姓名'); 749 this.showtoast('请输入姓名');
746 return 750 return
747 - } else if (!this.data.isself && this.data.relativeData.selected.length < 1) {  
748 - this.showtoast('请选择成员关系');  
749 - return  
750 - } else if (this.data.personstatusData.selected.length < 1) { 751 + }
  752 + // else if (!this.data.isself && this.data.relativeData.placeholder.length < 1) {
  753 + // this.showtoast('请选择成员关系');
  754 + // return
  755 + // }
  756 + else if (this.data.personstatusData.selected.length < 1) {
751 this.showtoast('请选择纳税人状态'); 757 this.showtoast('请选择纳税人状态');
752 return 758 return
753 } else if (this.data.cardtypeData.selected.length < 1) { 759 } else if (this.data.cardtypeData.selected.length < 1) {
@@ -768,6 +774,9 @@ Page({ @@ -768,6 +774,9 @@ Page({
768 } else if (this.data.specificIndustryInfo.selected.length < 1) { 774 } else if (this.data.specificIndustryInfo.selected.length < 1) {
769 this.showtoast('请选择是否特定行业'); 775 this.showtoast('请选择是否特定行业');
770 return 776 return
  777 + } else if (formdata.email && formdata.email.length > 0 && !regEmail.test(formdata.email)) {
  778 + this.showtoast('请输入正确的邮箱');
  779 + return
771 } 780 }
772 var new_ard_num = '' 781 var new_ard_num = ''
773 if (this.data.isIdCard && this.data.card_number.length > 0) { 782 if (this.data.isIdCard && this.data.card_number.length > 0) {
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <view class='item_body'> 13 <view class='item_body'>
14 <text style='color:red;font-size: 28rpx;line-height: 80rpx;float:left'>*</text> 14 <text style='color:red;font-size: 28rpx;line-height: 80rpx;float:left'>*</text>
15 <text class='text_black_28 float_left'>姓名</text> 15 <text class='text_black_28 float_left'>姓名</text>
16 - <input class='input_wrap float_right' placeholder='请填写姓名' name='name' value='{{name}}' disabled='true'></input> 16 + <input class='input_wrap float_right' placeholder="{{name?name:'请填写姓名'}}" name='name' disabled='true'></input>
17 </view> 17 </view>
18 <view class="divide_line"></view> 18 <view class="divide_line"></view>
19 <!-- <view class='item_body' bindtap='openpicker'> 19 <!-- <view class='item_body' bindtap='openpicker'>
@@ -46,7 +46,7 @@ @@ -46,7 +46,7 @@
46 <view class='item_body' hidden="{{!isself}}"> 46 <view class='item_body' hidden="{{!isself}}">
47 <text style='color:red;font-size: 28rpx;line-height: 80rpx;float:left'>*</text> 47 <text style='color:red;font-size: 28rpx;line-height: 80rpx;float:left'>*</text>
48 <text class='text_black_28 float_left'>姓名</text> 48 <text class='text_black_28 float_left'>姓名</text>
49 - <input class='input_wrap float_right' placeholder='请填写姓名' value='{{taxInfo.name}}' disabled='true'></input> 49 + <input class='input_wrap float_right' placeholder="{{name?name:'请填写姓名'}}"disabled='true'></input>
50 </view> 50 </view>
51 <view class="divide_line"></view> 51 <view class="divide_line"></view>
52 52
@@ -314,7 +314,7 @@ @@ -314,7 +314,7 @@
314 <view class="divide_line"></view> 314 <view class="divide_line"></view>
315 <view class='item_body '> 315 <view class='item_body '>
316 <text class='text_666_28 float_left '>工号</text> 316 <text class='text_666_28 float_left '>工号</text>
317 - <input class='input_wrap float_right ' name='employee_no' type='number' value='{{taxInfo.employee_no}}' placeholder-class='text_999_28' placeholder='请输入工号' maxlength='20'></input> 317 + <input class='input_wrap float_right ' name='employee_no' value='{{taxInfo.employee_no}}' placeholder-class='text_999_28' placeholder='请输入工号' maxlength='20'></input>
318 </view> 318 </view>
319 <view class="divide_line"></view> 319 <view class="divide_line"></view>
320 <!-- <view class='item_body '> 320 <!-- <view class='item_body '>
@@ -323,8 +323,8 @@ @@ -323,8 +323,8 @@
323 <text class='text_333_28 float_right '></text> 323 <text class='text_333_28 float_right '></text>
324 </view> --> 324 </view> -->
325 <template is="picker_cell_normal" data="{{...investpersonalInfo}}" /> 325 <template is="picker_cell_normal" data="{{...investpersonalInfo}}" />
326 - <view class="divide_line" hidden="{{investpersonalInfo.selected!='是'}}"></view>  
327 - <view class='item_body ' hidden="{{investpersonalInfo.selected!='是'}}"> 326 + <view class="divide_line" hidden="{{investpersonalInfo.selected=='否'}}"></view>
  327 + <view class='item_body ' hidden="{{investpersonalInfo.selected=='否'}}">
328 <text class='text_666_28 float_left '>个人投资总额</text> 328 <text class='text_666_28 float_left '>个人投资总额</text>
329 <input class='input_wrap float_right ' name='personal_equity_total' type='digit' value='{{taxInfo.personal_equity_total}}' placeholder-class='text_999_28' placeholder='请输入个人投资总额' maxlength='20'></input> 329 <input class='input_wrap float_right ' name='personal_equity_total' type='digit' value='{{taxInfo.personal_equity_total}}' placeholder-class='text_999_28' placeholder='请输入个人投资总额' maxlength='20'></input>
330 </view> 330 </view>
@@ -41,20 +41,22 @@ function dayFormString(dateStr) { @@ -41,20 +41,22 @@ function dayFormString(dateStr) {
41 } 41 }
42 42
43 //获取当前时间,格式YYYY-MM-DD 43 //获取当前时间,格式YYYY-MM-DD
44 -function getNowFormatDate() {  
45 - var date = new Date();  
46 - var seperator1 = "-";  
47 - var year = date.getFullYear();  
48 - var month = date.getMonth() + 1;  
49 - var strDate = date.getDate();  
50 - if (month >= 1 && month <= 9) {  
51 - month = "0" + month;  
52 - }  
53 - if (strDate >= 0 && strDate <= 9) {  
54 - strDate = "0" + strDate;  
55 - }  
56 - var currentdate = year + seperator1 + month + seperator1 + strDate;  
57 - return currentdate; 44 +function curDateTime() {
  45 + var d = new Date();
  46 + var year = d.getFullYear();
  47 + var month = d.getMonth() + 1;
  48 + var date = d.getDate();
  49 + var day = d.getDay();
  50 + var curDateTime = year;
  51 + if (month > 9)
  52 + curDateTime = curDateTime + "-" + month;
  53 + else
  54 + curDateTime = curDateTime + "-0" + month;
  55 + if (date > 9)
  56 + curDateTime = curDateTime + "-" + date;
  57 + else
  58 + curDateTime = curDateTime + "-0" + date;
  59 + return curDateTime;
58 } 60 }
59 61
60 /** 62 /**
@@ -91,5 +93,6 @@ module.exports = { @@ -91,5 +93,6 @@ module.exports = {
91 yearFormString: yearFormString, 93 yearFormString: yearFormString,
92 monthFormString: monthFormString, 94 monthFormString: monthFormString,
93 dayFormString: dayFormString, 95 dayFormString: dayFormString,
94 - isIDCardNum: isIDCardNum 96 + isIDCardNum: isIDCardNum,
  97 + curDateTime: curDateTime
95 } 98 }
注册登录 后发表评论