homework.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. List: [],
  7. },
  8. onLoad: function (options) {
  9. var that = this;
  10. that.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. NickName: app.globalData.userInfo.NickName,
  13. AvatarUrl: app.globalData.userInfo.AvatarUrl,
  14. });
  15. var userid = app.globalData.userInfo.UserID;
  16. if (options.UserID)
  17. userid=options.UserID;
  18. main.getData("GetMiaoguoCheckList?UserID=" + userid, function (data) {
  19. if (data) {
  20. common.getStorageValue(that, "HomeworkListClick", [0,0,0], function () {
  21. if (that.data.HomeworkListClick[1] == 0) {
  22. data.List[1].Finished = 0;
  23. data.FinishedCount -= 10;
  24. }
  25. if (that.data.HomeworkListClick[2] == 0) {
  26. data.List[2].Finished = 0;
  27. data.FinishedCount -= 10;
  28. }
  29. that.setData({
  30. FinishedCount: data.FinishedCount,
  31. List: data.List,
  32. NickName: data.NickName,
  33. AvatarUrl: data.AvatarUrl,
  34. });
  35. });
  36. }
  37. });
  38. app.globalData.Homework=0;
  39. },
  40. clickOK:function(e){
  41. var that = this;
  42. var index=e.currentTarget.dataset.index;
  43. common.getStorageValue(that, "HomeworkListClick", [0, 0, 0], function () {
  44. that.data.List[index].Finished = 1;
  45. that.data.FinishedCount += 10;
  46. that.setData({
  47. FinishedCount: that.data.FinishedCount,
  48. List: that.data.List,
  49. });
  50. that.data.HomeworkListClick[index]=1;
  51. wx.setStorageSync("HomeworkListClick", that.data.HomeworkListClick);
  52. });
  53. },
  54. gotoLessonList:function(){
  55. wx.navigateTo({
  56. url: '../other/lessonlist',
  57. });
  58. },
  59. onShareAppMessage: function () {
  60. return {
  61. title: "作业清单",
  62. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID +'&Homework=1',
  63. imageUrl: "../images/program_screenshot_checklist.png",
  64. }
  65. },
  66. })