import common from '../../utils/util'; import main from '../../utils/main'; import constant from '../../utils/constant'; const app = getApp(); Page({ data: { PageType:"school", ScoreTypeID:1,//四种得分类型 IsFold:false, Years:constant.arrYear, YearIndex:0, ImagePath: app.globalData.uploadImageUrl, ScoreType:constant.arrScoreType, TailScore:constant.arrTailScore, }, onLoad: function (options) { var that = this; that.setData({ Containnerheight: main.getWindowHeight(), SchoolID:options.ID, IsCollect:false, HasWish:false, }); if (!options.ID){ wx.navigateBack({ delta: 1, }); } else that.init(); }, onShow:function(){ this.getWish(); }, init:function(){ var that = this; wx.showLoading({title:"加载中"}); main.getData("GetMPSSchoolInfo?SchoolID="+that.data.SchoolID, function (data) { if (data) { var list=[]; that.data.ScoreTypeID=1; if (data['1-15志愿'] && !(data['自主招生'])){ that.data.ScoreTypeID=4; var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name; list=data[name][that.data.YearIndex].List; } else if (data['名额到校'] && data.SchoolType1=='初中'){ that.data.ScoreTypeID=3; var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name; list=data[name][that.data.YearIndex].List; } wx.setNavigationBarTitle({ title: data.SchoolType1, }); var schoolList=wx.getStorageSync('CollectList'); if (schoolList && schoolList["收藏的"+data.SchoolType1]){ schoolList=schoolList["收藏的"+data.SchoolType1]; for(var i=0;i26){ var str1=data.Website.substr(0,26); var str2=data.Website.substr(26); data.WebsiteStr=str1+"\n"+str2; } else data.WebsiteStr=data.Website; if (data.ImageOther) data.ImageOtherStr=data.ImageOther.join(","); //将保存的用户习惯(显示列表样式)提取出来 var isListAll=wx.getStorageSync('TailScore'); if (isListAll){ that.data.TailScore[0].CSS="Selected"; } that.setData({ Info:data, ScoreTypeID:that.data.ScoreTypeID, List:list, IsListAll:isListAll, TailScore:that.data.TailScore, Title:data.SchoolType1, }); } setTimeout(function(){ wx.hideLoading(); },800); }); }, collectSchool:function(e){ var that=this; var IsCollect=Number(e.currentTarget.dataset.index); main.getData("UpdateMPSSchoolCollect?SchoolID="+that.data.SchoolID+"&UserID="+app.globalData.userInfo.UserID+"&IsCollect="+IsCollect, function (data) { var title="收藏完成"; if (!IsCollect) title="取消收藏完成"; wx.showToast({ title: title, }); that.setData({ IsCollect:IsCollect, }); wx.removeStorageSync('CollectList'); //获得收藏学校数据 main.getCollect(); }); }, goto: function (e) { // var url=e.currentTarget.dataset.url; // if (url.indexOf("PageType=school")>0){ // url=url.replace("PageType=school&",""); // if (url.substr(url.length-3)!="ID="){ // wx.redirectTo({ // url: url, // }); // } // } // else{ // var b=true; // if (e.currentTarget.dataset.url.substr(0,3)=="map" && !e.currentTarget.dataset.isgoto) // b=false; // if (b) // main.goto(e); // } main.goto(e); }, onSelect:function(event){ var that=this; main.onSelect(that,event,function(obj,e,result){ if (e.currentTarget.dataset.object=="TailScore"){ that.setData({ IsListAll: result, }); wx.setStorageSync('TailScore', result); } else if (e.currentTarget.dataset.object=="ScoreType"){ var name=that.data.ScoreType[e.currentTarget.dataset.index].Name; var list=[]; if (that.data.Info[name]) list=that.data.Info[name][that.data.YearIndex].List; that.setData({ ScoreTypeID: e.currentTarget.dataset.index+1, List:list, }); } else if (e.currentTarget.dataset.object=="Years"){ var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name; var list=that.data.Info[name][e.currentTarget.dataset.index].List; that.setData({ List:list, YearIndex:e.currentTarget.dataset.index }); } }); }, onFold:function(e){ var that=this; that.setData({ IsFold: !that.data.IsFold, }); }, copyUrl:function(e){ var url=e.currentTarget.dataset.url; wx.setClipboardData({ data: url, success (res) { wx.showToast({ title: '已复制', }); } }); }, returnTop:function(){ main.returnTop(); }, onShareTimeline: function () { return this.onShareAppMessage(); }, onUpdateTitle:function(){ if (app.globalData.userInfo.UserID<6){ wx.setNavigationBarTitle({ title: "秒过分数线·小程序", }); } }, getWish:function(){ var that = this; main.getData("GetMPSWish?WishType=school&SchoolID="+that.data.SchoolID, function (data) { if (data) { that.setData({ WishList: data, }); main.getData("GetMPSWish?WishType=person&UserID="+app.globalData.userInfo.UserID+"&SchoolID="+that.data.SchoolID, function (data2) { //debugger; if (data2 && data2.length>0) { app.globalData.MyWish=data2[0]; that.setData({ HasWish: true, }); } else{ that.setData({ HasWish: false, }); } }); } }); }, onShareAppMessage: function () { var that=this; var name="中考招生信息:"; if (that.data.Info.SchoolType1=="初中") name+=that.data.Info.SchoolFullName; else name+=that.data.Info.SchoolShortName; return { title: name, path: app.globalData.SharePath+'?UserID=' + app.globalData.userInfo.UserID+'&type=school&ID=' + that.data.Info.ID, } }, })