123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- var urls = function() {
- //var host = "http://192.168.100.3:7979";
- //var host = "http://192.168.5.103:7979";
- //var host = "http://192.168.5.104:8080/djfp";
- //var host = "http://oa.gogo.sh:7979/djfp";
- var host = "http://111.12.52.222:7979";
- var url = {
- "path": host,
- "sendMessage": host + "/app/user/sendMessage", //发送注册短信
- "findPassMessage": host + "/app/user/findPassMessage", //发送找回密码短信
- "login": host + "/app/user/login", //用户登录
- "edit_pass": host + "/app/user/edit_pass", //找回密码
- "register": host + "/app/user/register", //用户注册
- "certification": host + "/app/user/certification", //企业重新认证
- "userInfo": host + "/app/user/userInfo", //用户信息
- "edit_info": host + "/app/user/edit", //编辑用户信息
- "user_upload": host + "/app/user/uploadHeader", //用户上传头像
- "uploadFj": host + "/app/user/uploadFj", //上传营业执照
- "uploadPhoto": host + "/app/resume/uploadPhoto", //上传简历照片
- "main": host + "/app/main", //首页加载数据
- "column": host + "/app/column", //文章栏目
- "news_list": host + "/app/news/jsonList", //新闻列表
- "news_detail": host + "/app/news/detail", //新闻详情
- "resume_detail": host + "/app/resume/my_resume", //简历信息
- "resume_list": host + "/app/resume/resume_list", //企业收到的简历列表
- "resume_ignore": host + "/app/resume/resume_ignore", //企业用户忽略该简历
- "resume_preview": host + "/app/resume/resume_preview", //企业预览用户的简历
- "resume_save": host + "/app/resume/save_resume", //保存简历
- "resume_delivery": host + "/app/resume/resume_delivery", //投递简历
- "resume_delivery_list": host + "/app/resume/resume_delivery_list", //用户投递简历列表
- "resume_delivery_delete": host + "/app/resume/resume_delivery_delete", //用户删除投递的简历
- "position_push": host + "/app/position/push_position", //发布职位
- "position_json_list": host + "/app/position/jsonList", //全部职位列表
- "position_list": host + "/app/position/position_list", //企业用户发布的职位列表
- "position_detail": host + "/app/position/position_detail", //职位预览
- "position_delete": host + "/app/position/position_delete", //删除职位
- "position_type_list": host + "/app/position_type/list", //职位分类列表
- "position_type_add": host + "/app/position_type/add", //添加职位分类
- "position_type_delete": host + "/app/position_type/delete", //删除职位分类
- "feedback": host + "/app/user/feedback", //意见反馈
- "agreement": host + "/app/other/agreement", //服务条款
- "guide": host + "/app/other/guide/", //萌新必读2
- "message_list": host + "/app/message/message_list", //消息列表
- "message_read": host + "/app/message/message_read", //消息设置已读
- "message_delete": host + "/app/message/message_delete", //删除消息
- };
- return url;
- }
- /**
- *一些常用参数
- */
- function getConstant() {
- var str = {
- "phone": "10086",
- "copyright": "xxx公司版权所有"
- }
- return str;
- }
- /**
- * i
- * @param 窗口id
- * @param 窗口地址url
- * @param 传递参数
- * @param 跳转动画
- */
- function open(id, url, para, anim) {
- anim == null || undefined ? 'pop-in' : anim;
- mui.openWindow({
- id: id,
- url: url,
- show: {
- aniShow: anim
- },
- styles: {
- popGesture: 'hide'
- },
- waiting: {
- autoShow: true,
- title: '正在加载...',
- },
- extras: {
- param: para
- },
- createNew: true,
- hardwareAccelerated: true
- });
- }
- /**
- *判断是否登录
- */
- var hasLogin = function() {
- var user = localStorage.getItem("user");
- return user == null || user == '' ? false : true;
- }
- /**
- *软件第一次运行
- */
- var first = function() {
- var f = localStorage.getItem("first");
- return f == null || f == '' ? true : false;
- }
- /**
- *获取用户信息
- */
- var getUser = function() {
- var user = localStorage.getItem("user");
- return JSON.parse(user);
- }
- /**
- *获取用户简历
- */
- var getResume = function() {
- var resume = localStorage.getItem("resume");
- return JSON.parse(resume);
- }
- var getToken = function() {
- return localStorage.getItem("token");
- }
- /**
- *
- * @param 请求url
- * @param 请求参数
- * @param 回调回调
- */
- function request(url, param, callback) {
- plus.nativeUI.showWaiting("正在加载...");
- mui.ajax(url, {
- data: param,
- dataType: 'json', //服务器返回json格式数据
- type: 'post', //HTTP请求类型
- contentType: "application/x-www-form-urlencoded; charset=utf-8",
- beforeSend: function(req) {
- if(hasLogin()) {
- req.setRequestHeader("token", getToken());
- req.setRequestHeader("phone", getUser().account);
- }
- },
- success: callback,
- error: function(xhr, type, errorThrown) {
- //plus.nativeUI.closeWaiting();
- }
- });
- }
- //手机格式验证
- function isPhone(phone) {
- var reg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
- if(reg.test(phone)) {
- return true;
- } else {
- return false;
- }
- return false;
- }
- //学历
- function xl() {
- return ['小学', '初级中学', '高级中学', '中专', '专科', '本科', '硕士研究生', '博士研究生'];
- }
- //学位
- function xw() {
- return ['无', '学士学位', '硕士学位', '博士学位'];
- }
- //工作经验
- function gzyl() {
- return ['不限', '一年以下', '1-2年', '2-3年', '3-5年', '6-7年', '8-10年', '10年以上'];
- }
- //学历要求
- function xlyq() {
- return ['不限', '高中', '技校', '中专', '大专', '本科', '硕士', '博士'];
- }
- //薪资待遇
- function xzdy() {
- return ['不限', '500-1000', '1000-2000', '2000-3000', '3000-5000', '5000-8000', '8000-12000', '12000-20000', '20000-25000', '25000以上'];
- }
- //工作经验
- function gzyl() {
- return ['不限', '1年以下', '1-2年', '2-3年', '3-5年', '6-7年', '8-10年', '10年以上'];
- }
- /**
- * 复制文本到剪贴板
- * @param {Object} copy_content
- */
- function copy(copy_content) {
- //判断是安卓还是ios
- if(mui.os.ios) {
- //ios
- var UIPasteboard = plus.ios.importClass("UIPasteboard");
- var generalPasteboard = UIPasteboard.generalPasteboard();
- //设置/获取文本内容:
- generalPasteboard.plusCallMethod({
- setValue: "" + copy_content,
- forPasteboardType: "public.utf8-plain-text"
- });
- generalPasteboard.plusCallMethod({
- valueForPasteboardType: "public.utf8-plain-text"
- });
- } else {
- //安卓
- var Context = plus.android.importClass("android.content.Context");
- var main = plus.android.runtimeMainActivity();
- var clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
- plus.android.invoke(clip, "setText", "" + copy_content);
- }
- }
- /**
- * 初始化剪裁
- * @param {Object} ratio 裁剪框比例1是正方形,0NaN是无限制,16:9/4:3/2:3
- * @param {Object} path 剪裁图像路径
- */
- function getClipper(ratio, path) {
- var cropper = null;
- document.getElementById("clipp").style.display = 'block';
- document.getElementById("image").src = path;
- var image = document.getElementById("image");
- cropper = new Cropper(image, {
- aspectRatio: ratio,
- viewMode: 1,
- });
- return cropper;
- }
- /**
- * 直接拍照
- * @param callback
- */
- function takePhoto(callback) {
- mui('#picture').popover('toggle');
- var cmr = plus.camera.getCamera();
- var res = cmr.supportedImageResolutions[0];
- var fmt = cmr.supportedImageFormats[0];
- cmr.captureImage(callback, function(error) {}, {
- resolution: res,
- format: fmt
- });
- }
- /**
- 从相册选择照片,返回files[]数组地址
- * @param limit 选择数量
- * @param callback
- * @param limit 数量
- */
- function pickImg(callback, limit) {
- mui('#picture').popover('toggle');
- plus.gallery.pick(callback, function(error) {}, {
- multiple: true,
- maximum: limit,
- system: false
- });
- }
- /**
- * 图片上传
- * @param url 上传地址
- * @param callback
- */
- function upload(url, path, callback) {
- var task = plus.uploader.createUpload(url, {
- method: "POST",
- blocksize: 204800,
- priority: 100
- }, callback);
- task.addFile(path, {
- key: 'img'
- });
- task.start();
- }
- /**
- * 图片压缩
- * @param callback
- * @param path 压缩地址
- * @param per 压缩率
- */
- function compress(callback, path, per) {
- plus.nativeUI.showWaiting("正在上传...");
- var name = path.substr(path.lastIndexOf('/') + 1);
- plus.zip.compressImage({
- src: path,
- dst: '_doc/' + name,
- width: "75%",
- overwrite: true
- }, callback,
- function(error) {});
- }
- function deleteEmptyProperty(object) {
- for(var i in object) {
- var value = object[i];
- if(typeof value === 'object') {
- if(Array.isArray(value)) {
- if(value.length == 0) {
- delete object[i];
- continue;
- }
- }
- this.deleteEmptyProperty(value);
- if(this.isEmpty(value)) {
- delete object[i];
- }
- } else {
- if(value === '' || value === null || value === undefined) {
- delete object[i];
- } else {}
- }
- }
- }
- function isEmpty(object) {
- for(var name in object) {
- return false;
- }
- return true;
- }
|