school.js 6.6 KB

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