recruitment.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import constant from '../../utils/constant';
  4. const app = getApp();
  5. var DistrictName="";
  6. Page({
  7. data: {
  8. Years:constant.arrYear,
  9. YearIndex:0,
  10. District:[],
  11. ListNullData:false,
  12. PublicOrPrivate2:constant.arrPublicOrPrivate2,
  13. PanelType:1,//1是自主招生,2是国际班
  14. },
  15. onLoad: function (options) {
  16. var that = this;
  17. var districtID=0;
  18. var title="自招·市重点和特高";
  19. if (Number(options.PanelType)==2){
  20. districtID=-1;
  21. title="自招·国际和中外合办";
  22. }
  23. else{
  24. districtID=Number(options.DistrictID);
  25. var arr=[{ID:0,Name:"委属",CSS:""}];
  26. for(var i=0;i<constant.arrDistrict.length;i++){
  27. var obj={};
  28. obj.ID=Number(constant.arrDistrict[i].ID);
  29. obj.Name=constant.arrDistrict[i].Name.substr(0,2);
  30. obj.CSS="";
  31. arr.push(obj);
  32. }
  33. arr[districtID].CSS="Selected";
  34. DistrictName=arr[districtID].Name;
  35. }
  36. that.setData({
  37. Containnerheight: main.getWindowHeight(),
  38. District:arr,
  39. PanelType:options.PanelType,
  40. DistrictID:districtID,
  41. YearIndex:0,
  42. });
  43. wx.setNavigationBarTitle({
  44. title: title,
  45. });
  46. that.init();
  47. },
  48. init:function(){
  49. var that = this;
  50. var districtID=Number(that.data.DistrictID);
  51. var year=that.data.Years[that.data.YearIndex].Name;
  52. var scoreTypeID="自主招生";
  53. wx.showLoading();
  54. main.getData("GetMPSScore?ScoreYear="+year+"&ScoreType="+scoreTypeID+"&DistrictID="+districtID, function (data) {
  55. if (data) {
  56. for(var i=0;i<data.length;i++){
  57. var item=data[i];
  58. item.IsPublicOrPrivate=true;
  59. }
  60. for(var i=0;i<that.data.PublicOrPrivate2.length;i++){
  61. var item=that.data.PublicOrPrivate2[i];
  62. item.CSS="Selected";
  63. }
  64. that.setData({
  65. List:data,
  66. PublicOrPrivate2:that.data.PublicOrPrivate2,
  67. });
  68. }
  69. setTimeout(function(){
  70. wx.hideLoading();
  71. },800);
  72. });
  73. },
  74. onSelect:function(event){
  75. var that=this;
  76. main.onSelect(that,event,function(obj,e,result){
  77. if (e.currentTarget.dataset.object=="District"){
  78. that.setData({
  79. DistrictID:e.currentTarget.dataset.index,
  80. });
  81. that.init();
  82. }
  83. else if (e.currentTarget.dataset.object=="Years"){
  84. that.setData({
  85. YearIndex:e.currentTarget.dataset.index,
  86. });
  87. that.init();
  88. }
  89. else if (e.currentTarget.dataset.object=="PublicOrPrivate2"){
  90. var selectIndex=e.currentTarget.dataset.index;
  91. var selectText=that.data.PublicOrPrivate2[selectIndex].Name;
  92. var isSelect=that.data.PublicOrPrivate2[selectIndex].CSS=="Selected";
  93. var isNull=true;
  94. for(var i=0;i<that.data.List.length;i++){
  95. var item=that.data.List[i];
  96. if (selectText==item.PublicOrPrivate)
  97. item.IsPublicOrPrivate=isSelect;
  98. if (item.IsPublicOrPrivate)
  99. isNull=false;
  100. }
  101. that.setData({
  102. List:that.data.List,
  103. ListNullData:isNull,
  104. });
  105. }
  106. });
  107. },
  108. goto: function (e) {
  109. main.goto(e);
  110. },
  111. onShareTimeline: function () {
  112. return this.onShareAppMessage();
  113. },
  114. onShareAppMessage: function () {
  115. var that=this;
  116. var title="上海中招自主招生";
  117. if (that.data.DistrictID>=0)
  118. title="上海中招自主招生·"+DistrictName;
  119. return {
  120. title: title,
  121. path: app.globalData.SharePath + '?type=recruitment&PanelType='+that.data.PanelType+'&DistrictID='+that.data.DistrictID+'&UserID=' + app.globalData.userInfo.UserID,
  122. }
  123. },
  124. })