servantCenter.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. noticeShow:true,//通知栏展示
  13. editModalShow:false,//编辑弹框
  14. unSetModal:false,//未设置偏好
  15. noSetSerHobby:false,//展示未设置服务偏好
  16. noSetSerStan:false,//展示未设置服务标准
  17. unSetBtn: [
  18. { text: '现在设置', extClass: 'buttonBold' },
  19. { text: '暂不' },
  20. ],
  21. buttonFooter:[
  22. { text: '取消' },
  23. { text: '确定', extClass: 'buttonBold' },
  24. ],
  25. customerName:'',//客户姓名
  26. editCustomerName:'',//编辑客户姓名
  27. workDay:'',//工作日
  28. serviceType:'',//保姆工种
  29. completeTaskCount:'',
  30. totalTaskCount:''
  31. },
  32. onLoad(query) {
  33. console.log(query);
  34. let emReNo=query.emReNo;
  35. // 存储此次进入任务中心的关联码
  36. app.globalData.employRelationNo=emReNo;
  37. my.setStorageSync({
  38. key: 'employRelationNo',
  39. data: emReNo
  40. });
  41. this.initCustomerInfo();
  42. this.isChooseSerHobSubject();
  43. this.isChooseSerStanSubject();
  44. this.selectTodayTaskItem();
  45. },
  46. onShow(query){
  47. console.log(query);
  48. },
  49. // 获取雇佣关系详情
  50. initCustomerInfo(){
  51. let params={
  52. "employRelationNo":app.globalData.employRelationNo
  53. }
  54. request.httpServiceGet(apiUrl.getRelationInfoPath,params).then(data=>{
  55. console.log(data);
  56. let isOnlyOne=(data.isMoreEmploy<=1);
  57. this.setData({
  58. customerName:data.employerName,
  59. workDay:data.servantTaskPeriod.workDay,
  60. serviceType:data.servantType,
  61. isOnlyOne:isOnlyOne
  62. });
  63. }).catch(e=>{
  64. console.log(e);
  65. })
  66. },
  67. // 是否设置服务偏好
  68. isChooseSerHobSubject(){
  69. let params={
  70. "employRelationNo":app.globalData.employRelationNo
  71. }
  72. request.httpServiceGet(apiUrl.isChooseSerHobSubjectPath,params).then(data=>{
  73. console.log(data);
  74. let noSetSerHobby=(data=='0'?true:false);
  75. this.setData({
  76. noSetSerHobby:noSetSerHobby,
  77. unSetModal:noSetSerHobby,
  78. });
  79. }).catch(e=>{
  80. console.log(e);
  81. })
  82. },
  83. // 是否设置服务标准
  84. isChooseSerStanSubject(){
  85. let params={
  86. "employRelationNo":app.globalData.employRelationNo
  87. }
  88. request.httpServiceGet(apiUrl.isChooseSerStanSubjectPath,params).then(data=>{
  89. console.log(data);
  90. let noSetSerStan=(data=='0'?true:false);
  91. this.setData({
  92. noSetSerStan:noSetSerStan,
  93. });
  94. }).catch(e=>{
  95. console.log(e);
  96. })
  97. },
  98. // 是否每日任务,每日任务前三条
  99. selectTodayTaskItem(){
  100. let params={
  101. "employRelationNo":app.globalData.employRelationNo
  102. }
  103. request.httpServiceGet(apiUrl.selectTodayTaskItemPath,params).then(data=>{
  104. console.log(data);
  105. // 未设置任务
  106. if(!data.isSet){
  107. this.setData({
  108. noAddTaskShow:true,
  109. noTaskShow:false,
  110. taskListShow:false,
  111. });
  112. }else{
  113. // 今天是休息日
  114. if(data.servantTasks.length==0){
  115. this.setData({
  116. noAddTaskShow:false,
  117. noTaskShow:true,
  118. taskListShow:false,
  119. taskList:data.servantTasks
  120. });
  121. }else{
  122. // 今天有任务
  123. this.setData({
  124. noAddTaskShow:false,
  125. noTaskShow:false,
  126. taskListShow:true,
  127. taskList:data.servantTasks,
  128. completeTaskCount:data.completeTaskCount,
  129. totalTaskCount:data.totalTaskCount
  130. });
  131. }
  132. }
  133. }).catch(e=>{
  134. console.log(e);
  135. })
  136. },
  137. switchList(){
  138. my.navigateTo({
  139. url: '../myCustomerList/myCustomerList'
  140. });
  141. },
  142. // 跳转到服务标准页面
  143. switchSerStandard(){
  144. my.navigateTo({
  145. url: '../servantdetail/servantdetail'
  146. });
  147. },
  148. editCustomer(event){
  149. console.log(event);
  150. this.setData({
  151. editCustomerName:'',
  152. editModalShow:true,
  153. });
  154. },
  155. onModalClose(e){
  156. console.log(e.target);
  157. if(e.target.dataset.index==0){
  158. this.setData({
  159. editModalShow: false,
  160. });
  161. }else{
  162. // 保存客户姓名
  163. this.editEmployerSubmit();
  164. }
  165. },
  166. // 编辑雇主提交
  167. editEmployerSubmit(){
  168. let params={
  169. "employerName":this.data.editCustomerName,
  170. "employRelationNo": app.globalData.employRelationNo,
  171. }
  172. request.httpServicePost(apiUrl.updateEmployerNamePath,params).then(data=>{
  173. console.log(data);
  174. my.showToast({
  175. content: '修改成功',
  176. });
  177. this.setData({
  178. editModalShow: false,
  179. });
  180. // 修改成功后刷新页面
  181. this.initCustomerInfo();
  182. }).catch(e=>{
  183. console.log(e);
  184. })
  185. },
  186. bindKeyInput(e) {
  187. this.setData({
  188. editCustomerName: e.detail.value,
  189. });
  190. },
  191. closeNotice(){
  192. this.setData({
  193. noticeShow:false
  194. });
  195. },
  196. switchTaskRemind(){
  197. // 跳转到任务提醒器页面
  198. my.navigateTo({
  199. url: '../taskreminder/taskreminder'
  200. });
  201. },
  202. // 点击设置按钮
  203. onSetButtonClick(e){
  204. console.log(e.target);
  205. if(e.target.dataset.index==0){
  206. this.setData({
  207. unSetModal: false,
  208. });
  209. // 跳转到服务偏好页面
  210. my.navigateTo({
  211. url: '../servantsettings/servantsettings'
  212. });
  213. }else{
  214. this.setData({
  215. unSetModal: false,
  216. });
  217. }
  218. },
  219. switchSerHobby(){
  220. // 跳转到服务偏好页面
  221. if(this.data.noSetSerHobby){
  222. my.navigateTo({
  223. url: '../servantsettings/servantsettings'
  224. });
  225. }else{
  226. my.navigateTo({
  227. url: '../servantlist/servantlist'
  228. });
  229. }
  230. }
  231. });