var businessT = require('../../../../../tool/business-tool.js') var sysT = require('../../../../../tool/sys-tool.js') var businessType = require('../../../../../public/business-type.js') var url = require('../../../../../constant/url.js') import Net from '../../../../../tool/net.js' var net = new Net() var app = getApp() const actions = { UPLOAD: ['上传资料', 'uploadPhoto'], POST: ['我已邮寄', 'sendMail'], INPUT_SB: ['输入', 'uploadMemo'], INPUT_FUND: ['输入', 'uploadMemo'], INPUT_POSTADDR: ['输入', 'uploadMemo'], INPUT_MEMO: ['输入', 'uploadMemo'], H5: ['提交资料', 'uploadH5'] } Page({ data: { data: [], status: null, showButton: true, tips: '温馨提示:续保需提供身份证复印件 (正反面在同一张纸上)、户口本复印件 (首页、本人页)。', information: {}, img: [], maxImg: 0, maxImgKey: 0, uploadMaterialData: [] }, getHeight() { swan.createSelectorQuery().select('.footer').boundingClientRect((rect) => { if (rect) { this.setData({ height: rect.height }) } else { this.setData({ height: 0 }) } }).exec() }, submitMaterials() { switch (this.data.status[1]) { case 'uploadPhoto': { this.uploadPhoto() break } case 'sendMail': { this.sendMail() break } case 'uploadMemo': { this.uploadMemo() break } case 'uploadH5': { this.uploadH5() break } default: break } }, initData(successT, failT) { net.connectNeedLogin({ url: url.app_host + url.getMaterialflowNodeList, data: { f_id: this.data.information.f_id }, success: (err, res) => { this.handleData(res.data) swan.hideLoading() if (successT != '') { swan.showToast({ title: successT, icon: 'none' }) } }, fail: (err, res) => { swan.hideLoading() businessT.showFailTips(err, failT) if (this.data.data.length == 0) { setTimeout(function () { swan.navigateBack({ }) }.bind(this), 1000) } } }, true) }, handleData(data) { for (var i in data.nodeList) { var item = data.nodeList[i] if (i == '0') { var action = actions[item.node_action] if (action) { this.data.status = action } } if (item.memo == '') { item.t = item.node_name } else { item.t = item.node_name + '(' + item.memo + ')' } item.d = item.create_time.slice(0, 16) var imgs = [] for (var y in item.materialList) { businessT.debugLog(url.img_host) businessT.debugLog(item.materialList[y].value) imgs.push(url.img_host + item.materialList[y].value) } item.imgs = imgs } this.data.data = data.nodeList var key = 0 for (var i in data.materialList) { var item = data.materialList[i] if (item.key > key) { key = item.key } } this.data.maxImgKey = key this.data.maxImg = data.remainUploadSize this.setData({ status: this.data.status, data: this.data.data, dataIndex: this.data.data.length - 1 }) }, uploadPhoto() { if (this.data.maxImg == 0) { swan.showToast({ title: '最多只能上传9张图片', icon: 'none', mask: true }); return } businessT.debugLog('uploadPhoto') var that = this swan.chooseImage({ sizeType: ['compressed'], count: this.data.maxImg, success(res) { res.tempFilePaths.forEach((item,index) => { swan.compressImage({ src: item, quality: 70, success: path => { res.tempFilePaths[index]=path.tempFilePath } }) }) that.data.img = res.tempFilePaths swan.showLoading({ title: '上传中', mask: true }) that.data.uploadMaterialData = [] that.upladImg(that.data.img, 0) swan.navigateTo({ url: '../todos-preview/todos-preview?max=' + that.data.maxImg + '&type=upload', }) }, }) }, sendMail() { businessT.debugLog('sendMail') swan.showLoading({ title: '操作中', mask: true }) net.connectNeedLogin({ url: url.app_host + url.uploadMaterialMailAction, data: { f_id: this.data.information.f_id }, success: (err, res) => { this.initData('操作成功', '操作失败') this.data.showButton = false this.setData({ showButton: this.data.showButton }) // if (res.code == businessType.NetworkErrorCode.success) { // this.initData('操作成功', '操作失败') // this.data.showButton = false // this.setData({ // showButton: this.data.showButton // }) // } else { // swan.hideLoading() // businessT.showFailTips(err, '操作失败') // } }, fail: (err, res) => { swan.hideLoading() businessT.showFailTips(err, '操作失败') } }) }, uploadMemo() { businessT.debugLog('uploadMemo') swan.navigateTo({ url: '../todos-input/todos-input?t=' + this.data.data[0].node_name, }) }, uploadH5() { businessT.debugLog('uploadH5') var host = url.www_host + url.waitToDoH5 var o = '&key=' + app.loginStatus.key + '&city_code=' + this.data.information.city_code + '&id_card=' + this.data.information.id_card + '&f_id=' + this.data.information.f_id swan.navigateTo({ url: '../../../../../public/pages/html/html?host=' + host + o + '&callback=1', }) }, // finishUploadPhoto (img) { // businessT.debugLog(img) // if (img.length == 0) { // swan.showToast({ // title: '没有图片上传', // }) // return // } // swan.showLoading({ // title: '上传中', // mask: true // }) // this.data.uploadMaterialData = [] // this.upladImg(img, 0) // }, upladImg(img, i) { net.uploadImage({ url: url.www_host + url.uploadMaterialPhoto, imgPath: img[i], imgName: 'file' + (i + 1), data: { f_id: this.data.information.f_id, indexs: this.data.maxImgKey + i + 1 }, success: (err, res) => { this.data.uploadMaterialData = this.data.uploadMaterialData.concat(res.data) this.data.img[i] = url.img_host + res.data[0].value if (i == img.length - 1) { this.uploadMaterial() } else { i++ this.upladImg(img, i) } }, fail: (err, res) => { swan.hideLoading() businessT.showFailTips(err, '上传失败') } }, true) }, uploadMaterial() { var indexs = '' for (var i in this.data.uploadMaterialData) { var item = this.data.uploadMaterialData[i] indexs = indexs + item.key + '#' + item.value + ',' } indexs = indexs.slice(0, -1) businessT.debugLog(indexs) net.connectNeedLogin({ url: url.app_host + url.uploadMaterialUploadAction, data: { f_id: this.data.information.f_id, upload_files: indexs }, success: (err, res) => { this.initData('提交成功', '提交失败') // if (res.code == businessType.NetworkErrorCode.success) { // this.initData('上传成功', '上传失败') // } else { // swan.hideLoading() // businessT.showFailTips(err, '上传失败') // } }, fail: (err, res) => { swan.hideLoading() businessT.showFailTips(err, '上传失败') } }) }, finishUploadMemo(value) { businessT.debugLog(value) swan.showLoading({ title: '提交中', mask: true }) net.connectNeedLogin({ url: url.app_host + url.uploadMemoAction, data: { n_id: this.data.data[0].n_id, memo: value }, success: (err, res) => { if (res.code == businessType.NetworkErrorCode.success) { this.initData('提交成功', '提交失败') } else { swan.hideLoading() businessT.showFailTips(err, '提交失败') } }, fail: (err, res) => { swan.hideLoading() businessT.showFailTips(err, '提交失败') } }) }, detailsAction(e) { this.data.img = this.data.data[e.currentTarget.id].imgs swan.navigateTo({ url: '../todos-preview/todos-preview?' + 'type=display', }) }, onLoad: function () { // 监听页面加载的生命周期函数 var pages = getCurrentPages() this.data.information = pages[pages.length - 2].data.currentData this.setData({ information: this.data.information, suffix: sysT.suffixOfClass() }) swan.showLoading({ title: '加载中', mask: true }) this.initData('', '加载失败') }, onReady: function () { // 监听页面初次渲染完成的生命周期函数 this.getHeight() }, onShow: function () { // 监听页面显示的生命周期函数 swan.setPageInfo && swan.setPageInfo({ title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页', keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号', description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。', articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页', release_date: '2019-02-23 20:00:00', success: function () { console.log('页面基础信息设置完成'); }, fail: function (res) { console.log('设置失败'); }, }) }, onHide: function () { // 监听页面隐藏的生命周期函数 }, onUnload: function () { // 监听页面卸载的生命周期函数 }, onPullDownRefresh: function () { // 监听用户下拉动作 }, onReachBottom: function () { // 页面上拉触底事件的处理函数 }, onShareAppMessage: function () { // 用户点击右上角转发 } });