index.js 2.7 KB

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