import { get,post } from "../../utils/http" // pages/recordSheet/recordSheet.js Page({ /** * 页面的初始数据 */ data: { currentTab: 0, current: 0, maxlength: 500, number: 0, value: "", imgs: [ { type: "video", url: "https://mvwebfs.ali.kugou.com/202111261459/1028ca74e752f8dacac505c930850a0e/G113/M00/05/01/sQ0DAFk-RiuAOdArCP4PLMr4D9g218.mp4" }, { type: "image", url: "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto" }, { type: "image", url: "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto" }, { type: "image", url: "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto" }, ], todayData: {}, detail: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options.check_id) this.setData({ check_id: options.check_id },() => { // this.getCheckInfo() // this.getCheckToday() }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getCheckInfo() this.getCheckToday() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, /** * 切换tab */ onChangeTab(e) { this.setData({ currentTab: e.currentTarget.dataset.index }) }, /** * 监听文本域 */ bindTextAreaInput(e) { this.setData({ number: e.detail.cursor, value: e.detail.value }) }, /** * 预览图片和视频 */ previewMedia(e) { let arr = this.data.imgs let current = e.currentTarget.dataset.index wx.previewMedia({ sources: arr, current }) }, /** * 删除列表项 */ onDeleteItem(e) { let imgs = this.data.imgs; imgs.splice(e.currentTarget.dataset.index, 1); this.setData({ imgs }) console.log(imgs) }, /** * 选择图片 */ chooseImage() { let that = this; let imgs = this.data.imgs; let count = 9 - this.data.imgs.length wx.chooseImage({ count, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success (res) { const tempFilePaths = res.tempFilePaths tempFilePaths.forEach((item) => { imgs.push({ type: 'image', url: item }) }) that.setData({ imgs }) } }) }, /** * 选择视频 */ chooseVideo(){ let that = this; let imgs = this.data.imgs; wx.chooseMedia({ count: 1, mediaType: ['video'], sourceType: ['album', 'camera'], maxDuration: 30, camera: 'back', success(res) { console.log(res) const tempFiles = res.tempFiles tempFiles.forEach((item) => { imgs.unshift({ type: 'video', thumb: item.thumbTempFilePath, url: item.tempFilePath }) }) that.setData({ imgs }) } }) }, /** * 选择星星 */ onChange(e) { let index = e.currentTarget.dataset.index let value = e.detail.value this.setData({ ['raterList[' + index + '].num']: value }) }, /** * 获取今日检查信息 * api/check/today */ getCheckToday() { get('api/check/today',{},(res) => { this.setData({ todayData: res.data }) console.log(res) }) }, /** * 获取检查记录详情 * api/check/info */ getCheckInfo() { get('api/check/info',{ check_id: this.data.check_id },(res) => { console.log(res.data.check.feedback) if(res.data.check && res.data.check.feedback) { res.data.check.feedback.media_list = JSON.parse(res.data.check.feedback.media_list) } if(res.data.review && res.data.review.feedback) { res.data.review.feedback.media_list = JSON.parse(res.data.review.feedback.media_list) } if(res.data.manager && res.data.manager.feedback) { res.data.manager.feedback.media_list = JSON.parse(res.data.manager.feedback.media_list) } // res.check.feedback.media_list.forEach(() => {}) this.setData({ detail: res.data }) }) }, })