wishinfo.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. var isUpdate=true;
  5. var historyLikeNum=0;
  6. Page({
  7. data: {
  8. },
  9. onLoad: function (options) {
  10. var that = this;
  11. that.setData({
  12. Containnerheight: main.getWindowHeight(),
  13. ID:options.ID,
  14. IsShare:options.Share
  15. });
  16. },
  17. onShow:function(){
  18. var that = this;
  19. if (that.data.ID){
  20. main.getData("GetMPSWish?WishType=person&ID="+that.data.ID, function (data2) {
  21. //debugger;
  22. if (data2 && data2.length>0) {
  23. app.globalData.MyWish=data2[0];
  24. console.log("data2[0]:"+data2[0]);
  25. that.setData({
  26. MyWish:app.globalData.MyWish,
  27. LikeNum:app.globalData.MyWish.LikeNum,
  28. ID:app.globalData.MyWish.ID,
  29. });
  30. historyLikeNum=app.globalData.MyWish.LikeNum;
  31. }
  32. });
  33. }
  34. else if (app.globalData.MyWish){
  35. that.setData({
  36. MyWish:app.globalData.MyWish,
  37. LikeNum:app.globalData.MyWish.LikeNum,
  38. UserID:app.globalData.userInfo.UserID,
  39. ID:app.globalData.MyWish.ID,
  40. });
  41. historyLikeNum=app.globalData.MyWish.LikeNum;
  42. }
  43. },
  44. onHide:function(){
  45. this.saveLikeNum();
  46. },
  47. onUnload:function(){
  48. this.saveLikeNum();
  49. },
  50. returnDefault:function(){
  51. wx.reLaunch({
  52. url: '../index/index'
  53. });
  54. },
  55. goto: function (e) {
  56. if (e.currentTarget.dataset.target=="school"){
  57. wx.navigateBack({
  58. delta: 3,
  59. });
  60. }
  61. main.goto(e);
  62. },
  63. gotoRedirectTo:function(e){
  64. var url=e.currentTarget.dataset.url;
  65. wx.redirectTo({
  66. url: url,
  67. })
  68. },
  69. clickLikeNum:function(){
  70. var that=this;
  71. that.setData({
  72. LikeNum:++that.data.LikeNum
  73. });
  74. if (isUpdate){
  75. isUpdate=false;
  76. setTimeout(function(){
  77. isUpdate=true;
  78. },3000);
  79. that.saveLikeNum();
  80. }
  81. },
  82. saveLikeNum:function(){
  83. var that = this;
  84. var likeNumAdd=that.data.LikeNum-historyLikeNum;
  85. main.getData("UpdateMPSWishLikeNum?ID="+that.data.ID+"&LikeNumAdd="+likeNumAdd, function (data2) {
  86. console.log(that.data.LikeNum);
  87. historyLikeNum=that.data.LikeNum;
  88. });
  89. },
  90. onShareAppMessage: function () {
  91. var that=this;
  92. var url=app.globalData.uploadImageUrl+"web/fs_a02.png";
  93. //debugger;
  94. return {
  95. title: that.data.MyWish.WishWhom2+that.data.MyWish.SchoolShortName,
  96. path: app.globalData.SharePath + '?type=wish&ID='+that.data.MyWish.ID+'&UserID=' + app.globalData.userInfo.UserID,
  97. imageUrl: url,
  98. }
  99. },
  100. })