app.js 11 KB

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