app.js 11 KB

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