'创建鸿蒙应用'
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
.info{
|
||||
text-align: center;
|
||||
.logo {
|
||||
width: 300rpx;
|
||||
height: 300rpx;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.storeStatus{
|
||||
margin: 20rpx;
|
||||
height: 220rpx;
|
||||
background:linear-gradient(180deg, #a4e8f5, #fff);
|
||||
border-top-right-radius: 20rpx;
|
||||
border-top-left-radius: 20rpx;
|
||||
padding: 20rpx;
|
||||
|
||||
.status,.timeInfo{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.status,.timeInfo{
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.title1,.title2{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.title2{
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.timeInfo{
|
||||
.timRange2{
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.time{
|
||||
background: #fff;
|
||||
height: 220rpx;
|
||||
margin:-40rpx 20rpx 20rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
border: 1rpx solid #eee;
|
||||
padding: 20rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.timeItem{
|
||||
background-color: #cccccc;
|
||||
border-radius: 20rpx;
|
||||
padding: 10rpx;
|
||||
color:#fff;
|
||||
}
|
||||
.disabledColor{
|
||||
opacity: 0.6;
|
||||
background-color: #ffad49;
|
||||
}
|
||||
|
||||
.notice{
|
||||
border: 1rpx solid #eee;
|
||||
text-align: left;
|
||||
margin:20rpx;
|
||||
padding: 20rpx;
|
||||
color:rgb(241, 167, 114);
|
||||
font-size: 28rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.jx-popup-update {
|
||||
box-sizing: border-box;
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 0 0 15rpx 15rpx;
|
||||
width: 94vw;
|
||||
|
||||
.text {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
margin-bottom: 25rpx;
|
||||
padding-bottom: 10rpx;
|
||||
border-bottom: 2rpx solid rgb(209, 209, 209);
|
||||
}
|
||||
|
||||
.ipt {
|
||||
border: 2rpx solid rgb(209, 209, 209);
|
||||
text-align: center;
|
||||
height: 140rpx;
|
||||
border-radius: 5rpx;
|
||||
padding-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.item{
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.btn-root {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 40rpx 0 0rpx 0;
|
||||
|
||||
.btn-esc,
|
||||
.btn-ok {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
padding: 15rpx 0;
|
||||
border-radius: 10rpx;
|
||||
border: 2rpx solid $jx-primary;
|
||||
color: $jx-primary;
|
||||
}
|
||||
|
||||
.btn-ok {
|
||||
background-color: $jx-primary;
|
||||
color: #fff;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.btn-esc {
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { getStorage } from '@/utils/storage';
|
||||
import merchant from '@/api/https/merchant';
|
||||
import { timeFormatD } from "@/utils/tools";
|
||||
import useGlobalFunc from '@/composables/useGlobalFunc';
|
||||
import { store } from '@/store'
|
||||
import toast from "@/utils/toast";
|
||||
export default {
|
||||
setup() {
|
||||
const businessStatusList = ref([
|
||||
{ id: 1, name: '营业' },
|
||||
{ id: 0, name: '临时休息' },
|
||||
{ id: -1, name: '休息' }
|
||||
// { id: -2, name: '禁用' },
|
||||
])
|
||||
const businessHours = ref<AnyObject>({}) // 营业时间段
|
||||
const businessStatus = ref(1) // 营业状态,默认营业
|
||||
const newAutoEnableAt = ref<string>('')
|
||||
const popupTime = ref() // 临时休息的时间弹框
|
||||
const dayList = ref(["休息到明天", "休息到后天"]); // 临时休息时间段
|
||||
const currentTime = ref(0)
|
||||
const storeName = ref('') // 门店名称
|
||||
const logoUrl = ref('https://image.jxc4.com/image/9b9436561e7ff7d8d764787b1aa5182e.jpg')
|
||||
|
||||
const { isTxd } = useGlobalFunc()
|
||||
|
||||
onLoad(async () => {
|
||||
store.commit('storeInfo/jxLoadingFn', true)
|
||||
if (getStorage('terrace') === 'jxgy') logoUrl.value = 'https://image.jxc4.com/image/9e26e6d4e8646d340c21dfe595ac4d08.jpg'
|
||||
else if (getStorage('terrace') === 'gblm') logoUrl.value = 'https://image.jxc4.com/image/5cd356df441a32295798f78a39491464.png'
|
||||
await getStores()
|
||||
store.commit('storeInfo/jxLoadingFn', false)
|
||||
})
|
||||
|
||||
|
||||
const switchOpenTime = computed(() => {
|
||||
if (newAutoEnableAt.value) {
|
||||
let now = +new Date(timeFormatD(+new Date()));
|
||||
let time = +new Date(timeFormatD(newAutoEnableAt.value));
|
||||
let num = time - now;
|
||||
if (num < 0) {
|
||||
return "营业时间错误请联系运营";
|
||||
} else {
|
||||
let day = num / 1000 / 3600 / 24;
|
||||
if (day < 1) return "门店将在今天自动营业";
|
||||
else if (day >= 1 && day < 2) return "门店将在明天自动营业";
|
||||
else if (day >= 2 && day < 3) return "门店将在后天自动营业";
|
||||
else return `将在 ${timeFormatD(newAutoEnableAt.value)} 自动营业`;
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取门店数据
|
||||
*/
|
||||
async function getStores() {
|
||||
await store.dispatch('storeInfo/getOneStore',getStorage("storeID"))
|
||||
const stateData = store.state.storeInfo.allStoreInfo
|
||||
storeName.value = stateData.name // 门店名
|
||||
businessStatus.value = stateData.status // 营业状态
|
||||
newAutoEnableAt.value = stateData.autoEnableAt // 手机门店休息时间
|
||||
businessHours.value = store.getters['storeInfo/businessHours'] // 营业时间
|
||||
}
|
||||
|
||||
|
||||
/*************************************************
|
||||
* 去修改营业时间
|
||||
*/
|
||||
function setTime() {
|
||||
uni.navigateTo({ url: `/subPages/merchantChild/setBusinessTime/setBusinessTime` })
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* 修改营业状态
|
||||
*/
|
||||
function setStatus(item: AnyObject) {
|
||||
if (item.id === businessStatus.value) return
|
||||
// console.log('修改营业状态', item)
|
||||
|
||||
if (item.id === 1) {
|
||||
uni.jxConfirm({
|
||||
title: '提示',
|
||||
content: '确定要将此门店设置为营业吗?',
|
||||
success: async () => {
|
||||
let data = {
|
||||
storeID: getStorage("storeID"),
|
||||
payload: JSON.stringify({
|
||||
status: 1,
|
||||
}),
|
||||
};
|
||||
await merchant.update_store(data);
|
||||
setTxdIngState(1)
|
||||
newAutoEnableAt.value = ''
|
||||
toast("操作成功", 1)
|
||||
// state.value = 1;
|
||||
// businessStatus.value = item.id
|
||||
await getStores()
|
||||
// uni.navigateBack()
|
||||
},
|
||||
})
|
||||
} else if (item.id === 0) {
|
||||
// console.log('设置门店为临时休息')
|
||||
popupTime.value.open()
|
||||
// businessStatus.value = item.id
|
||||
} else if (item.id === -1) {
|
||||
uni.jxConfirm({
|
||||
title: '提示',
|
||||
content: '确定要将此门店设置为休息吗?',
|
||||
success: async () => {
|
||||
let data = {
|
||||
storeID: getStorage("storeID"),
|
||||
payload: JSON.stringify({
|
||||
status: -1,
|
||||
}),
|
||||
};
|
||||
await merchant.update_store(data);
|
||||
setTxdIngState(-1)
|
||||
newAutoEnableAt.value = ''
|
||||
// businessStatus.value = item.id
|
||||
toast("操作成功", 1)
|
||||
await getStores()
|
||||
// uni.navigateBack()
|
||||
},
|
||||
})
|
||||
} else {
|
||||
// 禁用
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置第三方平台
|
||||
*/
|
||||
async function setTxdIngState(type: number) {
|
||||
if (isTxd()) {
|
||||
let data = {
|
||||
vendorOrgCode: 34402634,
|
||||
txdStores: JSON.stringify({
|
||||
flag: [1],
|
||||
txdStoreID: `JX${getStorage('storeID')}`,
|
||||
status: type
|
||||
})
|
||||
}
|
||||
await merchant.update_txd_store(data)
|
||||
}
|
||||
|
||||
// 更新线上平台的营业状态
|
||||
let arr = store.state.storeInfo.allStoreInfo.StoreMaps.map((item: AnyObject) => {
|
||||
if (item.isSync) return item.vendorID + ''
|
||||
})
|
||||
|
||||
arr = arr.filter((item: string) => item !== '9')
|
||||
if (arr.length > 0) {
|
||||
let data = {
|
||||
storeID: getStorage('storeID'),
|
||||
vendorIDs: arr.join(','),
|
||||
status: type
|
||||
}
|
||||
await merchant.update_vendors_store_states(data);
|
||||
}
|
||||
// uni.navigateBack()
|
||||
}
|
||||
|
||||
async function storeRest() {
|
||||
let autoEnableAt = currentTime.value
|
||||
? timeFormatD(+new Date() + 2 * 24 * 3600 * 1000)
|
||||
: timeFormatD(+new Date() + 1 * 24 * 3600 * 1000)
|
||||
let data = {
|
||||
storeID: getStorage("storeID"),
|
||||
payload: JSON.stringify({
|
||||
status: 0,
|
||||
autoEnableAt,
|
||||
}),
|
||||
};
|
||||
await merchant.update_store(data);
|
||||
setTxdIngState(0)
|
||||
toast("操作成功", 1);
|
||||
popupTime.value.close()
|
||||
businessStatus.value = 0;
|
||||
newAutoEnableAt.value = autoEnableAt
|
||||
getStores()
|
||||
}
|
||||
|
||||
function radioChange(e: any) {
|
||||
let findIndex = dayList.value.findIndex(item => item === e.detail.value)
|
||||
if (findIndex !== -1) currentTime.value = findIndex
|
||||
}
|
||||
|
||||
return {
|
||||
businessStatusList, // 营业时间列表
|
||||
businessHours, // 营业时间段
|
||||
businessStatus, // 营业状态
|
||||
switchOpenTime, // 临时休息 多久后自动回复营业
|
||||
setTime, // 去修改营业时间
|
||||
setStatus, // 修改营业状态
|
||||
popupTime, // 临时休息的时间弹框
|
||||
dayList, // 临时休息时间段
|
||||
currentTime, // 临时休息时间 动态index
|
||||
storeRest, // 临时休息的时间弹框 确认
|
||||
radioChange, // 临时休息的时间弹框 change事件
|
||||
storeName, // 门店名
|
||||
logoUrl // logoUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<view class="info">
|
||||
<image
|
||||
class="logo"
|
||||
:src="logoUrl"
|
||||
mode="scaleToFill"
|
||||
/>
|
||||
|
||||
<view class="storeStatus">
|
||||
<view class="title1">{{storeName}}:</view>
|
||||
<view class="status">
|
||||
<view>{{businessStatus === 1?'营业中':businessStatus === 0?'临时休息':businessStatus === -1?'休息':'禁用'}}</view>
|
||||
<view v-if="businessStatus === 1">(门店正常营业)</view>
|
||||
<view v-if="businessStatus === 0">({{switchOpenTime}})</view>
|
||||
<view v-if="businessStatus === -1">(门店已休息)</view>
|
||||
<view v-if="businessStatus === -2">(门店已禁用)</view>
|
||||
</view>
|
||||
<view class="title2">营业时间:</view>
|
||||
<view class="timeInfo" @tap="setTime">
|
||||
<view v-if="businessHours.timer1 != '00:00' && businessHours.timer2 != '00:00'">{{businessHours.timer1}}-{{businessHours.timer2}}</view>
|
||||
<view class="timRange2" v-if="businessHours.timer3 != '00:00' && businessHours.timer4 != '00:00'">{{businessHours.timer3}}-{{businessHours.timer4}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="time">
|
||||
<view v-for="(item,index) in businessStatusList" :key="index"
|
||||
class="timeItem"
|
||||
:class="{'disabledColor':businessStatus === item.id}"
|
||||
@tap="setStatus(item)">
|
||||
<jx-icon
|
||||
v-if="businessStatus === item.id"
|
||||
icon="duihao"
|
||||
:size="38"
|
||||
color="#fff"
|
||||
></jx-icon>
|
||||
{{ item.id === 1 && businessStatus === item.id && item.id!==0?'营业中':item.name }}
|
||||
<text v-if="item.id === -1">(不推荐)</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="notice">
|
||||
<view>临时休息:在休息一段时间后会自动恢复营业</view>
|
||||
<view>休息:在休息后,需要手动点击营业才会进行营业</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 临时休息的时间弹框 -->
|
||||
<uni-popup ref="popupTime" type="center">
|
||||
<view class="jx-popup-update">
|
||||
<view class="text">临时休息</view>
|
||||
<view class="ipt">
|
||||
<radio-group @change="radioChange">
|
||||
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in dayList" :key="index">
|
||||
<view class="item">
|
||||
<radio :value="item" :checked="index === currentTime" />{{item}}
|
||||
</view>
|
||||
</label>
|
||||
</radio-group>
|
||||
</view>
|
||||
<view class="btn-root">
|
||||
<view class="btn-esc" @tap="popupTime.close()">取消</view>
|
||||
<view class="btn-ok" @tap="storeRest">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<!-- 公共组件 -->
|
||||
<jx-loading />
|
||||
</template>
|
||||
|
||||
<script lang="ts" src="./setBusinessStatus" >
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import './setBusinessStatus.scss';
|
||||
</style>
|
||||
|
||||
<style>
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user