previewMenu.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. MenuArr: [
  7. { CardType: 0, Name: "日常练习", Remark: "常规长期记忆,系统首选" },
  8. { CardType: 1, Name: "紧急练习", Remark: "临时短期记忆,容量200张" },
  9. { CardType: -1, Name: "留白题卡", Remark: "暂不练习,到期时间留白" },
  10. ]
  11. },
  12. onLoad: function (options) {
  13. var that = this;
  14. that.setData({
  15. Containnerheight: main.getWindowHeight(),
  16. CardType:options.CardType,
  17. MiaoguoCardID:options.ID,
  18. CardNumberUrgent: app.globalData.TaskToday.CardNumberUrgent,
  19. });
  20. },
  21. changeCardType:function(e){
  22. var that = this;
  23. var cardType=e.currentTarget.dataset.cardtype;
  24. if (cardType!=that.data.CardType){
  25. if (cardType == 1 && that.data.CardNumberUrgent>=200){
  26. wx.showToast({
  27. title: '紧急练习容量已满',
  28. })
  29. }
  30. else{
  31. that.setData({
  32. CardType: cardType,
  33. });
  34. }
  35. }
  36. },
  37. close:function(){
  38. wx.navigateBack({
  39. delta: 1,
  40. });
  41. },
  42. save:function(){
  43. var that = this;
  44. var url = 'UpdateMiaoguoCardType?UserID=' + app.globalData.userInfo.UserID;
  45. url += "&CardType=" + that.data.CardType;
  46. url += "&ID=" + that.data.MiaoguoCardID;
  47. main.getData(url, function (data) {
  48. var list = app.globalData.CardList;
  49. for (var i = 0; i < list.length; i++) {
  50. if (list[i].MiaoguoCardID == that.data.MiaoguoCardID)
  51. list[i].CardType = that.data.CardType;
  52. }
  53. app.globalData.CardList = list;
  54. if (that.data.CardType==1){
  55. app.globalData.TaskToday.CardNumberUrgent++;
  56. }
  57. that.close();
  58. });
  59. },
  60. onShareAppMessage: function () {
  61. return {
  62. title: app.globalData.ShareTitle,
  63. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  64. imageUrl: app.globalData.ShareImage,
  65. }
  66. },
  67. })