| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- 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;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";
- }
- 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,
- }
- },
- })
|