edit-bank.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 publicData = require('../../../constant/data.js')
  5. var verify = require('../../../tool/verify.js')
  6. import Net from '../../../tool/net.js'
  7. var net = new Net()
  8. var app = getApp()
  9. Page({
  10. data: {
  11. card: '',
  12. bank: { bank: '', icon: '' },
  13. branch: '',
  14. isInput: false
  15. },
  16. inputAction(e) {
  17. if (e.currentTarget.dataset.type == 'card') {
  18. this.setData({
  19. card: e.detail.value
  20. })
  21. if (this.data.card.length == 22) {
  22. this.getBankWithInChooseBank()
  23. }
  24. } else {
  25. this.setData({
  26. branch: e.detail.value
  27. })
  28. }
  29. },
  30. intoChooseBank() {
  31. swan.navigateTo({
  32. url: './choose-bank/choose-bank',
  33. });
  34. },
  35. save() {
  36. if (!verify.isNumber(this.data.card) || this.data.card.length < publicData.minBankCodeLength) {
  37. swan.showToast({
  38. title: '请输入正确的银行卡卡号',
  39. icon: 'none',
  40. mask: true
  41. });
  42. } else if (this.data.bank.bank.length < publicData.minBankNameLength) {
  43. swan.showToast({
  44. title: '请输入正确的开户银行',
  45. icon: 'none',
  46. mask: true
  47. });
  48. } else {
  49. swan.showLoading({
  50. title: '请稍后...',
  51. mask: true,
  52. });
  53. net.connectNeedLogin({
  54. url: url.app_host + url.modifyBank,
  55. data: {
  56. sbu_id: this.data.current.id,
  57. bank: this.data.bank.bank,
  58. bank_code: this.data.card,
  59. bank_branch: this.data.branch
  60. },
  61. success: (err, res) => {
  62. swan.hideLoading();
  63. swan.showToast({
  64. title: '修改成功!',
  65. icon: 'none',
  66. mask: true
  67. });
  68. var pages = getCurrentPages()
  69. var prevPage = pages[pages.length - 2]
  70. var card = this.data.card
  71. card = "**** **** **** **** " + card.slice(-4)
  72. prevPage.setData({
  73. card
  74. })
  75. swan.navigateBack()
  76. },
  77. fail: (err, res) => {
  78. swan.hideLoading();
  79. businessT.showFailTips(err)
  80. }
  81. })
  82. }
  83. },
  84. inputFocus() {
  85. this.data.isInput = true
  86. },
  87. inputBlur() {
  88. if (this.data.isInput) {
  89. this.data.isInput = false
  90. this.getBankWithInChooseBank(false)
  91. }
  92. },
  93. getBankWithInChooseBank(flag) {
  94. net.connect({
  95. url: url.alipayGetBank + this.data.card,
  96. data: {},
  97. method: 'GET',
  98. success: (err, res) => { },
  99. fail: (err, res) => {
  100. businessT.debugLog(res)
  101. if (res && res['bank']) {
  102. var dic = publicData.alipayBankDic
  103. if (dic[res['bank']]) {
  104. this.data.bank.bank = dic[res['bank']]
  105. this.data.bank.icon = this.getBankIcon(this.data.bank.bank)
  106. this.setData({
  107. bank: this.data.bank
  108. })
  109. return
  110. }
  111. }
  112. if (flag) {
  113. this.chooesBank()
  114. }
  115. }
  116. }, false)
  117. },
  118. getBankIcon(bank) {
  119. var icon = publicData.bankDic[bank]
  120. return icon
  121. },
  122. chooseBank() {
  123. console.log(this.data.isInput)
  124. if (this.data.isInput) {
  125. this.data.isInput = false
  126. this.getBankWithInChooseBank(true)
  127. return
  128. }
  129. this.intoChooseBank()
  130. },
  131. onLoad: function (res) {
  132. // 监听页面加载的生命周期函数
  133. var current = JSON.parse(res.current)
  134. this.setData({
  135. current,
  136. card: current.bank_code,
  137. bank_branch:current.bank_branch
  138. })
  139. this.getBankWithInChooseBank(false)
  140. },
  141. onReady: function () {
  142. // 监听页面初次渲染完成的生命周期函数
  143. },
  144. onShow: function () {
  145. // 监听页面显示的生命周期函数
  146. swan.setPageInfo && swan.setPageInfo({
  147. title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  148. keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号',
  149. description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。',
  150. articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  151. release_date: '2019-02-23 20:00:00',
  152. success: function () {
  153. console.log('页面基础信息设置完成');
  154. },
  155. fail: function (res) {
  156. console.log('设置失败');
  157. },
  158. })
  159. this.setData({
  160. bank: this.data.bank
  161. })
  162. },
  163. onHide: function () {
  164. // 监听页面隐藏的生命周期函数
  165. },
  166. onUnload: function () {
  167. // 监听页面卸载的生命周期函数
  168. },
  169. onPullDownRefresh: function () {
  170. // 监听用户下拉动作
  171. },
  172. onReachBottom: function () {
  173. // 页面上拉触底事件的处理函数
  174. },
  175. onShareAppMessage: function () {
  176. // 用户点击右上角转发
  177. }
  178. });