admin/addon/cashier/source/os/pages/store/operate.vue

335 lines
9.7 KiB
Vue

<template>
<base-page>
<view class="common-wrap common-form fixd">
<view class="common-title">运营设置</view>
<view class="common-form-item">
<label class="form-label">门店名称</label>
<view class="form-input-inline">
<input type="text" v-model="storeData.store_name" disabled class="form-input" />
</view>
<text class="form-word-aux-line">门店的名称(招牌)</text>
</view>
<view class="common-form-item">
<label class="form-label">是否营业</label>
<view class="form-inline">
<radio-group @change="statusChange" class="form-radio-group">
<label class="radio form-radio-item">
<radio value="1" :checked="storeData.status==1"/>是
</label>
<label class="radio form-radio-item">
<radio value="0" :checked="storeData.status==0" />否
</label>
</radio-group>
</view>
</view>
<view class="common-form-item">
<label class="form-label">营业时间</label>
<view class="form-inline">
<view class="form-input-inline long">
<input type="text" v-model="storeData.open_date" class="form-input" />
</view>
</view>
</view>
<view class="common-form-item">
<label class="form-label">同城配送</label>
<view class="form-inline">
<radio-group @change="o2oChange" class="form-radio-group">
<label class="radio form-radio-item">
<radio value="1" :checked="storeData.is_o2o==1" />开启
</label>
<label class="radio form-radio-item">
<radio value="0" :checked="storeData.is_o2o==0" />关闭
</label>
</radio-group>
</view>
<text class="form-word-aux-line">开启同城配送需要门店设置配送费用以及配送员</text>
</view>
<view class="common-form-item">
<label class="form-label">门店自提</label>
<view class="form-inline">
<radio-group @change="pickupChange" class="form-radio-group">
<label class="radio form-radio-item">
<radio value="1" :checked="storeData.is_pickup==1" />开启
</label>
<label class="radio form-radio-item">
<radio value="0" :checked="storeData.is_pickup==0" />关闭
</label>
</radio-group>
</view>
</view>
<view class="common-form-item" v-if="storeData.is_pickup == 1">
<label class="form-label">自提日期</label>
<view class="form-inline">
<radio-group @change="timeTypeChange" class="form-radio-group">
<label class="radio form-radio-item">
<radio value="0" :checked="storeData.time_type==0" />每天
</label>
<label class="radio form-radio-item">
<radio value="1" :checked="storeData.time_type==1" />自定义
</label>
</radio-group>
</view>
</view>
<view class="common-form-item" v-if="storeData.is_pickup == 1 && storeData.time_type == 1">
<label class="form-label">自提时间</label>
<view class="form-block">
<checkbox-group class="form-checkbox-group" @change="checkboxChange">
<label class="form-checkbox-item">
<checkbox value="1" :checked="storeData.time_week.includes('1') || storeData.time_week.includes(1)" />周一
</label>
<label class="form-checkbox-item">
<checkbox value="2" :checked="storeData.time_week.includes('2') || storeData.time_week.includes(2)" />周二
</label>
<label class="form-checkbox-item">
<checkbox value="3" :checked="storeData.time_week.includes('3') || storeData.time_week.includes(3)" />周三
</label>
<label class="form-checkbox-item">
<checkbox value="4" :checked="storeData.time_week.includes('4') || storeData.time_week.includes(4)" />周四
</label>
<label class="form-checkbox-item">
<checkbox value="5" :checked="storeData.time_week.includes('5') || storeData.time_week.includes(5)" />周五
</label>
<label class="form-checkbox-item">
<checkbox value="6" :checked="storeData.time_week.includes('6') || storeData.time_week.includes(6)" />周六
</label>
<label class="form-checkbox-item">
<checkbox value="0" :checked="storeData.time_week.includes('0') || storeData.time_week.includes(0)" />周日
</label>
</checkbox-group>
</view>
</view>
<view class="common-form-item" v-if="storeData.is_pickup == 1">
<label class="form-label"></label>
<view class="form-inline">
<view class="form-input-inline">
<picker mode="time" class="form-input" :value="storeData.start_time" @change="bindStartTimeChange">
<view class="uni-input">{{storeData.start_time}}</view>
</picker>
</view>
<text class="form-mid">-</text>
<view class="form-input-inline">
<picker mode="time" class="form-input" :value="storeData.end_time" @change="bindEndTimeChange">
<view class="uni-input">{{storeData.end_time}}</view>
</picker>
</view>
</view>
</view>
<view class="common-form-item">
<label class="form-label">库存设置</label>
<view class="form-inline">
<radio-group @change="stockTypeChange" class="form-radio-group">
<label class="radio form-radio-item">
<radio value="all" :disabled="Boolean(storeData.is_default)" :checked="storeData.stock_type=='all'" />总部统一库存
</label>
<label class="radio form-radio-item">
<radio value="store" :disabled="Boolean(storeData.is_default)" :checked="storeData.stock_type=='store'" />门店独立库存
</label>
</radio-group>
</view>
</view>
<view class="common-btn-wrap">
<button type="default" class="screen-btn" @click="saveFn">保存</button>
<button type="default" class="" @click="$util.redirectTo('/pages/store/index')">返回</button>
</view>
<nc-loading :layer-background="{ background: 'rgba(255,255,255,.8)' }" ref="loading"></nc-loading>
</view>
</base-page>
</template>
<script>
export default {
data() {
return {
storeData:{
'store_name' : '',
'store_image' : '',
'status' : 0,
'telphone' : '',
'open_date' : '',
'is_o2o' : 0,
'is_pickup' : 0,
'time_type' : 0,
'start_time' : '00:00',
'end_time' : '23:59',
'stock_type' : 'all',
'time_week' : '',
'latitude' : 39.909,
'longitude' : 116.39742,
'province_id' : 110000,
'city_id' : 110100,
'district_id' : 110101,
'address' : '西长安街1号',
'full_address' : '北京市-北京市-东城区',
},
covers: [{
latitude: 39.909,
longitude: 116.39742,
iconPath: '/static/location.png'
}],
defaultRegions:[],
};
},
onLoad() {},
onShow() {
this.getData();
// uni.setLocale('zh-Hans')
},
methods: {
getData() {
this.$api.sendRequest({
url: '/store/storeapi/store/info',
success: res => {
if (res.code >= 0) {
this.storeData = res.data;
this.storeData.start_time = this.timeFormat(this.storeData.start_time);
this.storeData.end_time = this.timeFormat(this.storeData.end_time);
this.$refs.loading.hide();
} else {
this.$util.showToast({
title: res.message
});
}
}
});
},
statusChange(e) {
this.storeData.status = e.detail.value;
},
o2oChange(e){
this.storeData.is_o2o = e.detail.value;
},
pickupChange(e){
this.storeData.is_pickup = e.detail.value;
},
timeTypeChange(e){
this.storeData.time_type = e.detail.value;
},
bindStartTimeChange(e) {
this.storeData.start_time = e.detail.value;
},
bindEndTimeChange(e) {
this.storeData.end_time = e.detail.value;
},
stockTypeChange(e) {
this.storeData.stock_type = e.detail.value;
},
checkboxChange(e) {
this.storeData.time_week = e.detail.value;
},
getSaveData() {
let data = Object.assign({}, this.storeData);
data.start_time = this.timeTurnTimeStamp(data.start_time);
data.end_time = this.timeTurnTimeStamp(data.end_time);
data.time_week = this.storeData.time_week.toString();
return data;
},
checkData(data){
return true;
},
saveFn() {
let data = this.getSaveData();
if(this.checkData(data)){
if(this.flag) return false;
this.flag = true;
this.$api.sendRequest({
url: '/cashier/storeapi/store/editstoreoperate',
data: data,
success: res => {
this.flag = false;
this.$util.showToast({
title: res.message
});
if(res.code >= 0){
this.$refs.loading.show();
this.getData();
}
}
});
}
},
timeTurnTimeStamp(_time){
let data = _time.split(":");
return data[0]*3600 + data[1]*60;
},
timeFormat(time){
let h = parseInt(time / 3600);
let i = parseInt(time % 3600 / 60);
h = h < 10 ? '0'+h : h;
i = i < 10 ? '0'+i : i;
return h+':'+i;
}
}
}
</script>
<style lang="scss">
.common-wrap {
padding: 30rpx;
height: 100vh;
}
.upload-box{
border: .01rem dashed #e6e6e6!important;
width: 2.5rem!important;
height: 1.2rem!important;
display: flex;
align-items: center;
justify-content: center;
.upload{
text-align: center;
color: #5a5a5a;
.iconfont{
font-size: 0.3rem;
}
image{
max-width: 100%;
height: 1.2rem!important;
}
}
}
.store-img{
align-items: flex-start!important;
}
.map-box{
width: 6.5rem;
height: 5rem;
position: relative;
.map-icon{
position: absolute;
top: calc(50% - 0.36rem);
left: calc(50% - 0.18rem);
width: 0.36rem;
height: 0.36rem;
z-index: 100;
}
}
.form-input{
font-size: 0.16rem;
}
.form-input-inline.btn{
height: 0.37rem;
line-height: 0.35rem;
box-sizing: border-box;
border: 0.01rem solid #e6e6e6;
text-align: center;
cursor: pointer;
}
.common-title{
font-size: 0.18rem;
margin-bottom: 0.2rem;
}
</style>