school.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. IsShow:app.globalData.userInfo.IsShow,
  21. SchoolID:options.ID,
  22. IsCollect:false,
  23. HasWish: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. onFold:function(e){
  164. var that=this;
  165. that.setData({
  166. IsFold: !that.data.IsFold,
  167. });
  168. },
  169. copyUrl:function(e){
  170. var url=e.currentTarget.dataset.url;
  171. wx.setClipboardData({
  172. data: url,
  173. success (res) {
  174. wx.showToast({
  175. title: '已复制',
  176. });
  177. }
  178. });
  179. },
  180. returnTop:function(){
  181. main.returnTop();
  182. },
  183. onShareTimeline: function () {
  184. return this.onShareAppMessage();
  185. },
  186. onUpdateTitle:function(){
  187. if (app.globalData.userInfo.UserID<6){
  188. wx.setNavigationBarTitle({
  189. title: "秒过分数线·小程序",
  190. });
  191. }
  192. },
  193. getWish:function(){
  194. var that = this;
  195. main.getData("GetMPSWish?WishType=school&SchoolID="+that.data.SchoolID, function (data) {
  196. if (data) {
  197. that.setData({
  198. WishList: data,
  199. });
  200. main.getData("GetMPSWish?WishType=person&UserID="+app.globalData.userInfo.UserID+"&SchoolID="+that.data.SchoolID, function (data2) {
  201. //debugger;
  202. if (data2 && data2.length>0) {
  203. app.globalData.MyWish=data2[0];
  204. that.setData({
  205. HasWish: true,
  206. });
  207. }
  208. else{
  209. that.setData({
  210. HasWish: false,
  211. });
  212. }
  213. });
  214. }
  215. });
  216. },
  217. onShareAppMessage: function () {
  218. var that=this;
  219. var name="中考招生信息:";
  220. if (that.data.Info.SchoolType1=="初中")
  221. name+=that.data.Info.SchoolFullName;
  222. else
  223. name+=that.data.Info.SchoolShortName;
  224. return {
  225. title: name,
  226. path: app.globalData.SharePath+'?UserID=' + app.globalData.userInfo.UserID+'&type=school&ID=' + that.data.Info.ID,
  227. }
  228. },
  229. })