// pages/mUser/baseC/c_company-info/c_company-info.js import { companyLedger } from '../../../../data/sceneInfo'; import { sceneTypes1 } from '../../../../data/sceneTypes'; import userservice from '../../../../service/userservice'; import authservice from '../../../../service/authservice'; import ledgerservice from '../../../../service/ledgerservice'; import bInputCheck from '../../../../base/behaviors/bInputCheck'; import bUploadLedger from '../../../mLedger/behaviors/bUploadLedger'; import bLoadingToast from '../../../../base/behaviors/bLoadingToast'; const app = getApp(); Component({ behaviors: [bInputCheck, bUploadLedger, bLoadingToast], options: { addGlobalClass: true, }, /** * 组件的属性列表 */ properties: { submitText: { type: String, value: '提交', }, sceneType: { type: String, value: '1', }, }, /** * 页面的初始数据 */ data: { sceneTypes: sceneTypes1, sceneTypeIndex: 0, msg: [ { name: '企业名称', id: 'ciName', input: true, value: '', noValue: false, }, { name: '企业地址', id: 'ciAddress', input: true, value: '', noValue: false, }, { name: '信用代码', id: 'ciOrgCode', input: true, value: '', noValue: false, }, { name: '法人', id: 'ciJuridicalPerson', input: true, value: '', noValue: false, }, { name: '联系人', id: 'ciContactName', input: true, value: '', noValue: false, }, { name: '联系方式', id: 'ciTelephone', input: true, value: '', noValue: false, }, ], }, ready() { this.setData({ loadingText: '上传中', loadCompleteText: '上传完成', }); this.setData({ ledger: companyLedger[app.globalData.userInfo.extension2], }); this.getCompanyInfo(); }, /** * 组件的方法列表 */ methods: { changeSceneType(e) { let i = e.detail.value; this.setData({ sceneTypeIndex: i, }); }, //获取企业信息 getCompanyInfo() { var that = this; userservice.getBaseInfo( app.globalData.accessToken.userId, { success(data) { const msg = that.data.msg; if (data.company != null) { const info = data.company; msg[0].value = info.ciName; msg[1].value = info.ciAddress; msg[2].value = info.ciOrgCode; msg[3].value = info.ciJuridicalPerson; msg[4].value = info.ciContactName; msg[5].value = info.ciTelephone; that.setData({ msg, info, }); } }, }, app.globalData.accessToken.openId, ); ledgerservice.getLedgerDetail( app.globalData.accessToken.userId, that.data.ledger.ledgerSubTypeId, that.data.ledger.sceneType, undefined, { success(res) { if (res.length > 0) { let detail = res[0]; if (detail.upLoad) { let imgFiles = [ { url: detail.path1[0], loading: false, }, ]; that.setData({ imgFiles, }); } } }, }, ); }, //提交企业信息 _submit() { var that = this; this.setData({ loading: true }); authservice.authCompany( app.globalData.accessToken.openId, this.data.info, { success(res) { that.submintLedger(); }, }, ); }, //提交图片信息 submintLedger() { if (this.data.imgFiles.length == 0) { this.setData({ loading: false, }); wx.navigateBack({ delta: 1, }); return; } if (this.data.imgFiles[0].url.indexOf('http') != -1) { wx.downloadFile({ url: this.data.imgFiles[0].url, success: res => { const imgPath = res.tempFilePath; this.data.imgFiles[0].url = imgPath; this._uploadLedger(); }, }); } else { this._uploadLedger(); } }, //上传完成后,回退 _success(res) { wx.navigateBack({ delta: 1, }); }, }, });