school.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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][0] && data[that.data.ScoreType[i].Name][0].Total)
  88. data.PersonCount1+=data[that.data.ScoreType[i].Name][0].Total;
  89. if (data[that.data.ScoreType[i].Name] && data[that.data.ScoreType[i].Name][1] && data[that.data.ScoreType[i].Name][1].Total)
  90. data.PersonCount2+=data[that.data.ScoreType[i].Name][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. that.checkListNull(that,list);
  102. }
  103. setTimeout(function(){
  104. wx.hideLoading();
  105. },800);
  106. });
  107. },
  108. collectSchool:function(e){
  109. var that=this;
  110. var IsCollect=Number(e.currentTarget.dataset.index);
  111. main.getData("UpdateMPSSchoolCollect?SchoolID="+that.data.SchoolID+"&UserID="+app.globalData.userInfo.UserID+"&IsCollect="+IsCollect, function (data) {
  112. var title="收藏完成";
  113. if (!IsCollect)
  114. title="取消收藏完成";
  115. wx.showToast({
  116. title: title,
  117. });
  118. that.setData({
  119. IsCollect:IsCollect,
  120. });
  121. wx.removeStorageSync('CollectList');
  122. //获得收藏学校数据
  123. main.getCollect();
  124. });
  125. },
  126. goto: function (e) {
  127. if (e.currentTarget.dataset.url=="school?PageType=school&ID="
  128. || e.currentTarget.dataset.url=="school?PageType=school&ID=0")
  129. return null;
  130. else{
  131. app.globalData.FeedbackUrl="school?id="+this.data.Info.ID;
  132. main.goto(e);
  133. }
  134. },
  135. onSelect:function(event){
  136. var that=this;
  137. main.onSelect(that,event,function(obj,e,result){
  138. if (e.currentTarget.dataset.object=="TailScore"){
  139. that.setData({
  140. IsListAll: result,
  141. });
  142. wx.setStorageSync('TailScore', result);
  143. }
  144. else if (e.currentTarget.dataset.object=="ScoreType"){
  145. var name=that.data.ScoreType[e.currentTarget.dataset.index].Name;
  146. var list=[];
  147. if (that.data.Info[name])
  148. list=that.data.Info[name][that.data.YearIndex].List;
  149. that.setData({
  150. ScoreTypeID: e.currentTarget.dataset.index+1,
  151. List:list,
  152. });
  153. that.checkListNull(that,list);
  154. }
  155. else if (e.currentTarget.dataset.object=="Years"){
  156. var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name;
  157. var list=[];
  158. if (e.currentTarget.dataset.index>0 && that.data.Info[name].length>e.currentTarget.dataset.index)
  159. list = that.data.Info[name][e.currentTarget.dataset.index].List;
  160. else if (e.currentTarget.dataset.index==0)
  161. list = that.data.Info[name][e.currentTarget.dataset.index].List;
  162. that.setData({
  163. List:list,
  164. YearIndex:e.currentTarget.dataset.index
  165. });
  166. that.checkListNull(that,list);
  167. }
  168. });
  169. },
  170. checkListNull:function(obj,list){
  171. var that=obj;
  172. if (list.length==0
  173. && that.data.YearIndex==0
  174. && that.data.ScoreTypeID==4){
  175. // wx.showModal({
  176. // title: '暂无公布',
  177. // showCancel:false,
  178. // content: '教育局暂未公布2024年1-15志愿信息,正式数据一般在7月公布,敬请期待。',
  179. // confirmText: '知道了',
  180. // complete: (res) => {
  181. // if (res.confirm) {
  182. // list=that.data.Info["1-15志愿"][1].List;
  183. // that.setData({
  184. // ScoreTypeID: 4,
  185. // YearIndex:1,
  186. // List:list,
  187. // });
  188. // var eventTemp={
  189. // currentTarget:{
  190. // dataset:{
  191. // object:"Years",
  192. // clicktype:"radio",
  193. // index:1,
  194. // }
  195. // }
  196. // }
  197. // main.onSelect(that,eventTemp,function(){});
  198. // }
  199. // }
  200. // });
  201. }
  202. },
  203. onFold:function(e){
  204. var that=this;
  205. that.setData({
  206. IsFold: !that.data.IsFold,
  207. });
  208. },
  209. copyUrl:function(e){
  210. var url=e.currentTarget.dataset.url;
  211. wx.setClipboardData({
  212. data: url,
  213. success (res) {
  214. wx.showToast({
  215. title: '已复制',
  216. });
  217. }
  218. });
  219. },
  220. gotoMiniprogram:function(){
  221. var appid="wx84b3feac6069eec3";
  222. var path='pages/index/index?SourceID=' + app.globalData.ProgramID;
  223. main.gotoMiniprogram(appid,path);
  224. },
  225. returnTop:function(){
  226. main.returnTop();
  227. },
  228. onShareTimeline: function () {
  229. return this.onShareAppMessage();
  230. },
  231. onUpdateTitle:function(){
  232. if (app.globalData.userInfo.UserID<6){
  233. wx.setNavigationBarTitle({
  234. title: "秒过分数线·小程序",
  235. });
  236. }
  237. },
  238. getWish:function(){
  239. var that = this;
  240. main.getData("GetMPSWish?WishType=school&SchoolID="+that.data.SchoolID, function (data) {
  241. if (data) {
  242. that.setData({
  243. WishList: data,
  244. });
  245. main.getData("GetMPSWish?WishType=person&UserID="+app.globalData.userInfo.UserID+"&SchoolID="+that.data.SchoolID, function (data2) {
  246. //debugger;
  247. if (data2 && data2.length>0) {
  248. app.globalData.MyWish=data2[0];
  249. that.setData({
  250. HasWish: true,
  251. });
  252. }
  253. else{
  254. that.setData({
  255. HasWish: false,
  256. });
  257. }
  258. that.getSchoolClickLike();
  259. });
  260. }
  261. });
  262. },
  263. getSchoolClickLike:function(){
  264. var that = this;
  265. var arr2=[];
  266. var arr=constant.arrUserSchoolClickLike;
  267. for(var j=0;j<arr.length;j++){
  268. arr[j].Count=0;
  269. }
  270. main.getData("GetMPSSchoolLikeNum?SchoolID="+that.data.SchoolID+"&UserID="+app.globalData.userInfo.UserID, function (data3) {
  271. if (data3 && data3.length>0) {
  272. for(var j=0;j<arr.length;j++){
  273. arr[j].Count=0;
  274. for(var i=0;i<data3.length;i++){
  275. if (arr[j].ID==data3[i].ClickLikeID){
  276. arr[j].Count=data3[i].Count;
  277. if (data3[i].Show==1)
  278. arr2.push(arr[j]);
  279. break;
  280. }
  281. }
  282. }
  283. arr2 = common.sort(arr2,"DESC", "Count","Int");
  284. }
  285. that.setData({
  286. UserSchoolClickLike: arr,
  287. UserSchoolClickLike2: arr2,
  288. });
  289. });
  290. },
  291. clickLikeSchool:function(){
  292. this.setData({
  293. IsShowClickLike:true,
  294. });
  295. },
  296. cancelLikeSchool:function(){
  297. this.setData({
  298. IsShowClickLike:false,
  299. });
  300. },
  301. saveUserSchoolClickLike:function(event){
  302. var that=this;
  303. var id=event.currentTarget.dataset.id;
  304. main.getData("UpdateMPSUserSchoolLikeNum?UserID="+app.globalData.userInfo.UserID+"&SchoolID="+that.data.SchoolID+"&ClickLikeID="+id, function (data2) {
  305. that.getSchoolClickLike();
  306. that.setData({
  307. IsShowClickLike:false,
  308. });
  309. });
  310. },
  311. onShareAppMessage: function () {
  312. var that=this;
  313. var name="中考招生信息:";
  314. if (that.data.Info.SchoolType1=="初中")
  315. name+=that.data.Info.SchoolFullName;
  316. else
  317. name+=that.data.Info.SchoolShortName;
  318. return {
  319. title: name,
  320. path: app.globalData.SharePath+'?UserID=' + app.globalData.userInfo.UserID+'&type=school&ID=' + that.data.Info.ID,
  321. }
  322. },
  323. })