提交 f854be17edf8a8a39cf7d83bcd66e161fb4a2181

作者 wangyu
1 个父辈 aa535ebd

优化

... ... @@ -15,11 +15,12 @@ Page({
15 15 id_card_no: "",
16 16 birthday: "",
17 17 datas: "",
18   - cardTypeArray : ['居民身份证', '中国护照', '港澳居民居住证', '台湾居民居住证', '外国人永久居留身份证', '外国人工作许可证(A类)', '外国人工作许可证(B类)', '外国人工作许可证(C类)'],
19   - countryArray:[],
20   - countryAbleChoosed:false,
21   - cardtype:"",
22   - nation:"",
  18 + cardTypeArray: ['居民身份证', '中国护照', '港澳居民居住证', '台湾居民居住证', '外国人永久居留身份证', '外国人工作许可证(A类)', '外国人工作许可证(B类)', '外国人工作许可证(C类)'],
  19 + countryArray: [],
  20 + oricountryArray: [],
  21 + countryAbleChoosed: false,
  22 + cardtype: "",
  23 + nation: "",
23 24 birthday_datelong: -1,
24 25 },
25 26
... ... @@ -43,6 +44,7 @@ Page({
43 44 cardtype: curdata.id_card_type,
44 45 nation: curdata.nation,
45 46 id_card_no: curdata.id_card_no,
  47 + countryAbleChoosed: '居民身份证' == curdata.id_card_type || '中国护照' == curdata.id_card_type ? true : false,
46 48 birthday: curdata.birthday ? this.formatDate(curdata.birthday) : "",
47 49 birthday_datelong: curdata.birthday
48 50 })
... ... @@ -97,7 +99,7 @@ Page({
97 99 },
98 100
99 101 //****************获取国籍数据************/
100   - getCountry: function () {
  102 + getCountry: function() {
101 103 var that = this
102 104 wx.showLoading({
103 105 title: '',
... ... @@ -110,9 +112,9 @@ Page({
110 112 'content-type': 'application/json', // 默认值
111 113 "Authorization": Authorization
112 114 },
113   - success: function (res) {
  115 + success: function(res) {
114 116 var countrys = res.data.concat()
115   - that.data.countryArray = res.data
  117 + that.data.oricountryArray = res.data
116 118 if (countrys.indexOf('中国') > -1) {
117 119 countrys.splice(countrys.indexOf('中国'), 1);
118 120 }
... ... @@ -126,7 +128,7 @@ Page({
126 128 countrys.splice(countrys.indexOf('澳门'), 1);
127 129 }
128 130 that.setData({
129   - countryArray: countrys,
  131 + oricountryArray: countrys,
130 132 })
131 133 },
132 134 fail(res) {
... ... @@ -151,14 +153,14 @@ Page({
151 153 if (!formdata.name || formdata.name.length < 1) {
152 154 this.showToast("请输入姓名")
153 155 return;
154   - }
155   - if (this.data.cardtype.length<1){
  156 + }
  157 + if (this.data.cardtype.length < 1) {
156 158 this.showToast("请选择证照类型")
157 159 return;
158   - }else if (!formdata.id_card_no || formdata.id_card_no.length < 1) {
  160 + } else if (!formdata.id_card_no || formdata.id_card_no.length < 1) {
159 161 this.showToast("请输入证件号码")
160 162 return;
161   - } else if (this.data.cardtype=='居民身份证'&&!format.isIDCardNum(formdata.id_card_no)) {
  163 + } else if (this.data.cardtype == '居民身份证' && !format.isIDCardNum(formdata.id_card_no)) {
162 164 this.showToast("证件号码有误")
163 165 return;
164 166 }
... ... @@ -182,11 +184,7 @@ Page({
182 184 "id": that.data.supporter_id,
183 185 "legal_entity_id": that.data.legal_entity_id,
184 186 "co_supporter": formdata.name,
185   -<<<<<<< HEAD
186   - "id_card_type": "居民身份证",
187   -=======
188 187 "id_card_type": that.data.cardtype,
189   ->>>>>>> dev_wy
190 188 "id_card_no": formdata.id_card_no,
191 189 "birthday": that.data.birthday_datelong,
192 190 "nation": that.data.nation,
... ... @@ -224,17 +222,36 @@ Page({
224 222 })
225 223 },
226 224
227   - bindCardtypeChange:function(e){
  225 + bindCardtypeChange: function(e) {
228 226 console.log('bindCardtypeChange', e)
229 227 var card_type = this.data.cardTypeArray[e.detail.value]
  228 + var nation = this.data.nation
  229 + var countryAbleChoosed = this.data.countryAbleChoosed
  230 + var countryArray = this.data.oricountryArray
  231 +
  232 + if ('居民身份证' == card_type || '中国护照' == card_type) {
  233 + nation = '中国'
  234 + countryAbleChoosed = true
  235 + } else if (card_type.indexOf("港澳") != -1) {
  236 + nation = ''
  237 + countryArray = ['中国香港', '中国澳门']
  238 + countryAbleChoosed = false
  239 + } else if (card_type.indexOf("台湾") != -1) {
  240 + nation = '中国台湾'
  241 + countryAbleChoosed = true
  242 + } else {
  243 + nation = ''
  244 + countryAbleChoosed = false
  245 + }
230 246 this.setData({
231 247 cardtype: card_type,
232   - nation: card_type == "居民身份证" || card_type == "中国护照" ? "中国" : (this.data.nation == "中国" ? "" : this.data.nation),
233   - countryAbleChoosed: card_type == "居民身份证" || card_type == "中国护照" ? true : false
  248 + nation: nation,
  249 + countryArray: countryArray,
  250 + countryAbleChoosed: countryAbleChoosed
234 251 })
235 252 },
236 253
237   - bindnationChange: function (e) {
  254 + bindnationChange: function(e) {
238 255 console.log('bindnationChange', e)
239 256 this.setData({
240 257 nation: this.data.countryArray[e.detail.value]
... ... @@ -253,7 +270,7 @@ Page({
253 270 bindinput: function(e) {
254 271 console.log("bindinput", e.detail.value)
255 272 var idCardNo = e.detail.value
256   - if (this.data.cardtype=='居民身份证'&&idCardNo.length == 18) {
  273 + if (this.data.cardtype == '居民身份证' && idCardNo.length == 18) {
257 274 if (!format.isIDCardNum(idCardNo)) {
258 275 wx.showToast({
259 276 image: "../../../../images/warn.png",
... ...
注册登录 后发表评论