|
|
@@ -0,0 +1,255 @@
|
|
|
+<template>
|
|
|
+ <uni-popup ref="openTimeRef" background-color="#fff" type="center" :animation="false" class="open-time-popup">
|
|
|
+ <view class="open-time-panel">
|
|
|
+ <view class="open-time-title">经营时间</view>
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">状态</view>
|
|
|
+ <view class="select-button-wrap">
|
|
|
+ <button class="admin-button-com middle" :class="[openForm.open == 1 ? 'blue' : 'default']" @click="setOpenStatus(1)">营业</button>
|
|
|
+ <button class="admin-button-com middle" :class="[openForm.open == 0 ? 'blue' : 'default']" @click="setOpenStatus(0)">休息</button>
|
|
|
+ </view>
|
|
|
+ </tui-list-cell>
|
|
|
+ <template v-if="visible">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title">时间</view>
|
|
|
+ <view class="select-button-wrap time-button-wrap">
|
|
|
+ <button class="admin-button-com middle" :class="[openForm.openType == 0 ? 'blue' : 'default']" @click="setOpenType(0)">24小时</button>
|
|
|
+ <button class="admin-button-com middle" :class="[openForm.openType == 1 ? 'blue' : 'default']" @click="setOpenType(1)">自定义</button>
|
|
|
+ </view>
|
|
|
+ </tui-list-cell>
|
|
|
+ <template v-if="openTimeVisible">
|
|
|
+ <view class="open-time-wheel-section">
|
|
|
+ <view class="open-time-wheel-row">
|
|
|
+ <view class="open-time-wheel-col">
|
|
|
+ <view class="open-time-wheel-label">开店时间</view>
|
|
|
+ <view class="open-time-wheel-value">{{ start_time }}</view>
|
|
|
+ <open-time-wheel :value="start_time" @change="onStartTimeChange" />
|
|
|
+ </view>
|
|
|
+ <view class="open-time-wheel-split"></view>
|
|
|
+ <view class="open-time-wheel-col">
|
|
|
+ <view class="open-time-wheel-label">关店时间</view>
|
|
|
+ <view class="open-time-wheel-value">{{ end_time }}</view>
|
|
|
+ <open-time-wheel :value="end_time" @change="onEndTimeChange" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </view>
|
|
|
+ <view class="open-time-actions">
|
|
|
+ <button class="admin-button-com big default open-time-btn" @click="close">取消</button>
|
|
|
+ <button class="admin-button-com big blue open-time-btn" @click="submitOpenTime">保存</button>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </uni-popup>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { mapGetters } from 'vuex'
|
|
|
+import { getDetail, updateShopOpenTime } from '@/api/shop'
|
|
|
+import TuiListCell from '@/components/plugin/list-cell'
|
|
|
+import OpenTimeWheel from '@/components/module/open-time-wheel.vue'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'ShopOpenTimePopup',
|
|
|
+ components: {
|
|
|
+ TuiListCell,
|
|
|
+ OpenTimeWheel
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ visible: true,
|
|
|
+ openTimeVisible: false,
|
|
|
+ start_time: '09:00',
|
|
|
+ end_time: '18:00',
|
|
|
+ openForm: {
|
|
|
+ id: 0,
|
|
|
+ open: 1,
|
|
|
+ openType: 0,
|
|
|
+ openStartTime: '',
|
|
|
+ openEndTime: ''
|
|
|
+ },
|
|
|
+ openTimeLoading: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ...mapGetters({ loginInfo: 'getLoginInfo' })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ open() {
|
|
|
+ const shopId = this.loginInfo && this.loginInfo.shopId
|
|
|
+ if (!shopId) {
|
|
|
+ this.$msg('未获取到门店信息')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (this.openTimeLoading) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.openTimeLoading = true
|
|
|
+ getDetail({ shopId }).then(res => {
|
|
|
+ const data = res.data && res.data.info
|
|
|
+ if (this.$util.isEmpty(data)) {
|
|
|
+ this.$msg('获取门店详情失败')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.applyOpenTimeData(data)
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.openTimeRef && this.$refs.openTimeRef.open()
|
|
|
+ })
|
|
|
+ }).catch(() => {
|
|
|
+ this.$msg('获取门店详情失败')
|
|
|
+ }).finally(() => {
|
|
|
+ this.openTimeLoading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ applyOpenTimeData(data) {
|
|
|
+ this.openForm.id = data.id
|
|
|
+ this.openForm.open = data.open == null ? 1 : Number(data.open)
|
|
|
+ this.visible = this.openForm.open === 1
|
|
|
+ this.openForm.openType = 1
|
|
|
+ this.openTimeVisible = true
|
|
|
+ this.start_time = data.openStartTime || '09:00'
|
|
|
+ this.end_time = data.openEndTime || '18:00'
|
|
|
+ this.openForm.openStartTime = this.start_time
|
|
|
+ this.openForm.openEndTime = this.end_time
|
|
|
+ if (!data.openStartTime) {
|
|
|
+ this.openTimeVisible = false
|
|
|
+ this.openForm.openType = 0
|
|
|
+ this.start_time = '09:00'
|
|
|
+ this.openForm.openStartTime = this.start_time
|
|
|
+ }
|
|
|
+ if (!data.openEndTime) {
|
|
|
+ this.end_time = '18:00'
|
|
|
+ this.openForm.openEndTime = this.end_time
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close() {
|
|
|
+ this.$refs.openTimeRef.close()
|
|
|
+ },
|
|
|
+ setOpenStatus(value) {
|
|
|
+ const selected = Number(value)
|
|
|
+ this.visible = selected === 1
|
|
|
+ this.openForm.open = selected
|
|
|
+ },
|
|
|
+ setOpenType(value) {
|
|
|
+ const selected = Number(value)
|
|
|
+ this.openTimeVisible = selected === 1
|
|
|
+ this.openForm.openType = selected === 0 ? 0 : 1
|
|
|
+ if (this.openTimeVisible) {
|
|
|
+ this.start_time = '09:00'
|
|
|
+ this.end_time = '18:00'
|
|
|
+ this.openForm.openStartTime = this.start_time
|
|
|
+ this.openForm.openEndTime = this.end_time
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onStartTimeChange(time) {
|
|
|
+ this.start_time = time
|
|
|
+ this.openForm.openStartTime = time
|
|
|
+ },
|
|
|
+ onEndTimeChange(time) {
|
|
|
+ this.end_time = time
|
|
|
+ this.openForm.openEndTime = time
|
|
|
+ },
|
|
|
+ submitOpenTime() {
|
|
|
+ if (!this.openForm.id) {
|
|
|
+ this.$msg('门店信息异常')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const payload = {
|
|
|
+ shopId: this.openForm.id,
|
|
|
+ open: this.openForm.open,
|
|
|
+ openType: this.openForm.openType
|
|
|
+ }
|
|
|
+ if (this.openForm.openType === 1) {
|
|
|
+ payload.openStartTime = this.openForm.openStartTime
|
|
|
+ payload.openEndTime = this.openForm.openEndTime
|
|
|
+ } else {
|
|
|
+ payload.openStartTime = ''
|
|
|
+ payload.openEndTime = ''
|
|
|
+ }
|
|
|
+ updateShopOpenTime(payload).then(() => {
|
|
|
+ this.$msg('修改成功')
|
|
|
+ this.close()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.open-time-popup {
|
|
|
+ z-index: 99999;
|
|
|
+ border-radius: 20upx;
|
|
|
+}
|
|
|
+.open-time-panel {
|
|
|
+ width: 640upx;
|
|
|
+ max-width: 90vw;
|
|
|
+ padding: 30upx 20upx 20upx;
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+.open-time-title {
|
|
|
+ font-size: 34upx;
|
|
|
+ font-weight: bold;
|
|
|
+ text-align: center;
|
|
|
+ margin-bottom: 20upx;
|
|
|
+}
|
|
|
+.open-time-actions {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin-top: 30upx;
|
|
|
+ padding: 0 10upx;
|
|
|
+}
|
|
|
+.open-time-btn {
|
|
|
+ flex: 1;
|
|
|
+ margin: 0;
|
|
|
+}
|
|
|
+.open-time-btn + .open-time-btn {
|
|
|
+ margin-left: 20upx;
|
|
|
+}
|
|
|
+.select-button-wrap {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 150upx;
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+ .admin-button-com + .admin-button-com {
|
|
|
+ margin-left: 15upx;
|
|
|
+ }
|
|
|
+}
|
|
|
+.time-button-wrap {
|
|
|
+ .admin-button-com {
|
|
|
+ width: 150upx;
|
|
|
+ }
|
|
|
+}
|
|
|
+.open-time-wheel-section {
|
|
|
+ padding: 10upx 0 0;
|
|
|
+}
|
|
|
+.open-time-wheel-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: stretch;
|
|
|
+}
|
|
|
+.open-time-wheel-col {
|
|
|
+ flex: 1;
|
|
|
+ min-width: 0;
|
|
|
+}
|
|
|
+.open-time-wheel-split {
|
|
|
+ width: 1upx;
|
|
|
+ margin: 20upx 0;
|
|
|
+ background-color: #eeeeee;
|
|
|
+}
|
|
|
+.open-time-wheel-label {
|
|
|
+ text-align: center;
|
|
|
+ font-size: 28upx;
|
|
|
+ color: #666666;
|
|
|
+}
|
|
|
+.open-time-wheel-value {
|
|
|
+ text-align: center;
|
|
|
+ font-size: 34upx;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #3385FF;
|
|
|
+ margin-top: 8upx;
|
|
|
+ margin-bottom: 6upx;
|
|
|
+}
|
|
|
+</style>
|