123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- const app=getApp();
- var utils=require("../../../utils/http");
- var time=60;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl:app.globalData.imgUrl,
- tid:'',
- cid:'',
- trainobj:'',
- cover:'',
- summerymsg:'',
- sumuplist:[],
- sumupage:1,
- datashow:false,
- controls:true,
- timeout:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.showLoading({
- title: '加载中...',
- })
- this.setData({
- tid:options.tid,
- cid:options.cid
- })
- this.trainmsg();
- this.sumuplistfun();
- },
- trainmsg:function(){
- let that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/train/courseDetail',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- course_id:that.data.cid
- },
- success: function (res) {
- if(res.data.code=='0'){
- that.setData({
- trainobj:res.data.data
- })
- wx.setNavigationBarTitle({
- title: res.data.data.title
- })
- if(res.data.data.study_time!=0){
- time=res.data.data.study_time*60;
- that.setData({
- timeout:setInterval(function(){
- time--;
- if(time<=0){
- clearInterval(that.data.timeout);
- that.readfun();
- }
- },1000)
- })
- }else{
- time=0;
- }
-
- }
- wx.hideLoading();
- }
- })
- },
- sumuplistfun:function(){
- let that=this;
- that.setData({
- sumupage:1
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/train/watch_feel',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- page:1,
- course_id:that.data.cid,
- class_id:that.data.tid,
- },
- success: function (res) {
- if(res.data.code=='0'){
- that.setData({
- sumuplist:res.data.data,
- datashow:true
- })
- }
- setTimeout(function(){
- wx.hideLoading();
- },1000)
- }
- })
- },
- summerytap:function(e){
- let that=this;
- that.setData({
- summerymsg:e.detail.value
- })
- },
- setsumuptap: function () {
- let that=this;
- if(!that.data.summerymsg){
- wx.showToast({
- title: '总结不能为空!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- wx.showLoading({
- title: '添加中...',
- })
- console.log(time)
- utils.$get({
- url: app.globalData.webUrl + 'api/train/commentAdd',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- course_id:that.data.cid,
- class_id:that.data.tid,
- content:that.data.summerymsg,
- read_status:that.data.trainobj.comment_word_num==0?false:that.data.trainobj.study_time==0?true:time<=0?true:false
- },
- success: function (res) {
- wx.hideLoading();
- if(res.data.code=='0'){
- that.sumuplistfun();
- that.setData({
- summerymsg:""
- })
- wx.showToast({
- title: '总结添加成功!',
- icon: 'success',
- duration: 2000
- })
- setTimeout(function(){
- time=60;
- },3000)
-
- }
-
- }
- })
- },
- goodtap:function(e){
- var that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/train/thumbing',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- sumup_id:e.currentTarget.dataset.tid
- },
- success: function (res) {
- if(res.data.code=='0'){
- let sumuplist=that.data.sumuplist;
- if(res.data.msg.includes('取消点赞')){
- sumuplist[e.currentTarget.dataset.idx].thumb--;
- sumuplist[e.currentTarget.dataset.idx].thumblog=false;
- }else{
- sumuplist[e.currentTarget.dataset.idx].thumb++;
- sumuplist[e.currentTarget.dataset.idx].thumblog=true;
- }
- that.setData({
- sumuplist:sumuplist
- })
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- }
- })
- },
- readfun:function(){
- let that=this;
- clearInterval(that.data.timeout);
- utils.$post({
- url: app.globalData.webUrl + 'api/train/doneLogging',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- course_id:that.data.cid,
- class_id:that.data.tid,
- alertshow:152
- },
- success: function (res) {
- }
- })
- },
- looktap(e){
- wx.previewImage({
- current: e.currentTarget.dataset.src, // 当前显示图片的http链接
- urls: [e.currentTarget.dataset.src] // 需要预览的图片http链接列表
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- clearInterval(this.data.timeout);
- setTimeout(function(){
- time=60;
- },1000)
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- let that=this;
- that.setData({
- sumupage:1
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/train/watch_feel',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- course_id:that.data.cid,
- class_id:that.data.tid,
- page:1
- },
- success: function (res) {
- wx.stopPullDownRefresh();
- if(res.data.code=='0'){
- that.setData({
- sumuplist:res.data.data
- })
- }
- wx.hideLoading();
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- let that=this;
- let sumupage=that.data.sumupage;
- sumupage=sumupage*1+1;
- that.setData({
- sumupage:sumupage
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/train/watch_feel',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- course_id:that.data.cid,
- class_id:that.data.tid,
- page:sumupage,
- },
- success: function (res) {
- let sumuplist=that.data.sumuplist;
- if(res.data.code=='0'){
- sumuplist=sumuplist.concat(res.data.data);
- that.setData({
- sumuplist:sumuplist
- })
- }
- wx.hideLoading();
- }
- })
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
- // }
- })
|