index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="">
  3. <view class="page">
  4. <view class="uni-form-item uni-column">
  5. <view class="title">身份证号<text>*</text></view>
  6. <view>
  7. <input type="idcard" value="" v-model="form.cre_num" placeholder="请输入您的身份证号码" placeholder-style="font-size:32rpx;color:#ccc"/>
  8. </view>
  9. </view>
  10. <view class="uni-form-item uni-column">
  11. <view class="title">所在地区<text>*</text></view>
  12. <view style="position: relative;">
  13. <input type="text"
  14. disabled
  15. v-model="region"
  16. @click="lotusAddressData.visible=true"
  17. style="background-color: #F8F8F8;"
  18. placeholder="省市区、县乡镇等"
  19. placeholder-style="font-size:32rpx;color:#ccc"
  20. />
  21. <view class="three" @click="lotusAddressData.visible=true"></view>
  22. <lotus-address v-on:choseVal="choseValue" :lotusAddressData="lotusAddressData"></lotus-address>
  23. </view>
  24. </view>
  25. <view class="uni-form-item uni-column">
  26. <view class="title">详细地址<text>*</text></view>
  27. <view>
  28. <textarea placeholder-style="font-size:32rpx;color:#ccc" v-model="form.address" placeholder="街道、楼牌号等"/>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="showTotal" v-if="submit">
  33. <view class="box">
  34. <view style="position: relative;">
  35. <image
  36. :src="success?'../../static/team/success.png':'../../static/team/err.png'"
  37. mode="widthFix"
  38. class="box-image"></image>
  39. </view>
  40. <view class="show">
  41. <view class="show-top">
  42. {{success?'提交成功':'提交失败'}}
  43. </view>
  44. <view class="show-middle">
  45. {{success?'您已提交成功,可以使用系统!':'提交失败,请核对信息是否正确'}}
  46. </view>
  47. <view
  48. class="show-button"
  49. @click="toIndex"
  50. :style="success?'background: linear-gradient(267deg, #5FBC23 0%, #85CE52 100%);':'background: linear-gradient(90deg, #F97C55 0%, #F44545 100%)'">
  51. 知道了
  52. </view>
  53. </view>
  54. </view>
  55. <view class="over"></view>
  56. </view>
  57. <view class="button" @click="button">立即提交</view>
  58. </view>
  59. </template>
  60. <script>
  61. // import {IDCard} from "../../common/util/validator.js"
  62. import { _API_fillStatus } from '../../apis/user.js';
  63. import {getIdcardInfo } from '../../common/util/validator.js'
  64. import lotusAddress from "../../components/Winglau14-lotusAddress/Winglau14-lotusAddress.vue";
  65. export default{
  66. components:{
  67. "lotus-address":lotusAddress
  68. },
  69. data(){
  70. return{
  71. address:'',
  72. cre_num:'',
  73. moreAdress:'',
  74. IDCard:'',
  75. submit:false,
  76. form:{
  77. cre_num:'',
  78. address:'',
  79. province:'',
  80. city:'',
  81. country:''
  82. },
  83. lotusAddressData:{
  84. visible:false,
  85. provinceName:'',
  86. cityName:'',
  87. townName:'',
  88. },
  89. region:'',
  90. success:false
  91. }
  92. },
  93. methods:{
  94. //打开picker
  95. openPicker() {
  96. this.lotusAddressData.visible = true
  97. },
  98. //回传已选的省市区的值
  99. choseValue(res){
  100. //res数据源包括已选省市区与省市区code
  101. console.log(res);
  102. this.lotusAddressData.visible = res.visible;//visible为显示与关闭组件标识true显示false隐藏
  103. //res.isChose = 1省市区已选 res.isChose = 0;未选
  104. if(res.isChose){
  105. this.form.province = res.province;//省
  106. this.form.city = res.city;//市
  107. this.form.country = res.town;//区
  108. this.region = `${res.province} ${res.city} ${res.town}`; //region为已选的省市区的值
  109. }
  110. },
  111. button(){
  112. if(this.form.cre_num && this.form.address && this.region){
  113. //匹配数字字符开头18位数并允许最后一位是X
  114. // let reg = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
  115. let info = getIdcardInfo(this.form.cre_num);
  116. if(!info){
  117. uni.showToast({title:"身份证格式不正确!", icon:"none"})
  118. }else{
  119. var vcity={ 11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",
  120. 21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",
  121. 33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",
  122. 42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",
  123. 51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",
  124. 63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"
  125. };
  126. var province = this.form.cre_num.substr(0,2);
  127. if(vcity[province] == undefined)
  128. {
  129. uni.showToast({title:"身份证号输入有误!", icon:"none"})
  130. }else{
  131. let code =this.form.cre_num
  132. if (code.length == 18) {
  133. code = code.split('');
  134. //∑(ai×Wi)(mod 11)
  135. //加权因子
  136. var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
  137. //校验位
  138. var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];
  139. var sum = 0;
  140. var ai = 0;
  141. var wi = 0;
  142. for (var i = 0; i < 17; i++) {
  143. ai = code[i];
  144. wi = factor[i];
  145. sum += ai * wi;
  146. }
  147. var last = parity[sum % 11];
  148. if (parity[sum % 11] != code[17]) {
  149. uni.showToast({title:"身份证号输入有误!", icon:"none"})
  150. }
  151. else{
  152. // console.log("身份证格式正确")
  153. _API_fillStatus(this.form).then(res=>{
  154. console.log(22)
  155. if(res.code == 200){
  156. this.submit=true
  157. this.success=true
  158. }else{
  159. this.submit=true
  160. this.success=false
  161. }
  162. })
  163. }
  164. }
  165. }
  166. }
  167. }else{
  168. // console.log(this.cre_num,this.address,this.region)
  169. uni.showToast({title:"请补全信息!", icon:"none"})
  170. console.log("验证失败")
  171. }
  172. },
  173. toIndex(){
  174. if(this.success=true){
  175. uni.switchTab({
  176. url: '../index/index'
  177. });
  178. }
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. page{
  185. background-color: #fff;
  186. }
  187. .page {
  188. background-color: #fff;
  189. padding:30rpx
  190. }
  191. .uni-form-item{
  192. margin-bottom: 30rpx;
  193. text{
  194. color: #F7684F;
  195. margin-left: 5rpx;
  196. }
  197. input{
  198. background-color: #F8F8F8;
  199. height:104rpx ;
  200. padding: 30rpx;
  201. border-radius: 8rpx;
  202. }
  203. textarea{
  204. background-color: #F8F8F8;
  205. width: 100%;
  206. height:378rpx ;
  207. padding: 30rpx;
  208. border-radius: 8rpx;
  209. }
  210. .three{
  211. position: absolute;
  212. top: 40rpx;
  213. right: 30rpx;
  214. width: 0;
  215. height: 0;
  216. border: 16rpx solid transparent;
  217. border-top-color:#BABABA;
  218. }
  219. .title{
  220. font-size: 36rpx;
  221. color: #333;
  222. font-weight: bold;
  223. margin-bottom: 30rpx;
  224. }
  225. }
  226. .button{
  227. width: 750rpx;
  228. line-height: 104rpx;
  229. color: #fff;
  230. font-size: 32rpx;
  231. text-align: center;
  232. position: fixed;
  233. left: 0;
  234. bottom: 0;
  235. background-image: linear-gradient(#F97C55,#F44545);//渐变
  236. }
  237. .showTotal{
  238. .box{
  239. width: 620rpx;
  240. height: 384rpx;
  241. background-color: #fff;
  242. position: fixed;
  243. left: 0;
  244. right: 0;
  245. top:300rpx;
  246. margin: auto;
  247. z-index: 10000;
  248. border-radius: 26rpx;
  249. &-image{
  250. width: 200rpx;
  251. position:absolute;
  252. top: -50rpx;
  253. left: 225rpx;
  254. }
  255. .show{
  256. height: 384rpx;
  257. padding-bottom: 40rpx;
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. flex-direction: column;
  262. &-top{
  263. // width: 620rpx;
  264. margin-top: 120rpx;
  265. font-size: 36rpx;
  266. color: #333;
  267. font-weight: bold;
  268. }
  269. &-middle{
  270. font-size:32rpx;
  271. color: #999;
  272. }
  273. &-button{
  274. width: 528rpx;
  275. line-height: 88rpx;
  276. text-align: center;
  277. color: #fff;
  278. border-radius: 44rpx;
  279. }
  280. }
  281. }
  282. .over{
  283. width: 100%;
  284. height: 100%;
  285. background-color: #000;
  286. opacity: 0.6;
  287. position: fixed;
  288. top: 0;
  289. left: 0;
  290. z-index: 999;
  291. }
  292. .button{
  293. width: 400rpx;
  294. height: 96rpx;
  295. background: linear-gradient(90deg, #F97C55 0%, #F44545 100%);
  296. }
  297. }
  298. </style>