| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import constant from '../../utils/constant';
- const app = getApp();
- var canPage=true;
- Page({
- data: {
- PageType:"scoreline",
- DistrictID:1,
- ScoreTypeID:1,
- Years:constant.arrYear,
- YearIndex:0,
- IsSearch:false,
- Accommodation:constant.arrAccommodation,
- TailScore:constant.arrTailScore,
- PublicOrPrivate:constant.arrPublicOrPrivate,
- LocalOrNolocal:constant.arrLocalOrNolocal,
- },
- onLoad: function (options) {
- var that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- IsShow:app.globalData.userInfo.IsShow,
- ScoreTypeID:options.ScoreTypeID,
- DistrictID:options.DistrictID,
- YearIndex:options.YearIndex,
- PageType:options.PageType,
- SchoolType1:options.SchoolType1,
- IsSearch:false,
- IsFocus:false,
- PageCount:app.globalData.PageCount,//翻页数
- });
- var b=true;
- var title="";
- if (options.PageType=="collect"){
- var collectSchool=wx.getStorageSync('CollectList');
- var schoolCount=0;
- if (options.SchoolType1=="高中")
- schoolCount=collectSchool.收藏的高中.length;
- else
- schoolCount=collectSchool.收藏的初中.length;
- that.setData({
- SchoolCount:schoolCount,
- });
- if (schoolCount==0){
- that.setData({
- List:[],
- });
- b=false;
- }
- else{
- var arr=[];
-
- var name="";
- for(var i=0;i<constant.arrDistrict.length;i++){
- var obj={};
- obj.ID=Number(constant.arrDistrict[i].ID);
- obj.Name=constant.arrDistrict[i].Name.substr(0,2);
- obj.CSS="";
- arr.push(obj);
- }
- that.setData({
- SchoolType1:options.SchoolType1,
- District:arr,
- DistrictName:name,
- });
- }
- //debugger;
- //title="对比·"+options.SchoolType1+"·"+that.data.District[that.data.DistrictID-1].Name;
- title="对比·"+options.SchoolType1;
- }
- else{
- title=constant.arrScoreType[that.data.ScoreTypeID-1].Name+'·'+constant.arrDistrict[that.data.DistrictID-1].Name;
- }
- wx.setNavigationBarTitle({
- title: title,
- });
- that.setData({
- Title: title,
- });
-
- if (b)
- that.init();
-
- },
- onPullDownRefresh: function () {
- var that=this;
- //debugger;
- wx.redirectTo({
- url: 'scoreline?PageType='+that.data.PageType+'&ScoreTypeID='+that.data.ScoreTypeID+'&SchoolType1='+that.data.SchoolType1+'&DistrictID='+that.data.DistrictID+"&YearIndex="+that.data.YearIndex,
- })
- wx.stopPullDownRefresh();
- },
- init:function(){
- var that = this;
- var districtID=Number(that.data.DistrictID);
- var year=that.data.Years[that.data.YearIndex].Name;
- for(var i=0;i<that.data.Years.length;i++){
- that.data.Years[i].CSS="";
- }
- that.data.Years[that.data.YearIndex].CSS="Selected";
- that.setData({
- IsSearch:false,
- IsFocus:false,
- SearchNull:false,
- ContrastNull:false,
- InputValue:"",
- Years:that.data.Years,
- });
-
- var url="";
- var canSelect=true;
- if (that.data.PageType=="collect"){
- if (districtID==-1 && that.data.SchoolType1=="高中")
- canSelect=false;
- url="GetMPSScoreByCollect?SchoolType1="+that.data.SchoolType1+"&UserID="+app.globalData.userInfo.UserID+"&ScoreYear="+year+"&DistrictID="+districtID;
- }
- else{
- canSelect=true;
- var scoreTypeID=constant.arrScoreType[that.data.ScoreTypeID-1].Name;
- url="GetMPSScore?ScoreYear="+year+"&ScoreType="+scoreTypeID+"&DistrictID="+districtID;
- }
- if (canSelect){
- wx.showLoading({
- title: '加载中',
- });
- main.getData(url, function (data) {
- if (data) {
-
- for(var i=0;i<data.length;i++){
- var item=data[i];
- item.IsAccommodation=true;
- item.IsPublicOrPrivate=true;
- item.IsLocalOrNolocal=true;
- item.IsSearchResult=true;
- }
-
- // 是否住宿全部选中
- for(var i=0;i<constant.arrAccommodation.length;i++)
- constant.arrAccommodation[i].CSS="Selected";
-
- //若是高中收藏对比
- data=realData2(that,data);
- //名额到校将收藏初中提前显示
- data=realData(that,data);
-
- //将保存的用户习惯(显示列表样式)提取出来
- var isListAll=wx.getStorageSync('TailScore');
- if (isListAll){
- that.data.TailScore[0].CSS="Selected";
- }
-
- var pageCount=data.length;
- if (that.data.ScoreTypeID==3)
- pageCount=app.globalData.PageCount;
-
- //debugger;
- var isContrastNull=false;
- if (data.length==0 && that.data.SchoolCount>0)
- isContrastNull=true;
-
- that.setData({
- Accommodation:constant.arrAccommodation,
- List:data,
- IsSearch:false,
- IsListAll:isListAll,
- TailScore:that.data.TailScore,
- PageCount:pageCount,
- PageFilterCount:data.length,
- ContrastNull:isContrastNull,
- });
-
- }
- var timeTimeout=2000;
- if (that.data.ScoreTypeID==3 && that.data.DistrictID==11){
- timeTimeout=3000;
- if (app.globalData.IsAndroid)
- timeTimeout=4000;
- }
- setTimeout(function(){
- wx.hideLoading();
- },timeTimeout);
- });
- }
-
- function realData(obj,data){
- //名额到校将收藏初中提前显示
- if (obj.data.ScoreTypeID==3){
- //debugger;
- var schoolList=wx.getStorageSync('CollectList')["收藏的初中"];
- if (schoolList && schoolList.length>0){
- var arr=[];
- for(var i=0;i<data.length;i++){
- var item=data[i];
- for(var j=0;j<schoolList.length;j++){
- if (item.SchoolOfGraduation==schoolList[j].ID){
- item.IsCollect=true;
- arr.push(item);
- data.splice(i,1);
- i--;
- break;
- }
- }
- }
- if (arr.length>0){
- for(var i=arr.length-1;i>=0;i--){
- data.unshift(arr[i]);
- }
- }
- }
- }
- return data;
- }
- function realData2(obj,data){
- //若是高中收藏对比
- if (obj.data.SchoolType1=='高中' && obj.data.PageType=="collect"){
- var schoolList=wx.getStorageSync('CollectList')["收藏的高中"];
- for(var i=0;i<data.length;i++){
- var item=data[i];
- for(var j=0;j<schoolList.length;j++){
- if (item.ID==schoolList[j].ID){
- item.SchoolFullName=schoolList[j].SchoolFullName;
- item.District=schoolList[j].District;
- item.SchoolType2Short=schoolList[j].SchoolType2Short;
- item.PublicOrPrivate=schoolList[j].PublicOrPrivate;
- schoolList[j].IsExist=true;
- }
- }
- }
- var arr=[];
- for(var i=0;i<schoolList.length;i++){
- if (!schoolList[i].IsExist)
- arr.push(schoolList[i]);
- }
-
- obj.setData({
- ListNullData:arr,
- });
- var title="对比·"+obj.data.SchoolType1+"·"+obj.data.District[that.data.DistrictID-1].Name;
- wx.setNavigationBarTitle({
- title: title,
- });
- }
- return data;
- }
- },
- onPage: function (e) {
- var that=this;
- var count=that.data.PageCount;
- if (canPage && count<that.data.List.length){
- canPage=false
- count+=app.globalData.PageCount;
- that.setData({
- PageCount:count,
- });
- setTimeout(function(){
- canPage=true;
- },2000);
- }
- },
- onSelect:function(event){
- var that=this;
- main.onSelect(that,event,function(obj,e,result){
- //显示大图列表还是全部列表
- if (e.currentTarget.dataset.object=="TailScore"){
- wx.showLoading({
- title:"加载中",
- mask:true,
- });
- that.setData({
- IsListAll: result,
- });
- setTimeout(function(){
- wx.hideLoading();
- },2000);
- wx.setStorageSync('TailScore', result);
- }
- //选择年份
- else if (e.currentTarget.dataset.object=="Years"){
- if (that.data.PageType=="collect")
- that.data.DistrictID=-1;
- wx.redirectTo({
- url: 'scoreline?PageType='+that.data.PageType+'&SchoolType1='+that.data.SchoolType1+'&ScoreTypeID='+that.data.ScoreTypeID+'&DistrictID='+that.data.DistrictID+"&YearIndex="+e.currentTarget.dataset.index,
- });
- }
- //选择公办和民办
- else if (e.currentTarget.dataset.object=="PublicOrPrivate"){
- var selectIndex=e.currentTarget.dataset.index;
- var selectText=that.data.PublicOrPrivate[selectIndex].Name;
- var isSelect=that.data.PublicOrPrivate[selectIndex].CSS=="Selected";
-
-
- var isNull=true;
- for(var i=0;i<that.data.List.length;i++){
- var item=that.data.List[i];
- if (selectText==item.PublicOrPrivate)
- item.IsPublicOrPrivate=isSelect;
- if (item.IsPublicOrPrivate)
- isNull=false;
- }
- that.setData({
- List:that.data.List,
- SearchNull:isNull,
- });
- }
- //选择本地和非本地
- else if (e.currentTarget.dataset.object=="LocalOrNolocal"){
- var selectIndex=e.currentTarget.dataset.index;
- var isNull=true;
- for(var i=0;i<that.data.List.length;i++){
- var item=that.data.List[i];
- item.IsLocalOrNolocal=false;
- if (selectIndex==0)
- item.IsLocalOrNolocal=true;
- else if (selectIndex==1 && item.DistrictNameArea==constant.arrDistrict[that.data.DistrictID-1].Name)
- item.IsLocalOrNolocal=true;
- else if (selectIndex==2 && item.DistrictNameArea!=constant.arrDistrict[that.data.DistrictID-1].Name)
- item.IsLocalOrNolocal=true;
- }
- that.setData({
- List:that.data.List,
- });
- }
- //选择寄宿
- else if (e.currentTarget.dataset.object=="Accommodation"){
- var selectIndex=e.currentTarget.dataset.index;
- var selectText=that.data.Accommodation[selectIndex].Name;
- var isSelect=that.data.Accommodation[selectIndex].CSS=="Selected";
- var isNull=true;
- for(var i=0;i<that.data.List.length;i++){
- var item=that.data.List[i];
- if (selectText==item.Accommodation)
- item.IsAccommodation=isSelect;
-
- if (item.IsAccommodation)
- isNull=false;
- }
-
- that.setData({
- List:that.data.List,
- SearchNull:isNull,
- });
- }
- //选择区
- else if (e.currentTarget.dataset.object=="District"){
- that.setData({
- DistrictID:e.currentTarget.dataset.index+1,
- DistrictName:constant.arrDistrict[e.currentTarget.dataset.index].Name,
- });
- that.init();
- }
- });
- },
- showSearch:function(){
- var that=this;
- that.setData({
- IsSearch:true,
- IsFocus:true,
- });
- },
- clearInput:function(){
- var that=this;
- that.bindKeyInput({detail:{value:""}});
- that.setData({
- IsSearch:false,
- IsFocus:false,
- SearchNull:false,
- ContrastNull:false,
- });
- },
- clearInput2:function(){
- var that=this;
- that.bindKeyInput({detail:{value:""}});
- that.setData({
- IsSearch:true,
- IsFocus:true,
- });
- },
- bindKeyInput:function(e){
- var inputValue=e.detail.value;
- var that=this;
- var isNull=true;
- var count=0;
- for(var i=0;i<that.data.List.length;i++){
- var item=that.data.List[i];
- if (inputValue){
- if (item.SchoolFullNameJunior.indexOf(e.detail.value)>=0){
- item.IsSearchResult=true;
- count++;
- isNull=false;
- }
- else
- item.IsSearchResult=false;
- }
- else{
- item.IsSearchResult=true;
- count++;
- }
- }
-
- that.setData({
- List:that.data.List,
- SearchNull:isNull,
- InputValue:inputValue,
- PageFilterCount:count,
- });
- },
- goto: function (e) {
- main.goto(e);
- },
- returnTop:function(){
- main.returnTop();
- },
- onShareTimeline: function () {
- return this.onShareAppMessage();
- },
- onShareAppMessage: function () {
- var that=this;
- var title="上海中招"+that.data.Title;
- var path=app.globalData.SharePath+'?UserID=' + app.globalData.userInfo.UserID+'&type=scoreline&ScoreTypeID='+that.data.ScoreTypeID+'&ID=' + that.data.DistrictID+"&YearIndex="+that.data.YearIndex;
- if (that.data.PageType=="collect"){
- title=app.globalData.ShareTitle;
- path=app.globalData.SharePath+'?UserID=' + app.globalData.userInfo.UserID;
- }
- return {
- title: title,
- path: path,
- }
- }
- })
|