punchTime.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="container">
  3. <!-- 头部添加打卡时间区域 -->
  4. <view class="add">
  5. <view class="icon" @click="handleAdd">
  6. <img src="../../static/add.png">
  7. </view>
  8. <view class="title" @click="handleAdd">
  9. 添加打卡时间
  10. </view>
  11. <view class="none"></view>
  12. </view>
  13. <!-- 打卡时间列表 -->
  14. <view class="list">
  15. <uni-swipe-action>
  16. <!-- 每一个时间段区域 -->
  17. <uni-swipe-action-item :auto-close="true" :right-options="options" @click="onClick(item.id)"
  18. v-for="item in list" :key="item.id">
  19. <view class="box">
  20. <view class="left">
  21. <view class="week">
  22. <view class="key">
  23. 星期
  24. </view>
  25. <view class="value">
  26. {{item.week}}
  27. </view>
  28. </view>
  29. <view class="week">
  30. <view class="key">
  31. 时段
  32. </view>
  33. <view class="value">
  34. {{item.time}}
  35. </view>
  36. </view>
  37. </view>
  38. <view class="right">
  39. <img src="../../static/right.png">
  40. </view>
  41. </view>
  42. </uni-swipe-action-item>
  43. </uni-swipe-action>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. list: [{
  52. id: 1,
  53. week: "周一,周二,周三,周四,周五,周六,周日",
  54. time: "09:00-17:00、20:00-21:00、22:00-23:00"
  55. },
  56. {
  57. id: 2,
  58. week: "周一,周二,周三,周四,周五,周六,周日",
  59. time: "09:00-17:00"
  60. },
  61. {
  62. id: 3,
  63. week: "周一,周二,周三,周四,周五,周六,周日",
  64. time: "12:00-17:00"
  65. },
  66. {
  67. id: 4,
  68. week: "周一,周二,周三,周四,周五,周六,周日",
  69. time: "09:00-17:00、20:00-21:00、22:00-23:00"
  70. },
  71. ],
  72. options: [{
  73. text: '删除',
  74. style: {
  75. backgroundColor: '#D43030'
  76. }
  77. }],
  78. }
  79. },
  80. methods: {
  81. handleAdd() {
  82. console.log("添加打卡时间");
  83. uni.navigateTo({
  84. url:"/pages/setPunchTime/setPunchTime"
  85. })
  86. },
  87. // 点击右侧删除按钮回调
  88. onClick(id) {
  89. console.log(id);
  90. uni.showModal({
  91. title: '提示',
  92. content: '确定删除该打卡时间吗?',
  93. success: function(res) {
  94. if (res.confirm) {
  95. console.log('用户点击确定');
  96. uni.showToast({
  97. title: "删除成功",
  98. icon: 'success'
  99. })
  100. } else if (res.cancel) {
  101. console.log('用户点击取消');
  102. }
  103. }
  104. });
  105. },
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .container {
  111. padding-top: 20rpx;
  112. .add {
  113. display: flex;
  114. margin: 0 auto;
  115. width: 690rpx;
  116. height: 87rpx;
  117. line-height: 87rpx;
  118. border-radius: 14rpx;
  119. background-color: #fff;
  120. .icon {
  121. flex: 1;
  122. display: flex;
  123. justify-content: center;
  124. align-items: center;
  125. img {
  126. width: 36rpx;
  127. height: 36rpx;
  128. }
  129. }
  130. .title {
  131. flex: 3;
  132. font-size: 30rpx;
  133. color: #0082FC;
  134. }
  135. .none {
  136. flex: 5;
  137. }
  138. }
  139. .list {
  140. margin-top: 20rpx;
  141. padding-bottom: 30rpx;
  142. .box {
  143. display: flex;
  144. margin: 0 auto;
  145. margin-bottom: 20rpx;
  146. width: 690rpx;
  147. height: 132rpx;
  148. border-radius: 14rpx;
  149. background-color: #fff;
  150. .left {
  151. flex: 5;
  152. display: flex;
  153. flex-direction: column;
  154. margin-left: 17rpx;
  155. .week {
  156. flex: 1;
  157. display: flex;
  158. align-items: center;
  159. font-size: 24rpx;
  160. .key {
  161. flex: 1;
  162. margin-left: 8rpx;
  163. color: #A6A6A6;
  164. }
  165. .value {
  166. flex: 5;
  167. overflow: hidden;
  168. white-space: nowrap;
  169. text-overflow: ellipsis;
  170. }
  171. }
  172. }
  173. .right {
  174. flex: 2;
  175. display: flex;
  176. justify-content: flex-end;
  177. align-items: center;
  178. img {
  179. margin-right: 20rpx;
  180. width: 20rpx;
  181. height: 30rpx;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. // 解决左滑区域突出问题
  188. ::v-deep .uni-swipe_button-group {
  189. margin-bottom: 20rpx;
  190. }
  191. </style>