default.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. ImagePath: app.globalData.uploadImageUrl,
  8. ArticleList:[],
  9. District:constant.arrDistrict,
  10. Version:app.globalData.Version,
  11. Years:constant.arrYear,
  12. YearIndex:0,
  13. HideAddProgram:1,
  14. },
  15. onLoad: function (options) {
  16. var that = this;
  17. that.setData({
  18. Containnerheight: main.getWindowHeight(),
  19. IsShow:app.globalData.userInfo.IsShow,
  20. });
  21. if (app.globalData.GotoUrl) {
  22. //console.log(app.globalData.GotoUrl);
  23. wx.navigateTo({
  24. url: app.globalData.GotoUrl,
  25. });
  26. app.globalData.GotoUrl = "";
  27. }
  28. else{
  29. //获得收藏学校数据
  30. main.getCollect();
  31. }
  32. that.getNotice(function(){
  33. that.getPersonNum(function(){
  34. that.getArticle(function(){
  35. that.getWish();
  36. });
  37. });
  38. });
  39. var hideAddProgram=wx.getStorageSync('HideAddProgram');
  40. if (!hideAddProgram){
  41. wx.checkIsAddedToMyMiniProgram({
  42. success:function(e){
  43. console.log(e.added);
  44. that.setData({
  45. HideAddProgram:e.added,
  46. });
  47. }
  48. })
  49. }
  50. },
  51. onShow:function(){
  52. this.getWish();
  53. },
  54. onHideAddProgram:function(){
  55. wx.setStorageSync('HideAddProgram', 1);
  56. this.setData({
  57. HideAddProgram:1,
  58. });
  59. },
  60. showMore:function(e){
  61. var that = this;
  62. var id=e.currentTarget.dataset.id;
  63. if (id==1){
  64. that.setData({
  65. Page1:0,
  66. });
  67. }
  68. else if (id==2){
  69. that.setData({
  70. Page2:0,
  71. });
  72. }
  73. },
  74. getPersonNum:function(callback){
  75. var that = this;
  76. main.getData("GetMPSCityPersonNum", function (data) {
  77. if (data) {
  78. that.setData({
  79. PersonNum: data,
  80. });
  81. if (callback)
  82. callback();
  83. }
  84. });
  85. },
  86. getWish:function(callback){
  87. var that = this;
  88. main.getData("GetMPSWish?WishType=all", function (data) {
  89. if (data) {
  90. that.setData({
  91. WishList: data,
  92. Page1:1,
  93. Page2:1,
  94. });
  95. if (callback)
  96. callback();
  97. }
  98. });
  99. },
  100. getNotice:function(callback){
  101. var that = this;
  102. main.getData("GetMPSNotice", function (data) {
  103. if (data) {
  104. that.setData({
  105. Notice: data,
  106. });
  107. if (callback)
  108. callback();
  109. }
  110. });
  111. },
  112. getArticle:function(callback){
  113. var that = this;
  114. main.getData("GetMPSArticle", function (data) {
  115. if (data) {
  116. that.setData({
  117. ArticleList: data,
  118. });
  119. app.globalData.ArticleList=data;
  120. if (callback)
  121. callback();
  122. }
  123. });
  124. },
  125. goto: function (e) {
  126. main.goto(e);
  127. },
  128. onShareTimeline: function () {
  129. return this.onShareAppMessage();
  130. },
  131. gotoMiniprogram:function(){
  132. main.gotoMiniprogram(184);
  133. },
  134. onSelect:function(event){
  135. var that=this;
  136. main.onSelect(that,event,function(obj,e,result){
  137. if (e.currentTarget.dataset.object=="Years"){
  138. that.setData({
  139. YearIndex:e.currentTarget.dataset.index
  140. });
  141. }
  142. });
  143. },
  144. onShareAppMessage: function () {
  145. return {
  146. title: "上海中考招生信息查询工具",
  147. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  148. imageUrl: app.globalData.ShareImage,
  149. }
  150. },
  151. })