school.js 6.8 KB

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