index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. const app = getApp()
  2. Page({
  3. data: {
  4. spinShow: false,
  5. buyModel:false,
  6. code_url:'',
  7. info:{},
  8. system: "",
  9. groups: [],
  10. pushPaper: [],
  11. timeLimitPaper: [],
  12. userInfo:{},
  13. from:0,
  14. size: 10,
  15. courseList: []
  16. },
  17. onLoad: function(){
  18. let that = this
  19. wx.getSystemInfo({
  20. success: function(res) {
  21. that.setData({system: res.system})
  22. }
  23. })
  24. },
  25. gotoCourse( e ){
  26. let courseId = e.currentTarget.dataset.id;
  27. wx.navigateTo({
  28. url: `/pages/study/course/index?courseId=${courseId}`,
  29. })
  30. },
  31. onShow: function () {
  32. app.checkLogin( userInfo =>{
  33. this.setData({userInfo, from:0})
  34. this.indexLoad()
  35. })
  36. },
  37. onPullDownRefresh() {
  38. if (!this.loading) {
  39. this.indexLoad( this.stopPullDownRefresh )
  40. }
  41. },
  42. stopPullDownRefresh(){
  43. wx.stopPullDownRefresh()
  44. },
  45. indexLoad: function( cb ) {
  46. let param ={
  47. from: this.data.from,
  48. size: this.data.size,
  49. type:'继续教育',
  50. }
  51. app.formPost('Study.GetWxCourseList', param).then(res => {
  52. if (res.code === 200) {
  53. this.setData({
  54. from: res.data.from,
  55. courseList: res.data.list,
  56. });
  57. cb&&cb()
  58. }
  59. })
  60. },
  61. gotoExam:function( e ){
  62. let groupId = e.currentTarget.dataset.id
  63. wx.navigateTo({
  64. url: `/pages/exam/do/index?id=${groupId}`
  65. })
  66. },
  67. gotoCollection(){
  68. wx.navigateTo({
  69. url: '/pages/exam/collection/index',
  70. })
  71. },
  72. doWxPay( data ){
  73. let that = this
  74. wx.requestPayment({
  75. timeStamp: data.timeStamp,
  76. nonceStr: data.nonceStr,
  77. package: data.package,
  78. signType: data.signType,
  79. paySign: data.paySign,
  80. success: function (event) {
  81. wx.showModal({
  82. title: '支付成功',
  83. showCancel: false,
  84. content: '本次共支付费用¥'+(data.fee/100)+'元'+ `\n\n试卷更新可能延迟,请耐心等待`,
  85. success(res) {
  86. that.indexLoad()
  87. }
  88. })
  89. }
  90. })
  91. },
  92. startWxpay(e){
  93. let groupId = +e.currentTarget.dataset.id
  94. let system = this.data.system
  95. app.formPost('User.PayExam', {groupId, system}).then(res => {
  96. if (res.code === 200) {
  97. if( res.data.payType=="free" ){
  98. this.indexLoad()
  99. }else if (res.data.payType=="qrcode"){
  100. this.setData({info: res.data, buyModel:true})
  101. }else{
  102. this.doWxPay( res.data )
  103. }
  104. }
  105. })
  106. },
  107. onShareAppMessage: function(){
  108. },
  109. gotoError: function(){
  110. wx.navigateTo({
  111. url: '/pages/exam/error/index',
  112. })
  113. }
  114. })