Prechádzať zdrojové kódy

1.故障报修上传图片
2.监控-开始上课
3.监控-上课文件列表接口和显示
4.文件库列表显示

FailedToRead 2 rokov pred
rodič
commit
4ac3351cca

+ 38 - 2
miniprogram/component/fileItem/fileItem.ts

@@ -1,23 +1,59 @@
 // component/fileItem/fileItem.ts
+import { TimeUtil } from '../../utils/TimeUtil'
+import { httpUtil } from "../../utils/restful";
 Component({
     /**
      * 组件的属性列表
      */
     properties: {
-
+        itemData: null
     },
 
     /**
      * 组件的初始数据
      */
     data: {
-
+        fileUploadTime: ''
     },
 
+
+    lifetimes: {
+        attached: function () {
+            // 在组件实例被从页面节点树添加时执行
+            console.log("fileItem:", this.properties.itemData.uploadTime)
+            this.setData({
+                fileUploadTime: TimeUtil.dateFormat(parseInt(this.properties.itemData.uploadTime), "yyyy-MM-dd HH:mm"),
+            })
+
+        },
+        detached: function () {
+            // 在组件实例被从页面节点树移除时执行
+
+        },
+    },
     /**
      * 组件的方法列表
      */
     methods: {
+        clickFileItem: function (event: any) {
+            console.log("event.currentTarget.id:", event.currentTarget.id)
+            //根据ID查询文件库下所有文件
+            let params = {
+                lessId: event.currentTarget.id,
+                userId: httpUtil.httpData.userId,
+                pageNo: 1,
+                pageSize: 100000,
+
+            }
+            httpUtil.wxGet(httpUtil.interfaces.getDocumentFile, params).then((res: any) => {
+                console.log("获取所有文件成功:", res)
 
+            }).catch((res) => {
+                console.log("获取所有文件失败:", res)
+            })
+        },
+        clickMore: function (event: any) {
+            console.log("event.currentTarget.id:more----------", event.currentTarget.id)
+        }
     }
 })

+ 6 - 4
miniprogram/component/fileItem/fileItem.wxml

@@ -1,9 +1,11 @@
 <!--component/fileItem/fileItem.wxml-->
-<view class="fileitem_bg">
+<view class="fileitem_bg" bindtap="clickFileItem" id="{{itemData.id}}">
     <image src="../../image/teacher/file_icon.png" class="fileitem_icon"></image>
     <view class="fileitem_content">
-        <text style="color: #333333;font-size: 34rpx;">春夏秋冬</text>
-        <text style="color: #333333;font-size: 28rpx;">上传时间:2021-12-11 11:00</text>
+        <text style="color: #333333;font-size: 34rpx;">{{itemData.title}}</text>
+        <text style="color: #333333;font-size: 28rpx;">上传时间:{{fileUploadTime}}</text>
+    </view>
+    <view style="align-self: flex-start; height: 60rpx;" catchtap="clickMore">
+        <image src="../../image/teacher/file_more.png" class="fileitem_more_icon" ></image>
     </view>
-    <image src="../../image/teacher/file_more.png" class="fileitem_more_icon"></image>
 </view>

+ 7 - 1
miniprogram/component/tabBar/tabBar.ts

