// pages/mine/mydc/mydc.js const app = getApp() const util = require('../../../utils/util.js') Page({ data: { bank_card_number: "请拍照上传银行卡号", valid_date: '', bank_name: '', stauts: '', avatarUrl: '', nickName: '', wv_account_name: '', loaddisplay: true, loading: false }, onLoad: function (options) { if (options.accountnumber != null && options.accountnumber != '' && options.accountnumber != 'null') { this.setData({ bank_card_number: options.accountnumber }) } if (options.wv_account_name != null && options.wv_account_name != '' && options.wv_account_name != 'null') { this.setData({ wv_account_name: options.wv_account_name }) } console.log(app.globalData) if (app.globalData.usertype == 2) { this.setData({ nickName: app.globalData.userInfo.nickName, avatarUrl: app.globalData.userInfo.avatarUrl, link: true, loaddisplay: 'none' }) } else { this.setData({ nickName: app.globalData.nickName, avatarUrl: 'https://yuesuo.yueguanjia.com/MiniProgram/images/head.png', loaddisplay: 'none' }) } var that = this wx.request({ url: app.globalData.url + '/checkDcIntroducers', method: 'get', data: { wv_phone: app.globalData.userphone }, success: function (res) { if (res.data != "") { that.setData({ wv_account_number: res.data.wv_account_number, wv_account_name: res.data.wv_account_name }) } }, fail() { app.timeOut() } }) let _this = this; _this.setData({ navH: app.globalData.navHeight }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, phoneInput: function(e) { if (e.detail.value !== null && e.detail.value !== '') { wx.request({ url: app.globalData.url + '/updateAccountNumber', method: 'POST', header: { "Content-Type": "application/x-www-form-urlencoded" }, data: { wv_account_name: e.detail.value, wv_phone: app.globalData.userphone }, success: function (res) { }, fail() { app.timeOut() } }) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, getBankCard: function() { var that = this wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { var tempFilesSize = res.tempFiles[0].size if (tempFilesSize <= 5000000) { that.setData({ loading: true, stauts: "", bank_card_number: "" }) const tempFilePaths = res.tempFilePaths wx.uploadFile({ url: app.globalData.url + '/getAccountNumber', filePath: tempFilePaths[0], name: 'file', formData: { 'phone': app.globalData.userphone }, success(res) { let restemp = JSON.parse(res.data) if (res.data == "0") { that.setData({ stauts: "识别失败!", loading: false, bank_card_number: "请上传清晰的银行卡照片" }) } else { that.setData({ stauts: "识别成功!所属银行:" + restemp.result.bank_name + ",有效期:" + restemp.result.valid_date, bank_card_number: restemp.result.bank_card_number, loading: false }) } }, fail() { app.timeOut() } }) } else { wx.showToast({ title: '上传照片请不要大于5M!', icon: 'none' }) } }, fail() { app.timeOut() } }) } })