index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. // pages/application/index.js
  2. import {
  3. ajax,
  4. ele_height
  5. } from "../../utils/util";
  6. const {
  7. globalData: {
  8. systemInfo
  9. }
  10. } = getApp();
  11. Page({
  12. /**
  13. * 页面的初始数据
  14. */
  15. data: {
  16. multiIndex: [0, 0, 0],
  17. multiArray: [],
  18. uploadheight: 0,
  19. local_image_url: '',
  20. fileList: []
  21. },
  22. area: [],
  23. changeSelectArea: [0, 0, 0],
  24. bindMultiPickerChange: function (e) {
  25. this.setData({
  26. multiIndex: e.detail.value
  27. })
  28. },
  29. uploadimg(e) {
  30. this.setData({
  31. uploadheight: ele_height(e, systemInfo.screenWidth * 0.8)
  32. })
  33. },
  34. upload() {
  35. wx.chooseMedia({
  36. count: 1,
  37. mediaType: ['image'],
  38. success: e => {
  39. this.setData({
  40. local_image_url: e.tempFiles[0].tempFilePath
  41. })
  42. },
  43. })
  44. },
  45. delimg() {
  46. wx.showModal({
  47. title: "确定删除该图片?",
  48. content: "删除后需重新选择图片",
  49. success: (res) => {
  50. if (res.confirm) {
  51. this.setData({
  52. local_image_url: ''
  53. })
  54. }
  55. }
  56. })
  57. },
  58. bindMultiPickerColumnChange(e) {
  59. const {
  60. detail: {
  61. column,
  62. value
  63. }
  64. } = e;
  65. this.changeSelectArea[column] = value;
  66. const a0 = this.area[this.changeSelectArea[0]] || {
  67. child: []
  68. }
  69. const multiArray1 = a0.child.map(v => v.name);
  70. let multiArray2 = ((a0.child[this.changeSelectArea[1]] || {
  71. child: []
  72. }).child || []).map(v => v.name);
  73. this.setData({
  74. multiArray: [this.data.multiArray[0], multiArray1, multiArray2]
  75. })
  76. },
  77. /**
  78. * 生命周期函数--监听页面加载
  79. */
  80. onLoad(options) {
  81. ajax({
  82. urlType: "fileurl",
  83. api: "/topic/tool/img/%E5%B0%91%E5%84%BF%E4%B9%A6%E7%94%BB%E5%A4%A7%E8%B5%9B/narea.json?data=" +
  84. Date.now()
  85. }).then(res => {
  86. this.area = res || [];
  87. const a0 = this.area[0] || {
  88. child: []
  89. }
  90. const multiArray0 = this.area.map(v => v.name);
  91. const multiArray1 = a0.child.map(v => v.name);
  92. const multiArray2 = (a0.child[0] || {
  93. child: []
  94. }).child.map(v => v.name);
  95. this.setData({
  96. multiArray: [multiArray0, multiArray1, multiArray2]
  97. })
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady() {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow() {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide() {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload() {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh() {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom() {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage() {
  134. }
  135. })