| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- 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,
- IsShowClickLike:false,
- },
- onLoad: function (options) {
- var that = this;
-
- that.setData({
- Containnerheight: main.getWindowHeight(),
- IsShow:app.globalData.userInfo.IsShow,
- 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;i<schoolList.length;i++){
-
- if (that.data.SchoolID==schoolList[i].ID){
- that.setData({
- IsCollect:true,
- });
- break;
- }
- }
- }
- //data.Website="http://www.gezhi.sh.cn/infoweb/index.aspx?wzid=2";
-
- if (data.Website && data.Website.length>26){
- 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";
- }
- data.PersonCount1=0;
- data.PersonCount2=0;
- for(var i=0;i<that.data.ScoreType.length;i++){
- if (data[that.data.ScoreType[i].Name] && data[that.data.ScoreType[i].Name][0] && data[that.data.ScoreType[i].Name][0].Total)
- data.PersonCount1+=data[that.data.ScoreType[i].Name][0].Total;
- if (data[that.data.ScoreType[i].Name] && data[that.data.ScoreType[i].Name][1] && data[that.data.ScoreType[i].Name][1].Total)
- data.PersonCount2+=data[that.data.ScoreType[i].Name][1].Total;
- }
-
-
- //debugger;
- that.setData({
- Info:data,
- ScoreTypeID:that.data.ScoreTypeID,
- List:list,
- IsListAll:isListAll,
- TailScore:that.data.TailScore,
- Title:data.SchoolType1,
- });
- that.checkListNull(that,list);
- }
- 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) {
- if (e.currentTarget.dataset.url=="school?PageType=school&ID="
- || e.currentTarget.dataset.url=="school?PageType=school&ID=0")
- return null;
- else{
- app.globalData.FeedbackUrl="school?id="+this.data.Info.ID;
- 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,
- });
-
- that.checkListNull(that,list);
-
- }
- else if (e.currentTarget.dataset.object=="Years"){
- var name=that.data.ScoreType[that.data.ScoreTypeID-1].Name;
- var list=[];
-
- if (e.currentTarget.dataset.index>0 && that.data.Info[name].length>e.currentTarget.dataset.index)
- list = that.data.Info[name][e.currentTarget.dataset.index].List;
- else if (e.currentTarget.dataset.index==0)
- list = that.data.Info[name][e.currentTarget.dataset.index].List;
- that.setData({
- List:list,
- YearIndex:e.currentTarget.dataset.index
- });
- that.checkListNull(that,list);
- }
- });
- },
- checkListNull:function(obj,list){
- var that=obj;
- if (list.length==0
- && that.data.YearIndex==0
- && that.data.ScoreTypeID==4){
-
- // wx.showModal({
- // title: '暂无公布',
- // showCancel:false,
- // content: '教育局暂未公布2024年1-15志愿信息,正式数据一般在7月公布,敬请期待。',
- // confirmText: '知道了',
- // complete: (res) => {
- // if (res.confirm) {
- // list=that.data.Info["1-15志愿"][1].List;
- // that.setData({
- // ScoreTypeID: 4,
- // YearIndex:1,
- // List:list,
- // });
- // var eventTemp={
- // currentTarget:{
- // dataset:{
- // object:"Years",
- // clicktype:"radio",
- // index:1,
- // }
- // }
- // }
- // main.onSelect(that,eventTemp,function(){});
- // }
- // }
- // });
-
- }
- },
-
- 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: '已复制',
- });
- }
- });
- },
- gotoMiniprogram:function(){
- var appid="wx84b3feac6069eec3";
- var path='pages/index/index?SourceID=' + app.globalData.ProgramID;
- main.gotoMiniprogram(appid,path);
- },
- 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,
- });
- }
- that.getSchoolClickLike();
- });
- }
- });
- },
- getSchoolClickLike:function(){
- var that = this;
- var arr2=[];
- var arr=constant.arrUserSchoolClickLike;
- for(var j=0;j<arr.length;j++){
- arr[j].Count=0;
- }
- main.getData("GetMPSSchoolLikeNum?SchoolID="+that.data.SchoolID+"&UserID="+app.globalData.userInfo.UserID, function (data3) {
-
- if (data3 && data3.length>0) {
-
- for(var j=0;j<arr.length;j++){
- arr[j].Count=0;
- for(var i=0;i<data3.length;i++){
- if (arr[j].ID==data3[i].ClickLikeID){
- arr[j].Count=data3[i].Count;
-
- if (data3[i].Show==1)
- arr2.push(arr[j]);
- break;
- }
- }
- }
- arr2 = common.sort(arr2,"DESC", "Count","Int");
- }
- that.setData({
- UserSchoolClickLike: arr,
- UserSchoolClickLike2: arr2,
- });
- });
- },
- clickLikeSchool:function(){
- this.setData({
- IsShowClickLike:true,
- });
- },
- cancelLikeSchool:function(){
- this.setData({
- IsShowClickLike:false,
- });
- },
- saveUserSchoolClickLike:function(event){
- var that=this;
- var id=event.currentTarget.dataset.id;
- main.getData("UpdateMPSUserSchoolLikeNum?UserID="+app.globalData.userInfo.UserID+"&SchoolID="+that.data.SchoolID+"&ClickLikeID="+id, function (data2) {
- that.getSchoolClickLike();
- that.setData({
- IsShowClickLike: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,
- }
- },
- })
|