123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- 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
- })
- })
- },
- })
|