wait-for-do-details.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. var sysT = require('../../../../tool/sys-tool.js')
  2. var businessT = require('../../../../tool/business-tool.js')
  3. var url = require('../../../../constant/url.js')
  4. import Net from '../../../../tool/net.js'
  5. var net = new Net()
  6. var businessType = require('../../../../public/business-type.js')
  7. var app = getApp()
  8. const actions = {
  9. UPLOAD: ['上传资料', 'uploadPhoto'],
  10. POST: ['我已邮寄', 'sendMail'],
  11. INPUT_SB: ['输入', 'uploadMemo'],
  12. INPUT_FUND: ['输入', 'uploadMemo'],
  13. INPUT_POSTADDR: ['输入', 'uploadMemo'],
  14. INPUT_MEMO: ['输入', 'uploadMemo'],
  15. H5: ['提交资料', 'uploadH5']
  16. }
  17. Page({
  18. /**
  19. * 页面的初始数据
  20. */
  21. data: {
  22. ui: {
  23. scrollBottom: 0
  24. },
  25. adapter: {
  26. suffix: ''
  27. },
  28. data: [],
  29. status: null,
  30. showButton: true,
  31. tips: '温馨提示:续保需提供身份证复印件 (正反面在同一张纸上)、户口本复印件 (首页、本人页)。',
  32. information: {},
  33. img: [],
  34. maxImg: 0,
  35. maxImgKey: 0,
  36. uploadMaterialData:[]
  37. },
  38. submitMaterials: businessT.action(function (sender) {
  39. switch (this.data.status[1]) {
  40. case 'uploadPhoto': {
  41. this.uploadPhoto()
  42. break
  43. }
  44. case 'sendMail': {
  45. this.sendMail()
  46. break
  47. }
  48. case 'uploadMemo': {
  49. this.uploadMemo()
  50. break
  51. }
  52. case 'uploadH5': {
  53. this.uploadH5()
  54. break
  55. }
  56. default: break
  57. }
  58. }),
  59. getData: function (successT, failT) {
  60. net.connectNeedLogin({
  61. url: url.app_host + url.getMaterialflowNodeList,
  62. data: {
  63. f_id: this.data.information.f_id
  64. },
  65. success: (err, res) => {
  66. this.handleData(res.data)
  67. this.adapterScrollView()
  68. wx.hideLoading()
  69. if (successT != '') {
  70. wx.showToast({
  71. title: successT,
  72. icon: 'none'
  73. })
  74. }
  75. },
  76. fail: (err, res) => {
  77. wx.hideLoading()
  78. businessT.showFailTips(err, failT)
  79. if (this.data.data.length == 0) {
  80. setTimeout(function () {
  81. wx.navigateBack({
  82. })
  83. }.bind(this), 1000)
  84. }
  85. }
  86. }, true)
  87. },
  88. handleData: function (data) {
  89. for (var i in data.nodeList) {
  90. var item = data.nodeList[i]
  91. if (i == '0') {
  92. var action = actions[item.node_action]
  93. if (action) {
  94. this.data.status = action
  95. }
  96. }
  97. if (item.memo == '') {
  98. item.t = item.node_name
  99. } else {
  100. item.t = item.node_name + '(' + item.memo + ')'
  101. }
  102. item.d = item.create_time.slice(5, 16)
  103. var imgs = []
  104. for (var y in item.materialList) {
  105. businessT.debugLog(url.img_host)
  106. businessT.debugLog(item.materialList[y].value)
  107. imgs.push(url.img_host + item.materialList[y].value)
  108. }
  109. item.imgs = imgs
  110. }
  111. this.data.data = data.nodeList
  112. var key = 0
  113. for (var i in data.materialList) {
  114. var item = data.materialList[i]
  115. if (item.key > key) {
  116. key = item.key
  117. }
  118. }
  119. this.data.maxImgKey = key
  120. this.data.maxImg = data.remainUploadSize
  121. this.setData({
  122. status: this.data.status,
  123. data: this.data.data
  124. })
  125. },
  126. uploadPhoto: function () {
  127. businessT.debugLog('uploadPhoto')
  128. var that = this
  129. wx.chooseImage({
  130. sizeType: ['compressed'],
  131. count: this.data.maxImg,
  132. success: function(res) {
  133. that.data.img = res.tempFilePaths
  134. wx.navigateTo({
  135. url: '../wait-for-do-preview/wait-for-do-preview?max=' + that.data.maxImg + '&type=upload',
  136. })
  137. },
  138. })
  139. },
  140. sendMail: function () {
  141. businessT.debugLog('sendMail')
  142. wx.showLoading({
  143. title: '操作中',
  144. mask: true
  145. })
  146. net.connectNeedLogin({
  147. url: url.app_host + url.uploadMaterialMailAction,
  148. data: {
  149. f_id: this.data.information.f_id
  150. },
  151. success: (err, res) => {
  152. if (res.code == businessType.NetworkErrorCode.success) {
  153. this.getData('操作成功', '操作失败')
  154. this.data.showButton = false
  155. this.setData({
  156. showButton: this.data.showButton
  157. })
  158. } else {
  159. wx.hideLoading()
  160. businessT.showFailTips(err, '操作失败')
  161. }
  162. },
  163. fail: (err, res) => {
  164. wx.hideLoading()
  165. businessT.showFailTips(err, '操作失败')
  166. }
  167. })
  168. },
  169. uploadMemo: function () {
  170. businessT.debugLog('uploadMemo')
  171. wx.navigateTo({
  172. url: '../wait-for-do-input/wait-for-do-input?t=' + this.data.data[0].node_name,
  173. })
  174. },
  175. uploadH5: function () {
  176. businessT.debugLog('uploadH5')
  177. var host = url.www_host + url.waitToDoH5
  178. 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
  179. wx.navigateTo({
  180. url: '../../../../public/pages/html/html?host=' + host + o + '&callback=1',
  181. })
  182. },
  183. finishUploadPhoto: function (img) {
  184. businessT.debugLog(img)
  185. if (img.length == 0) {
  186. wx.showToast({
  187. title: '没有图片上传',
  188. })
  189. return
  190. }
  191. wx.showLoading({
  192. title: '上传中',
  193. mask: true
  194. })
  195. this.data.uploadMaterialData = []
  196. this.upladImg(img, 0)
  197. },
  198. upladImg: function (img, i) {
  199. net.uploadImage({
  200. url: url.www_host + url.uploadMaterialPhoto,
  201. imgPath: img[i],
  202. imgName: 'file' + (i + 1),
  203. data: { f_id: this.data.information.f_id, indexs: this.data.maxImgKey + i + 1 },
  204. success: (err, res) => {
  205. this.data.uploadMaterialData = this.data.uploadMaterialData.concat(res.data)
  206. if (i == img.length - 1) {
  207. this.uploadMaterial()
  208. } else {
  209. i ++
  210. this.upladImg(img, i)
  211. }
  212. },
  213. fail: (err, res) => {
  214. wx.hideLoading()
  215. businessT.showFailTips(err, '上传失败')
  216. }
  217. }, true)
  218. },
  219. uploadMaterial: function () {
  220. var indexs = ''
  221. for (var i in this.data.uploadMaterialData) {
  222. var item = this.data.uploadMaterialData[i]
  223. indexs = indexs + item.key + '#' + item.value + ','
  224. }
  225. indexs = indexs.slice(0, -1)
  226. businessT.debugLog(indexs)
  227. net.connectNeedLogin({
  228. url: url.app_host + url.uploadMaterialUploadAction,
  229. data: {
  230. f_id: this.data.information.f_id,
  231. upload_files: indexs
  232. },
  233. success: (err, res) => {
  234. if (res.code == businessType.NetworkErrorCode.success) {
  235. this.getData('上传成功', '上传失败')
  236. } else {
  237. wx.hideLoading()
  238. businessT.showFailTips(err, '上传失败')
  239. }
  240. },
  241. fail: (err, res) => {
  242. wx.hideLoading()
  243. businessT.showFailTips(err, '上传失败')
  244. }
  245. })
  246. },
  247. finishUploadMemo: function (value) {
  248. businessT.debugLog(value)
  249. wx.showLoading({
  250. title: '提交中',
  251. mask: true
  252. })
  253. net.connectNeedLogin({
  254. url: url.app_host + url.uploadMemoAction,
  255. data: {
  256. n_id: this.data.data[0].n_id,
  257. memo: value
  258. },
  259. success: (err, res) => {
  260. if (res.code == businessType.NetworkErrorCode.success) {
  261. this.getData('提交成功', '提交失败')
  262. } else {
  263. wx.hideLoading()
  264. businessT.showFailTips(err, '提交失败')
  265. }
  266. },
  267. fail: (err, res) => {
  268. wx.hideLoading()
  269. businessT.showFailTips(err, '提交失败')
  270. }
  271. })
  272. },
  273. detailsAction: businessT.action(function (sender) {
  274. businessT.debugLog(this.data.data)
  275. businessT.debugLog(sender.currentTarget.id)
  276. this.data.img = this.data.data[sender.currentTarget.id].imgs
  277. wx.navigateTo({
  278. url: '../wait-for-do-preview/wait-for-do-preview?' + 'type=display',
  279. })
  280. }),
  281. adapterScrollView: function () {
  282. var that = this
  283. wx.createSelectorQuery().select('#srollBottom').boundingClientRect().exec(function (res) {
  284. //res就是 该元素的信息 数组
  285. businessT.debugLog(res)
  286. if (res.length != 0) {
  287. that.data.ui.scrollBottom = res[0].height
  288. that.setData({
  289. ui: that.data.ui
  290. })
  291. }
  292. })
  293. },
  294. /**
  295. * 生命周期函数--监听页面加载
  296. */
  297. onLoad: function (options) {
  298. var pages = getCurrentPages()
  299. this.data.information = pages[pages.length - 2].data.detailsData
  300. this.data.adapter = {
  301. suffix: sysT.suffixOfClass()
  302. }
  303. this.setData({
  304. adapter: this.data.adapter,
  305. information: this.data.information
  306. })
  307. wx.showLoading({
  308. title: '加载中',
  309. mask: true
  310. })
  311. this.getData('', '加载失败')
  312. },
  313. /**
  314. * 生命周期函数--监听页面初次渲染完成
  315. */
  316. onReady: function () {
  317. },
  318. /**
  319. * 生命周期函数--监听页面显示
  320. */
  321. onShow: function () {
  322. },
  323. /**
  324. * 生命周期函数--监听页面隐藏
  325. */
  326. onHide: function () {
  327. },
  328. /**
  329. * 生命周期函数--监听页面卸载
  330. */
  331. onUnload: function () {
  332. },
  333. /**
  334. * 页面相关事件处理函数--监听用户下拉动作
  335. */
  336. onPullDownRefresh: function () {
  337. },
  338. /**
  339. * 页面上拉触底事件的处理函数
  340. */
  341. onReachBottom: function () {
  342. },
  343. /**
  344. * 用户点击右上角分享
  345. */
  346. onShareAppMessage: function () {
  347. return {
  348. path: '/page/home/index',
  349. imageUrl: '../../../../icon/public/share_img.png',
  350. title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
  351. }
  352. }
  353. })