123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- app.controller('AppCtrl', [ '$rootScope', '$scope', '$http', '$localStorage', '$location', '$q', '$timeout', '$sce', function($rootScope, $scope, $http, $localStorage, $location, $q, $timeout, $sce) {
-
- $scope.StdReg = {};
- $scope.result = {};
- $scope.param = {};
-
- /***************************************************************************
- * Frame参数
- */
- $rootScope.frame = {
- CompanyName : '',
- FrameVersion : '2.0.0',
- WaitWindow : false
- };
- $rootScope.ArtStdReg = undefined;
- // 设置cookeis
- $rootScope.setLocalStorage = function(name, value) {
- $localStorage[name] = value;
- };
- // 获取cookies
- $rootScope.getLocalStorage = function(name) {
- return $localStorage[name];
- };
- // 内部跳转
- $rootScope.goLocation = function(url) {
- $location.path('app/' + url);
- };
- // 到首页
- $rootScope.goWechat = function(url) {
- window.location = './wechat.jsp';
- };
- $scope.closeWechat = function() {
- WeixinJSBridge.call('closeWindow');
- }
- $rootScope.showHtml = function(html) {
- var value = html.replace(/ /g, ' ').replace(/\n/g, '<br />');
- return $sce.trustAsHtml(value);
- }
- // Ajax统一请求函数
- $rootScope.ajaxRequest = function(params, fn) {
- if (params == undefined)
- params = {};
- if (params.data == undefined)
- params.data = {};
- if ($rootScope.ArtStdReg != undefined)
- params.data.std_id = $rootScope.ArtStdReg.std_id;
- var params = angular.extend({
- method : 'post'
- }, params);
- $http(params).then(function onSuccess(response) {
- // $.hideLoading();
- if (response == undefined)
- console.log(params);
- fn.call(undefined, response.data);
- });
- };
- // 将date转换成长时间串
- $rootScope.isAfterTime = function(date, now) {
- if (now == undefined)
- now = new Date();
- if (!angular.isDate(date))
- date = $rootScope.parseLongString(date);
- console.log(date.getTime() - now.getTime());
- return date.getTime() > now.getTime();
- };
- // 将date转换成长时间串
- $rootScope.longDateString = function(date) {
- if (date == undefined)
- date = new Date();
- if (angular.isDate(date))
- return date.toJSON();
- return "";
- };
- // 将date转换成长时间串
- $rootScope.longMinuteString = function(date) {
- return $rootScope.longDateString(date).substr(0, 15);
- };
- // 将日期转换成短时间串
- $rootScope.shortDateString = function(date) {
- if (date == undefined)
- return "";
- if (angular.isDate(date))
- date = date.toJSON();
- if (date.length > 10)
- return date.substr(0, 10);
- return date;
- };
- // 获取日期的时间串
- $rootScope.shortTimeString = function(date) {
- if (date == undefined)
- return "";
- if (angular.isDate(date))
- date = date.toJSON();
- if (date.length > 10)
- return date.substr(11, 5);
- return date;
- }
- // 将短日期时间串转换成日期
- $rootScope.parseShortString = function(date) {
- if (date == undefined)
- date = new Date();
- var str = $rootScope.shortDateString(date);
- return new Date(Date.parse(str.replace(/-/g, "/")));
- }
- // 将长时间串转化成日期
- $rootScope.parseLongString = function(date) {
- if (angular.isDate(date))
- return date;
- if (date == undefined || date.length != 19)
- return undefined;
- return new Date(Date.parse(date.replace(/-/g, "/")));
- }
- // 获取url参数
- $rootScope.GetQueryString = function(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null)
- return unescape(r[2]);
- return null;
- };
- $rootScope.initWinxinApi = function() {
- $rootScope.ajaxRequest({
- url : '../enrol/wx/config.htm',
- data : {
- url : location.href.split('#')[0]
- }
- }, function(data) {
- var obj = angular.extend({
- debug : false
- }, data.entity, {
- jsApiList : [ 'checkJsApi', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'translateVoice', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'onVoicePlayEnd', 'pauseVoice', 'stopVoice', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard' ]
- });
- wx.error(function(res) {
- // 加载直到成功为止
- $rootScope.initWinxinApi();
- return false;
- });
- wx.config(obj);
- wx.ready(function() {
- wx.hideOptionMenu();
- wx.hideAllNonBaseMenuItem();
- });
- });
- };
- $rootScope.getParamValue = function(paran_name, default_value) {
- if ($rootScope.FrameParam[paran_name] == undefined)
- return default_value;
- return $rootScope.FrameParam[paran_name];
- }
- $rootScope.checkParamValue = function(param_name, default_value, check_value) {
- var value = $rootScope.getParamValue(param_name, default_value);
- if ((value + '') == (check_value + ''))
- return true;
- return false;
- }
- $rootScope.InitStatus = false;
- $rootScope.loginSuccess = false;
- $rootScope.getUserInfo = function() {
- // 请求用户信息
- $.ajax({
- url : '../enrol/wx/user/info.htm',
- async : false,
- type : "POST",
- dataType : "json",
- data : {
- code : $rootScope.GetQueryString('code')
- },
- success : function(data) {
- $.hideLoading();
- if (data.success == false) {
- $.alert(data.errorMsg, function() {
- WeixinJSBridge.call('closeWindow');
- });
- // if(data.login == false) {
- // $.alert("微信加载出现问题,请退出重新进入公众号!", function() {
- // WeixinJSBridge.call('closeWindow');
- // });
- // return;
- // }else {
- // $.alert(data.errorMsg, function() {
- // WeixinJSBridge.call('closeWindow');
- // });
- // return;
- // }
- return;
- }
- // 初始化成功
- $rootScope.InitStatus = true;
- $rootScope.loginSuccess = true;
- // 初始化参数信息
- $rootScope.FrameParam = {};
- angular.forEach(data.map.FrameParamArray, function(param) {
- $rootScope.FrameParam[param.param_name] = param.param_value;
- });
- $rootScope.StdTypeArray = data.map.StdTypeArray;
- // 设置微信抬头
- if ($rootScope.FrameParam.EnrolTitle) {
- document.title = $rootScope.FrameParam.EnrolTitle;
- }
- // 判断当前考务状态
- if ($rootScope.FrameParam.ArtStatus == 'Config') {
- // 未开放报名,
- $rootScope.InitStatus = false;
- WeixinJSBridge.call('closeWindow');
- return;
- }
- $rootScope.ArtStdReg = data.map.StdReg;
- $rootScope.WxUser = data.map.WxUser;
- // --std_info
- if (data.map.StdReg != undefined) {
- // 处理考生信息
- if (data.map.StdReg.reg_status == 'IdCard') {
- // 上传了证件照片
- $rootScope.goLocation('std/reg');
- } else if (data.map.StdReg.reg_status == 'NoCrownPhoto') {
- // 上传免冠照片
- $rootScope.goLocation('std/reg');
- } else if (data.map.StdReg.std_score_file == 'firstLogin') {
- $rootScope.goLocation('std/info');
- } else {
- $rootScope.goLocation('main');
- }
- } else {
- if ($rootScope.FrameParam.AllowStdReg == 'InActive') {
- // 不允许考生自行注册
- if($rootScope.FrameParam.GeneralExam == 'Active') {
- $rootScope.goLocation('std/wybinding');
- } else {
- $rootScope.goLocation('std/binding');
- }
- } else {
- $rootScope.goLocation('std/reg');
- }
- return;
- }
- },
- error : function(data) {
- }
- });
- }
- $rootScope.getJudgerInfo = function() {
- $.ajax({
- url : '../judge/wx/judger/info.htm',
- async : false,
- type : "POST",
- dataType : "json",
- data : {
- code : $rootScope.GetQueryString('code')
- },
- success : function(data) {
- $.hideLoading();
- if (data.success == false) {
- $.alert(data.errorMsg, function() {
- WeixinJSBridge.call('closeWindow');
- });
- return;
- }
- // 初始化成功
- $rootScope.InitStatus = true;
- $rootScope.loginSuccess = true;
- // 初始化参数信息
- $rootScope.FrameParam = {};
- angular.forEach(data.map.FrameParamArray, function(param) {
- $rootScope.FrameParam[param.param_name] = param.param_value;
- });
- $rootScope.WxUser = data.map.WxUser;
- if (data.map.WxUser) {
- $rootScope.goLocation('judge');
- }
- /*
- * else{ $rootScope.goLocation('judge/binding'); }
- */
- },
- error : function(data) {
- }
- });
- }
- // $rootScope.initWinxinApi();
- // if (location.search.indexOf('?judge') != -1) {
- // $rootScope.getJudgerInfo();
- // } else {
- // $rootScope.getUserInfo();
- // }
- $rootScope.isProvinceStd = function() {
- if ($rootScope.ArtStdReg.std_province == $rootScope.FrameParam.SchoolProvince)
- return true;
- return false;
- }
- $rootScope.getTimeName = function(time_type) {
- if (time_type + '' == '1')
- return '上午';
- else if (time_type + '' == '2')
- return '下午';
- if (time_type + '' == '3')
- return '晚上';
- else
- return time_type;
- }
- $rootScope.uploadStdMaterial = function(material_type, fn, enrol_id) {
- wx.chooseImage({
- count : 1, // 默认9
- sizeType : [ 'compressed' ], // 可以指定是原图还是压缩图,默认二者都有'original',
- sourceType : [ 'album', 'camera' ], // 可以指定来源是相册还是相机,默认二者都有
- success : function(res) {
- var localIds = res.localIds;
- wx.uploadImage({
- localId : localIds[0], // 需要上传的图片的本地ID,由chooseImage接口获得
- isShowProgressTips : 1, // 默认为1,显示进度提示
- success : function(serverRes) {
- var serverId = serverRes.serverId; // 返回图片的服务器端ID
- $.showLoading("考生材料上传中,请稍候...")
- // 上传成功,去服务器取图片
- var vData = {
- std_id : $rootScope.ArtStdReg.std_id,
- media_id : serverId,
- material_type : material_type
- };
- if (enrol_id)
- vData.enrol_id = enrol_id;
- $rootScope.ajaxRequest({
- url : '../enrol/std/material/upload.htm',
- method : 'post',
- data : vData
- }, function(data) {
- $.hideLoading();
- $rootScope[material_type] = data.entity;
- if (material_type == 'NoCrownPhoto') {
- $rootScope.ArtStdReg.std_image = data.entity.material_file;
- }
- if (fn)
- fn.call(undefined, data);
- });
- },
- fail : function(error) {
- $.alert('图片服务器暂时无法访问,请稍侯再试', '错误提示');
- }
- });
- }
- });
- }
-
- $rootScope.getParam = function() {
- $rootScope.ajaxRequest({
- url: '../wish/std/get/param.htm',
- method: 'post'
- },function(data) {
- $scope.param = data;
- });
- }
- $rootScope.getParam();
-
-
- $rootScope.searchStd = function() {
-
- var url = '../wish/std/search/all.htm';
- if($scope.param.map.schoolCode === '10331') {
- url = 'wish/std/searchNy.htm';
- }
- $rootScope.ajaxRequest({
- url : url,
- method : 'post',
- data : $scope.StdReg
- },function(data) {
- if(!data.map) {
- $scope.currStep = "noAdmis";
- $scope.result.std_name = $scope.StdReg.std_name;
- } else {
- $scope.currStep = "admis";
- $scope.result = data.map;
- }
- });
- }
-
- } ]);
|