app.js 10.0 KB

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