index.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // index.js
  2. let myPro = require("../../../../utils/wxRequest.js");
  3. let util = require("../../../../utils/util.js");
  4. Page({
  5. data: {
  6. dataList: []
  7. },
  8. onLoad: function (options) {
  9. // Do some initialize when page load.
  10. let that = this;
  11. },
  12. onShow: function () {
  13. // Do something when page show.
  14. let that = this;
  15. that.getBusinessTime();
  16. },
  17. onReady: function () {
  18. // Do something when page ready.
  19. },
  20. onHide: function () {
  21. // Do something when page hide.
  22. },
  23. onUnload: function () {
  24. // Do something when page close.
  25. },
  26. onPullDownRefresh: function () {
  27. // Do something when pull down.
  28. },
  29. onReachBottom: function () {
  30. // Do something when page reach bottom.
  31. },
  32. onShareAppMessage: function () {
  33. // return custom share data when user share.
  34. },
  35. onPageScroll: function () {
  36. // Do something when page scroll
  37. },
  38. onResize: function () {
  39. // Do something when page resize
  40. },
  41. // 列表
  42. getBusinessTime(){
  43. let that = this;
  44. myPro.wxRequest("store/businessHours/list","GET",{}).then(res=>{
  45. that.setData({
  46. dataList: res.result
  47. });
  48. }).catch(err=>{
  49. console.log('报错信息',err);
  50. wx.showToast({
  51. title: err,
  52. icon: "none"
  53. })
  54. })
  55. },
  56. // 添加
  57. toAddDetail(event){
  58. let that = this;
  59. let id = event.currentTarget.dataset.id;
  60. let url = id ? '/pages/shopRole/businesstime/detail/index?id='+id : '/pages/shopRole/businesstime/detail/index';
  61. wx.navigateTo({
  62. url: url
  63. });
  64. },
  65. // 删除
  66. toDelItem(event){
  67. let that = this;
  68. let id = event.currentTarget.dataset.id;
  69. let params = {
  70. id: id
  71. };
  72. myPro.wxRequest("store/businessHours/remove","POST",params).then(res=>{
  73. wx.showToast({
  74. title: res.msg,
  75. icon: "none"
  76. });
  77. that.getBusinessTime();
  78. }).catch(err=>{
  79. console.log('报错信息',err);
  80. wx.showToast({
  81. title: err,
  82. icon: "none"
  83. })
  84. })
  85. }
  86. });