couponList.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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. orderShow:false,
  22. couponList:[
  23. {
  24. name:'保洁双十一大促券199-10',
  25. date:'2022年11月11日至2022年11月'
  26. },
  27. {
  28. name:'保洁双十一大促券199-10',
  29. date:'2022年11月11日至2022年11月'
  30. }
  31. ],
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. this.getTypeList();
  38. // this.getMyCoupon();
  39. },
  40. showOrderCoupon(){
  41. this.setData({
  42. orderShow: true,
  43. });
  44. },
  45. onClickShow(){
  46. this.setData({
  47. orderShow: false,
  48. });
  49. },
  50. submitEval(){
  51. if(this.data.star==0){
  52. wx.showToast({
  53. title: '请选择评价星级',
  54. icon:'none'
  55. })
  56. }else{
  57. util.request(api.workerCourseScore, {
  58. enrolmentId:this.data.evalId,
  59. workerScore:this.data.star
  60. }, 'GET').then(res=> {
  61. if (res.errno === 0) {
  62. wx.showToast({
  63. title: '评价成功',
  64. icon:'none'
  65. })
  66. this.setData({
  67. evalShow:false,
  68. });
  69. this.getMyCoupon()
  70. }else{
  71. wx.showToast({
  72. title: res.errmsg,
  73. icon:'none'
  74. })
  75. }
  76. });
  77. }
  78. },
  79. stop:function(){
  80. //阻止弹框冒泡和捕获的空事件,不要删除!!!
  81. },
  82. goStar(e){
  83. let id=e.currentTarget.dataset.id;
  84. this.setData({
  85. evalShow: true,
  86. star:0,
  87. evalId:id
  88. });
  89. },
  90. onChange(event) {
  91. this.setData({
  92. star: event.detail,
  93. });
  94. },
  95. getMyCoupon(){
  96. util.request(api.getMyCourse, {
  97. categorySubId:this.data.type,
  98. courseType:this.data.currentTab,
  99. studyType :'2',
  100. yearMonth:this.data.date
  101. }, 'GET').then(res=> {
  102. if (res.errno === 0) {
  103. this.setData({
  104. couponList:res.data
  105. });
  106. }
  107. });
  108. },
  109. getTypeList(){
  110. util.request(api.getCategoryDict, {
  111. }, 'GET').then(res=> {
  112. if (res.errno === 0) {
  113. let list=res.data;
  114. let current=[{text:'全部',value:''}];
  115. list.forEach(item=>{
  116. let obj={text:item.type,value:item.id};
  117. current.push(obj);
  118. });
  119. this.setData({
  120. typeList:current,
  121. type:''
  122. });
  123. }
  124. });
  125. },
  126. dropdownChange(e){
  127. let type=e.detail;
  128. this.setData({
  129. type:type
  130. });
  131. // this.getMyCourse();
  132. },
  133. dateSelect(){
  134. this.setData({
  135. pickerShow:true
  136. })
  137. },
  138. onCancel(){
  139. this.setData({
  140. pickerShow:false
  141. })
  142. },
  143. onConfirm(e){
  144. console.log(e);
  145. let date=moment(e.detail).format('YYYY-MM');
  146. this.setData({
  147. date:date,
  148. pickerShow:false
  149. });
  150. this.getMyCoupon();
  151. },
  152. /**
  153. * 生命周期函数--监听页面初次渲染完成
  154. */
  155. onReady: function () {
  156. },
  157. /**
  158. * 生命周期函数--监听页面显示
  159. */
  160. onShow: function () {
  161. },
  162. onHide: function () {
  163. },
  164. onUnload: function () {
  165. },
  166. /**
  167. * 页面相关事件处理函数--监听用户下拉动作
  168. */
  169. onPullDownRefresh: function () {
  170. },
  171. /**
  172. * 页面上拉触底事件的处理函数
  173. */
  174. onReachBottom: function () {
  175. },
  176. /**
  177. * 用户点击右上角分享
  178. */
  179. onShareAppMessage: function () {
  180. },
  181. })