school.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. PageType:"school",
  8. ScoreTypeID:1,//四种得分类型
  9. IsFold:false,
  10. Years:constant.arrYear,
  11. YearIndex:0,
  12. ImagePath: app.globalData.uploadImageUrl,
  13. ScoreType:constant.arrScoreType,
  14. TailScore:constant.arrTailScore,
  15. },
  16. onLoad: function (options) {
  17. var that = this;
  18. that.setData({
  19. Containnerheight: main.getWindowHeight(),
  20. SchoolID:options.ID,
  21. IsCollect:false,
  22. });
  23. if (!options.ID){
  24. wx.navigateBack({
  25. delta: 1,
  26. });
  27. }
  28. else
  29. that.init();
  30. },
  31. init:function(){
  32. var that = this;
  33. wx.showLoading({title:"加载中"});
  34. main.getData("GetMPSSchoolInfo?SchoolID="+that.data.SchoolID, function (data) {
  35. if (data) {
  36. var list=[];
  37. that.data.ScoreTypeID=1;
  38. if (data['1-15志愿'] && !(data['自主招生'])){
  39. that.data.ScoreTypeID=4;
  40. var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name;
  41. list=data[name][that.data.YearIndex].List;
  42. }
  43. else if (data['名额到校'] && data.SchoolType1=='初中'){
  44. that.data.ScoreTypeID=3;
  45. var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name;
  46. list=data[name][that.data.YearIndex].List;
  47. }
  48. wx.setNavigationBarTitle({
  49. title: data.SchoolType1,
  50. });
  51. var schoolList=wx.getStorageSync('CollectList');
  52. if (schoolList && schoolList["收藏的"+data.SchoolType1]){
  53. schoolList=schoolList["收藏的"+data.SchoolType1];
  54. for(var i=0;i<schoolList.length;i++){
  55. if (that.data.SchoolID==schoolList[i].ID){
  56. that.setData({
  57. IsCollect:true,
  58. });
  59. break;
  60. }
  61. }
  62. }
  63. //data.Website="http://www.gezhi.sh.cn/infoweb/index.aspx?wzid=2";
  64. if (data.Website && data.Website.length>26){
  65. var str1=data.Website.substr(0,26);
  66. var str2=data.Website.substr(26);
  67. data.WebsiteStr=str1+"\n"+str2;
  68. }
  69. else
  70. data.WebsiteStr=data.Website;
  71. if (data.ImageOther)
  72. data.ImageOtherStr=data.ImageOther.join(",");
  73. //将保存的用户习惯(显示列表样式)提取出来
  74. var isListAll=wx.getStorageSync('TailScore');
  75. if (isListAll){
  76. that.data.TailScore[0].CSS="Selected";
  77. }
  78. that.setData({
  79. Info:data,
  80. ScoreTypeID:that.data.ScoreTypeID,
  81. List:list,
  82. IsListAll:isListAll,
  83. TailScore:that.data.TailScore,
  84. Title:data.SchoolType1,
  85. });
  86. }
  87. setTimeout(function(){
  88. wx.hideLoading();
  89. },800);
  90. });
  91. },
  92. collectSchool:function(e){
  93. var that=this;
  94. var IsCollect=Number(e.currentTarget.dataset.index);
  95. main.getData("UpdateMPSSchoolCollect?SchoolID="+that.data.SchoolID+"&UserID="+app.globalData.userInfo.UserID+"&IsCollect="+IsCollect, function (data) {
  96. var title="收藏完成";
  97. if (!IsCollect)
  98. title="取消收藏完成";
  99. wx.showToast({
  100. title: title,
  101. });
  102. that.setData({
  103. IsCollect:IsCollect,
  104. });
  105. wx.removeStorageSync('CollectList');
  106. //获得收藏学校数据
  107. main.getCollect();
  108. });
  109. },
  110. goto: function (e) {
  111. // var url=e.currentTarget.dataset.url;
  112. // if (url.indexOf("PageType=school")>0){
  113. // url=url.replace("PageType=school&","");
  114. // if (url.substr(url.length-3)!="ID="){
  115. // wx.redirectTo({
  116. // url: url,
  117. // });
  118. // }
  119. // }
  120. // else{
  121. // var b=true;
  122. // if (e.currentTarget.dataset.url.substr(0,3)=="map" && !e.currentTarget.dataset.isgoto)
  123. // b=false;
  124. // if (b)
  125. // main.goto(e);
  126. // }
  127. main.goto(e);
  128. },
  129. onSelect:function(event){
  130. var that=this;
  131. main.onSelect(that,event,function(obj,e,result){
  132. if (e.currentTarget.dataset.object=="TailScore"){
  133. that.setData({
  134. IsListAll: result,
  135. });
  136. wx.setStorageSync('TailScore', result);
  137. }
  138. else if (e.currentTarget.dataset.object=="ScoreType"){
  139. var name=that.data.ScoreType[e.currentTarget.dataset.index].Name;
  140. var list=[];
  141. if (that.data.Info[name])
  142. list=that.data.Info[name][that.data.YearIndex].List;
  143. that.setData({
  144. ScoreTypeID: e.currentTarget.dataset.index+1,
  145. List:list,
  146. });
  147. }
  148. else if (e.currentTarget.dataset.object=="Years"){
  149. var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name;
  150. var list=that.data.Info[name][e.currentTarget.dataset.index].List;
  151. that.setData({
  152. List:list,
  153. YearIndex:e.currentTarget.dataset.index
  154. });
  155. }
  156. });
  157. },
  158. onFold:function(e){
  159. var that=this;
  160. that.setData({
  161. IsFold: !that.data.IsFold,
  162. });
  163. },
  164. copyUrl:function(e){
  165. var url=e.currentTarget.dataset.url;
  166. wx.setClipboardData({
  167. data: url,
  168. success (res) {
  169. wx.showToast({
  170. title: '已复制',
  171. });
  172. }
  173. });
  174. },
  175. returnTop:function(){
  176. main.returnTop();
  177. },
  178. onShareTimeline: function () {
  179. return this.onShareAppMessage();
  180. },
  181. onUpdateTitle:function(){
  182. if (app.globalData.userInfo.UserID<6){
  183. wx.setNavigationBarTitle({
  184. title: "秒过分数线·小程序",
  185. });
  186. }
  187. },
  188. onShareAppMessage: function () {
  189. var that=this;
  190. var name="中考招生信息:";
  191. if (that.data.Info.SchoolType1=="初中")
  192. name+=that.data.Info.SchoolFullName;
  193. else
  194. name+=that.data.Info.SchoolShortName;
  195. return {
  196. title: name,
  197. path: app.globalData.SharePath+'?UserID=' + app.globalData.userInfo.UserID+'&type=school&ID=' + that.data.Info.ID,
  198. }
  199. },
  200. })