index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <!-- index.wxml -->
  3. <view class="wrap">
  4. <view class="wrap_nr">
  5. <view class="time_list">
  6. <view class="time_item" v-for="(item, index) in dataList" :key="index">
  7. <view class="item_t">
  8. <view class="col_text">开始时间:{{ item.begin_at }}</view>
  9. <view class="col_text">结束时间:{{ item.end_at }}</view>
  10. <view class="col_text">可用状态:{{ item.status ? '可用' : '禁用' }}</view>
  11. </view>
  12. <view class="item_b">
  13. <view class="ac_btn" @tap="toAddDetail" :data-id="item.id">编辑</view>
  14. <view class="ac_btn del" @tap="toDelItem" :data-id="item.id">删除</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="actions_wrap">
  20. <view class="btn" @tap="toAddDetail">添加</view>
  21. </view>
  22. </view>
  23. <!-- loading -->
  24. <!-- <van-overlay show="{{ loading }}" z-index="100">
  25. <van-loading custom-class="custom_loading" />
  26. </van-overlay> -->
  27. </template>
  28. <script>
  29. // index.js
  30. let myPro = require('../../../../utils/wxRequest.js');
  31. let util = require('../../../../utils/util.js');
  32. export default {
  33. data() {
  34. return {
  35. dataList: []
  36. };
  37. },
  38. onLoad: function (options) {
  39. // Do some initialize when page load.
  40. let that = this;
  41. },
  42. onShow: function () {
  43. // Do something when page show.
  44. let that = this;
  45. that.getBusinessTime();
  46. },
  47. onReady: function () {
  48. // Do something when page ready.
  49. },
  50. onHide: function () {
  51. // Do something when page hide.
  52. },
  53. onUnload: function () {
  54. // Do something when page close.
  55. },
  56. onPullDownRefresh: function () {
  57. // Do something when pull down.
  58. },
  59. onReachBottom: function () {
  60. // Do something when page reach bottom.
  61. },
  62. onShareAppMessage: function () {
  63. // return custom share data when user share.
  64. },
  65. onPageScroll: function () {
  66. // Do something when page scroll
  67. },
  68. onResize: function () {
  69. // Do something when page resize
  70. },
  71. methods: {
  72. // 列表
  73. getBusinessTime() {
  74. let that = this;
  75. myPro
  76. .wxRequest('store/businessHours/list', 'GET', {})
  77. .then((res) => {
  78. that.setData({
  79. dataList: res.result
  80. });
  81. })
  82. .catch((err) => {
  83. console.log('报错信息', err);
  84. uni.showToast({
  85. title: err,
  86. icon: 'none'
  87. });
  88. });
  89. },
  90. // 添加
  91. toAddDetail(event) {
  92. let that = this;
  93. let id = event.currentTarget.dataset.id;
  94. let url = id ? '/pages/shopRole/businesstime/detail/index?id=' + id : '/pages/shopRole/businesstime/detail/index';
  95. uni.navigateTo({
  96. url: url
  97. });
  98. },
  99. // 删除
  100. toDelItem(event) {
  101. let that = this;
  102. let id = event.currentTarget.dataset.id;
  103. let params = {
  104. id: id
  105. };
  106. myPro
  107. .wxRequest('store/businessHours/remove', 'POST', params)
  108. .then((res) => {
  109. uni.showToast({
  110. title: res.msg,
  111. icon: 'none'
  112. });
  113. that.getBusinessTime();
  114. })
  115. .catch((err) => {
  116. console.log('报错信息', err);
  117. uni.showToast({
  118. title: err,
  119. icon: 'none'
  120. });
  121. });
  122. }
  123. }
  124. };
  125. </script>
  126. <style>
  127. /**index.wxss**/
  128. .wrap {
  129. width: 690rpx;
  130. /* background:rgba(255,255,255,1);
  131. box-shadow:0rpx 0rpx 21rpx 0rpx rgba(0, 0, 0, 0.09); */
  132. margin: 0 auto;
  133. }
  134. .time_item {
  135. margin-top: 30rpx;
  136. font-size: 30rpx;
  137. background: rgba(255, 255, 255, 1);
  138. box-shadow: 0rpx 0rpx 21rpx 0rpx rgba(0, 0, 0, 0.09);
  139. border-radius: 10rpx;
  140. padding: 20rpx 30rpx;
  141. }
  142. .time_item .item_t {
  143. padding-bottom: 20rpx;
  144. }
  145. .time_item .item_b {
  146. border-top: 1px solid rgba(0, 0, 0, 0.1);
  147. display: flex;
  148. align-items: center;
  149. justify-content: flex-end;
  150. padding-top: 20rpx;
  151. }
  152. .time_item .ac_btn {
  153. width: 100rpx;
  154. height: 40rpx;
  155. background: #49c265;
  156. display: flex;
  157. align-items: center;
  158. justify-content: center;
  159. border-radius: 20rpx;
  160. color: #ffffff;
  161. }
  162. .time_item .ac_btn:not(:first-child) {
  163. margin-left: 10rpx;
  164. }
  165. .time_item .ac_btn.del {
  166. background: #d54c43;
  167. }
  168. .actions_wrap {
  169. margin-top: 40rpx;
  170. }
  171. .actions_wrap .btn {
  172. width: 320rpx;
  173. height: 80rpx;
  174. margin: 0 auto;
  175. color: #fff;
  176. background: #295c56;
  177. border-radius: 40rpx;
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. font-size: 28rpx;
  182. }
  183. </style>