recordSheet.js 5.0 KB

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