123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- 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: ''
- },
- scroll: true,
- inputHide: false,
- requireView: {
- animation: {},
- hidden: true
- },
- data: {},
- customer: {},//自动同步(引用)
- inputValue: '',
- textareaValue: '',
- textareaPlaceholderHide: false,
- idCard: {
- currentChose: '1',
- first_image: '',
- second_image: ''
- },
- userPhone: '',
- verify: {
- code: '',
- buttonT: '获取验证码',
- buttonC: 'verify-button-n',//verify-button-g
- hidden: true
- },
- // bankInfoHidden: true,
- bankCard: '',
- editBankCard: false
- },
- hiddenRequireView: businessT.action(function (sender) {
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: 'ease',
- })
- animation.bottom('-800rpx').step()
- this.setData({
- requireView: {
- animation: animation.export(),
- hidden: false
- }
- })
- setTimeout(function () {
- this.data.requireView.hidden = true
- this.setData({
- requireView: this.data.requireView,
- inputHide: false,
- scroll: true
- })
- }.bind(this), 300)
- }),
- requireAction: businessT.action(function (sender) {
- if (!this.data.requireView.hidden) {
- return
- }
- this.data.requireView.hidden = false
- this.setData({
- requireView: this.data.requireView,
- scroll: false,
- inputHide: true,
- })
- var animation = wx.createAnimation({
- duration: 300,
- timingFunction: 'ease',
- })
- animation.bottom('0rpx').step()
- this.setData({
- requireView: {
- animation: animation.export(),
- hidden: false
- }
- })
- }),
-
- saveAction: businessT.action(function (sender) {
- // businessT.debugLog(this.data.textareaValue.trim())
- var newData = false
- var phone = this.data.customer.phone
- var address = this.data.customer.hk_address
- if (this.data.inputValue != phone) {
- if (!verify.isPhoneNum(this.data.inputValue)) {
- wx.showToast({
- title: '请输入正确的手机号码',
- icon: 'none'
- })
- return
- }
- newData = true
- phone = this.data.inputValue
- }
- if (this.data.textareaValue != address) {
- var temp = this.data.textareaValue.trim()
- if (temp.length == 0) {
- wx.showToast({
- title: '请输入户籍地址',
- icon: 'none'
- })
- return
- }
- newData = true
- address = this.data.textareaValue
- } else {
- if (address.length == 0) {
- wx.showToast({
- title: '请输入户籍地址',
- icon: 'none'
- })
- return
- }
- }
- if (newData) {
- wx.showLoading({
- title: '正在保存',
- mask: true
- })
- net.connectNeedLogin({
- url: url.app_host + url.modifyCustomer,
- data: {
- id: this.data.customer.id,
- id_card: this.data.customer.id_card,
- hk_address: address,
- user_name: this.data.customer.user_name,
- nation: this.data.customer.nation,
- gender: this.data.customer.gender,
- phone: phone
- },
- success: (err, res) => {
- this.data.customer.phone = phone
- this.data.customer.hk_address = address
- wx.hideLoading()
- wx.showToast({
- title: '保存成功',
- icon: 'none'
- })
- },
- fail: (err, res) => {
- businessT.showFailTips(err, '保存失败')
- }
- })
- }
- if (this.data.idCard.first_image != '') {
- net.uploadImage({
- url: url.www_host + url.uploadIdcardById,
- imgPath: this.data.idCard.first_image,
- imgName: 'file1',
- data: { sbuId: this.data.customer.id, pos: 0 },
- success: (err, res) => {
-
- },
- fail: (err, res) => {
-
- }
- })
- this.data.idCard.first_image = ''
- }
- if (this.data.idCard.second_image != '') {
- net.uploadImage({
- url: url.www_host + url.uploadIdcardById,
- imgPath: this.data.idCard.second_image,
- imgName: 'file2',
- data: { sbuId: this.data.customer.id, pos: 1 },
- success: (err, res) => {
- },
- fail: (err, res) => {
- }
- })
- this.data.idCard.second_image = ''
- }
- if (!newData) {
- wx.showToast({
- title: '保存成功',
- icon: 'none'
- })
- }
- }),
- takePhoto: businessT.action(function (sender) {
- this.data.idCard.currentChose = sender.currentTarget.id
- wx.navigateTo({
- url: '../../../public/pages/take-photo/take-photo',
- })
- }),
- finishTakePhoto: function (path) {
- if (this.data.idCard.currentChose == '1') {
- this.data.idCard.first_image = path
- this.data.data.first_image = path
- this.setData({
- data: this.data.data
- })
- } else if (this.data.idCard.currentChose == '2') {
- this.data.idCard.second_image = path
- this.data.data.second_image = path
- this.setData({
- data: this.data.data
- })
- }
- },
- checkImage: businessT.action(function (sender) {
- if (sender.currentTarget.id == '1' && this.data.idCard.first_image != '') {
- wx.previewImage({
- urls: [this.data.idCard.first_image],
- })
- } else if (sender.currentTarget.id == '2' && this.data.idCard.second_image != '') {
- wx.previewImage({
- urls: [this.data.idCard.second_image],
- })
- }
- }),
- inputAction: function (sender) {
- businessT.debugLog(sender)
- this.data.inputValue = sender.detail.value
- this.setData({
- inputValue: this.data.inputValue
- })
- },
- 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
- })
- }
- },
- verifyInputAction: function (sender) {
- businessT.debugLog(sender)
- this.data.verify.code = sender.detail.value
- this.setData({
- verify: this.data.verify
- })
- },
- getVerify: businessT.action(function (sender) {
- if (this.data.verify.buttonC == 'verify-button-g') {
- return
- }
- this.data.verify.buttonC = 'verify-button-g'
- this.data.verify.buttonT = '正在获取'
- this.setData({
- verify: this.data.verify
- })
- net.connect({
- url: url.app_host + url.getVerifyCode,
- data: {
- phone: app.globalData.userInfo.phone,
- },
- method: 'POST',
- success: (err, res) => {
- this.setVerifyButtonReciprocal(60)
- },
- fail: (err, res) => {
- this.setVerifyButtonReciprocal(0)
- businessT.showFailTips(err, '获取验证码失败')
- }
- })
- }),
- setVerifyButtonReciprocal: function (i) {
- if (this.data.verify.hidden) {
- return
- }
- if (i == 0) {
- this.data.verify.buttonC = 'verify-button-n'
- this.data.verify.buttonT = '获取验证码'
- this.setData({
- verify: this.data.verify
- })
- } else {
- this.data.verify.buttonC = 'verify-button-g'
- this.data.verify.buttonT = '还剩' + i + '秒'
- this.setData({
- verify: this.data.verify
- })
- setTimeout(function () {
- i--
- this.setVerifyButtonReciprocal(i)
- }.bind(this), 1000)
- }
-
- },
- getIdCard: businessT.action(function (sender) {
- if (this.data.verify.code.length != publicData.verifyCodeLength) {
- wx.showToast({
- title: '请输入四位验证码',
- icon: 'none'
- })
- return
- }
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- net.connectNeedLogin({
- url: url.app_host + url.getCustomer,
- data: {
- id: this.data.customer.id,
- verifyCode: this.data.verify.code
- },
- success: (err, res) => {
- this.data.data.getIdCard = true
- this.hiddenVerifyView()
- this.data.data.id_card = res.data.id_card
- this.setData({
- data: this.data.data
- })
- wx.hideLoading()
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '加载失败')
- }
- }, true)
- }),
- hiddenVerifyView: function () {
- this.data.verify.hidden = true
- this.setData({
- verify: this.data.verify,
- inputHide: false,
- scroll: true
- })
- },
- hiddenIdCard: businessT.action(function (sender) {
- this.hiddenVerifyView()
- }),
- showIdCard: businessT.action(function (sender) {
- if (!this.data.verify.hidden || this.data.data.getIdCard) {
- return
- }
- this.data.verify = {
- code: '',
- buttonT: '获取验证码',
- buttonC: 'verify-button-n',
- hidden: false
- }
- this.setData({
- verify: this.data.verify,
- scroll: false,
- inputHide: true,
- })
- }),
- // bankInfo: businessT.action(function (sender) {
- // if (!this.data.bankInfoHidden) {
- // return
- // }
- // this.data.bankInfoHidden = false
- // this.setData({
- // bankInfoHidden: this.data.bankInfoHidden,
- // scroll: false,
- // inputHide: true,
- // })
- // }),
- // dismissBankInfo: businessT.action(function (sender) {
- // this.data.bankInfoHidden = true
- // this.setData({
- // bankInfoHidden: this.data.bankInfoHidden,
- // scroll: false,
- // inputHide: false,
- // })
- // }),
- editBankCard: businessT.action(function (sender) {
- this.data.editBankCard = true
- wx.navigateTo({
- url: '../edit-bank/edit-bank?i=' + this.data.customerIndex,
- })
- }),
- getBankCode: function () {
- var bankCode = String(this.data.customer.bank_code)
- if (bankCode.length == 0) {
- this.data.bankCard = '未添加'
- } else {
- this.data.bankCard = '**** **** **** ' + bankCode.substring(bankCode.length - 4)
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- sysT.adaptor()
- businessT.debugLog(sysT.usableHeight(112))
- this.data.customer = app.globalData.customerList[options.i]
- this.data.customerIndex = options.i
- this.data.data = {
- id_card: this.data.customer.id_card,
- user_name: this.data.customer.user_name,
- nation: this.data.customer.nation,
- phone: this.data.customer.phone,
- shebao_card: this.data.customer.shebao_card,
- fund_card: this.data.customer.fund_card,
- first_image: '../../../icon/public/customer_idcard_front.png',
- second_image: '../../../icon/public/customer_idcard_verso.png',
- getIdCard: false,
- hk_address: this.data.customer.hk_address,
- }
- businessT.debugLog(this.data.data)
- wx.setNavigationBarTitle({
- title: this.data.data.user_name,
- })
- var isIos = sysT.sysInfo().system.indexOf("iOS") == 0
- this.data.adapter = {
- isIos: isIos,
- bgHeight: sysT.usableHeight(112),
- suffix: sysT.suffixOfClass(),
- }
- this.data.userPhone = String(app.globalData.userInfo.phone).slice(0, 3) + '****' + String(app.globalData.userInfo.phone).slice(7, 11)
- this.data.textareaPlaceholderHide = this.data.data.hk_address.length > 0
- this.getBankCode()
-
- this.setData({
- adapter: this.data.adapter,
- data: this.data.data,
- textareaValue: this.data.data.hk_address,
- textareaPlaceholderHide: this.data.textareaPlaceholderHide,
- inputValue: this.data.data.phone,
- userPhone: this.data.userPhone,
- bankCard: this.data.bankCard
- })
- },
- wxvoid: function () {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- if (this.data.editBankCard) {
- this.data.editBankCard = false
- this.getBankCode()
- this.setData({
- bankCard: this.data.bankCard
- })
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
-
- // }
- })
|