forBack.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. // pages/forBack/forBack.js
  2. const app = getApp()
  3. const util = require("../../utils/util")
  4. const urlDef = require("../../utils/urls")
  5. const urls = urlDef.urls;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. radioList: [{
  12. name: '学校不满意',
  13. type: 'school'
  14. },
  15. {
  16. name: '课程不满意',
  17. type: 'school'
  18. },
  19. {
  20. name: '产品建议/功能优化',
  21. type: 'select'
  22. },
  23. {
  24. name: '其他问题',
  25. type: 'select'
  26. },
  27. ],
  28. curRadioIndex: '0',
  29. plateList: [
  30. '我的课表',
  31. '提交作业',
  32. '课堂点评',
  33. '成长足迹',
  34. '请假',
  35. '补课',
  36. '加课',
  37. '调课',
  38. ],
  39. plateIndex: 0,
  40. radioType: 'school',
  41. imgList:[]
  42. },
  43. getRadio: function (e) {
  44. const type = this.data.radioList[e.currentTarget.dataset.index].type
  45. this.setData({
  46. curRadioIndex: e.currentTarget.dataset.index,
  47. radioType: type
  48. })
  49. },
  50. bindPickerChange: function (e) {
  51. this.setData({
  52. plateIndex: e.detail.value
  53. })
  54. },
  55. uploadTap: function () {
  56. const that = this
  57. if(that.data.imgList.length>=6){
  58. wx.showToast({
  59. title: '最多上传6张图片',
  60. icon: 'none'
  61. })
  62. return false
  63. }
  64. wx.chooseImage({
  65. count: 6,
  66. sourceType: ['album', 'camera'],
  67. success(res) {
  68. wx.showLoading({
  69. title: '上传中...',
  70. })
  71. for (var i in res.tempFilePaths) {
  72. wx.uploadFile({
  73. filePath: res.tempFilePaths[i],
  74. name: 'name',
  75. url: urls.file_upload,
  76. header: util.getHeaders(),
  77. success(res) {
  78. wx.showToast({
  79. title: '上传成功',
  80. })
  81. const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
  82. const list = [{
  83. url: rs.data[0].url
  84. }]
  85. that.setData({
  86. imgList: that.data.imgList.concat(list)
  87. })
  88. },
  89. fail(res) {
  90. wx.showToast({
  91. title: '上传失败',
  92. icon: none
  93. })
  94. },
  95. complete(res) {
  96. wx.hideLoading({
  97. success: (res) => {},
  98. })
  99. }
  100. })
  101. }
  102. }
  103. })
  104. },
  105. delImg:function(e){
  106. const index = e.currentTarget.dataset.index
  107. this.data.imgList.splice(index,1)
  108. this.setData({
  109. imgList: this.data.imgList
  110. })
  111. },
  112. /**
  113. * 生命周期函数--监听页面加载
  114. */
  115. onLoad: function (options) {
  116. },
  117. /**
  118. * 生命周期函数--监听页面初次渲染完成
  119. */
  120. onReady: function () {
  121. },
  122. /**
  123. * 生命周期函数--监听页面显示
  124. */
  125. onShow: function () {
  126. },
  127. /**
  128. * 生命周期函数--监听页面隐藏
  129. */
  130. onHide: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面卸载
  134. */
  135. onUnload: function () {
  136. },
  137. /**
  138. * 页面相关事件处理函数--监听用户下拉动作
  139. */
  140. onPullDownRefresh: function () {
  141. },
  142. /**
  143. * 页面上拉触底事件的处理函数
  144. */
  145. onReachBottom: function () {
  146. },
  147. /**
  148. * 用户点击右上角分享
  149. */
  150. onShareAppMessage: function () {
  151. }
  152. })