customerCenter.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. import request from '../../../util/http'
  2. import apiUrl from '../../../util/apiUrl'
  3. var app = getApp();
  4. Page({
  5. data: {
  6. servantName:'',//保姆姓名
  7. workDay:'',//工作日
  8. isBind:false,// 是否关联 0 未关联 1关联
  9. isOnlyOne:false,//切换列表是否只有一个
  10. noAddTaskShow:false,//未添加任务
  11. noTaskShow:false,//今天无任务
  12. taskListShow:false,//任务列表
  13. bindCode:'',//关联码
  14. taskList:[],
  15. bmybgxShow:false,//通知栏展示
  16. rwwfwcShow:false,
  17. phszShow:false,
  18. phgxShow:false,
  19. unSetServiceModal:false,//未设置服务标准
  20. unSetTaskModal:false,//未设置任务提醒
  21. finishSetModal:false,//完成设置指引
  22. noSetSerStan:false,//未设置服务标准
  23. noReportShow:false,//没有月报
  24. taskTipText:'',
  25. unSetBtn: [
  26. { text: '设置', extClass: 'buttonBold' },
  27. { text: '暂不' },
  28. ],
  29. finishSetBtn: [
  30. { text: '开启体验', extClass: 'buttonBold' },
  31. {text:''}
  32. ],
  33. finishTitle:'',
  34. finishTips:'',
  35. finishModalCase1:['您差一点点就完成所有设置喽','记得设置服务标准哦'],
  36. finishModalCase2:['您差一点点就完成所有设置喽','记得设置任务提醒哦'],
  37. finishModalCase3:['恭喜您已完成所有设置','分享关联码关联保姆']
  38. },
  39. onLoad(query) {
  40. // 从存储中获取是否完成首次设置,如果完成则不弹框提示
  41. // 如果是首次未设置,首先弹框提示服务标准设置,然后提示任务设置,首次从设置任务跳转过来展示完成指引
  42. console.log(query);
  43. // this.setData({
  44. // finishTitle:this.data.finishModalCase1[0],
  45. // finishTips:this.data.finishModalCase1[1],
  46. // });
  47. let emReNo=query.emReNo;
  48. // 存储此次进入任务中心的关联码
  49. app.globalData.employRelationNo=emReNo;
  50. my.setStorageSync({
  51. key: 'userRelationNo',
  52. data: {
  53. employRelationNo:emReNo,
  54. userId:app.globalData.userInfo.id
  55. }
  56. });
  57. // this.initCustomerInfo();
  58. // 如果携带创建任务完成时参数,弹框提示完成指引
  59. },
  60. onShow(query){
  61. console.log(query);
  62. this.initCustomerInfo();
  63. this.selectTodayTaskItem();
  64. this.getEmployerNotice();
  65. this.selectMonthlyReport();
  66. },
  67. // 获取雇佣关系详情
  68. initCustomerInfo(){
  69. let params={
  70. "employRelationNo":app.globalData.employRelationNo
  71. }
  72. request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{
  73. console.log(data);
  74. app.globalData.relationInfo=data;
  75. let employSetState=data.employSetState;
  76. let isOnlyOne=(data.isMoreServant<=1);
  77. let isInvalid=(data.isInvalid=='1');
  78. this.setData({
  79. servantName:data.servantName,
  80. workDay:data.servantTaskPeriod.workDay,
  81. serviceType:data.servantType,
  82. isOnlyOne:isOnlyOne,
  83. isBind:isInvalid,
  84. bindCode:data.employIdentifier
  85. });
  86. // 完成初次设置的
  87. if(employSetState=='1'){
  88. this.setData({
  89. unSetServiceModal:false,
  90. });
  91. // 获取任务设置和服务标准设置
  92. this.isChooseSerStanSubject();
  93. // this.selectTodayTaskItem();
  94. }else{
  95. // this.setData({
  96. // unSetServiceModal:true,
  97. // noSetSerStan:true,
  98. // noAddTaskShow:true,
  99. // });
  100. // 获取服务标准和任务设置的具体情况
  101. this.isSetServiceAndTask();
  102. }
  103. }).catch(e=>{
  104. console.log(e);
  105. })
  106. },
  107. // 是否设置服务标准
  108. isChooseSerStanSubject(){
  109. let params={
  110. "employRelationNo":app.globalData.employRelationNo
  111. }
  112. request.httpServiceGet(apiUrl.isChooseSerStanSubjectPath,params).then(data=>{
  113. console.log(data);
  114. let noSetSerStan=(data=='0'?true:false);
  115. this.setData({
  116. noSetSerStan:noSetSerStan,
  117. });
  118. }).catch(e=>{
  119. console.log(e);
  120. })
  121. },
  122. // 是否每日任务,每日任务前三条
  123. selectTodayTaskItem(){
  124. let params={
  125. "employRelationNo":app.globalData.employRelationNo
  126. }
  127. request.httpServiceGet(apiUrl.selectTodayTaskItemPath,params).then(data=>{
  128. console.log('每日任务返回');
  129. console.log(data);
  130. // 未设置任务
  131. if(data.isSet==false){
  132. console.log('isSet:false');
  133. this.setData({
  134. noAddTaskShow:true,
  135. noTaskShow:false,
  136. taskListShow:false,
  137. });
  138. }else{
  139. // 今天是休息日
  140. if(data.workDay==false){
  141. this.setData({
  142. noAddTaskShow:false,
  143. noTaskShow:true,
  144. taskTipText:'今天保姆休息',
  145. taskListShow:false,
  146. taskList:data.servantTasks
  147. });
  148. }else if(data.servantTasks.length==0){
  149. // 今天无任务
  150. this.setData({
  151. noAddTaskShow:false,
  152. noTaskShow:true,
  153. taskTipText:'今天无任务',
  154. taskListShow:false,
  155. taskList:data.servantTasks
  156. });
  157. }else{
  158. // 今天有任务
  159. this.setData({
  160. noAddTaskShow:false,
  161. noTaskShow:false,
  162. taskListShow:true,
  163. taskList:data.servantTasks,
  164. completeTaskCount:data.completeTaskCount,
  165. totalTaskCount:data.totalTaskCount
  166. });
  167. }
  168. }
  169. }).catch(e=>{
  170. console.log(e);
  171. })
  172. },
  173. // 是否设置服务标准和任务
  174. isSetServiceAndTask(){
  175. let params={
  176. "employRelationNo":app.globalData.employRelationNo
  177. }
  178. request.httpServiceGet(apiUrl.isSetServiceAndTaskPath,params).then(data=>{
  179. console.log(data);
  180. let service=data.service;
  181. let task=data.task;
  182. if(!service && !task){
  183. // 任务和服务标准都未设置
  184. this.setData({
  185. finishTitle:this.data.finishModalCase1[0],
  186. finishTips:this.data.finishModalCase1[1],
  187. });
  188. this.setData({
  189. unSetServiceModal:true,
  190. noSetSerStan:true,
  191. });
  192. }else if(service &&!task){
  193. // 服务标准设置,任务未设置
  194. this.setData({
  195. finishTitle:this.data.finishModalCase2[0],
  196. finishTips:this.data.finishModalCase2[1],
  197. });
  198. this.setData({
  199. unSetServiceModal:false,
  200. noSetSerStan:false,
  201. unSetTaskModal:true
  202. });
  203. }else if(service &&task){
  204. // 服务标准完成,任务完成
  205. this.setData({
  206. finishTitle:this.data.finishModalCase3[0],
  207. finishTips:this.data.finishModalCase3[1],
  208. });
  209. this.setData({
  210. unSetServiceModal:false,
  211. noSetSerStan:false,
  212. unSetTaskModal:false,
  213. finishSetModal:true,
  214. });
  215. // this.selectTodayTaskItem();//获取任务前三条
  216. }
  217. }).catch(e=>{
  218. console.log(e);
  219. })
  220. },
  221. switchAddTask(){
  222. // 跳转到添加任务页面
  223. my.navigateTo({
  224. url: '../dailytasks/dailytasks'
  225. });
  226. },
  227. switchTaskRemind(){
  228. // 跳转到任务提醒器页面
  229. my.navigateTo({
  230. url: '../taskreminder/taskreminder'
  231. });
  232. },
  233. switchList(){
  234. my.navigateTo({
  235. url: '../myServantList/myServantList'
  236. });
  237. },
  238. editServant(){
  239. my.navigateTo({
  240. url: '../editServant/editServant'
  241. });
  242. },
  243. copyCode(){
  244. my.setClipboard({
  245. text: this.data.bindCode,
  246. success:()=>{
  247. my.showToast({
  248. content: '复制成功',
  249. });
  250. },
  251. fail:()=>{
  252. my.showToast({
  253. content: '复制失败',
  254. });
  255. }
  256. });
  257. },
  258. // 点击设置服务标准按钮
  259. onSetServiceButtonClick(e){
  260. console.log(e.target);
  261. if(e.target.dataset.index==0){
  262. this.setData({
  263. unSetServiceModal: false,
  264. });
  265. // 跳转到服务标准页面
  266. my.navigateTo({
  267. url: '../servantsettings/servantsettings'
  268. });
  269. }else{
  270. // 提醒设置任务
  271. this.setData({
  272. unSetServiceModal: false,
  273. unSetTaskModal:true
  274. });
  275. }
  276. },
  277. // 点击设置任务提醒按钮
  278. onSetTaskButtonClick(e){
  279. console.log(e.target);
  280. if(e.target.dataset.index==0){
  281. this.setData({
  282. unSetTaskModal: false,
  283. });
  284. // 跳转到任务设置页面,传首次设置任务的参数
  285. my.navigateTo({
  286. url: '../dailytasks/dailytasks?firstSetTask=1'
  287. });
  288. }else{
  289. // 提醒完成设置
  290. if(this.data.noSetSerStan&&this.data.noAddTaskShow){
  291. this.setData({
  292. finishTitle:this.data.finishModalCase1[0],
  293. finishTips:this.data.finishModalCase1[1],
  294. });
  295. }else if(!this.data.noSetSerStan&&this.data.noAddTaskShow){
  296. this.setData({
  297. finishTitle:this.data.finishModalCase2[0],
  298. finishTips:this.data.finishModalCase2[1],
  299. });
  300. }
  301. this.setData({
  302. unSetTaskModal: false,
  303. finishSetModal:true
  304. });
  305. // 首次设置完成标示缓存下来
  306. }
  307. },
  308. // 跳转到服务标准页面
  309. switchSerStandard(){
  310. if(this.data.noSetSerStan){
  311. my.navigateTo({
  312. url: '../servantsettings/servantsettings'
  313. });
  314. }else{
  315. my.navigateTo({
  316. url: '../servantlist/servantlist'
  317. });
  318. }
  319. },
  320. switchSerHobby(){
  321. // 跳转到服务偏好页面
  322. my.navigateTo({
  323. url: '../servantdetail/servantdetail'
  324. });
  325. },
  326. // 点击开启体验按钮
  327. onFinishButtonClick(e){
  328. console.log(e.target);
  329. // if(this.data.finishTitle==this.data.finishModalCase3[0]){
  330. // // 复制关联码
  331. // this.copyCode();
  332. // }
  333. if(e.target.dataset.index==0){
  334. this.setData({
  335. finishSetModal: false,
  336. });
  337. // 首次设置完成提交后台完成引导设置
  338. this.finishAllSet();
  339. }else{
  340. }
  341. },
  342. finishAllSet(){
  343. let params={
  344. employRelationNo:app.globalData.employRelationNo,
  345. employSetState:'1'
  346. }
  347. request.httpServicePost(apiUrl.updateEmploySetStatePath,params).then(data=>{
  348. console.log(data);
  349. }).catch(e=>{
  350. console.log(e);
  351. })
  352. },
  353. // 获取通知
  354. getEmployerNotice(){
  355. let params={
  356. employRelationNo:app.globalData.employRelationNo,
  357. userId:app.globalData.userInfo.id
  358. }
  359. request.httpServicePost(apiUrl.getEmployerNoticePath,params).then(data=>{
  360. console.log('雇主通知');
  361. console.log(data);
  362. let bmybgx=(data.bmybgx.size>=1);
  363. let rwwfwc=(data.rwwfwc.size>=1);
  364. let phsz=(data.phsz.size>=1);
  365. let phgx=(data.phgx.size>=1);
  366. this.setData({
  367. bmybgxShow:bmybgx,
  368. rwwfwcShow:rwwfwc,
  369. phszShow:phsz,
  370. phgxShow:phgx,
  371. });
  372. }).catch(e=>{
  373. console.log(e);
  374. })
  375. },
  376. // 查看月报
  377. async viewMonthReport(e){
  378. try{
  379. let data=await this.readNotice(e);
  380. if(data!=undefined){
  381. my.navigateTo({
  382. url: '../reportList/reportList'
  383. });
  384. }
  385. }catch(e){
  386. console.log(e);
  387. }
  388. },
  389. // 查看任务
  390. async viewTaskReminder(e){
  391. try{
  392. let data=await this.readNotice(e);
  393. if(data!=undefined){
  394. my.navigateTo({
  395. url: '../taskreminder/taskreminder'
  396. });
  397. }
  398. }catch(e){
  399. console.log(e);
  400. }
  401. },
  402. // 查看偏好
  403. async viewSerHobby(e){
  404. console.log(e);
  405. try{
  406. let data=await this.readNotice(e);
  407. if(data!=undefined){
  408. my.navigateTo({
  409. url: '../servantdetail/servantdetail'
  410. });
  411. }
  412. }catch(e){
  413. console.log(e);
  414. }
  415. },
  416. async readNotice(e){
  417. let type=e.target.dataset.noticeType;
  418. console.log(type);
  419. let params={
  420. "employRelationNo": app.globalData.employRelationNo,
  421. "noticeType": type,
  422. "userId": app.globalData.userInfo.id
  423. }
  424. try{
  425. let data=await request.httpServicePost(apiUrl.userReadNoticePath,params);
  426. return data;
  427. }catch(e){
  428. console.log(e);
  429. }
  430. // request.httpServicePost(apiUrl.userReadNoticePath,params).then(data=>{
  431. // console.log(data);
  432. // }).catch(e=>{
  433. // console.log(e);
  434. // })
  435. },
  436. async closeNotice(e){
  437. console.log('关闭通知');
  438. try{
  439. let data=await this.readNotice(e);
  440. console.log(data);
  441. if(data!=undefined){
  442. // 通知不展示
  443. let type=e.target.dataset.noticeType;
  444. console.log(type);
  445. if(type=='bmybgx'){
  446. this.setData({
  447. bmybgxShow:false
  448. })
  449. }else if(type=='rwwfwc'){
  450. this.setData({
  451. rwwfwcShow:false
  452. })
  453. }else if(type=='phsz'){
  454. this.setData({
  455. phszShow:false
  456. })
  457. }else if(type=='phgx'){
  458. this.setData({
  459. phgxShow:false
  460. })
  461. }
  462. }
  463. }catch(e){
  464. console.log(e);
  465. }
  466. },
  467. // 获取月报
  468. selectMonthlyReport(){
  469. let params={
  470. "employRelationNo":app.globalData.employRelationNo,
  471. "reportType": '1',
  472. }
  473. request.httpServicePost(apiUrl.selectMonthlyReportPath,params).then(data=>{
  474. console.log('月报信息response');
  475. console.log(data);
  476. let noReport=(data.length==0)
  477. this.setData({
  478. noReportShow: noReport,
  479. });
  480. if(!noReport){
  481. app.globalData.reportList=data;
  482. }
  483. }).catch(e=>{
  484. console.log(e);
  485. })
  486. },
  487. switchReportList(){
  488. if(!this.data.noReportShow){
  489. my.navigateTo({
  490. url: '../reportList/reportList'
  491. });
  492. }
  493. }
  494. });