servantCenter.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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. customerName:'',//客户姓名
  30. editCustomerName:'',//编辑客户姓名
  31. workDay:'',//工作日
  32. serviceType:'',//保姆工种
  33. completeTaskCount:'',
  34. totalTaskCount:''
  35. },
  36. onLoad(query) {
  37. console.log(query);
  38. let emReNo=query.emReNo;
  39. // 存储此次进入任务中心的关联码
  40. app.globalData.employRelationNo=emReNo;
  41. my.setStorageSync({
  42. key: 'employRelationNo',
  43. data: emReNo
  44. });
  45. // this.initCustomerInfo();
  46. // this.isChooseSerHobSubject();
  47. // this.isChooseSerStanSubject();
  48. // this.selectTodayTaskItem();
  49. // this.getServantNotice();
  50. },
  51. onShow(query){
  52. console.log(query);
  53. this.initCustomerInfo();
  54. this.isChooseSerHobSubject();
  55. this.isChooseSerStanSubject();
  56. this.selectTodayTaskItem();
  57. this.getServantNotice();
  58. },
  59. // 获取雇佣关系详情
  60. initCustomerInfo(){
  61. let params={
  62. "employRelationNo":app.globalData.employRelationNo
  63. }
  64. request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{
  65. console.log(data);
  66. let isOnlyOne=(data.isMoreEmploy<=1);
  67. this.setData({
  68. customerName:data.employerName,
  69. workDay:data.servantTaskPeriod.workDay,
  70. serviceType:data.servantType,
  71. isOnlyOne:isOnlyOne
  72. });
  73. }).catch(e=>{
  74. console.log(e);
  75. })
  76. },
  77. // 是否设置服务偏好
  78. isChooseSerHobSubject(){
  79. let params={
  80. "employRelationNo":app.globalData.employRelationNo
  81. }
  82. request.httpServiceGet(apiUrl.isChooseSerHobSubjectPath,params).then(data=>{
  83. console.log('是否设置服务偏好'+data);
  84. let noSetSerHobby=(data=='0'?true:false);
  85. this.setData({
  86. noSetSerHobby:noSetSerHobby,
  87. unSetModal:noSetSerHobby,
  88. });
  89. }).catch(e=>{
  90. console.log(e);
  91. })
  92. },
  93. // 是否设置服务标准
  94. isChooseSerStanSubject(){
  95. let params={
  96. "employRelationNo":app.globalData.employRelationNo
  97. }
  98. request.httpServiceGet(apiUrl.isChooseSerStanSubjectPath,params).then(data=>{
  99. console.log('是否设置服务标准'+data);
  100. let noSetSerStan=(data=='0'?true:false);
  101. this.setData({
  102. noSetSerStan:noSetSerStan,
  103. });
  104. }).catch(e=>{
  105. console.log(e);
  106. })
  107. },
  108. // 是否每日任务,每日任务前三条
  109. selectTodayTaskItem(){
  110. let params={
  111. "employRelationNo":app.globalData.employRelationNo
  112. }
  113. request.httpServiceGet(apiUrl.selectTodayTaskItemPath,params).then(data=>{
  114. console.log(data);
  115. // 未设置任务
  116. if(!data.isSet){
  117. this.setData({
  118. noAddTaskShow:true,
  119. noTaskShow:false,
  120. taskListShow:false,
  121. });
  122. }else{
  123. // 今天是休息日
  124. if(data.servantTasks.length==0){
  125. this.setData({
  126. noAddTaskShow:false,
  127. noTaskShow:true,
  128. taskListShow:false,
  129. taskList:data.servantTasks
  130. });
  131. }else{
  132. // 今天有任务
  133. this.setData({
  134. noAddTaskShow:false,
  135. noTaskShow:false,
  136. taskListShow:true,
  137. taskList:data.servantTasks,
  138. completeTaskCount:data.completeTaskCount,
  139. totalTaskCount:data.totalTaskCount
  140. });
  141. }
  142. }
  143. }).catch(e=>{
  144. console.log(e);
  145. })
  146. },
  147. switchList(){
  148. my.navigateTo({
  149. url: '../myCustomerList/myCustomerList'
  150. });
  151. },
  152. // 跳转到服务标准页面
  153. switchSerStandard(){
  154. my.navigateTo({
  155. url: '../servantdetail/servantdetail'
  156. });
  157. },
  158. editCustomer(event){
  159. console.log(event);
  160. this.setData({
  161. editCustomerName:'',
  162. editModalShow:true,
  163. });
  164. },
  165. onModalClose(e){
  166. console.log(e.target);
  167. if(e.target.dataset.index==0){
  168. this.setData({
  169. editModalShow: false,
  170. });
  171. }else{
  172. // 保存客户姓名
  173. this.editEmployerSubmit();
  174. }
  175. },
  176. // 编辑雇主提交
  177. editEmployerSubmit(){
  178. let params={
  179. "employerName":this.data.editCustomerName,
  180. "employRelationNo": app.globalData.employRelationNo,
  181. }
  182. request.httpServicePost(apiUrl.updateEmployerNamePath,params).then(data=>{
  183. console.log(data);
  184. my.showToast({
  185. content: '修改成功',
  186. });
  187. this.setData({
  188. editModalShow: false,
  189. });
  190. // 修改成功后刷新页面
  191. this.initCustomerInfo();
  192. }).catch(e=>{
  193. console.log(e);
  194. })
  195. },
  196. bindKeyInput(e) {
  197. this.setData({
  198. editCustomerName: e.detail.value,
  199. });
  200. },
  201. switchTaskRemind(){
  202. // 跳转到任务提醒器页面
  203. my.navigateTo({
  204. url: '../taskreminder/taskreminder'
  205. });
  206. },
  207. // 点击设置按钮
  208. onSetButtonClick(e){
  209. console.log(e.target);
  210. if(e.target.dataset.index==0){
  211. this.setData({
  212. unSetModal: false,
  213. });
  214. // 跳转到服务偏好页面
  215. my.navigateTo({
  216. url: '../servantsettings/servantsettings'
  217. });
  218. }else{
  219. this.setData({
  220. unSetModal: false,
  221. });
  222. }
  223. },
  224. switchSerHobby(){
  225. // 跳转到服务偏好页面
  226. if(this.data.noSetSerHobby){
  227. my.navigateTo({
  228. url: '../servantsettings/servantsettings'
  229. });
  230. }else{
  231. my.navigateTo({
  232. url: '../servantlist/servantlist'
  233. });
  234. }
  235. },
  236. // 获取保姆通知
  237. getServantNotice(){
  238. let params={
  239. employRelationNo:app.globalData.employRelationNo,
  240. userId:app.globalData.userInfo.id
  241. }
  242. request.httpServicePost(apiUrl.getServantNoticePath,params).then(data=>{
  243. console.log('保姆通知');
  244. console.log(data);
  245. let gzybgx=(data.gzybgx.size>=1);
  246. let rwsz=(data.rwsz.size>=1);
  247. let rwgx=(data.rwgx.size>=1);
  248. let fwbzsz=(data.fwbzsz.size>=1);
  249. let fwbzgx=(data.fwbzgx.size>=1);
  250. this.setData({
  251. gzybgxShow:gzybgx,
  252. rwszShow:rwsz,
  253. rwgxShow:rwgx,
  254. fwbzszShow:fwbzsz,
  255. fwbzgxShow:fwbzgx,
  256. });
  257. }).catch(e=>{
  258. console.log(e);
  259. })
  260. },
  261. // 查看月报
  262. async viewMonthReport(e){
  263. try{
  264. let data=await this.readNotice(e);
  265. if(data!=undefined){
  266. // my.navigateTo({
  267. // url: '../monthReport/monthReport'
  268. // });
  269. }
  270. }catch(e){
  271. console.log(e);
  272. }
  273. },
  274. // 查看任务
  275. async viewTaskReminder(e){
  276. try{
  277. let data=await this.readNotice(e);
  278. if(data!=undefined){
  279. my.navigateTo({
  280. url: '../taskreminder/taskreminder'
  281. });
  282. }
  283. }catch(e){
  284. console.log(e);
  285. }
  286. },
  287. // 查看服务标准
  288. async viewSerStan(e){
  289. console.log(e);
  290. try{
  291. let data=await this.readNotice(e);
  292. if(data!=undefined){
  293. my.navigateTo({
  294. url: '../servantdetail/servantdetail'
  295. });
  296. }
  297. }catch(e){
  298. console.log(e);
  299. }
  300. },
  301. async readNotice(e){
  302. let type=e.target.dataset.noticeType;
  303. console.log(type);
  304. let params={
  305. "employRelationNo": app.globalData.employRelationNo,
  306. "noticeType": type,
  307. "userId": app.globalData.userInfo.id
  308. }
  309. try{
  310. let data=await request.httpServicePost(apiUrl.userReadNoticePath,params);
  311. return data;
  312. }catch(e){
  313. console.log(e);
  314. }
  315. },
  316. async closeNotice(e){
  317. console.log('关闭通知');
  318. try{
  319. let data=await this.readNotice(e);
  320. console.log(data);
  321. if(data!=undefined){
  322. // 通知不展示
  323. let type=e.target.dataset.noticeType;
  324. console.log(type);
  325. if(type=='gzybgx'){
  326. this.setData({
  327. gzybgxShow:false
  328. })
  329. }else if(type=='rwsz'){
  330. this.setData({
  331. rwszShow:false
  332. })
  333. }else if(type=='rwgx'){
  334. this.setData({
  335. rwgxShow:false
  336. })
  337. }else if(type=='fwbzsz'){
  338. this.setData({
  339. fwbzszShow:false
  340. })
  341. }else if(type=='fwbzgx'){
  342. this.setData({
  343. fwbzgxShow:false
  344. })
  345. }
  346. }
  347. }catch(e){
  348. console.log(e);
  349. }
  350. }
  351. });