123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- // pages/teacher/monitor/monitor.ts
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- region: ['北京市', '北京市', '海淀区'],
- schoolArray: ['中国', '美国', '巴西', '日本'],
- schoolIndex: 0,
- classArray: ['一年级一班', '一年级2班', '一年级3班', '一年级4班'],
- classIndex: 0,
- deviceId: '',
- //0=未上课 1=正在上课
- pageState: 0,
- //开始上课用到的数据
- //0是正常,1是error
- videostatus: 0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad() {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- //选择地区回调
- bindRegionChange: function (event: any) {
- this.setData({
- region: event.detail.value
- })
- },
- //选择学校回调
- bindSchoolPicker: function (event: any) {
- let newArray;
- switch (Number(event.detail.value)) {
- case 0:
- newArray = ["一", "二", "三"];
- this.setData({
- classArray: newArray,
- classIndex: 0
- })
- break;
- case 1:
- newArray = ["4", "5", "6"];
- this.setData({
- classArray: newArray,
- classIndex: 0
- })
- break;
- case 2:
- newArray = ["as", "ad", "af"];
- this.setData({
- classArray: newArray,
- classIndex: 0
- })
- break;
- case 3:
- newArray = ["b1", "b2", "b3"];
- this.setData({
- classArray: newArray,
- classIndex: 0
- })
- break;
- }
- this.setData({
- schoolIndex: event.detail.value
- })
- },
- //选择班级回调
- bindClssPicker: function (event: any) {
- this.setData({
- classIndex: event.detail.value
- })
- },
- //扫码界面(未处理回调)
- scanCode: function () {
- var that = this;
- wx.scanCode({ //扫描API
- success(res) { //扫描成功
- console.log(res) //输出回调信息
- that.setData({
- scanCodeMsg: res.result
- });
- wx.showToast({
- title: '扫码成功',
- icon: 'success',
- duration: 1000
- })
- },
- fail: (res: any) => {//接口调用失败的回调函数
- wx.showToast({
- title: '扫码失败',
- icon: 'success',
- duration: 1000
- })
- },
- })
- },
- //获取设备ID的输入
- bindDeviceInput(event: any) {
- this.setData({
- deviceId: event.detail.value
- })
- },
- //上课
- startMonitor: function () {
- if (!this.data.deviceId) {
- wx.showToast({
- title: '请输入设备ID',
- icon: 'none', //如果要纯文本,不要icon,将值设为'none'
- duration: 1000
- })
- 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
- }
- console.log("params:", params)
- //开始上课
- this.setData({
- pageState: 1
- })
- },
- //上课之后的方法
- //下课
- classOver: function () {
- //下课
- let that = this;
- wx.showModal({
- title: '',
- content: '确定下课么',
- success: function (res) {
- if (res.confirm) {
- console.log('点击确认回调')
- that.setData({
- pageState: 0
- })
- } else {
- console.log('点击取消回调')
- }
- }
- })
- }
- })
|