projectDetail.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. // pages/experienceList/experienceList.js
  2. const app = getApp()
  3. var util = require("../../../utils/util.js")
  4. Page({
  5. data: {
  6. collegeId: '',
  7. c_code: '',
  8. showPayTime: '',
  9. timer: null,
  10. video_length: '',
  11. testFinish: ''
  12. },
  13. onLoad: function(options) {
  14. console.log(options)
  15. this.setData({
  16. navH: app.globalData.navHeight,
  17. collegeId: options.collegeId,
  18. c_code: options.code,
  19. testFinish: options.testFinish
  20. })
  21. this.init(options.collegeId)
  22. },
  23. init(id) {
  24. const that = this
  25. util.postData('/college/queryCoreDetail', {
  26. openid: app.globalData.openid,
  27. collegeId: id
  28. })
  29. .then(res => {
  30. console.log(res)
  31. this.setData({
  32. info: res
  33. })
  34. if (res.status == 9) {
  35. } else {
  36. // var hour = time.split(':')[0];
  37. let min = res.countdown.split(':')[0];
  38. let sec = res.countdown.split(':')[1];
  39. let s = Number(min * 60) + Number(sec);
  40. // console.log(s); //130
  41. this.getTime(s)
  42. }
  43. })
  44. .catch(err => {
  45. console.log(err);
  46. })
  47. },
  48. gototest() {
  49. wx.navigateTo({
  50. url: "/pages/testing/testing?core_id=" + this.data.collegeId + '&testFinish=' + this.data.testFinish
  51. })
  52. },
  53. thumbsUp() {
  54. const that = this;
  55. // console.log(app.globalData.userphone,that.data.collegeId)
  56. util.postData('/college/corePositive', {
  57. openid: app.globalData.openid,
  58. c_code: that.data.c_code
  59. })
  60. .then(res => {
  61. console.log(res)
  62. if (res == '1') {
  63. wx.showToast({
  64. title: '点赞成功',
  65. icon: 'none',
  66. duration: 2000
  67. })
  68. let res2 = { ...this.data.info,
  69. positive: this.data.info.positive + 1,
  70. ispositive: 8
  71. }
  72. this.setData({
  73. info: res2
  74. })
  75. } else {
  76. wx.showToast({
  77. title: '您已经点过赞了~',
  78. icon: 'none',
  79. duration: 2000
  80. })
  81. }
  82. })
  83. .catch(err => {
  84. console.log(err);
  85. })
  86. },
  87. // 获取计算的时间
  88. getShowTime(maxtime) {
  89. const that = this;
  90. let minutes = Math.floor((maxtime % 3600) / 60).toString().padStart(2, '0');
  91. let seconds = Math.floor(maxtime % 60).toString().padStart(2, '0');
  92. this.setData({
  93. showPayTime: `${minutes}:${seconds}`
  94. })
  95. console.log(this.data.showPayTime);
  96. // let min = this.data.showPayTime.split(':')[0];
  97. // let sec = this.data.showPayTime.split(':')[1];
  98. // let s = Number(min * 60) + Number(sec);
  99. // console.log(s); //130
  100. util.postData('/college/coreLearningUpdate', {
  101. openid: app.globalData.openid,
  102. c_code: that.data.c_code,
  103. rate: that.data.showPayTime
  104. })
  105. .then(res => {
  106. // console.log(res)
  107. })
  108. .catch(err => {
  109. console.log(err);
  110. })
  111. },
  112. // 倒计时
  113. getTime(maxtime, callback) {
  114. const that = this;
  115. this.getShowTime(maxtime);
  116. let Timer = setInterval(() => {
  117. if (!!maxtime && maxtime >= 0) {
  118. this.getShowTime(maxtime);
  119. --maxtime;
  120. } else {
  121. util.postData('/college/coreLearningFinish', {
  122. openid: app.globalData.openid,
  123. c_code: that.data.c_code
  124. })
  125. .then(res => {
  126. console.log(res)
  127. })
  128. .catch(err => {
  129. console.log(err);
  130. })
  131. this.setData({
  132. showPayTime: '00:00'
  133. })
  134. clearInterval(Timer);
  135. }
  136. }, 1000)
  137. this.setData({
  138. timer: Timer
  139. })
  140. },
  141. onUnload: function() {
  142. // console.log('onUnload')
  143. console.log(this.data.timer)
  144. if (this.data.timer) {
  145. this.setData({
  146. showPayTime: ''
  147. })
  148. clearInterval(this.data.timer);
  149. }
  150. },
  151. /**
  152. * 用户点击右上角分享
  153. */
  154. onShareAppMessage: function() {
  155. }
  156. })