servantCenter.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. import moment from 'moment';
  2. import request from '../../../util/http'
  3. import apiUrl from '../../../util/apiUrl'
  4. var app = getApp();
  5. Page({
  6. data: {
  7. isOnlyOne:true,//切换列表是否只有一个
  8. noAddTaskShow:true,//未添加任务
  9. noTaskShow:false,//今天无任务
  10. taskListShow:false,//任务列表
  11. taskList:[],
  12. gzybgxShow:false,//通知栏展示
  13. rwszShow:false,
  14. rwgxShow:false,
  15. fwbzszShow:false,
  16. fwbzgxShow:false,
  17. editModalShow:false,//编辑弹框
  18. unSetModal:false,//未设置偏好
  19. noSetSerHobby:false,//展示未设置服务偏好
  20. noSetSerStan:false,//展示未设置服务标准
  21. unSetBtn: [
  22. { text: '去设置', extClass: 'buttonBold' },
  23. { text: '暂不' },
  24. ],
  25. buttonFooter:[
  26. { text: '取消' },
  27. { text: '确定', extClass: 'buttonBold' },
  28. ],
  29. finishSetModal:false,//完成设置指引
  30. finishSetBtn: [
  31. { text: '开启体验', extClass: 'buttonBold' },
  32. {text:''}],
  33. customerName:'',//客户姓名
  34. editCustomerName:'',//编辑客户姓名
  35. workDay:'',//工作日
  36. serviceType:'',//保姆工种
  37. completeTaskCount:'',
  38. totalTaskCount:'',
  39. noReportShow:false,//没有月报
  40. servantSetState:'',
  41. },
  42. onLoad(query) {
  43. console.log(query);
  44. let emReNo=query.emReNo;
  45. // 存储此次进入任务中心的关联码
  46. app.globalData.employRelationNo=emReNo;
  47. my.setStorageSync({
  48. key: 'userRelationNo',
  49. data: {
  50. employRelationNo:emReNo,
  51. userId:app.globalData.userInfo.id
  52. }
  53. });
  54. // this.initCustomerInfo();
  55. // this.isChooseSerHobSubject();
  56. // this.isChooseSerStanSubject();
  57. // this.selectTodayTaskItem();
  58. // this.getServantNotice();
  59. },
  60. onShow(query){
  61. console.log(query);
  62. this.initCustomerInfo();
  63. // this.isChooseSerHobSubject();
  64. this.isChooseSerStanSubject();
  65. this.selectTodayTaskItem();
  66. this.getServantNotice();
  67. this.selectMonthlyReport();
  68. },
  69. // 获取雇佣关系详情
  70. initCustomerInfo(){
  71. let params={
  72. "employRelationNo":app.globalData.employRelationNo
  73. }
  74. request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{
  75. console.log(data);
  76. app.globalData.servantInfo=data;
  77. let isOnlyOne=(data.isMoreEmploy<=1);
  78. this.setData({
  79. customerName:data.employerName,
  80. workDay:data.servantTaskPeriod.workDay,
  81. serviceType:data.servantType,
  82. isOnlyOne:isOnlyOne,
  83. servantSetState:data.servantSetState
  84. });
  85. this.isChooseSerHobSubject();
  86. }).catch(e=>{
  87. console.log(e);
  88. })
  89. },
  90. // 是否设置服务偏好
  91. isChooseSerHobSubject(){
  92. let params={
  93. "employRelationNo":app.globalData.employRelationNo
  94. }
  95. request.httpServiceGet(apiUrl.isChooseSerHobSubjectPath,params).then(data=>{
  96. console.log('是否设置服务偏好'+data);
  97. let noSetSerHobby=(data=='0'?true:false);
  98. this.setData({
  99. noSetSerHobby:noSetSerHobby,
  100. });
  101. // 未完成首次设置并且未设置的
  102. if(this.data.servantSetState=='0'&&noSetSerHobby){
  103. this.setData({
  104. unSetModal:true,
  105. });
  106. }else{
  107. this.setData({
  108. unSetModal:false,
  109. });
  110. }
  111. }).catch(e=>{
  112. console.log(e);
  113. })
  114. },
  115. // 是否设置服务标准
  116. isChooseSerStanSubject(){
  117. let params={
  118. "employRelationNo":app.globalData.employRelationNo
  119. }
  120. request.httpServiceGet(apiUrl.isChooseSerStanSubjectPath,params).then(data=>{
  121. console.log('是否设置服务标准'+data);
  122. let noSetSerStan=(data=='0'?true:false);
  123. this.setData({
  124. noSetSerStan:noSetSerStan,
  125. });
  126. }).catch(e=>{
  127. console.log(e);
  128. })
  129. },
  130. // 是否每日任务,每日任务前三条
  131. selectTodayTaskItem(){
  132. let params={
  133. "employRelationNo":app.globalData.employRelationNo
  134. }
  135. request.httpServiceGet(apiUrl.selectTodayTaskItemPath,params).then(data=>{
  136. console.log('每日任务返回');
  137. console.log(data);
  138. // 未设置任务
  139. if(!data.isSet){
  140. this.setData({
  141. noAddTaskShow:true,
  142. noTaskShow:false,
  143. taskListShow:false,
  144. });
  145. }else{
  146. if(data.workDay==false){
  147. // 今天是休息日
  148. this.setData({
  149. noAddTaskShow:false,
  150. noTaskShow:true,
  151. taskTipText:'今天是休息日',
  152. taskListShow:false,
  153. taskList:data.servantTasks
  154. });
  155. }else if(data.servantTasks.length==0){
  156. // 今天无任务
  157. this.setData({
  158. noAddTaskShow:false,
  159. noTaskShow:true,
  160. taskTipText:'今天无任务',
  161. taskListShow:false,
  162. taskList:data.servantTasks
  163. });
  164. }else{
  165. // 今天有任务
  166. this.setData({
  167. noAddTaskShow:false,
  168. noTaskShow:false,
  169. taskListShow:true,
  170. taskList:data.servantTasks,
  171. completeTaskCount:data.completeTaskCount,
  172. totalTaskCount:data.totalTaskCount
  173. });
  174. }
  175. }
  176. }).catch(e=>{
  177. console.log(e);
  178. })
  179. },
  180. switchList(){
  181. my.navigateTo({
  182. url: '../myCustomerList/myCustomerList'
  183. });
  184. },
  185. // 跳转到服务标准页面
  186. switchSerStandard(){
  187. my.navigateTo({
  188. url: '../servantdetail/servantdetail'
  189. });
  190. },
  191. editCustomer(event){
  192. console.log(event);
  193. this.setData({
  194. editCustomerName:'',
  195. editModalShow:true,
  196. });
  197. },
  198. onModalClose(e){
  199. console.log(e.target);
  200. if(e.target.dataset.index==0){
  201. this.setData({
  202. editModalShow: false,
  203. });
  204. }else{
  205. // 保存客户姓名
  206. this.editEmployerSubmit();
  207. }
  208. },
  209. // 编辑雇主提交
  210. editEmployerSubmit(){
  211. let params={
  212. "employerName":this.data.editCustomerName,
  213. "employRelationNo": app.globalData.employRelationNo,
  214. }
  215. request.httpServicePost(apiUrl.updateEmployerNamePath,params).then(data=>{
  216. console.log(data);
  217. my.showToast({
  218. content: '修改成功',
  219. });
  220. this.setData({
  221. editModalShow: false,
  222. });
  223. // 修改成功后刷新页面
  224. this.initCustomerInfo();
  225. }).catch(e=>{
  226. console.log(e);
  227. })
  228. },
  229. bindKeyInput(e) {
  230. this.setData({
  231. editCustomerName: e.detail.value,
  232. });
  233. },
  234. switchTaskRemind(){
  235. if(this.data.noAddTaskShow==false){
  236. // 跳转到任务提醒器页面
  237. my.navigateTo({
  238. url: '../taskreminder/taskreminder'
  239. });
  240. }
  241. },
  242. // 点击设置按钮
  243. onSetButtonClick(e){
  244. console.log(e.target);
  245. if(e.target.dataset.index==0){
  246. this.setData({
  247. unSetModal: false,
  248. });
  249. // 跳转到服务偏好页面
  250. my.navigateTo({
  251. url: '../servantsettings/servantsettings'
  252. });
  253. }else{
  254. this.setData({
  255. unSetModal: false,
  256. finishSetModal:true
  257. });
  258. }
  259. },
  260. switchSerHobby(){
  261. // 跳转到服务偏好页面
  262. if(this.data.noSetSerHobby){
  263. my.navigateTo({
  264. url: '../servantsettings/servantsettings'
  265. });
  266. }else{
  267. my.navigateTo({
  268. url: '../servantlist/servantlist'
  269. });
  270. }
  271. },
  272. // 获取保姆通知
  273. getServantNotice(){
  274. let params={
  275. employRelationNo:app.globalData.employRelationNo,
  276. userId:app.globalData.userInfo.id
  277. }
  278. request.httpServicePost(apiUrl.getServantNoticePath,params).then(data=>{
  279. console.log('保姆通知');
  280. console.log(data);
  281. let gzybgx=(data.gzybgx.size>=1);
  282. let rwsz=(data.rwsz.size>=1);
  283. let rwgx=(data.rwgx.size>=1);
  284. let fwbzsz=(data.fwbzsz.size>=1);
  285. let fwbzgx=(data.fwbzgx.size>=1);
  286. this.setData({
  287. gzybgxShow:gzybgx,
  288. rwszShow:rwsz,
  289. rwgxShow:rwgx,
  290. fwbzszShow:fwbzsz,
  291. fwbzgxShow:fwbzgx,
  292. });
  293. }).catch(e=>{
  294. console.log(e);
  295. })
  296. },
  297. // 查看月报
  298. async viewMonthReport(e){
  299. try{
  300. let data=await this.readNotice(e);
  301. if(data!=undefined){
  302. my.navigateTo({
  303. url: '../reportList/reportList'
  304. });
  305. }
  306. }catch(e){
  307. console.log(e);
  308. }
  309. },
  310. // 查看任务
  311. async viewTaskReminder(e){
  312. try{
  313. let data=await this.readNotice(e);
  314. if(data!=undefined){
  315. my.navigateTo({
  316. url: '../taskreminder/taskreminder'
  317. });
  318. }
  319. }catch(e){
  320. console.log(e);
  321. }
  322. },
  323. // 查看服务标准
  324. async viewSerStan(e){
  325. console.log(e);
  326. try{
  327. let data=await this.readNotice(e);
  328. if(data!=undefined){
  329. my.navigateTo({
  330. url: '../servantdetail/servantdetail'
  331. });
  332. }
  333. }catch(e){
  334. console.log(e);
  335. }
  336. },
  337. async readNotice(e){
  338. let type=e.target.dataset.noticeType;
  339. console.log(type);
  340. let params={
  341. "employRelationNo": app.globalData.employRelationNo,
  342. "noticeType": type,
  343. "userId": app.globalData.userInfo.id
  344. }
  345. try{
  346. let data=await request.httpServicePost(apiUrl.userReadNoticePath,params);
  347. return data;
  348. }catch(e){
  349. console.log(e);
  350. }
  351. },
  352. async closeNotice(e){
  353. console.log('关闭通知');
  354. try{
  355. let data=await this.readNotice(e);
  356. console.log(data);
  357. if(data!=undefined){
  358. // 通知不展示
  359. let type=e.target.dataset.noticeType;
  360. console.log(type);
  361. if(type=='gzybgx'){
  362. this.setData({
  363. gzybgxShow:false
  364. })
  365. }else if(type=='rwsz'){
  366. this.setData({
  367. rwszShow:false
  368. })
  369. }else if(type=='rwgx'){
  370. this.setData({
  371. rwgxShow:false
  372. })
  373. }else if(type=='fwbzsz'){
  374. this.setData({
  375. fwbzszShow:false
  376. })
  377. }else if(type=='fwbzgx'){
  378. this.setData({
  379. fwbzgxShow:false
  380. })
  381. }
  382. }
  383. }catch(e){
  384. console.log(e);
  385. }
  386. },
  387. // 获取月报
  388. selectMonthlyReport(){
  389. let params={
  390. "employRelationNo":app.globalData.employRelationNo,
  391. "reportType": '2',
  392. }
  393. request.httpServicePost(apiUrl.selectMonthlyReportPath,params).then(data=>{
  394. console.log('月报信息response');
  395. console.log(data);
  396. let noReport=(data.length==0)
  397. this.setData({
  398. noReportShow: noReport,
  399. });
  400. if(!noReport){
  401. app.globalData.reportList=data;
  402. }
  403. }).catch(e=>{
  404. console.log(e);
  405. })
  406. },
  407. switchReportList(){
  408. if(!this.data.noReportShow){
  409. my.navigateTo({
  410. url: '../reportList/reportList'
  411. });
  412. }
  413. },
  414. // 点击开启体验按钮
  415. onFinishButtonClick(e){
  416. console.log(e.target);
  417. // if(this.data.finishTitle==this.data.finishModalCase3[0]){
  418. // // 复制关联码
  419. // this.copyCode();
  420. // }
  421. if(e.target.dataset.index==0){
  422. this.setData({
  423. finishSetModal: false,
  424. });
  425. // 首次设置完成提交后台完成引导设置
  426. this.finishAllSet();
  427. }else{
  428. }
  429. },
  430. finishAllSet(){
  431. let params={
  432. employRelationNo:app.globalData.employRelationNo,
  433. servantSetState:'1'
  434. }
  435. request.httpServicePost(apiUrl.updateServantSetStatePath,params).then(data=>{
  436. console.log(data);
  437. }).catch(e=>{
  438. console.log(e);
  439. })
  440. },
  441. });