set_grade.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // compontents/share/share.js
  2. const util = require('../../utils/util.js');
  3. const APIClient = require('../../utils/APIClient.js');
  4. const login = require('../../utils/loginSchedule.js');
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. * grade年级
  9. */
  10. properties: {
  11. "grade": {
  12. type: String,
  13. value: ''
  14. }
  15. },
  16. /**
  17. * 组件的初始数据
  18. */
  19. data: {
  20. flag: true,
  21. gradeData: [
  22. '一年级',
  23. '二年级',
  24. '三年级'
  25. ]
  26. },
  27. /**
  28. * 组件的方法列表
  29. */
  30. methods: {
  31. //隐藏框
  32. hidePopup: function () {
  33. this.setData({
  34. flag: !this.data.flag
  35. })
  36. },
  37. //展示框
  38. showPopup () {
  39. this.setData({
  40. flag: !this.data.flag
  41. })
  42. },
  43. grade (e) {
  44. const grade = e.currentTarget.dataset.grade + 1
  45. this.setData({
  46. grade: util.gradeUpper(grade)
  47. })
  48. //调用更改年级接口
  49. login.getOpenidSessionKey((res) => {
  50. //console.log(res.data.data.uid);
  51. APIClient.getSetNameSchedule({
  52. uid: res.data.data.uid
  53. }, {
  54. grade: grade
  55. }).success(res => {
  56. console.log(res)
  57. if(res.data.success) {
  58. wx.redirectTo({
  59. url: '../index/index?ind=0'
  60. })
  61. }
  62. })
  63. }, function() {
  64. wx.showModal({
  65. title: '提示',
  66. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  67. showCancel: false,
  68. success: function (res) {
  69. if (res.confirm) {
  70. console.log('用户点击确定')
  71. } else if (res.cancel) {
  72. console.log('用户点击取消')
  73. }
  74. }
  75. })
  76. });
  77. }
  78. }
  79. })