online.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // pages/online/online.js
  2. const app = getApp()
  3. const host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. tab:0,
  10. array1: ['特种作业'],
  11. index1: 0,
  12. papers:[],
  13. videos:[],
  14. show:0
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. this.setData({
  21. openid: app.globalData.openid
  22. })
  23. if(options.tab){
  24. this.setData({
  25. tab: options.tab
  26. })
  27. }
  28. this.getData();
  29. },
  30. tabChange:function(e){
  31. this.setData({
  32. tab:e.target.dataset.id
  33. })
  34. },
  35. getData:function(){
  36. wx.request({
  37. url: host+'/api/wx/training/list',
  38. method:'GET',
  39. header: {
  40. openid: this.data.openid
  41. },
  42. data:{},
  43. success:res=>{
  44. let video = res.data.data.videos, papers = res.data.data.papers;
  45. let flag1=1,flag=1;
  46. for(let i=0;i<video.length;i++){
  47. if (!video[i].status){
  48. flag1=0
  49. }
  50. };
  51. for (let i = 0; i < papers.length; i++) {
  52. if (!papers[i].status) {
  53. flag2 = 0
  54. }
  55. };
  56. this.setData({
  57. papers: papers,
  58. videos: video,
  59. show: flag1 || flag2
  60. })
  61. }
  62. })
  63. },
  64. genclasshour:function(){
  65. wx.request({
  66. url: host+'/api/wx/genclasshour',
  67. method:'POST',
  68. header: {
  69. openid: app.globalData.openid
  70. },
  71. success:res=>{
  72. wx.previewImage({
  73. current: res.data.data.url, // 当前显示图片的http链接
  74. urls: [res.data.data.url] // 需要预览的图片http链接列表
  75. })
  76. }
  77. })
  78. },
  79. /**
  80. * 生命周期函数--监听页面初次渲染完成
  81. */
  82. onReady: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面隐藏
  91. */
  92. onHide: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面卸载
  96. */
  97. onUnload: function () {
  98. },
  99. /**
  100. * 页面相关事件处理函数--监听用户下拉动作
  101. */
  102. onPullDownRefresh: function () {
  103. },
  104. /**
  105. * 页面上拉触底事件的处理函数
  106. */
  107. onReachBottom: function () {
  108. },
  109. /**
  110. * 用户点击右上角分享
  111. */
  112. onShareAppMessage: function () {
  113. }
  114. })