app.js 9.8 KB

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