school.js 8.3 KB

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