default.js 3.8 KB

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