servantCenter.js 9.0 KB

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