123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- var sysT = require('../../../../tool/sys-tool.js')
- var businessT = require('../../../../tool/business-tool.js')
- var url = require('../../../../constant/url.js')
- import Net from '../../../../tool/net.js'
- var net = new Net()
- var businessType = require('../../../../public/business-type.js')
- 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: {
- ui: {
- scrollBottom: 0
- },
- adapter: {
- suffix: ''
- },
- data: [],
- status: null,
- showButton: true,
- tips: '温馨提示:续保需提供身份证复印件 (正反面在同一张纸上)、户口本复印件 (首页、本人页)。',
- information: {},
- img: [],
- maxImg: 0,
- maxImgKey: 0,
- uploadMaterialData:[]
- },
- submitMaterials: businessT.action(function (sender) {
- 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
- }
- }),
- getData: function (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)
- this.adapterScrollView()
- wx.hideLoading()
- if (successT != '') {
- wx.showToast({
- title: successT,
- icon: 'none'
- })
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, failT)
- if (this.data.data.length == 0) {
- setTimeout(function () {
- wx.navigateBack({
- })
- }.bind(this), 1000)
- }
- }
- }, true)
- },
- handleData: function (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(5, 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
- })
- },
- uploadPhoto: function () {
- businessT.debugLog('uploadPhoto')
- var that = this
- wx.chooseImage({
- sizeType: ['compressed'],
- count: this.data.maxImg,
- success: function(res) {
- that.data.img = res.tempFilePaths
- wx.navigateTo({
- url: '../wait-for-do-preview/wait-for-do-preview?max=' + that.data.maxImg + '&type=upload',
- })
- },
- })
- },
- sendMail: function () {
- businessT.debugLog('sendMail')
- wx.showLoading({
- title: '操作中',
- mask: true
- })
- net.connectNeedLogin({
- url: url.app_host + url.uploadMaterialMailAction,
- data: {
- f_id: this.data.information.f_id
- },
- success: (err, res) => {
- if (res.code == businessType.NetworkErrorCode.success) {
- this.getData('操作成功', '操作失败')
- this.data.showButton = false
- this.setData({
- showButton: this.data.showButton
- })
- } else {
- wx.hideLoading()
- businessT.showFailTips(err, '操作失败')
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '操作失败')
- }
- })
- },
- uploadMemo: function () {
- businessT.debugLog('uploadMemo')
- wx.navigateTo({
- url: '../wait-for-do-input/wait-for-do-input?t=' + this.data.data[0].node_name,
- })
- },
- uploadH5: function () {
- 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
- wx.navigateTo({
- url: '../../../../public/pages/html/html?host=' + host + o + '&callback=1',
- })
- },
- finishUploadPhoto: function (img) {
- businessT.debugLog(img)
- if (img.length == 0) {
- wx.showToast({
- title: '没有图片上传',
- })
- return
- }
- wx.showLoading({
- title: '上传中',
- mask: true
- })
- this.data.uploadMaterialData = []
- this.upladImg(img, 0)
- },
- upladImg: function (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)
- if (i == img.length - 1) {
- this.uploadMaterial()
- } else {
- i ++
- this.upladImg(img, i)
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '上传失败')
- }
- }, true)
- },
- uploadMaterial: function () {
- 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) => {
- if (res.code == businessType.NetworkErrorCode.success) {
- this.getData('上传成功', '上传失败')
- } else {
- wx.hideLoading()
- businessT.showFailTips(err, '上传失败')
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '上传失败')
- }
- })
- },
- finishUploadMemo: function (value) {
- businessT.debugLog(value)
- wx.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.getData('提交成功', '提交失败')
- } else {
- wx.hideLoading()
- businessT.showFailTips(err, '提交失败')
- }
- },
- fail: (err, res) => {
- wx.hideLoading()
- businessT.showFailTips(err, '提交失败')
- }
- })
- },
- detailsAction: businessT.action(function (sender) {
- businessT.debugLog(this.data.data)
- businessT.debugLog(sender.currentTarget.id)
- this.data.img = this.data.data[sender.currentTarget.id].imgs
- wx.navigateTo({
- url: '../wait-for-do-preview/wait-for-do-preview?' + 'type=display',
- })
- }),
- adapterScrollView: function () {
- var that = this
- wx.createSelectorQuery().select('#srollBottom').boundingClientRect().exec(function (res) {
- //res就是 该元素的信息 数组
- businessT.debugLog(res)
- if (res.length != 0) {
- that.data.ui.scrollBottom = res[0].height
- that.setData({
- ui: that.data.ui
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var pages = getCurrentPages()
- this.data.information = pages[pages.length - 2].data.detailsData
- this.data.adapter = {
- suffix: sysT.suffixOfClass()
- }
- this.setData({
- adapter: this.data.adapter,
- information: this.data.information
- })
- wx.showLoading({
- title: '加载中',
- mask: true
- })
- this.getData('', '加载失败')
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- path: '/page/home/index',
- imageUrl: '../../../../icon/public/share_img.png',
- title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
- }
- }
- })
|