app.js 8.5 KB

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