currentCourse.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. import moment from 'moment'
  6. Page({
  7. data: {
  8. evalId:'',
  9. skillList:[],
  10. sumStudyTime:'',
  11. currentTab:'4',
  12. typeList: [
  13. {text:'全部',value:''}
  14. ],
  15. type: '',
  16. date: moment(new Date()).format('YYYY-MM'),
  17. currentDate: new Date().getTime(),
  18. minDate: new Date('2022-01-01').getTime(),
  19. pickerShow:false,
  20. star:0,
  21. evalShow:false,
  22. courseList:[],
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. this.selectComponent('#tabs').resize();
  29. this.getStudyDuration();
  30. this.getTypeList();
  31. // this.getMyCourse();
  32. },
  33. onClickShow(){
  34. this.setData({
  35. evalShow: false,
  36. });
  37. },
  38. submitEval(){
  39. if(this.data.star==0){
  40. wx.showToast({
  41. title: '请选择评价星级',
  42. icon:'none'
  43. })
  44. }else{
  45. util.request(api.workerCourseScore, {
  46. enrolmentId:this.data.evalId,
  47. workerScore:this.data.star
  48. }, 'GET').then(res=> {
  49. if (res.errno === 0) {
  50. wx.showToast({
  51. title: '评价成功',
  52. icon:'none'
  53. })
  54. this.setData({
  55. evalShow:false,
  56. });
  57. this.getMyCourse()
  58. }else{
  59. wx.showToast({
  60. title: res.errmsg,
  61. icon:'none'
  62. })
  63. }
  64. });
  65. }
  66. },
  67. stop:function(){
  68. //阻止弹框冒泡和捕获的空事件,不要删除!!!
  69. },
  70. goStar(e){
  71. let id=e.currentTarget.dataset.id;
  72. this.setData({
  73. evalShow: true,
  74. star:0,
  75. evalId:id
  76. });
  77. },
  78. onChange(event) {
  79. this.setData({
  80. star: event.detail,
  81. });
  82. },
  83. getMyCourse(){
  84. util.request(api.getMyCourse, {
  85. categorySubId:this.data.type,
  86. courseType:this.data.currentTab,
  87. studyType :'2',
  88. yearMonth:this.data.date
  89. }, 'GET').then(res=> {
  90. if (res.errno === 0) {
  91. this.setData({
  92. courseList:res.data
  93. });
  94. }
  95. });
  96. },
  97. getStudyDuration(){
  98. util.request(api.getStudyDuration, {
  99. }, 'GET').then(res=> {
  100. if (res.errno === 0) {
  101. this.setData({
  102. sumStudyTime:res.data.sumStudyTime,
  103. skillList:res.data.willSkill
  104. });
  105. }
  106. });
  107. },
  108. getTypeList(){
  109. util.request(api.getCategoryDict, {
  110. }, 'GET').then(res=> {
  111. if (res.errno === 0) {
  112. let list=res.data;
  113. let current=[{text:'全部',value:''}];
  114. list.forEach(item=>{
  115. let obj={text:item.type,value:item.id};
  116. current.push(obj);
  117. });
  118. this.setData({
  119. typeList:current,
  120. type:''
  121. });
  122. }
  123. });
  124. },
  125. dropdownChange(e){
  126. let type=e.detail;
  127. this.setData({
  128. type:type
  129. });
  130. this.getMyCourse();
  131. },
  132. dateSelect(){
  133. this.setData({
  134. pickerShow:true
  135. })
  136. },
  137. onCancel(){
  138. this.setData({
  139. pickerShow:false
  140. })
  141. },
  142. onConfirm(e){
  143. console.log(e);
  144. let date=moment(e.detail).format('YYYY-MM');
  145. this.setData({
  146. date:date,
  147. pickerShow:false
  148. });
  149. this.getMyCourse();
  150. },
  151. /**
  152. * 生命周期函数--监听页面初次渲染完成
  153. */
  154. onReady: function () {
  155. },
  156. /**
  157. * 生命周期函数--监听页面显示
  158. */
  159. onShow: function () {
  160. this.getMyCourse();
  161. },
  162. switchTab(e){
  163. let tab=e.detail.name;
  164. this.setData({
  165. currentTab:tab,
  166. courseList:[]
  167. });
  168. this.getMyCourse();
  169. },
  170. goHistory(){
  171. wx.pageScrollTo({
  172. selector: '.tab-sticky',
  173. duration: 300
  174. })
  175. this.setData({
  176. currentTab:'history'
  177. });
  178. },
  179. goLearn(e){
  180. // let id=e.currentTarget.dataset.id;
  181. let courseid=e.currentTarget.dataset.courseid;
  182. let userInfo = wx.getStorageSync('userInfo');
  183. util.request(api.startStudy, {
  184. courseId:courseid,
  185. workerNo: userInfo.workerNo,
  186. }, 'GET').then(res=> {
  187. if (res.errno == 0) {
  188. let id=res.data.enrolmentId;
  189. wx.navigateTo({
  190. url: '/pages/upgrade/courseDetail/courseDetail?id='+id+'&courseid='+courseid,
  191. });
  192. }
  193. });
  194. },
  195. continueLearn(e){
  196. let id=e.currentTarget.dataset.id;
  197. let courseid=e.currentTarget.dataset.courseid;
  198. wx.navigateTo({
  199. url: '/pages/upgrade/courseDetail/courseDetail?id='+id+'&courseid='+courseid,
  200. });
  201. },
  202. onHide: function () {
  203. },
  204. onUnload: function () {
  205. },
  206. /**
  207. * 页面相关事件处理函数--监听用户下拉动作
  208. */
  209. onPullDownRefresh: function () {
  210. },
  211. /**
  212. * 页面上拉触底事件的处理函数
  213. */
  214. onReachBottom: function () {
  215. },
  216. /**
  217. * 用户点击右上角分享
  218. */
  219. onShareAppMessage: function () {
  220. },
  221. })