123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- var sysT = require('../../../tool/sys-tool.js')
- var verify = require('../../../tool/verify.js')
- var businessT = require('../../../tool/business-tool.js')
- var publicData = require('../../../constant/data.js')
- var url = require('../../../constant/url.js')
- import Net from '../../../tool/net.js'
- var net = new Net()
- var app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- adapter: {
- isIos: false,
- bgHeight: '',
- suffix: ''
- },
- customer: {},//自动同步(引用)
- data: {},
- inputValue: '',
- textareaValue: '',
- textareaPlaceholderHide: false,
- bankIcon: '',
- refreshBank: false,
- isInput: false
- },
- getBankIcon: function (bank) {
- var icon = publicData.bankDic[bank]
- if (icon) {
- icon = '../../../icon/bank/' + icon + '.png'
- } else {
- icon = ''
- }
- return icon
- },
-
- chooseBank: businessT.action(function () {
- if (this.data.isInput) {
- this.data.isInput = false
- this.getBankWithInChooseBank(true)
- return
- }
- this.intoChooseBank()
- }),
- inputAction: function (sender) {
- businessT.debugLog(sender)
- this.data.inputValue = sender.detail.value
- this.setData({
- inputValue: this.data.inputValue
- })
- },
- inputFocus: function (sender) {
- businessT.debugLog('inputfocus')
- this.data.isInput = true
- },
- inputBlur: function (sender) {
- businessT.debugLog('inputblur')
- if (this.data.isInput) {
- this.data.isInput = false
- this.getBankWithInChooseBank(false)
- }
- },
- getBankWithInChooseBank: function (flag) {
- var that = this
- net.connect({
- url: url.alipayGetBank + this.data.inputValue,
- data: {},
- method: 'GET',
- success: (err, res) => {},
- fail: (err, res) => {
- businessT.debugLog(res)
- if (res && res['bank']) {
- var dic = publicData.alipayBankDic
- if (dic[res['bank']]) {
- that.data.data.bank = dic[res['bank']]
- that.data.bankIcon = that.getBankIcon(that.data.data.bank)
- that.setData({
- data: that.data.data,
- bankIcon: that.data.bankIcon
- })
- return
- }
- }
- if (flag) {
- businessT.debugLog('flag')
- that.intoChooseBank()
- }
- }
- }, false)
- },
- intoChooseBank: function () {
- wx.navigateTo({
- url: '../choose-bank/choose-bank',
- })
- },
- textareaInput: function (sender) {
- businessT.debugLog(sender)
- this.data.textareaValue = sender.detail.value
- this.setData({
- textareaValue: this.data.textareaValue
- })
- },
- textareaFocus: function (sender) {
- if (!this.data.textareaPlaceholderHide) {
- this.data.textareaPlaceholderHide = true;
- this.setData({
- textareaPlaceholderHide: this.data.textareaPlaceholderHide
- })
- }
- },
- textareaBlur: function (sender) {
- if (this.data.textareaValue.length == 0 && this.data.textareaPlaceholderHide) {
- this.data.textareaPlaceholderHide = false;
- this.setData({
- textareaPlaceholderHide: this.data.textareaPlaceholderHide
- })
- }
- },
- saveAction: businessT.action(function (sender) {
- businessT.debugLog(this.data.inputValue)
- if (!verify.isNumber(this.data.inputValue) || this.data.inputValue.length < publicData.minBankCodeLength) {
- wx.showToast({
- title: '请输入正确的银行卡号',
- icon: 'none'
- })
- return
- }
- if (this.data.data.bank.length < publicData.minBankNameLength) {
- wx.showToast({
- title: '请输入正确的银行名称',
- icon: 'none'
- })
- return
- }
-
- wx.showLoading({
- title: '正在保存',
- mask: true
- })
- net.connectNeedLogin({
- url: url.app_host + url.modifyBank,
- data: {
- sbu_id: this.data.customer.id,
- bank: this.data.data.bank,
- bank_branch: this.data.textareaValue,
- bank_code: this.data.inputValue
- },
- success: (err, res) => {
- this.data.customer.bank = this.data.data.bank
- this.data.customer.bank_branch = this.data.textareaValue
- this.data.customer.bank_code = this.data.inputValue
- wx.hideLoading()
- wx.showToast({
- title: '保存成功',
- icon: 'none'
- })
- wx.navigateBack({})
- },
- fail: (err, res) => {
- businessT.showFailTips(err, '保存失败')
- }
- })
- }),
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- sysT.adaptor()
- businessT.debugLog(sysT.usableHeight(112))
- this.data.customer = app.globalData.customerList[options.i]
- businessT.debugLog(this.data.customer)
- this.data.data = {
- bank_code: this.data.customer.bank_code,
- bank_branch: this.data.customer.bank_branch,
- bank: this.data.customer.bank,
- user_name: this.data.customer.user_name
- }
- var isIos = sysT.sysInfo().system.indexOf("iOS") == 0
- this.data.adapter = {
- isIos: isIos,
- bgHeight: sysT.usableHeight(112),
- suffix: sysT.suffixOfClass(),
- }
- this.data.textareaPlaceholderHide = this.data.data.bank_branch.length > 0
- this.data.bankIcon = this.getBankIcon(this.data.data.bank)
- this.setData({
- textareaValue: this.data.data.bank_branch,
- textareaPlaceholderHide: this.data.textareaPlaceholderHide,
- inputValue: this.data.data.bank_code,
- adapter: this.data.adapter,
- data: this.data.data,
- bankIcon: this.data.bankIcon
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (this.data.refreshBank) {
- this.data.refreshBank = false
- this.data.bankIcon = this.getBankIcon(this.data.data.bank)
- this.setData({
- data: this.data.data,
- bankIcon: this.data.bankIcon
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|