app.js 7.9 KB

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