recordSheet.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. // pages/recordSheet/recordSheet.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. currentTab: 0,
  8. current: 0,
  9. maxlength: 500,
  10. number: 0,
  11. value: "",
  12. imgs: [
  13. {
  14. type: "video",
  15. url: "https://mvwebfs.ali.kugou.com/202111261459/1028ca74e752f8dacac505c930850a0e/G113/M00/05/01/sQ0DAFk-RiuAOdArCP4PLMr4D9g218.mp4"
  16. },
  17. {
  18. type: "image",
  19. url: "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto"
  20. },
  21. {
  22. type: "image",
  23. url: "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto"
  24. },
  25. {
  26. type: "image",
  27. url: "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto"
  28. },
  29. {
  30. type: "image",
  31. url: "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto"
  32. },
  33. {
  34. type: "image",
  35. url: "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto"
  36. },
  37. {
  38. type: "image",
  39. url: "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto"
  40. },
  41. ],
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面隐藏
  60. */
  61. onHide: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面卸载
  65. */
  66. onUnload: function () {
  67. },
  68. /**
  69. * 页面相关事件处理函数--监听用户下拉动作
  70. */
  71. onPullDownRefresh: function () {
  72. },
  73. /**
  74. * 页面上拉触底事件的处理函数
  75. */
  76. onReachBottom: function () {
  77. },
  78. /**
  79. * 用户点击右上角分享
  80. */
  81. onShareAppMessage: function () {
  82. },
  83. /**
  84. * 切换tab
  85. */
  86. onChangeTab(e) {
  87. this.setData({
  88. currentTab: e.currentTarget.dataset.index
  89. })
  90. },
  91. /**
  92. * 监听文本域
  93. */
  94. bindTextAreaInput(e) {
  95. this.setData({
  96. number: e.detail.cursor,
  97. value: e.detail.value
  98. })
  99. },
  100. /**
  101. * 预览图片和视频
  102. */
  103. previewMedia(e) {
  104. let arr = this.data.imgs
  105. let current = e.currentTarget.dataset.index
  106. wx.previewMedia({
  107. sources: arr,
  108. current
  109. })
  110. },
  111. /**
  112. * 删除列表项
  113. */
  114. onDeleteItem(e) {
  115. let imgs = this.data.imgs;
  116. imgs.splice(e.currentTarget.dataset.index, 1);
  117. this.setData({ imgs })
  118. console.log(imgs)
  119. },
  120. /**
  121. * 选择图片
  122. */
  123. chooseImage() {
  124. let that = this;
  125. let imgs = this.data.imgs;
  126. let count = 9 - this.data.imgs.length
  127. wx.chooseImage({
  128. count,
  129. sizeType: ['original', 'compressed'],
  130. sourceType: ['album', 'camera'],
  131. success (res) {
  132. const tempFilePaths = res.tempFilePaths
  133. tempFilePaths.forEach((item) => {
  134. imgs.push({
  135. type: 'image',
  136. url: item
  137. })
  138. })
  139. that.setData({
  140. imgs
  141. })
  142. }
  143. })
  144. },
  145. /**
  146. * 选择视频
  147. */
  148. chooseVideo(){
  149. let that = this;
  150. let imgs = this.data.imgs;
  151. wx.chooseMedia({
  152. count: 1,
  153. mediaType: ['video'],
  154. sourceType: ['album', 'camera'],
  155. maxDuration: 30,
  156. camera: 'back',
  157. success(res) {
  158. console.log(res)
  159. const tempFiles = res.tempFiles
  160. tempFiles.forEach((item) => {
  161. imgs.unshift({
  162. type: 'video',
  163. thumb: item.thumbTempFilePath,
  164. url: item.tempFilePath
  165. })
  166. })
  167. that.setData({ imgs })
  168. }
  169. })
  170. },
  171. /**
  172. * 选择星星
  173. */
  174. onChange(e) {
  175. let index = e.currentTarget.dataset.index
  176. let value = e.detail.value
  177. this.setData({
  178. ['raterList[' + index + '].num']: value
  179. })
  180. }
  181. })