customerCenter.js 12 KB

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