123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- // 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: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.id){
- this.setData({
- signup_id: options.id
- })
- }
- this.setData({
- openid: app.globalData.openid
- })
- if(options.tab){
- this.setData({
- tab: options.tab
- })
- }
- this.getData();
- },
- tabChange:function(e){
- this.setData({
- tab:e.target.dataset.id
- })
- },
- 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 () {
- }
- })
|