position_detail.dart 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/res/gaps.dart';
  3. import 'package:liftmanager/net/api_service.dart';
  4. import 'package:liftmanager/utils/toast.dart';
  5. import 'package:liftmanager/widgets/app_bar.dart';
  6. import 'package:liftmanager/internal/search/search_router.dart';
  7. import 'package:liftmanager/widgets/app_search_bar.dart';
  8. import 'package:liftmanager/res/resources.dart';
  9. import 'package:liftmanager/routers/fluro_navigator.dart';
  10. import 'package:liftmanager/widgets/load_image.dart';
  11. import 'package:liftmanager/widgets/selected_image.dart';
  12. import 'package:image_picker/image_picker.dart';
  13. import 'package:liftmanager/internal/bbs/bbs_router.dart';
  14. import 'dart:io';
  15. import 'package:flutter_screenutil/flutter_screenutil.dart';
  16. import 'package:liftmanager/widgets/my_card.dart';
  17. // import 'package:liftmanager/internal/bbs/model/question_detail.dart';
  18. import 'package:liftmanager/internal/bbs/model/position_model.dart';
  19. import 'package:liftmanager/utils/time_format.dart';
  20. import 'package:liftmanager/utils/url.dart';
  21. import 'dart:convert';
  22. import 'package:liftmanager/utils/fast_notification.dart';
  23. import 'dart:math';
  24. import 'package:flustars/flustars.dart' as FlutterStars;
  25. import 'package:liftmanager/common/common.dart';
  26. import 'package:liftmanager/internal/account/account_router.dart';
  27. import 'package:fluwx/fluwx.dart' as fluwx;
  28. import 'package:liftmanager/utils/theme_utils.dart';
  29. class PositionDetail extends StatefulWidget {
  30. PositionDetail(this.id);
  31. final String id;
  32. @override
  33. State<StatefulWidget> createState() {
  34. return PositionDetailState();
  35. }
  36. }
  37. class PositionDetailState extends State<PositionDetail> {
  38. @override
  39. void initState() {
  40. super.initState();
  41. getPositionDetail();
  42. FastNotification.addListener("apply",(isApply){
  43. print(isApply);
  44. print(456456);
  45. if(isApply == true){
  46. getPositionDetail();
  47. }
  48. setState(() {});
  49. });
  50. }
  51. bool _hasData = false;
  52. PositionDetailModel detailObj;
  53. Future getPositionDetail() async {
  54. await NewApiService().getPositionDetail(int.parse(widget.id),
  55. onSuccess: (res) {
  56. if (res != null) {
  57. print(123456);
  58. print(res);
  59. detailObj = res;
  60. _hasData = true;
  61. setState(() {});
  62. }
  63. }, onError: (code, msg) {
  64. toasts(msg);
  65. });
  66. }
  67. Future changeFavorite() async {
  68. showLoading(context);
  69. print(detailObj.isFavorite);
  70. if (detailObj.isFavorite == 0) {
  71. await NewApiService().insertRecruitmentOperates(
  72. detailObj.id,
  73. 3,
  74. onSuccess: (res) {
  75. print(res);
  76. dismissLoading(context);
  77. initCollect();
  78. this.getPositionDetail();
  79. },
  80. onError: (code, msg) {
  81. dismissLoading(context);
  82. toasts(msg);
  83. },
  84. );
  85. } else {
  86. await NewApiService().deleteRecruitmentOperates(
  87. detailObj.favoriteId,
  88. onSuccess: (res) {
  89. print(res);
  90. dismissLoading(context);
  91. initCollect();
  92. this.getPositionDetail();
  93. },
  94. onError: (code, msg) {
  95. dismissLoading(context);
  96. toasts(msg);
  97. },
  98. );
  99. }
  100. }
  101. showAlertEvent(){
  102. showAlert(
  103. context,
  104. "提示",
  105. "确定登录?",
  106. "确定",
  107. () {
  108. NavigatorUtils.push(context, AccountRouter.loginPage, clearStack: true);
  109. },
  110. txt2: "取消",
  111. onPre2: () {
  112. NavigatorUtils.goBack(context);
  113. },
  114. );
  115. }
  116. initCollect(){
  117. String collectInit = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
  118. FastNotification.push("collectAction",collectInit);
  119. }
  120. randomInt(int min, int max) {
  121. return new Random().nextInt(max) % (max - min + 1) + min;
  122. }
  123. @override
  124. Widget build(BuildContext context) {
  125. print(widget.id);
  126. double width = MediaQuery.of(context).size.width;
  127. return Scaffold(
  128. resizeToAvoidBottomPadding: false, //不让键盘弹上去
  129. appBar: MyAppBar(
  130. centerTitle: "职位详情",
  131. ),
  132. body: _hasData
  133. ? Stack(
  134. children: <Widget>[
  135. Container(
  136. child: ListView(children: <Widget>[
  137. Column(
  138. mainAxisAlignment: MainAxisAlignment.start,
  139. crossAxisAlignment: CrossAxisAlignment.start,
  140. children: <Widget>[
  141. Container(
  142. padding: EdgeInsets.only(
  143. left: ScreenUtil().setWidth(15),
  144. right: ScreenUtil().setWidth(15),
  145. top: ScreenUtil().setWidth(10),
  146. bottom: ScreenUtil().setWidth(10)),
  147. decoration: BoxDecoration(
  148. border: Border(
  149. bottom:
  150. BorderSide(width: 0.5, color: Colours.line),
  151. ),
  152. ),
  153. child: Column(
  154. mainAxisAlignment: MainAxisAlignment.start,
  155. crossAxisAlignment: CrossAxisAlignment.start,
  156. children: <Widget>[
  157. MyCard(
  158. child: Container(
  159. color:ThemeUtils.getDialogTextFieldColor(context),
  160. padding: EdgeInsets.only(
  161. left: ScreenUtil().setWidth(10),
  162. right: ScreenUtil().setWidth(10),
  163. top: ScreenUtil().setWidth(20),
  164. bottom: ScreenUtil().setWidth(20)),
  165. width: width,
  166. child: Column(
  167. crossAxisAlignment:
  168. CrossAxisAlignment.start,
  169. children: <Widget>[
  170. Container(
  171. padding: EdgeInsets.only(
  172. bottom: ScreenUtil()
  173. .setWidth(10)),
  174. child: Row(
  175. crossAxisAlignment: CrossAxisAlignment.start,
  176. mainAxisAlignment:
  177. MainAxisAlignment
  178. .spaceBetween,
  179. children: <Widget>[
  180. Expanded(child: Text(
  181. // detailObj.job,
  182. detailObj.job ?? '',
  183. style: TextStyle(
  184. fontSize: ScreenUtil()
  185. .setSp(16)),
  186. textAlign: TextAlign.start,
  187. ),),
  188. Container(
  189. padding:EdgeInsets.only(top: 5),
  190. child:Text(
  191. DateUtils.instance
  192. .getFormartData(
  193. timeSamp: detailObj
  194. .createTime,
  195. format:
  196. "yyyy/MM/dd"),
  197. style: TextStyle(
  198. color:
  199. Color(0xff999999),
  200. fontSize: ScreenUtil()
  201. .setSp(14)),
  202. textAlign: TextAlign.start,
  203. ),
  204. )
  205. ],
  206. ),
  207. ),
  208. Container(
  209. child: Text(
  210. "¥" +
  211. detailObj.lowerSalary
  212. .toString() +
  213. "-" +
  214. detailObj.upperSalary
  215. .toString(),
  216. style: TextStyle(
  217. color: Colors.red,
  218. fontSize:
  219. ScreenUtil().setSp(16)),
  220. textAlign: TextAlign.start,
  221. ),
  222. ),
  223. Container(
  224. child: Text(
  225. // (detailObj.typeName ?? '') +
  226. // "|" +
  227. ((detailObj.eduName != '' && detailObj.eduName != null ) ? detailObj.eduName : "不限学历") +
  228. " | " +
  229. (detailObj.upperWorking !=
  230. null&&detailObj.lowerWorking != null
  231. ? detailObj.lowerWorking.toString()+ "-" + detailObj.upperWorking
  232. .toString()
  233. : '0') +
  234. "年",
  235. style: TextStyle(
  236. color: Color(0xff999999),
  237. fontSize:
  238. ScreenUtil().setSp(14)),
  239. textAlign: TextAlign.start,
  240. ),
  241. ),
  242. Container(
  243. child: Row(
  244. crossAxisAlignment: CrossAxisAlignment.start,
  245. children: <Widget>[
  246. Text(
  247. "地址:",
  248. style: TextStyle(
  249. color: Color(0xff999999),
  250. fontSize:
  251. ScreenUtil().setSp(14),
  252. ),
  253. textAlign: TextAlign.left,
  254. ),
  255. Container(
  256. width: width*0.7,
  257. child: Text(
  258. (detailObj.provinceName ?? '') + (detailObj.cityName ?? '') + (detailObj.address ?? ''),
  259. style: TextStyle(
  260. color: Color(0xff999999),
  261. fontSize:
  262. ScreenUtil().setSp(14),
  263. ),
  264. textAlign: TextAlign.left,
  265. ),
  266. )
  267. ])),
  268. ])),
  269. ),
  270. SizedBox(
  271. height: ScreenUtil().setWidth(20),
  272. ),
  273. Text(
  274. "公司信息",
  275. style: TextStyle(
  276. fontSize: ScreenUtil().setSp(16)),
  277. textAlign: TextAlign.start,
  278. ),
  279. SizedBox(
  280. height: 5,
  281. ),
  282. ]),
  283. ),
  284. Container(
  285. padding: EdgeInsets.only(
  286. left: ScreenUtil().setWidth(15),
  287. top: ScreenUtil().setWidth(20),
  288. bottom: ScreenUtil().setWidth(20)),
  289. width: width,
  290. decoration: BoxDecoration(
  291. border: Border(
  292. bottom: BorderSide(
  293. width: 5, color: ThemeUtils.getDialogTextFieldColor(context)),
  294. ),
  295. ),
  296. child: Column(
  297. crossAxisAlignment: CrossAxisAlignment.start,
  298. children: <Widget>[
  299. Container(
  300. child: Text(
  301. detailObj.company.name == null ? '' : detailObj.company.name,
  302. style: TextStyle(
  303. color: Color(0xff666666),
  304. fontSize: ScreenUtil().setSp(14),
  305. ),
  306. textAlign: TextAlign.left,
  307. ),
  308. ),
  309. SizedBox(
  310. height: ScreenUtil().setWidth(10),
  311. ),
  312. // Container(
  313. // child: Text(
  314. // (detailObj.typeName ?? '') +
  315. // "|" +
  316. // (detailObj.company.companySize == null
  317. // ? ''
  318. // : detailObj.company.companySize) +
  319. // "|" +
  320. // (detailObj.company.mainbusiness == null
  321. // ? ''
  322. // : detailObj.company.mainbusiness),
  323. // style: TextStyle(
  324. // color: Color(0xff666666),
  325. // fontSize: ScreenUtil().setSp(14),
  326. // ),
  327. // textAlign: TextAlign.left,
  328. // ),
  329. // ),
  330. // SizedBox(
  331. // height: ScreenUtil().setWidth(10),
  332. // ),
  333. Container(
  334. child: Row(children: <Widget>[
  335. Text(
  336. "联系人:",
  337. style: TextStyle(
  338. color: Color(0xff666666),
  339. fontSize: ScreenUtil().setSp(14),
  340. ),
  341. textAlign: TextAlign.left,
  342. ),
  343. Text(
  344. detailObj.company.corporator == null ? '' : detailObj.company.corporator,
  345. style: TextStyle(
  346. color: Color(0xff666666),
  347. fontSize: ScreenUtil().setSp(14),
  348. ),
  349. textAlign: TextAlign.left,
  350. ),
  351. ])),
  352. SizedBox(
  353. height: ScreenUtil().setWidth(10),
  354. ),
  355. Container(
  356. child: Row(children: <Widget>[
  357. Text(
  358. "联系电话:",
  359. style: TextStyle(
  360. color: Color(0xff666666),
  361. fontSize: ScreenUtil().setSp(14),
  362. ),
  363. textAlign: TextAlign.left,
  364. ),
  365. Text(
  366. detailObj.company.telephone == null ? '' : detailObj.company.telephone,
  367. style: TextStyle(
  368. color: Color(0xff666666),
  369. fontSize: ScreenUtil().setSp(14),
  370. ),
  371. textAlign: TextAlign.left,
  372. ),
  373. ])),
  374. ],
  375. ),
  376. ),
  377. Column(
  378. crossAxisAlignment: CrossAxisAlignment.start,
  379. mainAxisAlignment: MainAxisAlignment.start,
  380. children: <Widget>[
  381. Container(
  382. padding: EdgeInsets.only(
  383. left: ScreenUtil().setWidth(15),
  384. top: ScreenUtil().setWidth(15),
  385. bottom: ScreenUtil().setWidth(15)),
  386. width: width,
  387. decoration: BoxDecoration(
  388. border: Border(
  389. bottom: BorderSide(
  390. width: 0.5, color: ThemeUtils.getDialogTextFieldColor(context)),
  391. ),
  392. ),
  393. child: Text(
  394. "职位信息",
  395. style: TextStyle(
  396. fontSize: ScreenUtil().setSp(16),
  397. ),
  398. textAlign: TextAlign.left,
  399. ),
  400. ),
  401. Container(
  402. padding: EdgeInsets.only(
  403. left: ScreenUtil().setWidth(15),
  404. right: ScreenUtil().setWidth(15),
  405. top: ScreenUtil().setWidth(10),
  406. bottom: ScreenUtil().setWidth(90)),
  407. child: Text(
  408. detailObj.info ?? '',
  409. style: TextStyle(
  410. color: Color(0xff666666),
  411. fontSize: ScreenUtil().setSp(14),
  412. ),
  413. textAlign: TextAlign.left,
  414. ),
  415. ),
  416. ],
  417. ),
  418. ],
  419. ),
  420. ])),
  421. Positioned(
  422. bottom: 0,
  423. left: 0,
  424. child: Container(
  425. width: width,
  426. child: Row(children: <Widget>[
  427. Container(
  428. height: ScreenUtil().setWidth(70),
  429. width: width / 2,
  430. color: Colors.white,
  431. padding: EdgeInsets.only(
  432. left: ScreenUtil().setWidth(10),
  433. right: ScreenUtil().setWidth(10),
  434. top: ScreenUtil().setWidth(10)),
  435. child: Row(
  436. mainAxisAlignment:
  437. MainAxisAlignment.spaceAround,
  438. children: <Widget>[
  439. GestureDetector(
  440. onTap: () {
  441. print('分享');
  442. print(jsonEncode(detailObj));
  443. if(FlutterStars.SpUtil.getString(Constant.userId) == "-1"){
  444. showAlertEvent();
  445. }else {
  446. String initThis = randomInt(1111,9999).toString() + DateTime.now().millisecondsSinceEpoch.toString();
  447. fluwx.shareToWeChat(fluwx.WeChatShareWebPageModel(
  448. scene: fluwx.WeChatScene.SESSION,
  449. webPage: "http://lift.whlhcx.com/h5/index.html?num=$initThis&page=/bbs/positionDetail&id=${widget.id}",
  450. title: detailObj.job,
  451. description: detailObj.info,
  452. thumbnail: "",
  453. )).then((result){
  454. },
  455. onError: (msg){
  456. // print(msg);
  457. });
  458. }
  459. },
  460. child: Container(
  461. // padding: EdgeInsets.only(left:25,right:30),
  462. child: Column(children: <Widget>[
  463. Icon(
  464. IconData(0xe6f4,
  465. fontFamily: "myfont"),
  466. size: 26.0,
  467. color: Color(0xff000000),
  468. ),
  469. Text(
  470. "分享",
  471. style: TextStyle(
  472. color: Color(0xff000000),
  473. fontSize: ScreenUtil().setSp(14)),
  474. textAlign: TextAlign.start,
  475. ),
  476. ])),
  477. ),
  478. GestureDetector(
  479. onTap: () {
  480. print(jsonEncode(detailObj));
  481. if(FlutterStars.SpUtil.getString(Constant.userId) == "-1"){
  482. showAlertEvent();
  483. }else {
  484. changeFavorite();}
  485. },
  486. child: Container(
  487. // padding: EdgeInsets.only(left:25,right:30),
  488. child: Column(children: <Widget>[
  489. Icon(
  490. IconData(
  491. detailObj.isFavorite == 1
  492. ? 0xe654
  493. : 0xe604,
  494. fontFamily: "myfont"),
  495. size: 26.0,
  496. color: detailObj.isFavorite == 1
  497. ? Color(0xff0388FD)
  498. : Color(0xff333333),
  499. ),
  500. Text(
  501. "收藏",
  502. style: TextStyle(
  503. color: detailObj.isFavorite == 1
  504. ? Color(0xff0388FD)
  505. : Color(0xff333333),
  506. fontSize: ScreenUtil().setSp(14)),
  507. textAlign: TextAlign.start,
  508. ),
  509. ])),
  510. ),
  511. ],
  512. )),
  513. Container(
  514. height: ScreenUtil().setWidth(70),
  515. width: width / 2,
  516. // color: Color(0xff0388FD),
  517. color: detailObj.isApply == 1
  518. ? Color(0xff999999)
  519. : Color(0xff0388FD),
  520. child: FlatButton(
  521. // padding: EdgeInsets.all(15.0),
  522. child: Text(
  523. detailObj.isApply == 1 ? "已申请" : "申请职位",
  524. style: TextStyle(
  525. fontSize: ScreenUtil().setSp(16)),
  526. ),
  527. textColor: Colors.white,
  528. onPressed: () {
  529. if(FlutterStars.SpUtil.getString(Constant.userId) == "-1"){
  530. showAlertEvent();
  531. }else {
  532. if(detailObj.isApply == 1){
  533. toasts("您已经提交申请了哦");
  534. }else {
  535. NavigatorUtils.push(context,
  536. "${BbsRouter.positionApply}?id=${detailObj.id.toString()}");
  537. }
  538. }
  539. },
  540. ),
  541. ),
  542. ])))
  543. ],
  544. )
  545. : Center(
  546. child: Text("正在加载..."),
  547. ));
  548. }
  549. }