new-person.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. var businessT = require('../../../tool/business-tool.js')
  2. var sysT = require('../../../tool/sys-tool.js')
  3. var url = require('../../../constant/url.js')
  4. var verify = require('../../../tool/verify.js')
  5. import Net from '../../../tool/net.js'
  6. var net = new Net()
  7. var app = getApp()
  8. var wxyj = require('../../../public/wxyj.js')
  9. Page({
  10. data: {
  11. firstImgPath: '../../../icon/home/idcard_front.png',
  12. secondImgPath: '../../../icon/home/idcard_back.png',
  13. events: [{ e: 'goCamrea', t: '上传身份证正面' }, { e: 'goCamrea', t: '上传身份证反面' }],
  14. personInfo: {}
  15. },
  16. openModal() {
  17. this.cameramodal = this.selectComponent("#camera-modal");
  18. this.cameramodal.openModal();
  19. },
  20. goCamrea(e) {
  21. //513022199610170018 13350283559
  22. var idCard = this.data.personInfo.id_card
  23. if (idCard) {
  24. if (idCard.length != 18 || !verify.isIdentityCard(idCard)) {
  25. swan.showToast({
  26. title: '请填写正确的身份证号',
  27. icon: 'none',
  28. });
  29. } else if (e.currentTarget.id == 'front' || e.currentTarget.id == 'back') {
  30. swan.navigateTo({
  31. url: '../../../public/pages/camera/camera?type=' + e.currentTarget.id + '&idCard=' + idCard,
  32. })
  33. } else if (e.currentTarget.id == 'first') {
  34. swan.navigateTo({
  35. url: '../../../public/pages/camera/camera?type=front' + '&idCard=' + idCard,
  36. })
  37. } else if (e.currentTarget.id == 'second') {
  38. swan.navigateTo({
  39. url: '../../../public/pages/camera/camera?type=back' + '&idCard=' + idCard,
  40. })
  41. }
  42. } else {
  43. swan.showToast({
  44. title: '请填写正确的身份证号',
  45. icon: 'none',
  46. })
  47. }
  48. },
  49. inputAction(e) {
  50. switch (e.currentTarget.dataset.type) {
  51. case "name": {
  52. this.data.personInfo.user_name = e.detail.value
  53. break
  54. }
  55. case "nation": {
  56. this.data.personInfo.nation = e.detail.value
  57. break
  58. }
  59. case "id_card": {
  60. this.data.personInfo.id_card = e.detail.value
  61. break
  62. }
  63. case "hk_address": {
  64. this.data.personInfo.hk_address = e.detail.value
  65. break
  66. }
  67. case "phone": {
  68. this.data.personInfo.phone = e.detail.value
  69. break
  70. }
  71. }
  72. },
  73. btnAction() {
  74. const gender=verify.getIdentityCardGender(this.data.personInfo.id_card),
  75. age=verify.getIdentityCardAge(this.data.personInfo.id_card)
  76. var tips1=false,tips2=false
  77. if(gender ==1){
  78. if(age>58||age<18){
  79. tips1=true
  80. }
  81. }else{
  82. if(age>48||age<18){
  83. tips2=true
  84. }
  85. }
  86. if (!this.data.personInfo.user_name) {
  87. swan.showToast({
  88. title: '请正确输入姓名',
  89. icon: 'none',
  90. });
  91. } else if (!this.data.personInfo.nation) {
  92. swan.showToast({
  93. title: '请输入民族',
  94. icon: 'none',
  95. })
  96. } else if (!verify.isIdentityCard(this.data.personInfo.id_card)) {
  97. console.log(this.data.personInfo.id_card)
  98. swan.showToast({
  99. title: '请填写正确的身份证号',
  100. icon: 'none',
  101. });
  102. }
  103. else if (tips1) {
  104. swan.showToast({
  105. title: '暂时只受理18-58岁的男性用户哦',
  106. icon: 'none',
  107. })
  108. }else if (tips2) {
  109. swan.showToast({
  110. title: '暂时只受理18-48岁的女性用户哦',
  111. icon: 'none',
  112. })
  113. } else if (!this.data.personInfo.hk_address) {
  114. swan.showToast({
  115. title: '请正确输入户籍地址',
  116. icon: 'none',
  117. })
  118. } else if (!verify.isPhoneNum(this.data.personInfo.phone)) {
  119. swan.showToast({
  120. title: '请填写正确的手机号',
  121. icon: 'none',
  122. })
  123. } else if (!this.data.personInfo.id_card_img) {
  124. swan.showToast({
  125. title: '请拍摄身份证正面',
  126. icon: 'none',
  127. })
  128. }
  129. else if (!this.data.personInfo.id_card_img1) {
  130. swan.showToast({
  131. title: '请拍摄身份证反面',
  132. icon: 'none',
  133. })
  134. } else {
  135. swan.showLoading({
  136. title: '正在生成参保人',
  137. mask: true,
  138. })
  139. net.connectNeedLogin({
  140. url: url.app_host + url.modifyCustomer,
  141. data: this.data.personInfo,
  142. success: (err, res) => {
  143. swan.hideLoading()
  144. wxyj.wxyjData.order.sbuId = res.data.id
  145. net.connectNeedLogin({
  146. url: url.app_host + url.getCustomerList,
  147. data: {},
  148. success: (err, res) => {
  149. app.globalData.customerList = res.data
  150. if (this.data.goOrder) {
  151. var page = getCurrentPages()
  152. var prevPage = page[page.length - 2]
  153. prevPage.goNext()
  154. } else {
  155. swan.navigateBack()
  156. }
  157. swan.hideLoading();
  158. },
  159. fail: (err, res) => {
  160. swan.hideLoading();
  161. businessT.showFailTips(err)
  162. }
  163. }, true)
  164. },
  165. fail: (err, res) => {
  166. swan.hideLoading();
  167. businessT.showFailTips(err, '生成参保人信息失败')
  168. }
  169. }, true)
  170. app.idCard.front= ""
  171. app.idCard.back= ""
  172. }
  173. },
  174. idCardImg() {
  175. this.data.personInfo.id_card_img = app.idCard.front
  176. this.data.personInfo.id_card_img1 = app.idCard.back
  177. if (app.idCard.front) {
  178. this.setData({ firstImgPath: app.idCard.front })
  179. this.data.events[0].e = 'previewImg'
  180. this.data.events[0].t = '重拍正面'
  181. this.setData({
  182. events: this.data.events
  183. })
  184. }
  185. if (app.idCard.back) {
  186. this.setData({ secondImgPath: app.idCard.back })
  187. this.data.events[1].e = 'previewImg'
  188. this.data.events[1].t = '重拍反面'
  189. this.setData({
  190. events: this.data.events
  191. })
  192. }
  193. if (!app.idCard.front && !app.idCard.back) {
  194. this.setData({
  195. firstImgPath: '../../../icon/home/idcard_front.png',
  196. secondImgPath: '../../../icon/home/idcard_back.png',
  197. events: [{ e: 'goCamrea', t: '上传身份证正面' }, { e: 'goCamrea', t: '上传身份证反面' }]
  198. })
  199. }
  200. },
  201. previewImg(e) {
  202. console.log(this.data.firstImgPath)
  203. if (e.currentTarget.id == 'first') {
  204. swan.previewImage({
  205. urls: [this.data.firstImgPath]
  206. });
  207. }
  208. if (e.currentTarget.id == 'second') {
  209. swan.previewImage({
  210. urls: [this.data.secondImgPath]
  211. });
  212. }
  213. },
  214. onLoad: function (res) {
  215. // 监听页面加载的生命周期函数
  216. swan.setPageInfo && swan.setPageInfo({
  217. title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  218. keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号',
  219. description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。',
  220. articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  221. release_date: '2019-02-23 20:00:00',
  222. success: function () {
  223. console.log('页面基础信息设置完成');
  224. },
  225. fail: function (res) {
  226. console.log('设置失败');
  227. },
  228. })
  229. this.setData({ suffix: sysT.suffixOfClass(), goOrder: res.goOrder })
  230. },
  231. onReady: function () {
  232. // 监听页面初次渲染完成的生命周期函数
  233. },
  234. onShow: function () {
  235. // 监听页面显示的生命周期函数
  236. this.idCardImg()
  237. },
  238. onHide: function () {
  239. // 监听页面隐藏的生命周期函数
  240. },
  241. onUnload: function () {
  242. // 监听页面卸载的生命周期函数
  243. app.idCard.front=''
  244. app.idCard.back=''
  245. },
  246. onPullDownRefresh: function () {
  247. // 监听用户下拉动作
  248. },
  249. onReachBottom: function () {
  250. // 页面上拉触底事件的处理函数
  251. },
  252. onShareAppMessage: function () {
  253. // 用户点击右上角转发
  254. }
  255. });