123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- // pages/online/online.js
- const app = getApp()
- const host = app.globalData.host;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- tab:1,
- array1: ['特种作业'],
- index1: 0,
- papers:[],
- videos:[],
- show:0,
- video_ids: [],
- paper_ids: [],
- array1:['特种作业'],
- index1:0
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.id){
- this.setData({
- signup_id: options.id,
- class_id: options.class_id
- })
- }
- this.setData({
- openid: app.globalData.openid
- })
- if(options.tab){
- this.setData({
- tab: options.tab
- })
- }
- this.getData();
- this.getClockStatus()
- },
- tabChange:function(e){
- this.setData({
- tab:e.target.dataset.id
- })
- },
- getClockStatus:function(){
- var that=this
- wx.request({
- url: host+'/api/wx/clockin/status',
- method:'GET',
- header: {
- openid: this.data.openid
- },
- data:{
- class_id:this.data.class_id,
- order_id:this.data.signup_id
- },
- success:res=>{
- if(!res.data.data){
- wx.showModal({
- title: '提示',
- content: '你今天尚未打开,请拍照打卡!',
- showCancel:false,
- confirmText:'立即打卡',
- success (res) {
- wx.chooseMedia({
- count: 1,
- mediaType: ['image'],
- sourceType: ['album', 'camera'],
- camera: 'back',
- success(res) {
- wx.showLoading({
- title: '正在打卡...',
- })
- wx.uploadFile({
- url: host+'/api/wx/uploadfile',
- filePath: res.tempFiles[0].tempFilePath,
- name: 'file',
- formData: {
- 'file': res.tempFiles[0].tempFilePath
- },
- success:res=>{
- var data=JSON.parse(res.data)
- that.setData({
- img:data.data.url
- })
- that.getClock()
- }
- })
- }
- })
- }
- })
- }
- }
- })
- },
- getClock:function(){
- wx.request({
- url: host+'/api/wx/clockin',
- method:'POST',
- header: {
- openid: this.data.openid
- },
- data:{
- class_id:this.data.class_id,
- order_id:this.data.signup_id,
- img:this.data.img
- },
- success:res=>{
- wx.hideLoading()
- wx.showToast({
- title: '打卡成功',
- })
- }
- })
- },
- getData:function(){
- wx.request({
- url: host+'/api/wx/training/list',
- method:'GET',
- header: {
- openid: this.data.openid
- },
- data:{},
- success:res=>{
-
- let video = res.data.data.videos, papers = res.data.data.papers;
- let flag1=1,flag=1;
- var video_ids=[],paper_ids=[]
- for(let i=0;i<video.length;i++){
- video_ids.push(video[i].id)
- if (!video[i].status){
- flag1=0
- }
- };
- for (let i = 0; i < papers.length; i++) {
- paper_ids.push(papers[i].id)
- if (!papers[i].status) {
- flag2 = 0
- }
- };
- this.setData({
- papers: papers,
- videos: video,
- show: flag1 || flag2,
- paper_ids: paper_ids,
- video_ids: video_ids
- })
- }
- })
- },
- genclasshour:function(){
- wx.request({
- url: host+'/api/wx/genclasshour',
- method:'POST',
- header: {
- openid: app.globalData.openid
- },
- data:{
- video_ids: this.data.video_ids,
- paper_ids: this.data.paper_ids,
- signup_id: this.data.signup_id
- },
- success:res=>{
- wx.previewImage({
- current: res.data.data.url, // 当前显示图片的http链接
- urls: [res.data.data.url] // 需要预览的图片http链接列表
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|