todos-detail.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. var businessT = require('../../../../../tool/business-tool.js')
  2. var sysT = require('../../../../../tool/sys-tool.js')
  3. var businessType = require('../../../../../public/business-type.js')
  4. var url = require('../../../../../constant/url.js')
  5. import Net from '../../../../../tool/net.js'
  6. var net = new Net()
  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. data: {
  19. data: [],
  20. status: null,
  21. showButton: true,
  22. tips: '温馨提示:续保需提供身份证复印件 (正反面在同一张纸上)、户口本复印件 (首页、本人页)。',
  23. information: {},
  24. img: [],
  25. maxImg: 0,
  26. maxImgKey: 0,
  27. uploadMaterialData: []
  28. },
  29. getHeight() {
  30. swan.createSelectorQuery().select('.footer').boundingClientRect((rect) => {
  31. if (rect) {
  32. this.setData({ height: rect.height })
  33. } else {
  34. this.setData({ height: 0 })
  35. }
  36. }).exec()
  37. },
  38. submitMaterials() {
  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. initData(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. swan.hideLoading()
  68. if (successT != '') {
  69. swan.showToast({
  70. title: successT,
  71. icon: 'none'
  72. })
  73. }
  74. },
  75. fail: (err, res) => {
  76. swan.hideLoading()
  77. businessT.showFailTips(err, failT)
  78. if (this.data.data.length == 0) {
  79. setTimeout(function () {
  80. swan.navigateBack({
  81. })
  82. }.bind(this), 1000)
  83. }
  84. }
  85. }, true)
  86. },
  87. handleData(data) {
  88. for (var i in data.nodeList) {
  89. var item = data.nodeList[i]
  90. if (i == '0') {
  91. var action = actions[item.node_action]
  92. if (action) {
  93. this.data.status = action
  94. }
  95. }
  96. if (item.memo == '') {
  97. item.t = item.node_name
  98. } else {
  99. item.t = item.node_name + '(' + item.memo + ')'
  100. }
  101. item.d = item.create_time.slice(0, 16)
  102. var imgs = []
  103. for (var y in item.materialList) {
  104. businessT.debugLog(url.img_host)
  105. businessT.debugLog(item.materialList[y].value)
  106. imgs.push(url.img_host + item.materialList[y].value)
  107. }
  108. item.imgs = imgs
  109. }
  110. this.data.data = data.nodeList
  111. var key = 0
  112. for (var i in data.materialList) {
  113. var item = data.materialList[i]
  114. if (item.key > key) {
  115. key = item.key
  116. }
  117. }
  118. this.data.maxImgKey = key
  119. this.data.maxImg = data.remainUploadSize
  120. this.setData({
  121. status: this.data.status,
  122. data: this.data.data,
  123. dataIndex: this.data.data.length - 1
  124. })
  125. },
  126. uploadPhoto() {
  127. if (this.data.maxImg == 0) {
  128. swan.showToast({
  129. title: '最多只能上传9张图片',
  130. icon: 'none',
  131. mask: true
  132. });
  133. return
  134. }
  135. businessT.debugLog('uploadPhoto')
  136. var that = this
  137. swan.chooseImage({
  138. sizeType: ['compressed'],
  139. count: this.data.maxImg,
  140. success(res) {
  141. res.tempFilePaths.forEach((item,index) => {
  142. swan.compressImage({
  143. src: item,
  144. quality: 70,
  145. success: path => {
  146. res.tempFilePaths[index]=path.tempFilePath
  147. }
  148. })
  149. })
  150. that.data.img = res.tempFilePaths
  151. swan.showLoading({
  152. title: '上传中',
  153. mask: true
  154. })
  155. that.data.uploadMaterialData = []
  156. that.upladImg(that.data.img, 0)
  157. swan.navigateTo({
  158. url: '../todos-preview/todos-preview?max=' + that.data.maxImg + '&type=upload',
  159. })
  160. },
  161. })
  162. },
  163. sendMail() {
  164. businessT.debugLog('sendMail')
  165. swan.showLoading({
  166. title: '操作中',
  167. mask: true
  168. })
  169. net.connectNeedLogin({
  170. url: url.app_host + url.uploadMaterialMailAction,
  171. data: {
  172. f_id: this.data.information.f_id
  173. },
  174. success: (err, res) => {
  175. this.initData('操作成功', '操作失败')
  176. this.data.showButton = false
  177. this.setData({
  178. showButton: this.data.showButton
  179. })
  180. // if (res.code == businessType.NetworkErrorCode.success) {
  181. // this.initData('操作成功', '操作失败')
  182. // this.data.showButton = false
  183. // this.setData({
  184. // showButton: this.data.showButton
  185. // })
  186. // } else {
  187. // swan.hideLoading()
  188. // businessT.showFailTips(err, '操作失败')
  189. // }
  190. },
  191. fail: (err, res) => {
  192. swan.hideLoading()
  193. businessT.showFailTips(err, '操作失败')
  194. }
  195. })
  196. },
  197. uploadMemo() {
  198. businessT.debugLog('uploadMemo')
  199. swan.navigateTo({
  200. url: '../todos-input/todos-input?t=' + this.data.data[0].node_name,
  201. })
  202. },
  203. uploadH5() {
  204. businessT.debugLog('uploadH5')
  205. var host = url.www_host + url.waitToDoH5
  206. 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
  207. swan.navigateTo({
  208. url: '../../../../../public/pages/html/html?host=' + host + o + '&callback=1',
  209. })
  210. },
  211. // finishUploadPhoto (img) {
  212. // businessT.debugLog(img)
  213. // if (img.length == 0) {
  214. // swan.showToast({
  215. // title: '没有图片上传',
  216. // })
  217. // return
  218. // }
  219. // swan.showLoading({
  220. // title: '上传中',
  221. // mask: true
  222. // })
  223. // this.data.uploadMaterialData = []
  224. // this.upladImg(img, 0)
  225. // },
  226. upladImg(img, i) {
  227. net.uploadImage({
  228. url: url.www_host + url.uploadMaterialPhoto,
  229. imgPath: img[i],
  230. imgName: 'file' + (i + 1),
  231. data: { f_id: this.data.information.f_id, indexs: this.data.maxImgKey + i + 1 },
  232. success: (err, res) => {
  233. this.data.uploadMaterialData = this.data.uploadMaterialData.concat(res.data)
  234. this.data.img[i] = url.img_host + res.data[0].value
  235. if (i == img.length - 1) {
  236. this.uploadMaterial()
  237. } else {
  238. i++
  239. this.upladImg(img, i)
  240. }
  241. },
  242. fail: (err, res) => {
  243. swan.hideLoading()
  244. businessT.showFailTips(err, '上传失败')
  245. }
  246. }, true)
  247. },
  248. uploadMaterial() {
  249. var indexs = ''
  250. for (var i in this.data.uploadMaterialData) {
  251. var item = this.data.uploadMaterialData[i]
  252. indexs = indexs + item.key + '#' + item.value + ','
  253. }
  254. indexs = indexs.slice(0, -1)
  255. businessT.debugLog(indexs)
  256. net.connectNeedLogin({
  257. url: url.app_host + url.uploadMaterialUploadAction,
  258. data: {
  259. f_id: this.data.information.f_id,
  260. upload_files: indexs
  261. },
  262. success: (err, res) => {
  263. this.initData('提交成功', '提交失败')
  264. // if (res.code == businessType.NetworkErrorCode.success) {
  265. // this.initData('上传成功', '上传失败')
  266. // } else {
  267. // swan.hideLoading()
  268. // businessT.showFailTips(err, '上传失败')
  269. // }
  270. },
  271. fail: (err, res) => {
  272. swan.hideLoading()
  273. businessT.showFailTips(err, '上传失败')
  274. }
  275. })
  276. },
  277. finishUploadMemo(value) {
  278. businessT.debugLog(value)
  279. swan.showLoading({
  280. title: '提交中',
  281. mask: true
  282. })
  283. net.connectNeedLogin({
  284. url: url.app_host + url.uploadMemoAction,
  285. data: {
  286. n_id: this.data.data[0].n_id,
  287. memo: value
  288. },
  289. success: (err, res) => {
  290. if (res.code == businessType.NetworkErrorCode.success) {
  291. this.initData('提交成功', '提交失败')
  292. } else {
  293. swan.hideLoading()
  294. businessT.showFailTips(err, '提交失败')
  295. }
  296. },
  297. fail: (err, res) => {
  298. swan.hideLoading()
  299. businessT.showFailTips(err, '提交失败')
  300. }
  301. })
  302. },
  303. detailsAction(e) {
  304. this.data.img = this.data.data[e.currentTarget.id].imgs
  305. swan.navigateTo({
  306. url: '../todos-preview/todos-preview?' + 'type=display',
  307. })
  308. },
  309. onLoad: function () {
  310. // 监听页面加载的生命周期函数
  311. var pages = getCurrentPages()
  312. this.data.information = pages[pages.length - 2].data.currentData
  313. this.setData({
  314. information: this.data.information,
  315. suffix: sysT.suffixOfClass()
  316. })
  317. swan.showLoading({
  318. title: '加载中',
  319. mask: true
  320. })
  321. this.initData('', '加载失败')
  322. },
  323. onReady: function () {
  324. // 监听页面初次渲染完成的生命周期函数
  325. this.getHeight()
  326. },
  327. onShow: function () {
  328. // 监听页面显示的生命周期函数
  329. swan.setPageInfo && swan.setPageInfo({
  330. title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  331. keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号',
  332. description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。',
  333. articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页',
  334. release_date: '2019-02-23 20:00:00',
  335. success: function () {
  336. console.log('页面基础信息设置完成');
  337. },
  338. fail: function (res) {
  339. console.log('设置失败');
  340. },
  341. })
  342. },
  343. onHide: function () {
  344. // 监听页面隐藏的生命周期函数
  345. },
  346. onUnload: function () {
  347. // 监听页面卸载的生命周期函数
  348. },
  349. onPullDownRefresh: function () {
  350. // 监听用户下拉动作
  351. },
  352. onReachBottom: function () {
  353. // 页面上拉触底事件的处理函数
  354. },
  355. onShareAppMessage: function () {
  356. // 用户点击右上角转发
  357. }
  358. });