customerCenter.js 13 KB

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