myServantList.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import request from '../../../util/http'
  2. import apiUrl from '../../../util/apiUrl'
  3. var app = getApp();
  4. Page({
  5. data: {
  6. listShow:false,
  7. noServantList:false,
  8. unSetModal:false,//未设置服务者提醒
  9. unSetBtn: [
  10. { text: '设置', extClass: 'buttonBold' },
  11. { text: '暂不' },
  12. ],
  13. buttonFooter:[
  14. { text: '取消' },
  15. { text: '确定', extClass: 'buttonBold' },
  16. ],
  17. servantList:[]
  18. },
  19. onLoad() {
  20. // this.initServantList();
  21. },
  22. onShow(){
  23. this.initServantList();
  24. },
  25. initServantList(){
  26. let params={
  27. "employerId":app.globalData.userInfo.id,
  28. "pageNo": 1,
  29. "pageSize": 100,
  30. }
  31. request.httpServicePost(apiUrl.findByEmployerIdListPath,params).then(data=>{
  32. console.log(data);
  33. if(data.dataList.length==0){
  34. this.setData({
  35. listShow:false,
  36. noServantList:true,
  37. unSetModal:true,
  38. });
  39. }else{
  40. this.setData({
  41. listShow:true,
  42. noServantList:false,
  43. unSetModal:false,
  44. servantList:data.dataList
  45. });
  46. }
  47. }).catch(e=>{
  48. console.log(e);
  49. })
  50. },
  51. editServant(e){
  52. console.log(e);
  53. app.globalData.relationInfo=e.target.dataset.relationInfo;
  54. my.navigateTo({ url: '../editServant/editServant' });
  55. },
  56. addServant(){
  57. my.navigateTo({ url: '../createServant/createServant' });
  58. },
  59. enterCustomerCenter(e){
  60. let emReNo=e.target.dataset.emReNo;
  61. my.navigateTo({
  62. url: '../customerCenter/customerCenter?emReNo='+emReNo
  63. });
  64. },
  65. // 点击设置按钮
  66. onSetButtonClick(e){
  67. console.log(e.target);
  68. if(e.target.dataset.index==0){
  69. this.setData({
  70. unSetModal: false,
  71. });
  72. my.navigateTo({ url: '../createServant/createServant' });
  73. }else{
  74. this.setData({
  75. unSetModal: false,
  76. });
  77. }
  78. },
  79. // 切换角色
  80. switchRole(){
  81. my.navigateTo({ url: '../../common/selectRole/selectRole' });
  82. },
  83. copyCode(e){
  84. let code=e.target.dataset.code;
  85. console.log(code);
  86. my.setClipboard({
  87. text: code,
  88. success:()=>{
  89. my.showToast({
  90. content: '复制成功',
  91. });
  92. },
  93. fail:()=>{
  94. my.showToast({
  95. content: '复制失败',
  96. });
  97. }
  98. });
  99. },
  100. });