app.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. var urls = function() {
  2. //var host = "http://192.168.100.3:7979";
  3. //var host = "http://192.168.5.103:7979";
  4. //var host = "http://192.168.5.104:8080/djfp";
  5. //var host = "http://oa.gogo.sh:7979/djfp";
  6. var host = "http://111.12.52.222:7979";
  7. var url = {
  8. "path": host,
  9. "sendMessage": host + "/app/user/sendMessage", //发送注册短信
  10. "findPassMessage": host + "/app/user/findPassMessage", //发送找回密码短信
  11. "login": host + "/app/user/login", //用户登录
  12. "edit_pass": host + "/app/user/edit_pass", //找回密码
  13. "register": host + "/app/user/register", //用户注册
  14. "certification": host + "/app/user/certification", //企业重新认证
  15. "userInfo": host + "/app/user/userInfo", //用户信息
  16. "edit_info": host + "/app/user/edit", //编辑用户信息
  17. "user_upload": host + "/app/user/uploadHeader", //用户上传头像
  18. "uploadFj": host + "/app/user/uploadFj", //上传营业执照
  19. "uploadPhoto": host + "/app/resume/uploadPhoto", //上传简历照片
  20. "main": host + "/app/main", //首页加载数据
  21. "column": host + "/app/column", //文章栏目
  22. "news_list": host + "/app/news/jsonList", //新闻列表
  23. "news_detail": host + "/app/news/detail", //新闻详情
  24. "resume_detail": host + "/app/resume/my_resume", //简历信息
  25. "resume_list": host + "/app/resume/resume_list", //企业收到的简历列表
  26. "resume_ignore": host + "/app/resume/resume_ignore", //企业用户忽略该简历
  27. "resume_preview": host + "/app/resume/resume_preview", //企业预览用户的简历
  28. "resume_save": host + "/app/resume/save_resume", //保存简历
  29. "resume_delivery": host + "/app/resume/resume_delivery", //投递简历
  30. "resume_delivery_list": host + "/app/resume/resume_delivery_list", //用户投递简历列表
  31. "resume_delivery_delete": host + "/app/resume/resume_delivery_delete", //用户删除投递的简历
  32. "position_push": host + "/app/position/push_position", //发布职位
  33. "position_json_list": host + "/app/position/jsonList", //全部职位列表
  34. "position_list": host + "/app/position/position_list", //企业用户发布的职位列表
  35. "position_detail": host + "/app/position/position_detail", //职位预览
  36. "position_delete": host + "/app/position/position_delete", //删除职位
  37. "position_type_list": host + "/app/position_type/list", //职位分类列表
  38. "position_type_add": host + "/app/position_type/add", //添加职位分类
  39. "position_type_delete": host + "/app/position_type/delete", //删除职位分类
  40. "feedback": host + "/app/user/feedback", //意见反馈
  41. "agreement": host + "/app/other/agreement", //服务条款
  42. "guide": host + "/app/other/guide/", //萌新必读2
  43. "message_list": host + "/app/message/message_list", //消息列表
  44. "message_read": host + "/app/message/message_read", //消息设置已读
  45. "message_delete": host + "/app/message/message_delete", //删除消息
  46. };
  47. return url;
  48. }
  49. /**
  50. *一些常用参数
  51. */
  52. function getConstant() {
  53. var str = {
  54. "phone": "10086",
  55. "copyright": "xxx公司版权所有"
  56. }
  57. return str;
  58. }
  59. /**
  60. * i
  61. * @param 窗口id
  62. * @param 窗口地址url
  63. * @param 传递参数
  64. * @param 跳转动画
  65. */
  66. function open(id, url, para, anim) {
  67. anim == null || undefined ? 'pop-in' : anim;
  68. mui.openWindow({
  69. id: id,
  70. url: url,
  71. show: {
  72. aniShow: anim
  73. },
  74. styles: {
  75. popGesture: 'hide'
  76. },
  77. waiting: {
  78. autoShow: true,
  79. title: '正在加载...',
  80. },
  81. extras: {
  82. param: para
  83. },
  84. createNew: true,
  85. hardwareAccelerated: true
  86. });
  87. }
  88. /**
  89. *判断是否登录
  90. */
  91. var hasLogin = function() {
  92. var user = localStorage.getItem("user");
  93. return user == null || user == '' ? false : true;
  94. }
  95. /**
  96. *软件第一次运行
  97. */
  98. var first = function() {
  99. var f = localStorage.getItem("first");
  100. return f == null || f == '' ? true : false;
  101. }
  102. /**
  103. *获取用户信息
  104. */
  105. var getUser = function() {
  106. var user = localStorage.getItem("user");
  107. return JSON.parse(user);
  108. }
  109. /**
  110. *获取用户简历
  111. */
  112. var getResume = function() {
  113. var resume = localStorage.getItem("resume");
  114. return JSON.parse(resume);
  115. }
  116. var getToken = function() {
  117. return localStorage.getItem("token");
  118. }
  119. /**
  120. *
  121. * @param 请求url
  122. * @param 请求参数
  123. * @param 回调回调
  124. */
  125. function request(url, param, callback) {
  126. plus.nativeUI.showWaiting("正在加载...");
  127. mui.ajax(url, {
  128. data: param,
  129. dataType: 'json', //服务器返回json格式数据
  130. type: 'post', //HTTP请求类型
  131. contentType: "application/x-www-form-urlencoded; charset=utf-8",
  132. beforeSend: function(req) {
  133. if(hasLogin()) {
  134. req.setRequestHeader("token", getToken());
  135. req.setRequestHeader("phone", getUser().account);
  136. }
  137. },
  138. success: callback,
  139. error: function(xhr, type, errorThrown) {
  140. //plus.nativeUI.closeWaiting();
  141. }
  142. });
  143. }
  144. //手机格式验证
  145. function isPhone(phone) {
  146. var reg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  147. if(reg.test(phone)) {
  148. return true;
  149. } else {
  150. return false;
  151. }
  152. return false;
  153. }
  154. //学历
  155. function xl() {
  156. return ['小学', '初级中学', '高级中学', '中专', '专科', '本科', '硕士研究生', '博士研究生'];
  157. }
  158. //学位
  159. function xw() {
  160. return ['无', '学士学位', '硕士学位', '博士学位'];
  161. }
  162. //工作经验
  163. function gzyl() {
  164. return ['不限', '一年以下', '1-2年', '2-3年', '3-5年', '6-7年', '8-10年', '10年以上'];
  165. }
  166. //学历要求
  167. function xlyq() {
  168. return ['不限', '高中', '技校', '中专', '大专', '本科', '硕士', '博士'];
  169. }
  170. //薪资待遇
  171. function xzdy() {
  172. return ['不限', '500-1000', '1000-2000', '2000-3000', '3000-5000', '5000-8000', '8000-12000', '12000-20000', '20000-25000', '25000以上'];
  173. }
  174. //工作经验
  175. function gzyl() {
  176. return ['不限', '1年以下', '1-2年', '2-3年', '3-5年', '6-7年', '8-10年', '10年以上'];
  177. }
  178. /**
  179. * 复制文本到剪贴板
  180. * @param {Object} copy_content
  181. */
  182. function copy(copy_content) {
  183. //判断是安卓还是ios
  184. if(mui.os.ios) {
  185. //ios
  186. var UIPasteboard = plus.ios.importClass("UIPasteboard");
  187. var generalPasteboard = UIPasteboard.generalPasteboard();
  188. //设置/获取文本内容:
  189. generalPasteboard.plusCallMethod({
  190. setValue: "" + copy_content,
  191. forPasteboardType: "public.utf8-plain-text"
  192. });
  193. generalPasteboard.plusCallMethod({
  194. valueForPasteboardType: "public.utf8-plain-text"
  195. });
  196. } else {
  197. //安卓
  198. var Context = plus.android.importClass("android.content.Context");
  199. var main = plus.android.runtimeMainActivity();
  200. var clip = main.getSystemService(Context.CLIPBOARD_SERVICE);
  201. plus.android.invoke(clip, "setText", "" + copy_content);
  202. }
  203. }
  204. /**
  205. * 初始化剪裁
  206. * @param {Object} ratio 裁剪框比例1是正方形,0NaN是无限制,16:9/4:3/2:3
  207. * @param {Object} path 剪裁图像路径
  208. */
  209. function getClipper(ratio, path) {
  210. var cropper = null;
  211. document.getElementById("clipp").style.display = 'block';
  212. document.getElementById("image").src = path;
  213. var image = document.getElementById("image");
  214. cropper = new Cropper(image, {
  215. aspectRatio: ratio,
  216. viewMode: 1,
  217. });
  218. return cropper;
  219. }
  220. /**
  221. * 直接拍照
  222. * @param callback
  223. */
  224. function takePhoto(callback) {
  225. mui('#picture').popover('toggle');
  226. var cmr = plus.camera.getCamera();
  227. var res = cmr.supportedImageResolutions[0];
  228. var fmt = cmr.supportedImageFormats[0];
  229. cmr.captureImage(callback, function(error) {}, {
  230. resolution: res,
  231. format: fmt
  232. });
  233. }
  234. /**
  235. 从相册选择照片,返回files[]数组地址
  236. * @param limit 选择数量
  237. * @param callback
  238. * @param limit 数量
  239. */
  240. function pickImg(callback, limit) {
  241. mui('#picture').popover('toggle');
  242. plus.gallery.pick(callback, function(error) {}, {
  243. multiple: true,
  244. maximum: limit,
  245. system: false
  246. });
  247. }
  248. /**
  249. * 图片上传
  250. * @param url 上传地址
  251. * @param callback
  252. */
  253. function upload(url, path, callback) {
  254. var task = plus.uploader.createUpload(url, {
  255. method: "POST",
  256. blocksize: 204800,
  257. priority: 100
  258. }, callback);
  259. task.addFile(path, {
  260. key: 'img'
  261. });
  262. task.start();
  263. }
  264. /**
  265. * 图片压缩
  266. * @param callback
  267. * @param path 压缩地址
  268. * @param per 压缩率
  269. */
  270. function compress(callback, path, per) {
  271. plus.nativeUI.showWaiting("正在上传...");
  272. var name = path.substr(path.lastIndexOf('/') + 1);
  273. plus.zip.compressImage({
  274. src: path,
  275. dst: '_doc/' + name,
  276. width: "75%",
  277. overwrite: true
  278. }, callback,
  279. function(error) {});
  280. }
  281. function deleteEmptyProperty(object) {
  282. for(var i in object) {
  283. var value = object[i];
  284. if(typeof value === 'object') {
  285. if(Array.isArray(value)) {
  286. if(value.length == 0) {
  287. delete object[i];
  288. continue;
  289. }
  290. }
  291. this.deleteEmptyProperty(value);
  292. if(this.isEmpty(value)) {
  293. delete object[i];
  294. }
  295. } else {
  296. if(value === '' || value === null || value === undefined) {
  297. delete object[i];
  298. } else {}
  299. }
  300. }
  301. }
  302. function isEmpty(object) {
  303. for(var name in object) {
  304. return false;
  305. }
  306. return true;
  307. }