酒店桌布为微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
4.0 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <template>
  2. <!-- 修改营业时间弹框 -->
  3. <uv-overlay :show="show" @click="close">
  4. <view class="warp">
  5. <view class="rect" @tap.stop>
  6. <view class="title">修改营业时间</view>
  7. <view class="center">
  8. <view style="display: flex;justify-content: space-around;">
  9. <view>上班时间</view>
  10. <view @click="startDateOpen()">
  11. {{ startTime }}
  12. <uv-datetime-picker ref="startDateRef" v-model="startTime" mode="time"
  13. @confirm="startDateChange()"></uv-datetime-picker>
  14. </view>
  15. </view>
  16. <view style="display: flex;justify-content: space-around;">
  17. <view>下班时间</view>
  18. <view @click="endDateOpen()">
  19. {{ endTime }}
  20. <uv-datetime-picker style="z-index: 999;" ref="endDateRef" v-model="endTime" mode="time"
  21. @confirm="endDateChange()"></uv-datetime-picker>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="bottom">
  26. <view>
  27. <uv-button type="info" shape="circle" text="取消" :custom-style="customStyle1"
  28. @click="close"></uv-button>
  29. </view>
  30. <view>
  31. <uv-button type="info" shape="circle" text="确定" :custom-style="customStyle2"
  32. @click="confirm"></uv-button>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </uv-overlay>
  38. </template>
  39. <script>
  40. import {
  41. mapGetters,
  42. mapState,
  43. } from 'vuex'
  44. import dayjs from '../../uni_modules/uv-ui-tools/libs/util/dayjs';
  45. export default {
  46. data() {
  47. return {
  48. show: false,
  49. startTime: dayjs(new Date()).format("HH:mm"),
  50. endTime: dayjs(new Date()).format("HH:mm")
  51. }
  52. },
  53. computed: {
  54. ...mapGetters(['userShop']),
  55. ...mapState(['userInfo']),
  56. customStyle1() {
  57. return {
  58. height: '60rpx',
  59. background: '#FFF',
  60. color: '#000000',
  61. fontSize: '36rpx',
  62. borderRadius: '40rpx', //圆角
  63. // nvue中必须是下方的写法
  64. 'border-top-right-radius': '40rpx',
  65. 'border-bottom-left-radius': '40rpx',
  66. 'border-bottom-right-radius': '40rpx',
  67. 'width': '150rpx',
  68. }
  69. },
  70. customStyle2() {
  71. return {
  72. height: '60rpx',
  73. background: '#fd5100',
  74. color: '#FFF',
  75. fontSize: '34px',
  76. borderRadius: '40rpx', //圆角
  77. // nvue中必须是下方的写法
  78. 'border-top-right-radius': '40rpx',
  79. 'border-bottom-left-radius': '40rpx',
  80. 'border-bottom-right-radius': '40rpx',
  81. 'width': '150rpx',
  82. }
  83. }
  84. },
  85. onShow() {
  86. this.$store.commit('getUserInfo')
  87. },
  88. methods: {
  89. startDateChange(val) {
  90. this.$nextTick(() => {
  91. this.startTime = val.value
  92. });
  93. },
  94. startDateOpen() {
  95. this.$refs.startDateRef.open();
  96. },
  97. endDateChange(val) {
  98. this.$nextTick(() => {
  99. this.endTime = val.value
  100. });
  101. },
  102. endDateOpen() {
  103. this.$refs.endDateRef.open();
  104. },
  105. open() {
  106. this.show = true
  107. this.startTime = this.userInfo.shop.jobTime.split("-")[0]
  108. this.endTime = this.userInfo.shop.jobTime.split("-")[1]
  109. },
  110. close() {
  111. this.show = false
  112. },
  113. confirm() {
  114. this.show = false
  115. this.$api('updateJobTime', {
  116. time: this.startTime + '-' + this.endTime
  117. }, res => {
  118. if (res.code == 200) {
  119. this.$store.commit('getUserInfo')
  120. uni.showToast({
  121. icon: 'success',
  122. title: '修改营业时间成功',
  123. duration: 1500
  124. })
  125. }
  126. })
  127. },
  128. }
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .uv-popup {
  133. z-index: 999;
  134. }
  135. .warp {
  136. display: flex;
  137. align-items: center;
  138. justify-content: center;
  139. height: 100%;
  140. }
  141. .rect {
  142. width: 600rpx;
  143. height: 300rpx;
  144. background-color: #fff;
  145. border-radius: 20rpx;
  146. overflow: hidden;
  147. .title {
  148. padding: 10rpx 0 0 15rpx;
  149. background-color: #fd5100;
  150. color: #FFF;
  151. text-align: left;
  152. width: 100%;
  153. height: 18%;
  154. font-size: 36rpx;
  155. }
  156. .center {
  157. height: 50%;
  158. display: flex;
  159. flex-direction: column;
  160. gap: 20rpx;
  161. // justify-content: center;
  162. // align-items: center;
  163. font-size: 36rpx;
  164. padding: 20rpx 50rpx 0 50rpx;
  165. }
  166. .bottom {
  167. display: flex;
  168. justify-content: center;
  169. gap: 50rpx;
  170. }
  171. }
  172. </style>