wishinfo.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. wx.setNavigationBarColor({
  17. frontColor: "#ffffff",
  18. backgroundColor: "#DB1824",
  19. });
  20. },
  21. onPullDownRefresh: function () {
  22. var that=this;
  23. that.saveLikeNum(function(){
  24. that.onShow();
  25. });
  26. wx.stopPullDownRefresh();
  27. },
  28. onShow:function(){
  29. var that = this;
  30. if (that.data.ID){
  31. main.getData("GetMPSWish?WishType=person&ID="+that.data.ID, function (data2) {
  32. //debugger;
  33. if (data2 && data2.length>0) {
  34. app.globalData.MyWish=data2[0];
  35. console.log("data2[0]:"+data2[0]);
  36. that.setData({
  37. MyWish:app.globalData.MyWish,
  38. LikeNum:app.globalData.MyWish.LikeNum,
  39. ID:app.globalData.MyWish.ID,
  40. });
  41. historyLikeNum=app.globalData.MyWish.LikeNum;
  42. }
  43. });
  44. }
  45. else if (app.globalData.MyWish){
  46. that.setData({
  47. MyWish:app.globalData.MyWish,
  48. LikeNum:app.globalData.MyWish.LikeNum,
  49. UserID:app.globalData.userInfo.UserID,
  50. ID:app.globalData.MyWish.ID,
  51. });
  52. historyLikeNum=app.globalData.MyWish.LikeNum;
  53. }
  54. },
  55. onHide:function(){
  56. this.saveLikeNum();
  57. },
  58. onUnload:function(){
  59. this.saveLikeNum();
  60. },
  61. returnDefault:function(e){
  62. var url='../index/index';
  63. var url1=e.currentTarget.dataset.url;
  64. if (url1)
  65. url+=url1;
  66. wx.reLaunch({
  67. url: url,
  68. });
  69. },
  70. goto: function (e) {
  71. main.goto(e);
  72. },
  73. gotoRedirectTo:function(e){
  74. var url=e.currentTarget.dataset.url;
  75. wx.redirectTo({
  76. url: url,
  77. })
  78. },
  79. clickLikeNum:function(){
  80. var that=this;
  81. this.animateSmallShow();
  82. var count=++that.data.LikeNum;
  83. if (count>9999)
  84. count=9999;
  85. that.setData({
  86. LikeNum:count,
  87. });
  88. if (isUpdate){
  89. isUpdate=false;
  90. setTimeout(function(){
  91. isUpdate=true;
  92. },3000);
  93. that.saveLikeNum();
  94. }
  95. if (count==66){
  96. wx.showModal({
  97. title: '66大顺',
  98. content: '一分耕耘,一分收获。祝您心想事成,鱼跃龙门,考中心仪学校。',
  99. showCancel: false,
  100. confirmText: '中',
  101. });
  102. }
  103. else if (count==666){
  104. wx.showModal({
  105. title: '666厉害了',
  106. content: '努力必有回报,祝您考中心仪学校,实现梦想,继续闪耀!',
  107. showCancel: false,
  108. confirmText: '中',
  109. });
  110. }
  111. },
  112. saveLikeNum:function(callback){
  113. var that = this;
  114. var likeNumAdd=that.data.LikeNum-historyLikeNum;
  115. main.getData("UpdateMPSWishLikeNum?ID="+that.data.ID+"&LikeNumAdd="+likeNumAdd, function (data2) {
  116. console.log(that.data.LikeNum);
  117. historyLikeNum=that.data.LikeNum;
  118. if (callback)
  119. callback();
  120. });
  121. },
  122. //动画缩小淡出
  123. animateSmallShow: function () {
  124. var that = this;
  125. var animation = wx.createAnimation({
  126. duration: 100,
  127. timingFunction: 'ease-in',
  128. });
  129. //this.animation = animation;
  130. animation.scale(1.3, 1.3).step();
  131. this.setData({
  132. animationDataShow: animation.export(),
  133. });
  134. setTimeout(function () {
  135. var animation2 = wx.createAnimation({
  136. duration: 100,
  137. timingFunction: 'ease-in',
  138. });
  139. that.animation = animation2;
  140. animation2.scale(1, 1).step();
  141. that.setData({
  142. animationDataShow: animation2.export()
  143. });
  144. }, 150);
  145. },
  146. onShareAppMessage: function () {
  147. var that=this;
  148. var url=app.globalData.uploadImageUrl+"web/fs_a02.png";
  149. //debugger;
  150. return {
  151. title: "中考祝福",
  152. path: app.globalData.SharePath + '?type=wish&ID='+that.data.MyWish.ID+'&UserID=' + app.globalData.userInfo.UserID,
  153. imageUrl: url,
  154. }
  155. },
  156. })