app.js 8.5 KB

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