123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- // pages/experienceList/experienceList.js
- const app = getApp()
- var util = require("../../../utils/util.js")
- Page({
- data: {
- collegeId: '',
- c_code: '',
- showPayTime: '',
- timer: null,
- video_length: '',
- testFinish: ''
- },
- onLoad: function(options) {
- console.log(options)
- this.setData({
- navH: app.globalData.navHeight,
- collegeId: options.collegeId,
- c_code: options.code,
- testFinish: options.testFinish
- })
- this.init(options.collegeId)
- },
- init(id) {
- const that = this
- util.postData('/college/queryCoreDetail', {
- openid: app.globalData.openid,
- collegeId: id
- })
- .then(res => {
- console.log(res)
- this.setData({
- info: res
- })
- if (res.status == 9) {
- } else {
- // var hour = time.split(':')[0];
- let min = res.countdown.split(':')[0];
- let sec = res.countdown.split(':')[1];
- let s = Number(min * 60) + Number(sec);
- // console.log(s); //130
- this.getTime(s)
- }
- })
- .catch(err => {
- console.log(err);
- })
- },
- gototest() {
- wx.navigateTo({
- url: "/pages/testing/testing?core_id=" + this.data.collegeId + '&testFinish=' + this.data.testFinish
- })
- },
- thumbsUp() {
- const that = this;
- // console.log(app.globalData.userphone,that.data.collegeId)
- util.postData('/college/corePositive', {
- openid: app.globalData.openid,
- c_code: that.data.c_code
- })
- .then(res => {
- console.log(res)
- if (res == '1') {
- wx.showToast({
- title: '点赞成功',
- icon: 'none',
- duration: 2000
- })
- let res2 = { ...this.data.info,
- positive: this.data.info.positive + 1,
- ispositive: 8
- }
- this.setData({
- info: res2
- })
- } else {
- wx.showToast({
- title: '您已经点过赞了~',
- icon: 'none',
- duration: 2000
- })
- }
- })
- .catch(err => {
- console.log(err);
- })
- },
- // 获取计算的时间
- getShowTime(maxtime) {
- const that = this;
- let minutes = Math.floor((maxtime % 3600) / 60).toString().padStart(2, '0');
- let seconds = Math.floor(maxtime % 60).toString().padStart(2, '0');
- this.setData({
- showPayTime: `${minutes}:${seconds}`
- })
- console.log(this.data.showPayTime);
- // let min = this.data.showPayTime.split(':')[0];
- // let sec = this.data.showPayTime.split(':')[1];
- // let s = Number(min * 60) + Number(sec);
- // console.log(s); //130
- util.postData('/college/coreLearningUpdate', {
- openid: app.globalData.openid,
- c_code: that.data.c_code,
- rate: that.data.showPayTime
- })
- .then(res => {
- // console.log(res)
- })
- .catch(err => {
- console.log(err);
- })
- },
- // 倒计时
- getTime(maxtime, callback) {
- const that = this;
- this.getShowTime(maxtime);
- let Timer = setInterval(() => {
- if (!!maxtime && maxtime >= 0) {
- this.getShowTime(maxtime);
- --maxtime;
- } else {
- util.postData('/college/coreLearningFinish', {
- openid: app.globalData.openid,
- c_code: that.data.c_code
- })
- .then(res => {
- console.log(res)
- })
- .catch(err => {
- console.log(err);
- })
- this.setData({
- showPayTime: '00:00'
- })
- clearInterval(Timer);
- }
- }, 1000)
- this.setData({
- timer: Timer
- })
- },
- onUnload: function() {
- // console.log('onUnload')
- console.log(this.data.timer)
- if (this.data.timer) {
- this.setData({
- showPayTime: ''
- })
- clearInterval(this.data.timer);
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|