set_grade.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. */
  31. methods: {
  32. //隐藏框
  33. hidePopup: function () {
  34. this.setData({
  35. flag: !this.data.flag
  36. })
  37. },
  38. //展示框
  39. showPopup () {
  40. this.setData({
  41. flag: !this.data.flag
  42. })
  43. },
  44. grade (e) {
  45. const grade = e.currentTarget.dataset.grade + 1
  46. this.setData({
  47. grade: util.gradeUpper(grade)
  48. })
  49. //调用更改年级接口
  50. login.getOpenidSessionKey((res) => {
  51. //console.log(res.data.data.uid);
  52. APIClient.getSetNameSchedule({
  53. uid: res.data.data.uid
  54. }, {
  55. grade: grade
  56. }).success(res => {
  57. console.log(res)
  58. if(res.data.success) {
  59. wx.redirectTo({
  60. url: '../my/my?ind=0'
  61. })
  62. }
  63. })
  64. }, function() {
  65. wx.showModal({
  66. title: '提示',
  67. content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
  68. showCancel: false,
  69. success: function (res) {
  70. if (res.confirm) {
  71. console.log('用户点击确定')
  72. } else if (res.cancel) {
  73. console.log('用户点击取消')
  74. }
  75. }
  76. })
  77. });
  78. }
  79. }
  80. })