previewMenu.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import constant from '../../utils/constant';
  4. const app = getApp();
  5. Page({
  6. data: {
  7. MenuArr: constant.arrStudyPlay,
  8. },
  9. onLoad: function (options) {
  10. var that = this;
  11. that.setData({
  12. Containnerheight: main.getWindowHeight(),
  13. CardType:options.CardType,
  14. MiaoguoCardID:options.ID,
  15. CardNumberUrgent: app.globalData.TaskToday.CardNumberUrgent,
  16. });
  17. if (app.globalData.IsIPhoneX) {
  18. that.setData({
  19. IsIPhoneX: "_IsIPhoneX",
  20. });
  21. }
  22. },
  23. changeCardType:function(e){
  24. var that = this;
  25. var cardType=e.currentTarget.dataset.cardtype;
  26. if (cardType!=that.data.CardType){
  27. if (cardType == 1 && that.data.CardNumberUrgent>=200){
  28. wx.showToast({
  29. title: '紧急练习容量已满',
  30. })
  31. }
  32. else{
  33. that.setData({
  34. CardType: cardType,
  35. });
  36. }
  37. }
  38. },
  39. close:function(){
  40. wx.navigateBack({
  41. delta: 1,
  42. });
  43. },
  44. save:function(){
  45. var that = this;
  46. var url = 'UpdateMiaoguoCardType?UserID=' + app.globalData.userInfo.UserID;
  47. url += "&CardType=" + that.data.CardType;
  48. url += "&ID=" + that.data.MiaoguoCardID;
  49. main.getData(url, function (data) {
  50. var list = app.globalData.CardList;
  51. for (var i = 0; i < list.length; i++) {
  52. if (list[i].MiaoguoCardID == that.data.MiaoguoCardID)
  53. list[i].CardType = that.data.CardType;
  54. }
  55. app.globalData.CardList = list;
  56. app.globalData.IsUpdateStudyPlan = 1;
  57. if (that.data.CardType==1){
  58. app.globalData.TaskToday.CardNumberUrgent++;
  59. var cardType=wx.getStorageSync('CardType');
  60. if (cardType==0 && app.globalData.TaskToday.CardNumberUrgent==1){
  61. wx.redirectTo({
  62. url: "../other/menu?Type=0",
  63. });
  64. }
  65. else{
  66. that.close();
  67. }
  68. }
  69. else{
  70. that.close();
  71. }
  72. });
  73. },
  74. onShareAppMessage: function () {
  75. return {
  76. title: app.globalData.ShareTitle,
  77. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  78. imageUrl: app.globalData.ShareImage,
  79. }
  80. },
  81. })