edit-person-detail.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. var businessT = require('../../../tool/business-tool.js')
  2. var sysT = require('../../../tool/sys-tool.js')
  3. var url = require('../../../constant/url.js')
  4. import Net from '../../../tool/net.js'
  5. var net = new Net()
  6. var app = getApp()
  7. Page({
  8. data: {
  9. ui: [{ t: '真实姓名' }, { t: '民族' }, { t: '身份证号', p: '请输入身份证号' }, { t: '户籍地址', p: '请输入户籍地址' }, { t: '手机号码', p: '请输入手机号码' }],
  10. idCardStatus: false,
  11. modalStatus: false,
  12. time: 60,
  13. },
  14. //拍摄要求模态框
  15. openModal() {
  16. var cameramodal = this.selectComponent("#camera-modal")
  17. cameramodal.openModal();
  18. },
  19. goBack() {
  20. swan.navigateBack();
  21. },
  22. goCamera(e) {
  23. var url
  24. if (e.currentTarget.dataset.type == 'front') {
  25. url = '../camera/camera?type=front&id=' + this.data.current.id + '&status=edit'
  26. } else {
  27. url = '../camera/camera?type=back&id=' + this.data.current.id + '&status=edit'
  28. }
  29. swan.navigateTo({
  30. url: url,
  31. });
  32. },
  33. initData() {
  34. var pages = getCurrentPages()
  35. this.setData({
  36. current: pages[pages.length - 2].data.current
  37. })
  38. console.log(this.data.current)
  39. swan.setNavigationBarTitle({
  40. title: this.data.current.user_name,
  41. })
  42. this.data.ui[0].v = this.data.current.user_name
  43. this.data.ui[1].v = this.data.current.nation
  44. this.data.ui[2].v = this.data.current.id_card
  45. this.data.ui[3].v = this.data.current.hk_address
  46. this.data.ui[4].v = this.data.current.phone
  47. var phone = app.globalData.userInfo.phone,userPhone=phone,
  48. card = this.data.current.bank_code
  49. card = "**** **** **** **** " + card.slice(-4)
  50. var str1 = phone.slice(0, 3)
  51. var str2 = phone.substring(11, 7)
  52. phone = str1 + "****" + str2
  53. this.setData({
  54. ui: this.data.ui,
  55. phone,
  56. userPhone,
  57. card
  58. })
  59. },
  60. refreshImg() {
  61. if (app.idCard.front) {
  62. var firstImg = app.idCard.front
  63. }
  64. if (app.idCard.back) {
  65. var secondImg = app.idCard.back
  66. }
  67. this.setData({
  68. firstImg,
  69. secondImg
  70. })
  71. },
  72. previewImg(e) {
  73. if (e.currentTarget.dataset.id == 'first') {
  74. swan.previewImage({
  75. urls: [this.data.firstImg]
  76. });
  77. }
  78. if (e.currentTarget.dataset.id == 'second') {
  79. swan.previewImage({
  80. urls: [this.data.secondImg]
  81. });
  82. }
  83. },
  84. inputAction(e) {
  85. if (e.currentTarget.dataset.index == 3) {
  86. this.data.current.hk_address = e.detail.value
  87. }
  88. else if (e.currentTarget.dataset.index == 4) {
  89. this.data.current.phone = e.detail.value
  90. }
  91. this.setData({
  92. current: this.data.current
  93. })
  94. if (e.currentTarget.dataset.type == 'checkingNum') {
  95. this.setData({ code: e.detail.value })
  96. }
  97. },
  98. openCheckingModal() {
  99. this.setData({
  100. modalStatus: true
  101. })
  102. },
  103. closeCheckingModal() {
  104. this.setData({
  105. modalStatus: false,
  106. code: ''
  107. })
  108. },
  109. getCode() {
  110. net.connect({
  111. url: url.app_host + url.getVerifyCode,
  112. data: { phone:this.data.userPhone },
  113. method: "POST",
  114. })
  115. var time = 60
  116. this.setData({ countDown: true })
  117. var timer1 = setInterval(() => {
  118. time -= 1
  119. this.setData({ time: time })
  120. }, 1000)
  121. var timer2 = setTimeout(() => {
  122. this.setData({ countDown: false, time: '60' })
  123. clearInterval(timer1)
  124. clearTimeout(timer2)
  125. }, 60000)
  126. },
  127. sendCode() {
  128. net.connectNeedLogin({
  129. url: url.app_host + url.getCustomer,
  130. data: { id: this.data.current.id, verifyCode: this.data.code },
  131. success: (err, res) => {
  132. this.data.ui[2].v = res.data.id_card
  133. this.setData({
  134. currentDetail: res.data,
  135. idCardStatus: true,
  136. ui: this.data.ui
  137. })
  138. this.closeCheckingModal()
  139. },
  140. fail: (err, res) => {
  141. businessT.showFailTips(err)
  142. }
  143. })
  144. },
  145. btnAction() {
  146. // 6217003800020952846
  147. if (this.data.current.phone.length != 11) {
  148. swan.showToast({
  149. title: '请输入正确的手机号码!',
  150. icon: 'none',
  151. mask: true
  152. });
  153. } else if (!this.data.current.hk_address) {
  154. swan.showToast({
  155. title: '请输入正确的户籍地址!',
  156. icon: 'none',
  157. mask: true
  158. });
  159. } else {
  160. this.data.current.id_card_img = this.data.firstImg
  161. this.data.current.id_card_img1 = this.data.secondImg
  162. swan.showLoading({
  163. title: '请稍后...',
  164. mask: true,
  165. })
  166. net.connectNeedLogin({
  167. url: url.app_host + url.modifyCustomer,
  168. data: { ...this.data.current },
  169. success: (err, res) => {
  170. swan.hideLoading();
  171. swan.showToast({
  172. title: '修改成功',
  173. mask: true
  174. });
  175. },
  176. fail: (err, res) => {
  177. swan.hideLoading();
  178. businessT.showFailTips(err)
  179. }
  180. }, true)
  181. }
  182. },
  183. goBank() {
  184. swan.navigateTo({
  185. url: '../edit-bank/edit-bank?current='+JSON.stringify(this.data.current),
  186. });
  187. },
  188. onLoad: function () {
  189. this.initData()
  190. this.setData({ suffix: sysT.suffixOfClass() })
  191. },
  192. onReady: function () {
  193. // 监听页面初次渲染完成的生命周期函数
  194. },
  195. onShow: function () {
  196. // 监听页面显示的生命周期函数
  197. swan.setPageInfo && swan.setPageInfo({
  198. title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  199. keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号',
  200. description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。',
  201. articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  202. release_date: '2019-02-23 20:00:00',
  203. success: function () {
  204. console.log('页面基础信息设置完成');
  205. },
  206. fail: function (res) {
  207. console.log('设置失败');
  208. },
  209. })
  210. this.refreshImg()
  211. },
  212. onHide: function () {
  213. // 监听页面隐藏的生命周期函数
  214. },
  215. onUnload: function () {
  216. // 监听页面卸载的生命周期函数
  217. app.idCard.front = ''
  218. app.idCard.back = ''
  219. },
  220. onPullDownRefresh: function () {
  221. // 监听用户下拉动作
  222. },
  223. onReachBottom: function () {
  224. // 页面上拉触底事件的处理函数
  225. },
  226. onShareAppMessage: function () {
  227. // 用户点击右上角转发
  228. }
  229. });