feedback.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // pages/feedback/feedback.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. maxlength: 500,
  8. number: 0,
  9. value: "",
  10. imgs: [
  11. {
  12. type: "video",
  13. url: "http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"
  14. },
  15. {
  16. type: "image",
  17. url: "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto"
  18. },
  19. {
  20. type: "image",
  21. url: "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto"
  22. },
  23. {
  24. type: "image",
  25. url: "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto"
  26. },
  27. {
  28. type: "image",
  29. url: "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto"
  30. },
  31. {
  32. type: "image",
  33. url: "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto"
  34. },
  35. {
  36. type: "image",
  37. url: "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto"
  38. },
  39. ]
  40. },
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */
  44. onLoad: function (options) {
  45. },
  46. /**
  47. * 生命周期函数--监听页面初次渲染完成
  48. */
  49. onReady: function () {
  50. },
  51. /**
  52. * 生命周期函数--监听页面显示
  53. */
  54. onShow: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面隐藏
  58. */
  59. onHide: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面卸载
  63. */
  64. onUnload: function () {
  65. },
  66. /**
  67. * 页面相关事件处理函数--监听用户下拉动作
  68. */
  69. onPullDownRefresh: function () {
  70. },
  71. /**
  72. * 页面上拉触底事件的处理函数
  73. */
  74. onReachBottom: function () {
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. onShareAppMessage: function () {
  80. },
  81. /**
  82. * 监听文本域
  83. */
  84. bindTextAreaInput(e) {
  85. this.setData({
  86. number: e.detail.cursor,
  87. value: e.detail.value
  88. })
  89. },
  90. /**
  91. * 预览图片和视频
  92. */
  93. previewMedia(e) {
  94. let arr = this.data.imgs
  95. let current = e.currentTarget.dataset.index
  96. wx.previewMedia({
  97. sources: arr,
  98. current
  99. })
  100. },
  101. /**
  102. * 删除列表项
  103. */
  104. onDeleteItem(e) {
  105. let imgs = this.data.imgs;
  106. imgs.splice(e.currentTarget.dataset.index, 1);
  107. this.setData({ imgs })
  108. console.log(imgs)
  109. },
  110. /**
  111. * 选择图片
  112. */
  113. chooseImage() {
  114. let that = this;
  115. let imgs = this.data.imgs;
  116. let count = 9 - this.data.imgs.length
  117. wx.chooseImage({
  118. count,
  119. sizeType: ['original', 'compressed'],
  120. sourceType: ['album', 'camera'],
  121. success (res) {
  122. const tempFilePaths = res.tempFilePaths
  123. tempFilePaths.forEach((item) => {
  124. imgs.push({
  125. type: 'image',
  126. url: item
  127. })
  128. })
  129. that.setData({
  130. imgs
  131. })
  132. }
  133. })
  134. }
  135. })