|
@@ -6,49 +6,46 @@
|
|
|
<view class="tab-top bg-fff">
|
|
<view class="tab-top bg-fff">
|
|
|
<view class="title ">营业日</view>
|
|
<view class="title ">营业日</view>
|
|
|
<view style="padding-bottom:20upx;border-bottom: 1px solid #EEEEEE;">
|
|
<view style="padding-bottom:20upx;border-bottom: 1px solid #EEEEEE;">
|
|
|
- <text v-for="(tag, index) in tags" :key="index" class="tag-type"
|
|
|
|
|
- :class="{ 'selected-background': isSelected(tag) }"
|
|
|
|
|
- :style="tag == '周四' || tag == '整周' ? 'margin-right:0' : ''" @click="toggleSelection(tag)">
|
|
|
|
|
|
|
+ <text v-for="(tag, index) in tags" :key="index" class="tag-type" :class="{
|
|
|
|
|
+ 'disable-background': isDisable(tag),
|
|
|
|
|
+ 'selected-background': isSelected(tag)
|
|
|
|
|
+ }" :style="tag == '周四' || tag == '整周' ? 'margin-right:0' : ''" @click="toggleSelection(tag)">
|
|
|
{{ tag }}
|
|
{{ tag }}
|
|
|
</text>
|
|
</text>
|
|
|
</view>
|
|
</view>
|
|
|
- <view style="padding-top:18upx">营业时段</view>
|
|
|
|
|
- <view style="border-bottom: 1upx solid #eee;margin:0" v-for="(tim,timInd) in timeArr" :key="timInd">
|
|
|
|
|
- <view class="cu-form-group" style="margin:0" v-if="timInd==0 && timeArr.length<3">
|
|
|
|
|
|
|
+ <view style="padding-top:18upx">营业时段</view>
|
|
|
|
|
+ <view class="cu-form-group" style="border-bottom: 1upx solid #eee;margin:0" v-if="timeType.length > 0">
|
|
|
|
|
+ <input v-model="time" name="input"></input>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <view style="border-bottom: 1upx solid #eee;margin:0" v-for="(tim, timInd) in timeArr" :key="timInd" v-else>
|
|
|
|
|
+ <view class="cu-form-group" style="margin:0" v-if="timInd == 0 && timeArr.length < 3">
|
|
|
<input placeholder="添加营业时段(1/3)" v-model="tim.value" name="input" @click="open(timInd)"></input>
|
|
<input placeholder="添加营业时段(1/3)" v-model="tim.value" name="input" @click="open(timInd)"></input>
|
|
|
<view @click="add()" class="add-style">添加</view>
|
|
<view @click="add()" class="add-style">添加</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <view v-else >
|
|
|
|
|
|
|
+ <view v-else>
|
|
|
<uni-swipe-action>
|
|
<uni-swipe-action>
|
|
|
- <uni-swipe-action-item
|
|
|
|
|
- :right-options="options2"
|
|
|
|
|
- :show="timInd.show"
|
|
|
|
|
- :auto-close="false"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <uni-swipe-action-item :right-options="options2" :show="timInd.show" :auto-close="false">
|
|
|
<view class="cu-form-group" style="margin:0">
|
|
<view class="cu-form-group" style="margin:0">
|
|
|
- <input :placeholder='"添加营业时段("+(timInd+1)+"/3)"' v-model="tim.value" name="input" @click="open(timInd)"></input>
|
|
|
|
|
- <text class='cuIcon-right' style="color: #C7C6CA ;" @click="open(timInd)"></text>
|
|
|
|
|
|
|
+ <input :placeholder='"添加营业时段(" + (timInd + 1) + "/3)"' v-model="tim.value" name="input"
|
|
|
|
|
+ @click="open(timInd)"></input>
|
|
|
|
|
+ <text class='cuIcon-right' style="color: #C7C6CA ;" @click="open(timInd)"></text>
|
|
|
</view>
|
|
</view>
|
|
|
<template v-slot:right>
|
|
<template v-slot:right>
|
|
|
<view>
|
|
<view>
|
|
|
- <view @click="bindClick" class="add-style" style="background: #FF6067;">删除</view>
|
|
|
|
|
|
|
+ <view @click="bindClick" class="add-style" style="background: #FF6067;">删除</view>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
</uni-swipe-action-item>
|
|
</uni-swipe-action-item>
|
|
|
</uni-swipe-action>
|
|
</uni-swipe-action>
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
</view>
|
|
</view>
|
|
|
-
|
|
|
|
|
- <view class="flex align-center justify-between date24" >
|
|
|
|
|
|
|
+ <view class="flex align-center justify-between date24">
|
|
|
<view>24小时营业</view>
|
|
<view>24小时营业</view>
|
|
|
- <uni-data-checkbox multiple :localdata="sex" v-model="timeType" active-color="#FF852D "
|
|
|
|
|
- ></uni-data-checkbox>
|
|
|
|
|
|
|
+ <uni-data-checkbox multiple :localdata="sex" v-model="timeType"
|
|
|
|
|
+ active-color="#FF852D "></uni-data-checkbox>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
- <rangTime ref="rangTime"
|
|
|
|
|
- :mode="mode"
|
|
|
|
|
- @onSubmit="onEndTimeChange" />
|
|
|
|
|
|
|
+ <rangTime ref="rangTime" :mode="mode" @onSubmit="onEndTimeChange" />
|
|
|
<view class="padding flex flex-direction sub-bottom">
|
|
<view class="padding flex flex-direction sub-bottom">
|
|
|
<button class="cu-btn bg-blue round " @click="sumbit">提交</button>
|
|
<button class="cu-btn bg-blue round " @click="sumbit">提交</button>
|
|
|
</view>
|
|
</view>
|
|
@@ -60,97 +57,204 @@ import { USER_INFO } from "@/common/util/constants"
|
|
|
export default {
|
|
export default {
|
|
|
components: {
|
|
components: {
|
|
|
rangTime
|
|
rangTime
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- options2:[{
|
|
|
|
|
|
|
+ time: '00:00-24:00',
|
|
|
|
|
+ options2: [{
|
|
|
text: '删除',
|
|
text: '删除',
|
|
|
style: {
|
|
style: {
|
|
|
backgroundColor: '#FF6067',
|
|
backgroundColor: '#FF6067',
|
|
|
fontSize: '28upx',
|
|
fontSize: '28upx',
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
],
|
|
],
|
|
|
- timeArr:[{
|
|
|
|
|
- value:'',
|
|
|
|
|
- show:false ,
|
|
|
|
|
-
|
|
|
|
|
|
|
+ timeArr: [{
|
|
|
|
|
+ value: '',
|
|
|
|
|
+ show: false,
|
|
|
}],
|
|
}],
|
|
|
- timeType:[],
|
|
|
|
|
|
|
+ timeType: [],
|
|
|
sex: [{
|
|
sex: [{
|
|
|
- text: '',
|
|
|
|
|
- value: 1
|
|
|
|
|
- }],
|
|
|
|
|
|
|
+ text: '',
|
|
|
|
|
+ value: 1
|
|
|
|
|
+ }],
|
|
|
mode: 6,
|
|
mode: 6,
|
|
|
- corporateName:'',
|
|
|
|
|
- tags: ['周一', '周二', '周三', '周四', '周五', '周六', '周日', '整周'], // 你的标签数组
|
|
|
|
|
|
|
+ corporateName: '',
|
|
|
|
|
+ tags: ['周一', '周二', '周三', '周四', '周五', '周六', '周日', '整周'], // 标签数组
|
|
|
selectedIndices: [], // 用于存储被选中的标签索引
|
|
selectedIndices: [], // 用于存储被选中的标签索引
|
|
|
|
|
+ disableIndices: [], // 用于存储被禁用的标签索引
|
|
|
timeIndex: '',
|
|
timeIndex: '',
|
|
|
merchantId: '',
|
|
merchantId: '',
|
|
|
-
|
|
|
|
|
|
|
+ arrData:[],//传参进来的数组
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- async onLoad() {
|
|
|
|
|
|
|
+ async onLoad(data) {
|
|
|
this.merchantId = uni.getStorageSync(USER_INFO).merchantId;
|
|
this.merchantId = uni.getStorageSync(USER_INFO).merchantId;
|
|
|
|
|
+ if (data.params) {
|
|
|
|
|
+ let obj = JSON.parse(decodeURIComponent(data.params));
|
|
|
|
|
+ this.arrData=obj
|
|
|
|
|
+ if ( obj.arr.length>0) {
|
|
|
|
|
+ this.otherProhibitions(obj.arr,obj.index)
|
|
|
|
|
+ obj.arr.forEach((val, index1) => {
|
|
|
|
|
+ if (index1 == obj.index) {
|
|
|
|
|
+ this.selectedIndices = val.period ? val.period.split('、').filter(id => id !== '') : []
|
|
|
|
|
+ }
|
|
|
|
|
+ this.timeType = val.timeType == '1' ? [1] : []
|
|
|
|
|
+ if (val.middleTime) {
|
|
|
|
|
+ this.timeArr = [
|
|
|
|
|
+ {
|
|
|
|
|
+ value: val.middleTime,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ if (val.beginTime) {
|
|
|
|
|
+ this.timeArr = [
|
|
|
|
|
+ {
|
|
|
|
|
+ value: val.middleTime,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ value: val.beginTime,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ if (val.endTime) {
|
|
|
|
|
+ this.timeArr = [
|
|
|
|
|
+ {
|
|
|
|
|
+ value: val.middleTime,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ value: val.beginTime,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ value: val.endTime,
|
|
|
|
|
+ show: false,
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- open(index){
|
|
|
|
|
- this.timeIndex=index
|
|
|
|
|
|
|
+ open(index) {
|
|
|
|
|
+ this.timeIndex = index
|
|
|
this.$refs.rangTime.open()
|
|
this.$refs.rangTime.open()
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
- bindClick(e){
|
|
|
|
|
|
|
+ // 选择整周其他所有禁用
|
|
|
|
|
+ otherProhibitions(arr,index){
|
|
|
|
|
+ if(arr.length==2){
|
|
|
|
|
+ let adjacentObj=arr.find((_, i) => i !== index)
|
|
|
|
|
+ this.disableIndices = adjacentObj.period? adjacentObj.period.split('、').filter(id => id !== ''):
|
|
|
|
|
+ adjacentObj.period==['整周']?this.tags: []
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(arr.length==1){
|
|
|
|
|
+
|
|
|
|
|
+ this.disableIndices = arr[0].period=='整周'?
|
|
|
|
|
+ this.tags:arr[0].period?
|
|
|
|
|
+ arr[0].period.split('、').filter(id => id !== '')
|
|
|
|
|
+ : []
|
|
|
|
|
+ console.log(this.disableIndices,22222222);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ this.disableIndices=[]
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ bindClick(e) {
|
|
|
this.timeArr.splice(this.timeIndex, 1);
|
|
this.timeArr.splice(this.timeIndex, 1);
|
|
|
},
|
|
},
|
|
|
// 检查一个标签是否被选中
|
|
// 检查一个标签是否被选中
|
|
|
isSelected(index) {
|
|
isSelected(index) {
|
|
|
return this.selectedIndices.includes(index);
|
|
return this.selectedIndices.includes(index);
|
|
|
},
|
|
},
|
|
|
|
|
+ // 检查一个标签是否被禁用
|
|
|
|
|
+ isDisable(index) {
|
|
|
|
|
+ return this.disableIndices.includes(index);
|
|
|
|
|
+ },
|
|
|
// 切换标签的选中状态
|
|
// 切换标签的选中状态
|
|
|
toggleSelection(index) {
|
|
toggleSelection(index) {
|
|
|
|
|
+
|
|
|
const indexIndex = this.selectedIndices.indexOf(index);
|
|
const indexIndex = this.selectedIndices.indexOf(index);
|
|
|
|
|
+ console.log(indexIndex,89999);
|
|
|
|
|
+
|
|
|
if (indexIndex > -1) {
|
|
if (indexIndex > -1) {
|
|
|
|
|
+ if (index == '整周') {
|
|
|
|
|
+ if(this.arrData.arr.length==1 && this.arrData.arr[0].period=='整周'){
|
|
|
|
|
+ this.disableIndices=[];
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ this.otherProhibitions(this.arrData.arr,this.arrData.index)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
// 如果标签已经被选中,则移除它
|
|
// 如果标签已经被选中,则移除它
|
|
|
this.selectedIndices.splice(indexIndex, 1);
|
|
this.selectedIndices.splice(indexIndex, 1);
|
|
|
} else {
|
|
} else {
|
|
|
- // 如果标签没有被选中,则添加它
|
|
|
|
|
- this.selectedIndices.push(index);
|
|
|
|
|
|
|
+ if (!this.disableIndices.includes(index)) {
|
|
|
|
|
+ if (index == '整周') {
|
|
|
|
|
+ this.selectedIndices = []
|
|
|
|
|
+ this.disableIndices.push('周一', '周二', '周三', '周四', '周五', '周六', '周日');
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果标签没有被选中,则添加它
|
|
|
|
|
+ this.selectedIndices.push(index);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- add(){
|
|
|
|
|
|
|
+ add() {
|
|
|
this.timeArr.push({
|
|
this.timeArr.push({
|
|
|
- value:'',
|
|
|
|
|
- show:false ,
|
|
|
|
|
|
|
+ value: '',
|
|
|
|
|
+ show: false,
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- onEndTimeChange(val){
|
|
|
|
|
- this.timeArr[this.timeIndex].value=val.startDate+'-'+val.endDate
|
|
|
|
|
- // this.time=val.startDate+'-'+val.endDate
|
|
|
|
|
-
|
|
|
|
|
|
|
+ onEndTimeChange(val) {
|
|
|
|
|
+ this.timeArr[this.timeIndex].value = val.startDate + '-' + val.endDate
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
- sumbit(){
|
|
|
|
|
- let data={
|
|
|
|
|
- merchantId: this.merchantId,
|
|
|
|
|
- timeType:this.timeType.length>0?1:0,
|
|
|
|
|
- period:this.selectedIndices.length>0?this.selectedIndices.join(','):null,
|
|
|
|
|
- middleTime: this.timeArr.length>=1?this.timeArr[0].value :null,
|
|
|
|
|
- beginTime: this.timeArr.length>=2? this.timeArr[1].value:null,
|
|
|
|
|
- endTime:this.timeArr.length>=3? this.timeArr[2].value:null
|
|
|
|
|
|
|
+ sumbit() {
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ merchantId: this.merchantId,
|
|
|
|
|
+ timeType: this.timeType.length > 0 ? 1 : 2,
|
|
|
|
|
+ period: this.selectedIndices.length > 0 ? this.selectedIndices.join('、') : null,
|
|
|
|
|
+ middleTime: this.timeArr.length >= 1 ? this.timeArr[0].value : null,
|
|
|
|
|
+ beginTime: this.timeArr.length >= 2 ? this.timeArr[1].value : null,
|
|
|
|
|
+ endTime: this.timeArr.length >= 3 ? this.timeArr[2].value : null,
|
|
|
|
|
+ id:this.arrData.index==1 || this.arrData.index==0?this.arrData.arr[this.arrData.index].id:null
|
|
|
|
|
+ }
|
|
|
|
|
+ if(this.selectedIndices.length==0){
|
|
|
|
|
+ this.$tip.toast('请选择营业日');
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if(this.timeArr.length==0 && this.timeType.length==0){
|
|
|
|
|
+ this.$tip.toast('请选择营业s时段');
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
- console.log(data,444444444);
|
|
|
|
|
- this.$http.post('/merchant/localMerchantTime/add', data).then(res => {
|
|
|
|
|
|
|
+ let interfaceData = data.id ? "/merchant/localMerchantTime/edit" : "/merchant/localMerchantTime/add"
|
|
|
|
|
+
|
|
|
|
|
+ this.$http.post(interfaceData, data).then(res => {
|
|
|
if (res.data.success) {
|
|
if (res.data.success) {
|
|
|
this.$tip.success(res.data.result || '成功')
|
|
this.$tip.success(res.data.result || '成功')
|
|
|
uni.navigateBack({
|
|
uni.navigateBack({
|
|
|
- delta: 1 // 返回的页面数,默认为1
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ delta: 1, // 返回的页面数,默认为1
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ const pages = getCurrentPages();
|
|
|
|
|
+ pages[pages.length-1].$vm.$forceUpdate();
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
this.$tip.error(res.data.message);
|
|
this.$tip.error(res.data.message);
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
@@ -177,6 +281,12 @@ page {
|
|
|
line-height: 54upx;
|
|
line-height: 54upx;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+.disable-background {
|
|
|
|
|
+ background: #F2F3F5;
|
|
|
|
|
+ border: 1px solid #D2D9DC;
|
|
|
|
|
+ color: #C0C0C0;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
.selected-background {
|
|
.selected-background {
|
|
|
color: #2983EC;
|
|
color: #2983EC;
|
|
|
position: relative;
|
|
position: relative;
|
|
@@ -205,7 +315,7 @@ page {
|
|
|
border-top: 1px solid #EEEEEE;
|
|
border-top: 1px solid #EEEEEE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-.add-style{
|
|
|
|
|
|
|
+.add-style {
|
|
|
padding: 0 30upx;
|
|
padding: 0 30upx;
|
|
|
background: #449AFF;
|
|
background: #449AFF;
|
|
|
color: #fff;
|
|
color: #fff;
|
|
@@ -213,13 +323,16 @@ page {
|
|
|
margin-top: 22upx;
|
|
margin-top: 22upx;
|
|
|
border-radius: 4px 4px 4px 4px;
|
|
border-radius: 4px 4px 4px 4px;
|
|
|
}
|
|
}
|
|
|
-.date24{
|
|
|
|
|
- line-height:80upx;
|
|
|
|
|
- /deep/ .uni-data-checklist{
|
|
|
|
|
- flex: none;
|
|
|
|
|
- .checklist-group .checklist-box{
|
|
|
|
|
- margin-right: 0;
|
|
|
|
|
|
|
+
|
|
|
|
|
+.date24 {
|
|
|
|
|
+ line-height: 80upx;
|
|
|
|
|
+
|
|
|
|
|
+ /deep/ .uni-data-checklist {
|
|
|
|
|
+ flex: none;
|
|
|
|
|
+
|
|
|
|
|
+ .checklist-group .checklist-box {
|
|
|
|
|
+ margin-right: 0;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
</style>
|
|
</style>
|