customerCenter.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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. my.navigateTo({
  248. url: '../servantsettings/servantsettings'
  249. });
  250. }else{
  251. // 提醒设置任务
  252. this.setData({
  253. unSetServiceModal: false,
  254. unSetTaskModal:true
  255. });
  256. }
  257. },
  258. // 点击设置任务提醒按钮
  259. onSetTaskButtonClick(e){
  260. console.log(e.target);
  261. if(e.target.dataset.index==0){
  262. this.setData({
  263. unSetTaskModal: false,
  264. });
  265. // 跳转到任务设置页面,传首次设置任务的参数
  266. my.navigateTo({
  267. url: '../dailytasks/dailytasks?firstSetTask=1'
  268. });
  269. }else{
  270. // 提醒完成设置
  271. if(this.data.noSetSerStan&&this.data.noAddTaskShow){
  272. this.setData({
  273. finishTitle:this.data.finishModalCase1[0],
  274. finishTips:this.data.finishModalCase1[1],
  275. });
  276. }else if(!this.data.noSetSerStan&&this.data.noAddTaskShow){
  277. this.setData({
  278. finishTitle:this.data.finishModalCase2[0],
  279. finishTips:this.data.finishModalCase2[1],
  280. });
  281. }
  282. this.setData({
  283. unSetTaskModal: false,
  284. finishSetModal:true
  285. });
  286. // 首次设置完成标示缓存下来
  287. }
  288. },
  289. // 跳转到服务标准页面
  290. switchSerStandard(){
  291. if(this.data.noSetSerStan){
  292. my.navigateTo({
  293. url: '../servantsettings/servantsettings'
  294. });
  295. }else{
  296. my.navigateTo({
  297. url: '../servantlist/servantlist'
  298. });
  299. }
  300. },
  301. switchSerHobby(){
  302. // 跳转到服务偏好页面
  303. my.navigateTo({
  304. url: '../servantdetail/servantdetail'
  305. });
  306. },
  307. // 点击开启体验按钮
  308. onFinishButtonClick(e){
  309. console.log(e.target);
  310. if(e.target.dataset.index==0){
  311. this.setData({
  312. finishSetModal: false,
  313. });
  314. // 首次设置完成提交后台完成引导设置
  315. // this.finishAllSet();
  316. }else{
  317. }
  318. },
  319. finishAllSet(){
  320. let params={
  321. employRelationNo:app.globalData.employRelationNo,
  322. employSetState:'1'
  323. }
  324. request.httpServicePost(apiUrl.updateEmploySetStatePath,params).then(data=>{
  325. console.log(data);
  326. }).catch(e=>{
  327. console.log(e);
  328. })
  329. },
  330. // 获取通知
  331. getEmployerNotice(){
  332. let params={
  333. employRelationNo:app.globalData.employRelationNo,
  334. userId:app.globalData.userInfo.id
  335. }
  336. request.httpServicePost(apiUrl.getEmployerNoticePath,params).then(data=>{
  337. console.log('雇主通知');
  338. console.log(data);
  339. let bmybgx=(data.bmybgx.size>=1);
  340. let rwwfwc=(data.rwwfwc.size>=1);
  341. let phsz=(data.phsz.size>=1);
  342. let phgx=(data.phgx.size>=1);
  343. this.setData({
  344. bmybgxShow:bmybgx,
  345. rwwfwcShow:rwwfwc,
  346. phszShow:phsz,
  347. phgxShow:phgx,
  348. });
  349. }).catch(e=>{
  350. console.log(e);
  351. })
  352. },
  353. // 查看月报
  354. async viewMonthReport(e){
  355. try{
  356. let data=await this.readNotice(e);
  357. if(data!=undefined){
  358. // my.navigateTo({
  359. // url: '../monthReport/monthReport'
  360. // });
  361. }
  362. }catch(e){
  363. console.log(e);
  364. }
  365. },
  366. // 查看任务
  367. async viewTaskReminder(e){
  368. try{
  369. let data=await this.readNotice(e);
  370. if(data!=undefined){
  371. my.navigateTo({
  372. url: '../taskreminder/taskreminder'
  373. });
  374. }
  375. }catch(e){
  376. console.log(e);
  377. }
  378. },
  379. // 查看偏好
  380. async viewSerHobby(e){
  381. console.log(e);
  382. try{
  383. let data=await this.readNotice(e);
  384. if(data!=undefined){
  385. my.navigateTo({
  386. url: '../servantdetail/servantdetail'
  387. });
  388. }
  389. }catch(e){
  390. console.log(e);
  391. }
  392. },
  393. async readNotice(e){
  394. let type=e.target.dataset.noticeType;
  395. console.log(type);
  396. let params={
  397. "employRelationNo": app.globalData.employRelationNo,
  398. "noticeType": type,
  399. "userId": app.globalData.userInfo.id
  400. }
  401. try{
  402. let data=await request.httpServicePost(apiUrl.userReadNoticePath,params);
  403. return data;
  404. }catch(e){
  405. console.log(e);
  406. }
  407. // request.httpServicePost(apiUrl.userReadNoticePath,params).then(data=>{
  408. // console.log(data);
  409. // }).catch(e=>{
  410. // console.log(e);
  411. // })
  412. },
  413. async closeNotice(e){
  414. console.log('关闭通知');
  415. try{
  416. let data=await this.readNotice(e);
  417. console.log(data);
  418. if(data!=undefined){
  419. // 通知不展示
  420. let type=e.target.dataset.noticeType;
  421. console.log(type);
  422. if(type=='bmybgx'){
  423. this.setData({
  424. bmybgxShow:false
  425. })
  426. }else if(type=='rwwfwc'){
  427. this.setData({
  428. rwwfwcShow:false
  429. })
  430. }else if(type=='phsz'){
  431. this.setData({
  432. phszShow:false
  433. })
  434. }else if(type=='phgx'){
  435. this.setData({
  436. phgxShow:false
  437. })
  438. }
  439. }
  440. }catch(e){
  441. console.log(e);
  442. }
  443. }
  444. });