review.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. IsEdit: false,
  7. SelectedCount: 0,
  8. },
  9. onLoad: function (options) {
  10. this.setData({
  11. Height: common.getSystemHeight(),
  12. });
  13. },
  14. onShow:function(){
  15. this.initReview();
  16. },
  17. initReview: function () {
  18. var arrReview = wx.getStorageSync("ReviewList");
  19. if (!arrReview)
  20. arrReview = [];
  21. this.setData({
  22. IsEdit: false,
  23. List: arrReview,
  24. });
  25. },
  26. startEdit: function () {
  27. this.setData({
  28. IsEdit: true,
  29. });
  30. },
  31. gotoReview: function (e) {
  32. var id = e.currentTarget.dataset.id;
  33. var cotegory = "review";
  34. wx.navigateTo({
  35. url: '../main/detail?Type=' + cotegory + '&indexID=' + id,
  36. });
  37. },
  38. selectedHanzi: function (e) {
  39. var id = e.currentTarget.dataset.id;
  40. this.data.List[id].IsSelected = !this.data.List[id].IsSelected;
  41. var SelectedCount = 0;
  42. for (var i = 0; i < this.data.List.length; i++) {
  43. if (this.data.List[i].IsSelected)
  44. SelectedCount++;
  45. }
  46. this.setData({
  47. List: this.data.List,
  48. SelectedCount: SelectedCount,
  49. });
  50. },
  51. cancelHanzi: function () {
  52. var that = this;
  53. var arr = [];
  54. for (var i = 0; i < this.data.List.length; i++) {
  55. if (this.data.List[i].IsSelected)
  56. arr.push(this.data.List[i].ID);
  57. }
  58. server.postData('UpdateHanziReview', {
  59. UserID: app.globalData.userInfo.UserID,
  60. WordID: arr.join(","),
  61. Status: "deleteAll",
  62. }, function (data) {
  63. if (data) {
  64. wx.setStorageSync("ReviewList", data);
  65. that.initReview();
  66. wx.showToast({
  67. title: '删除成功',
  68. })
  69. }
  70. });
  71. },
  72. onShareAppMessage: function () {
  73. return {
  74. title: app.globalData.ShareTitle,
  75. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  76. imageUrl: '../../images/07001.png',
  77. }
  78. },
  79. });