@@ -13,6 +13,10 @@ Component({
         initTabIndex: {
             type: Number,
             value: 0
+        },
+        canChangeIndex: {
+            type: Boolean,
+            value: true
         }
     },
 
@@ -41,7 +45,9 @@ Component({
     methods: {
         //选择某一项并且给上层id
         bindTabItem: function (event: any) {
-            this.initTab(Number(event.target.id))
+            if(this.properties.canChangeIndex){
+                this.initTab(Number(event.target.id))
+            }
         },
         initTab: function (index: any) {
             this.setData({

+ 9 - 7
miniprogram/component/teacher/teacherFault/teacherFault.ts

@@ -367,13 +367,12 @@ Component({
                             'userId': httpUtil.httpData.userId,
                             'deviceId': that.data.deviceId
                         }).then((res: any) => {
-                            //拿不到data
-                            console.log("上传图片成功:", res)
-                            console.log("上传图片成功:", res.data)
+
+                            let json = JSON.parse(res.data);
+                            console.log("json:", json.data)
                             that.setData({
-                                postImg: that.data.postImg.concat(res.data)
+                                postImg: that.data.postImg.concat(json.data)
                             })
-                            console.log(" that.data.postImg:", that.data.postImg)
                         }).catch((res => {
                             console.log("上传图片失败:", res)
                         }))
@@ -412,13 +411,15 @@ Component({
 
             let img = '';
             this.data.postImg.forEach((res, index) => {
-                if (index < this.data.postImg.length) {
+                if (index < this.data.postImg.length - 1) {
                     img = img + res + ","
                 } else {
                     img = img + res
                 }
             })
 
+            console.log("postImg:", img)
+
             let params = {
                 city: this.data.cityValue,
                 classId: this.data.classId,
@@ -428,7 +429,8 @@ Component({
                 deviceId: this.data.deviceId,
                 faultLevel: this.data.faultIndex,
                 describe: this.data.describe,
-                userId: httpUtil.httpData.userId
+                userId: httpUtil.httpData.userId,
+                img: img
 
             }
             console.log("params:", params)

+ 17 - 10
miniprogram/component/teacher/teacherFile/teacherFile.ts

@@ -1,4 +1,5 @@
 // component/teacher/teacherFile/teacherFile.ts
+import { httpUtil } from '../../../utils/restful'
 Component({
     /**
      * 组件的属性列表
@@ -11,20 +12,13 @@ Component({
      * 组件的初始数据
      */
     data: {
-        scrollHeight: 0
+        fileList: []
     },
     lifetimes: {
         attached: function () {
             // 在组件实例被从页面节点树添加时执行
-            let that = this;
-            wx.getSystemInfo({
-                success: function (res) {
-                    that.setData({
-                        scrollHeight: res.windowHeight
-                    });
-                }
-            });
 
+            this.getLessAll()
 
         },
         detached: function () {
@@ -36,6 +30,19 @@ Component({
      * 组件的方法列表
      */
     methods: {
-
+        getLessAll: function () {
+            let params = {
+                pageNo: 1,
+                pageSize: 10000
+            }
+            httpUtil.wxGet(httpUtil.interfaces.createLess, params).then((res: any) => {
+                console.log("获取所有文件库成功", res)
+                this.setData({
+                    fileList: res.data.data.list
+                })
+            }).catch((res) => {
+                console.log("获取所有文件库失败:", res)
+            })
+        }
     }
 })

+ 2 - 2
miniprogram/component/teacher/teacherFile/teacherFile.wxml

@@ -12,8 +12,8 @@
     </view>
 
     <scroll-view scroll-y="true" class="scrollview">
-        <view wx:for="{{5}}" class="scroll_item_bg" wx:key="index">
-            <fileItem></fileItem>
+        <view wx:for="{{fileList}}" class="scroll_item_bg" wx:key="index">
+            <fileItem itemData="{{item}}"> </fileItem>
         </view>
 
     </scroll-view>

+ 97 - 16
miniprogram/component/teacher/teacherMonitor/monitor.ts

@@ -31,15 +31,19 @@ Component({
         classData: [{ 'id': '' }],
         classId: '',
         initFirst: true,
-        deviceId: '6f7aea71-3ed6-3919-ad36-8b94f768b8c1',
+        deviceId: '',
         //0=未上课 1=正在上课
         pageState: 0,
 
-        //开始上课用到的数据
+        //#region 开始上课用到的数据
 
         //0是正常,1是error
-        videostatus: 0
-
+        videostatus: 0,
+        videoUrl: '',
+        lessId: '',
+        hasGetFile: false,
+        imgList: [],
+        //#endregion
     },
 
     lifetimes: {
@@ -240,6 +244,36 @@ Component({
             })
         },
 
+
+        //根据地区,学校,班级获取deviceId
+        getDeviceByRSC: function () {
+            let params = {
+                city: this.data.cityValue,
+                classId: this.data.classId,
+                province: this.data.provinceValue,//省份
+                region: this.data.regionValue,//地区
+                schoolId: this.data.schoolId,
+            }
+            httpUtil.wxGet(httpUtil.interfaces.getDevideIdByRSC, params).then((res: any) => {
+                console.log("根据省市学校班级获取deviceId成功:", res)
+                if (res.data.success) {
+                    this.setData({
+                        deviceId: res.data.data.deviceId
+                    })
+                } else {
+                    this.setData({
+                        deviceId: ''
+                    })
+                }
+            }).catch((res) => {
+                console.log("根据省市学校班级获取deviceId失败:", res)
+                this.setData({
+                    deviceId: '暂无设备'
+                })
+            })
+        },
+
+
         bindMultiPickerColumnChange: function (event: any) {
 
             //
@@ -288,6 +322,7 @@ Component({
                 classIndex: event.detail.value,
                 classId: this.data.classData[event.detail.value].id
             })
+            this.getDeviceByRSC()
         },
 
 
@@ -336,32 +371,35 @@ Component({
                 return;
             }
             let params = {
-                address: this.data.region[0] + "--" + this.data.region[1] + "--" + this.data.region[2],
-                school: this.data.schoolArray[this.data.schoolIndex],
-                class: this.data.classArray[this.data.classIndex],
-                deviceId: this.data.deviceId
+                deviceId: this.data.deviceId,
+                teacherId: httpUtil.httpData.userId,
+                // title: ''
             }
             console.log("params:", params)
 
-            httpUtil.wxGet(httpUtil.interfaces.getDeviceById + this.data.deviceId, null).then((res: any) => {
-                console.log("根据ID获取设备信息成功:", res)
+            httpUtil.wxPost(httpUtil.interfaces.createLess, params).then((res: any) => {
+                console.log("创建文件成功(开始上课):", res)
+                //开始上课
                 if (res.data.success) {
-                    //开始上课
                     this.setData({
-                        pageState: 1
+                        pageState: 1,
+                        videoUrl: res.data.data.liveUrl,
+                        lessId: res.data.data.id,
+                        hasGetFile: true
                     })
+                    this.triggerEvent('canChangeIndex', { canChange: false })
+                    this.getDocumentFile()
                 }
             }).catch((res) => {
-                console.log("根据ID获取设备信息失败:", res)
+                console.log("创建文件失败(开始上课):", res)
             })
 
 
-
         },
 
 
 
-        //上课之后的方法
+        //#region  上课之后的方法
         //下课
         classOver: function () {
             //下课
@@ -373,8 +411,10 @@ Component({
                     if (res.confirm) {
                         console.log('点击确认回调')
                         that.setData({
-                            pageState: 0
+                            pageState: 0,
+                            hasGetFile: false
                         })
+                        that.triggerEvent('canChangeIndex', { canChange: true })
                     } else {
                         console.log('点击取消回调')
                     }
@@ -382,7 +422,48 @@ Component({
             })
 
 
+        },
+
+        //心跳获取文件库所有文件
+        getDocumentFile: function () {
+            let that = this;
+            let params = {
+                lessId: that.data.lessId,
+                deviceId: that.data.deviceId,
+                userId: httpUtil.httpData.userId,
+                pageNo: 1,
+                pageSize: 100000,
+
+            }
+            httpUtil.wxGet(httpUtil.interfaces.getDocumentFile, params).then((res: any) => {
+                console.log("获取所有文件成功:", res)
+                that.setData({
+                    imgList: res.data.data.list
+                })
+                let getfile = setInterval(function () {
+                    if (that.data.hasGetFile) {
+                        httpUtil.wxGet(httpUtil.interfaces.getDocumentFile, params).then((res: any) => {
+                            console.log("获取所有文件成功:", res)
+                            that.setData({
+                                imgList: res.data.data.list
+                            })
+                        }).catch((res) => {
+                            console.log("获取所有文件失败:", res)
+                        })
+                    } else {
+                        clearInterval(getfile)
+                    }
+                }, 5000)
+            }).catch((res) => {
+                console.log("获取所有文件失败:", res)
+            })
+
+
         }
+
+
+
+        ////#endregion
     }
 
 })

+ 9 - 9
miniprogram/component/teacher/teacherMonitor/monitor.wxml

@@ -41,10 +41,10 @@
             <view class="item_input_bg" style=" margin-top: 2rpx;box-shadow: 0px 1px 0px 0px #EEEEEE;">
                 <text class="item_input_title">班级:</text>
                 <picker bindchange="bindClssPicker" value="{{classIndex}}" range="{{classArray}}" class="item_picker_bg">
-                <view class="item_picker_content">
-                    {{classArray[classIndex]}}
-                </view>
-            </picker>
+                    <view class="item_picker_content">
+                        {{classArray[classIndex]}}
+                    </view>
+                </picker>
                 <view class="item_picker_icon_layout">
                     <image src="../../../image/teacher/dropdown_icon.png" class="item_picker_icon"></image>
                 </view>
@@ -52,7 +52,7 @@
             <!--选择班级end-->
             <view class="item_input_bg" style="margin-top: 1rpx;">
                 <text class="item_input_title">设备ID:</text>
-                <input class="item_input_content" placeholder="请输入设备ID" bindinput="bindDeviceInput" value="{{deviceId}}"  />
+                <input class="item_input_content" placeholder="请输入设备ID" bindinput="bindDeviceInput" value="{{deviceId}}" />
             </view>
         </view>
         <view class="login_btn_layout" style="margin-left: 0rpx;margin-top: 190rpx;" bindtap="startMonitor">
@@ -69,7 +69,7 @@
     </view>
     <!--播放视频的视频框-->
     <view style="width: 100%;height: 422rpx; background-color: blue;margin-top: 40rpx;;display: flex;">
-        <live-player style="width: 100%; height: 100%; "></live-player>
+        <live-player style="width: 100%; height: 100%; " src="{{videoUrl}}" autoplay="{{true}}"></live-player>
         <view style="width: 100%;height: 422rpx; position: absolute;">
             <view class="light_green {{videostatus==1?'light_red':''}}"></view>
         </view>
@@ -80,9 +80,9 @@
     <view style="margin-top:48rpx;font-size:25rpx;font-weight: 500;">
         <text style="margin-left:10rpx">快照</text>
         <scroll-view scroll-x class="image_scroll">
-            <view wx:for="{{20}}" wx:key="index" style="display:inline-block;">
-                <image class="image"></image>
-                <view class="image_index">{{index}}</view>
+            <view wx:for="{{imgList}}" wx:key="index" style="display:inline-block;">
+                <image class="image" src="{{item.url}}"></image>
+                <view class="image_index">{{index+1}}</view>
             </view>
         </scroll-view>
     </view>

+ 0 - 1
miniprogram/component/teacher/teacherMonitor/monitor.wxss

@@ -79,7 +79,6 @@
 .image {
     height: 115rpx;
     width: 203rpx;
-    background-color: burlywood;
     margin-left: 10rpx;
     margin-right: 10rpx;
     align-items: center;

+ 2 - 1
miniprogram/pages/faultInfo/faultInfo.json

@@ -3,5 +3,6 @@
 
     "faultInfoItem": "../../component/fauleInfoItem/faultInfoItem"
 
-  }
+  },
+  "navigationBarTitleText": "设备维修"
 }

+ 25 - 2
miniprogram/pages/faultInfo/faultInfo.ts

@@ -6,9 +6,11 @@ Page({
      */
     data: {
         //是否隐藏评价按钮
-        showAppraise: false,
+        showAppraise: true,
         contentLineHeight: 0,
         itemData: null,
+        faultLevText: '',
+        imgList: []
     },
 
     /**
@@ -17,9 +19,30 @@ Page({
     onLoad(options) {
         let obj = JSON.parse(options.item);
         console.log("obnj-----", obj)
+        let showAppraise = true
+        if (obj.processType == 2) {
+            showAppraise = false
+        }
+        // 0:普通 1:待查 2:紧急
+        let faulevText = '';
+        switch (obj.faultLevel) {
+            case 0:
+                faulevText = '普通'
+                break;
+            case 1:
+                faulevText = '待查'
+                break;
+            case 2:
+                faulevText = '紧急'
+                break;
+        }
         this.setData({
-            itemData: obj
+            itemData: obj,
+            showAppraise: showAppraise,
+            faultLevText: faulevText,
+            imgList: obj.img.split(',')
         })
+        console.log("imgList:", this.data.imgList)
     },
 
     /**

+ 1 - 1
miniprogram/pages/faultInfo/faultInfo.wxml

@@ -21,7 +21,7 @@
                                 <view class="centerFaultDeviceLayout_ItemLayout2">
                                     <view class="centerFaultDeviceLayout_ItemLayout3">
                                         <text class="centerFaultDeviceLayout_ItemLayout3_Left">故障级别</text>
-                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{itemData.faultLevel}}</text>
+                                        <text class="centerFaultDeviceLayout_ItemLayout3_Rgiht">{{faultLevText}}</text>
                                     </view>
                                     <view class="centerFaultDeviceLayout_ItemLayout3">
                                         <text class="centerFaultDeviceLayout_ItemLayout3_Left">地区:</text>

+ 15 - 2
miniprogram/pages/teacher/index/index.ts

@@ -10,7 +10,8 @@ Page({
         { icon: "../../image/teacher/fault.png", selectedIcon: "../../image/teacher/fault_selected.png", title: "报修" },
         { icon: "../../image/teacher/my.png", selectedIcon: "../../image/teacher/my_selected.png", title: "我的" }
         ],
-        currPageIndex: 0
+        currPageIndex: 0,
+        canChangeIndex: true
     },
 
     /**
@@ -52,9 +53,21 @@ Page({
 
     //禁止用户手滑选项卡
     catchTouchMove: function () {
-       
+
+    },
+
+
+    //是否能切换index
+    canChangeIndex: function (event: any) {
+        this.setData({
+            canChangeIndex: event.detail.canChange
+        })
+
+
     },
 
+
+
     //选项卡滑动
     selectItemIndex: function (event: any) {
         console.log("click selected", event.detail.selectIndex)

+ 2 - 2
miniprogram/pages/teacher/index/index.wxml

@@ -2,7 +2,7 @@
 <view class="container">
     <!-- 根据选项卡选择的index显示界面 -->
     <view style="width: 100%; height: 100%;">
-        <teacherMonitor wx:if="{{currPageIndex==0}}"></teacherMonitor>
+        <teacherMonitor wx:if="{{currPageIndex==0}}" bind:canChangeIndex="canChangeIndex"></teacherMonitor>
         <teacherFile wx:if="{{currPageIndex==1}}"></teacherFile>
         <teacherFault wx:if="{{currPageIndex==2}}"></teacherFault>
         <myInfo wx:if="{{currPageIndex==3}}"></myInfo>
@@ -10,6 +10,6 @@
 
     <!-- 根据选项卡选择的index显示界面 -->
     <!-- 选项卡tab -->
-    <tabBar bind:selectItemIndex="selectItemIndex" tabItemJson="{{tabJson}}" initTabIndex="{{0}}"></tabBar>
+    <tabBar bind:selectItemIndex="selectItemIndex" tabItemJson="{{tabJson}}" initTabIndex="{{0}}" canChangeIndex="{{canChangeIndex}}"></tabBar>
     <!-- 选项卡tab -->
 </view>

+ 13 - 4
miniprogram/utils/restful.ts

@@ -20,6 +20,8 @@ const httpData = {
 const interfaces = {
     //这里边放入请求的接口
 
+
+    //#region 教师端
     //获取全国地址
     getOrganizeAll: '/organize/all',
 
@@ -61,7 +63,14 @@ const interfaces = {
     getDeviceFault: '/tch/fault',
 
     //根据故障ID获取故障详情(后面拼接ID)
-    getFaultInfoByDevId: '/tch/fault/'
+    getFaultInfoByDevId: '/tch/fault/',
+
+    //开始上课(创建文件库)(获取文件库get方法)
+    createLess: '/tch/lesson/',
+
+    //获取文件夹所有文件接口(拼接ID)
+    getDocumentFile:'/tch/document',
+    //#endregion
 
 
 
@@ -112,12 +121,12 @@ function uploadFile(url: String, filePath: string, fileName: string, formData: a
             filePath: filePath,
             name: fileName,
             formData: formData,
-            success(res) {
-                resolve(res.data)
+            success(res: any) {
+                resolve(res)
                 // const data = res.data
                 //do something
             },
-            fail(res) {
+            fail(res: any) {
                 reject(res)
             }
         })