订单列表添加联系客户虚拟电话

This commit is contained in:
Mr.jiang 2024-08-27 10:03:13 +08:00
parent 8fb9888ecc
commit 455d4e742c
10 changed files with 1240 additions and 8 deletions

View File

@ -0,0 +1,304 @@
<template>
<view>
<view class="calendar">
<view class="calendar_day">
<view class="day_x" :style="{'color': (day_index == index ? '#52C375' : '')}"
v-for="(item, index) in dayArr" :key="index" @click.stop="dayList(item,index)">
<view class="day_x_a">{{item.weeks}}</view>
<view class="day_x_b">{{item.days}}</view>
</view>
</view>
<view scroll-y class="calendar_time">
<view class="time_x" :class="host_index == item.timeStamp ? 'time_x_sty' : '' "
v-for="(item, index) in hostArr[day_index]" :key="index"
@click.stop="(nowTimes < item.timeStamp) || (msformatArr.indexOf(item.hours) == -1) ? hosts(item) : ''"
:style="[{'color':((nowTimes > item.timeStamp) || (msformatArr.indexOf(item.hours) !== -1 ) ? '#999999' : '')},{'fontSize':((nowTimes < item.timeStamp) && (msformatArr.indexOf(item.hours) !== -1 )) || (msformatArr.indexOf(item.hours) !== -1 ) ? '32rpx' : '30rpx'},
{'letter-spacing':((nowTimes < item.timeStamp) && (msformatArr.indexOf(item.hours) !== -1 )) || (msformatArr.indexOf(item.hours) !== -1 ) ? '4rpx' : '0rpx'}]">
{{ ((nowTimes < item.timeStamp) && (msformatArr.indexOf(item.hours) !== -1)) || (msformatArr.indexOf(item.hours) !== -1) ? '约满' : item.hours }}
</view>
</view>
<view style="color: #096f4b;width: 100%;text-align: center;" @click="sub()">添加时间</view>
</view>
<!-- <view class="sub" @click="sub()">
添加待选
</view> -->
</view>
</template>
<script>
export default {
props: {
sta_num: {
type: Number | String,
default: 9
},
end_num: {
type: Number | String,
default: 18
},
int_num: {
type: Number | String,
default: 30
},
},
data() {
return {
dayArr: [],
hostArr: [],
day_index: 0,
host_index: '',
host_All: [],
nowTimes: '',
isShow: true,
msformatArr: [],
}
},
mounted() {
let dateArr = []
let today = new Date();
let nowTime = today.getTime() //
this.nowTimes = parseInt(nowTime / 1000)
for (let i = 0; i < 5; i++) {
let newDate = new Date(today.getTime() + i * 1000 * 60 * 60 * 24)
let month = (parseInt(newDate.getMonth()) + 1) > 9 ? (parseInt(newDate.getMonth()) + 1) : "0" + (parseInt(
newDate.getMonth()) + 1) //
let day = (newDate.getDate()) > 9 ? newDate.getDate() : "0" + newDate.getDate() //
let backTime = newDate.getTime() //
let backDays = newDate.getDay() //
let remTime = (backTime - nowTime) / 1000 //
let week = ''
if (remTime == 0) {
week = "今天"
} else if (remTime == 86400) {
week = "明天"
} else if (remTime == 172800) {
week = "后天"
} else {
if (backDays == 0) {
week = "周日"
} else if (backDays == 1) {
week = "周一"
} else if (backDays == 2) {
week = "周二"
} else if (backDays == 3) {
week = "周三"
} else if (backDays == 4) {
week = "周四"
} else if (backDays == 5) {
week = "周五"
} else if (backDays == 6) {
week = "周六"
}
}
let fullDate = `${month}-${day}`
let ass = {
weeks: week,
days: fullDate
}
dateArr.push(ass)
}
this.dayArr = dateArr
let timeArr = []
for (let i = 0; i < 5; i++) {
// let as = new Date(new Date().toLocaleDateString()).getTime() / 1000
let as = new Date(new Date().toLocaleDateString()).getTime() / 1000 + i * 60 * 60 * 24
let staTime = this.sta_num * 60 * 60 + as
let endTime = this.end_num * 60 * 60 + as
let int = this.int_num * 60
let timeArr_s = []
let datatime = {
hours: '00:00',
timeStamp: ''
}
timeArr_s.push(datatime)
for (staTime; staTime < endTime - int; staTime + int) {
staTime = staTime + int
let hours = this.times(staTime)
let asb = {
hours,
timeStamp: staTime
}
timeArr_s.push(asb)
if (timeArr_s.length == 2) {
timeArr_s[0].timeStamp = timeArr_s[1].timeStamp - 1800
}
}
timeArr.push(timeArr_s)
}
this.hostArr = timeArr;
uni.$on("sendChildMsList", (e) => {
console.log(e);
if (e) {
this.msformatArr = e;
}
});
},
onUnload() {
uni.$off("sendChildMsList");
},
destroyed() {
uni.$off("sendChildMsList");
},
methods: {
//
dayList(e, index) {
this.day_index = index
let day = this.dayArr[this.day_index]
let comTime = {
days: day.days,
weeks: day.weeks
}
this.$emit('getDate', comTime);
},
//
hosts(e) {
if ( (this.nowTimes < e.timeStamp) && (this.msformatArr.indexOf(e.hours) == -1)) {
this.host_All = e
this.host_index = e.timeStamp
}
},
//
sub() {
console.log(this.host_All);
delete this.host_All.timeStamp;
if (this.host_index == '') {
this.$queue.showToast('请选择时间')
} else {
let day = this.dayArr[this.day_index]
let time = this.time(this.host_index)
let comTime = {
days: day.days,
weeks: day.weeks,
hours: this.host_All.hours,
timeStamp: this.host_All.timeStamp,
time: time
}
this.$emit('getTime', comTime);
}
},
//
times(data) {
let date = new Date(data * 1000);
//10*1000131000
let h = date.getHours();
h = h < 10 ? ('0' + h) : h; //0
let m = date.getMinutes();
m = m < 10 ? ('0' + m) : m; //0
return h + ':' + m
},
time(data, type) {
let date = new Date(data * 1000);
//10*1000131000
let y = date.getFullYear();
let MM = date.getMonth() + 1;
MM = MM < 10 ? ('0' + MM) : MM; //0
let d = date.getDate();
d = d < 10 ? ('0' + d) : d; //0
let h = date.getHours();
h = h < 10 ? ('0' + h) : h; //0
let m = date.getMinutes();
m = m < 10 ? ('0' + m) : m; //0
let s = date.getSeconds();
s = s < 10 ? ('0' + s) : s; //0
if (type == 'yymmdd') {
return y + '-' + MM + '-' + d
} else if (type == 'hhmmss') {
return h + ':' + m + ':' + s;
} else {
return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
}
}
}
}
</script>
<style lang="scss">
page {
background-color: #F4F4F4;
}
.act {
color: #52C375;
}
.calendar {
width: 710rpx;
height: min-content;
background-color: #FFFFFF;
margin: 20rpx auto 10rpx;
border-radius: 8rpx;
padding-bottom: 20rpx;
}
.calendar_day {
display: flex;
width: 100%;
height: 120rpx;
.day_x {
display: flex;
flex-flow: column nowrap;
justify-content: center;
align-items: center;
width: 20%;
height: 100%;
font-size: 30rpx;
color: #333333;
}
}
.calendar_time {
display: flex;
width: 100%;
height: min-content;
flex-flow: row wrap;
align-content: flex-start;
margin: 20rpx 0;
overflow-y: auto;
.time_x {
display: flex;
flex-flow: row;
justify-content: center;
align-items: center;
width: 20%;
height: 54rpx;
border-radius: 26rpx;
margin: 10rpx 0;
font-size: 30rpx;
color: #333333;
}
.time_x_sty {
background-color: #E8FAE1;
color: #096f4b !important;
}
}
.sub {
display: flex;
justify-content: center;
align-items: center;
width: 710rpx;
height: 100rpx;
border-radius: 50rpx;
margin: 30rpx auto;
color: #FFFFFF;
font-size: 36rpx;
background-color: #096f4b;
}
</style>

View File

@ -0,0 +1,107 @@
.container{
view,text,image{
box-sizing: border-box;
}
scroll-view{
width: 100%;
white-space: nowrap;
height: 75px;
background-color: #fff;
position: relative;
padding-top: 10px;
// margin-top:10px;
&::after{
background: #e5e5e5;
content: '';
display:block;
width: 100%;
height: 1px;
position: absolute;
bottom: 0;
left: 0;
transform:scaleY(0.5);
}
.flex-box{
display: inline-block;
height: 60px;
width: 25%;
margin: 0 7rpx 0 7rpx;
box-sizing: border-box;
&.active{
.date-box{
border: none;
.days{
font-weight: bold;
color: #818181;
}
.date{
font-weight: bold;
color: #818181;
}
}
}
.date-box{
border: none;
display: flex;
height: 50px;
flex-direction: column;
align-items: center;
justify-content: space-around;
font-size: 30upx;
color: rgba(129, 129, 129, 1);
.date{
font-weight: bold;
color: #818181;
font-size: 30upx;
}
}
}
}
.time-box{
padding:28upx 12upx 26upx;
display: flex;
flex-wrap: wrap;
// margin-top:10px;
background-color:#fff;
.item{
width: 25%;
padding: 0 9upx;
margin:10px 0;
&-box{
width: 100%;
height: 106upx;
padding:0 44upx;
background: #fff;
color: #333;
border: 1px solid #EEEEEE;
font-size: 28upx;
border-radius: 10upx;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&.disable{
background: #F1F3F6 !important;
color: #999 !important;
// border: 1px solid #EEEEEE;
}
&.active{
// background: #0094D7;
border: 1px solid #FB5D6B;
font-weight: bold;
}
.all{
white-space: nowrap;
font-size: 22upx;
padding-top: 5px;
}
}
}
}
}

View File

@ -0,0 +1,418 @@
<template>
<view class="content">
<view class="container">
<!-- 日期列表 -->
<scroll-view class="scroll-view_H b-t b-b" scroll-x>
<block v-for="(item,index) in dateArr" :key="index">
<div class="flex-box" @click="selectDateEvent(index,item)" :class="{ borderb: index==dateActive}">
<view class="date-box" :style="{color:index==dateActive?selectedTabColor:'#333'}">
<text class="fontw">{{item.week}}</text>
<text>{{item.date}}</text>
</view>
</div>
</block>
</scroll-view>
<!-- 时间选项 -->
<view class="time-box" v-if="!isSection || isQuantum">
<template v-for="(item,_index) in timeArr">
<view class="item" :key="_index">
<view class="item-box" :class="{'disable':item.disable,
'active':isMultiple?item.isActive:_index==timeActive}" :style="{color:isMultiple?item.isActive? selectedItemColor:'#333'
:_index==timeActive?selectedItemColor:'#333'}" @click="selectTimeEvent(_index,item)">
<text v-if="isQuantum">{{item.begin}}~{{item.end}}</text>
<text v-else>{{item.time}}</text>
<text class="all">{{item.disable?disableText:undisableText}}</text>
</view>
</view>
</template>
</view>
<!-- 预约时间段 -->
<view class="time-box" v-else>
<template v-for="(item,_index) in timeArr">
<view class="item" :key="_index">
<view class="item-box" :class="{'disable':item.disable || item.isInclude,
'active':item.time == timeQuanBegin || item.time == timeQuanEnd }"
:style="{color:item.time == timeQuanBegin || item.time == timeQuanEnd? selectedItemColor:'#333'}"
@click="handleSection(_index,item)">
<text>{{item.time}}</text>
<text class="all">{{item.disable?disableText:undisableText}}</text>
</view>
</view>
</template>
</view>
</view>
<view class="bottom">
<view class="show-time" v-if="!isMultiple && !isSection && !isQuantum">
预约时间{{orderDateTime}}
</view>
<button form-type="submit" type="default" size="mini" class="submit-btn" @click="handleSubmit">
保存
</button>
</view>
</view>
</template>
<script>
import {
initData,
initTime,
timeStamp,
currentTime
} from '../../utils/date.js'
export default {
name: 'times',
model: {
prop: "showPop",
event: "change"
},
props: {
isQuantum: {
type: Boolean,
default: false
},
isMultiple: { //
type: Boolean,
default: false
},
isSection: { //
type: Boolean,
default: false
},
disableText: { //
type: String,
default: "不可预约"
},
undisableText: { //
type: String,
default: "可预约"
},
timeInterval: { //
type: Number,
default: 1
},
selectedTabColor: { //
type: String,
default: "#FB4B5C"
},
selectedItemColor: { //
type: String,
default: "#FB4B5C"
},
beginTime: {
type: String,
},
endTime: {
type: String,
},
appointTime: { //
type: Array,
default () {
return []
}
},
disableTimeSlot: { //
type: Array,
default () {
return []
}
}
},
watch: {
appointTime: {
handler(val) {
if (val && val.length) {
this.initOnload()
}
}
},
disableTimeSlot: {
handler(val) {
if (val && val.length) {
this.initOnload()
}
}
}
},
data() {
return {
orderDateTime: '暂无选择', //
orderTimeArr: {}, //
dateArr: [], //
timeArr: [], //
nowDate: "", //
dateActive: 0, //
timeActive: 0, //
timeQuanBeginIndex: 0, //
selectDate: "", //
timeQuanBegin: "", //
timeQuanEnd: "", //
}
},
created(props) {
this.selectDate = this.nowDate = currentTime().date
this.initOnload()
},
methods: {
initOnload() {
this.dateArr = initData() //
console.log(this.dateArr)
this.timeArr = initTime(this.beginTime, this.endTime, this.timeInterval, this.isQuantum) //
this.timeQuanBegin = this.timeQuanEnd = ""
let isFullTime = true
this.timeArr.forEach((item, index) => {
//
if (this.isQuantum) {
const cur_be_time = `${this.selectDate} ${item.begin}:00`
const cur_end_time = `${this.selectDate} ${item.end}:00`
for (let time of this.disableTimeSlot) {
const [begin_time = "", end_time = ""] = time
if (begin_time && end_time && (begin_time <= cur_be_time && cur_end_time <=
end_time)) {
item.disable = true
}
}
if (this.selectDate == this.nowDate && currentTime().time > `${item.begin}:00`) {
item.disable = true
}
//
if (this.orderTimeArr[this.selectDate]) {
for (let items of this.orderTimeArr[this.selectDate]) {
if (items[0].split(' ')[1] === `${item.begin}:00` && items[1].split(' ')[1] ===
`${item.end}:00`) {
item.isActive = true
}
}
}
} else {
//
if (this.selectDate == this.nowDate && currentTime().time > item.time) {
item.disable = true
}
//
this.appointTime.forEach(t => {
let [date, time] = t.split(' ')
if (date == this.selectDate && item.time == time) {
item.disable = true
}
})
//
const cur_time = `${this.selectDate} ${item.time}`
for (let time of this.disableTimeSlot) {
const [begin_time = "", end_time = ""] = time
if (begin_time && end_time && (begin_time <= cur_time && cur_time <= end_time)) {
item.disable = true
}
}
//
if (!item.disable) {
isFullTime = false
}
this.isSection && (item.isInclude = false)
//
if (this.isMultiple && (this.orderTimeArr[this.selectDate] || []).includes(item.time)) {
item.isActive = true
}
}
})
this.orderDateTime = isFullTime ? "暂无选择" : this.selectDate
this.timeActive = -1
for (let i = 0, len = this.timeArr.length; i < len; i++) {
if (!this.timeArr[i].disable) {
this.orderDateTime = `${this.selectDate} ${this.timeArr[i].time}`
this.timeActive = i
return
}
}
},
//
selectDateEvent(index, item) {
this.dateActive = index
this.selectDate = item.date
this.initOnload()
},
//
selectTimeEvent(index, item) {
if (this.isQuantum) {
return this.handleSelectQuantum(index, item)
}
if (item.disable) return
if (this.isMultiple) {
item.isActive = !item.isActive
this.timeArr = this.timeArr.slice()
this.orderTimeArr[this.selectDate] = this.timeArr.reduce((prev, cur) => {
cur.isActive && prev.push(cur.time)
return prev
}, [])
} else {
this.timeActive = index
this.orderDateTime = `${this.selectDate} ${item.time}`
}
},
//
handleSection(index, item) {
if (item.disable) return
function clearTime() {
this.timeQuanBeginIndex = index
this.timeQuanBegin = item.time
this.timeQuanEnd = ""
}
if (!this.timeQuanBegin) {
clearTime.call(this)
return
}
if (!this.timeQuanEnd && this.timeQuanBegin) {
let isDisble = false
let start = this.timeQuanBeginIndex
let end = index
start > end && ([start, end] = [end, start])
for (let i = start + 1; i < end; i++) {
if (this.timeArr[i].disable) {
isDisble = true
clearTime.call(this)
return
}
}
if (!isDisble) {
for (let i = start + 1; i < end; i++) {
this.timeArr[i].isInclude = true
}
}
this.timeQuanEnd = item.time
return
}
if (this.timeQuanBegin && this.timeQuanEnd) {
this.timeArr.forEach(t => {
t.isInclude = false
})
clearTime.call(this)
}
},
handleSelectQuantum(index, item) {
if (item.disable) return
if (this.isMultiple) {
item.isActive = !item.isActive
this.timeArr = this.timeArr.slice()
this.orderTimeArr[this.selectDate] = this.timeArr.reduce((prev, cur) => {
const cur_be_time = `${this.selectDate} ${cur.begin}:00`
const cur_end_time = `${this.selectDate} ${cur.end}:00`
cur.isActive && prev.push([cur_be_time, cur_end_time])
return prev
}, [])
} else {
this.timeActive = index
this.orderDateTime = {
begin: `${this.selectDate} ${item.begin}:00`,
end: `${this.selectDate} ${item.end}:00`,
}
}
console.log(this.orderTimeArr)
},
handleChange() {
this.timeQuanBegin > this.timeQuanEnd && ([this.timeQuanBegin, this.timeQuanEnd] = [this.timeQuanEnd, this
.timeQuanBegin
])
},
handleSubmit() {
if (this.isSection) {
this.handleChange()
this.$emit('change', {
beginTime: `${this.selectDate} ${this.timeQuanBegin}`,
endTime: `${this.selectDate} ${this.timeQuanEnd}`
})
return
}
console.log(this.orderTimeArr)
if (this.isMultiple) {
if (this.isQuantum) {
this.$emit('change', this.orderTimeArr)
return
}
let time = []
for (let date in this.orderTimeArr) {
this.orderTimeArr[date].forEach(item => {
time.push(`${date} ${item}`)
})
}
this.$emit('change', time)
} else {
this.$emit('change', this.orderDateTime)
}
}
}
}
</script>
<style lang="scss" scoped>
@import './pretty-times.scss';
page {
height: 100%;
}
.content {
width:100%;
text-align: center;
height: 100%;
}
/* 两个按钮 */
.bottom {
display: flex;
flex-direction: row;
position: fixed;
bottom: 8px;
top: auto;
left: 0px;
width: 100%;
background-color: #fff;
}
.show-time {
width: 70%;
height: 47px;
color: #505050;
background-color: rgba(255, 255, 255, 1);
font-size: 15px;
line-height: 47px;
text-align: center;
}
.submit-btn {
width: 25%;
height: 40px;
color: white;
background-color: #CA89FF;
font-size: 15px;
line-height: 40px;
text-align: center;
margin: auto;
padding: 0;
}
.fontw {
font-weight: bold;
}
.borderb {
border-bottom: 2px solid #FB4B5C;
}
</style>

View File

@ -2,8 +2,8 @@
"name" : "盛安到家",
"appid" : "__UNI__B37C795",
"description" : "",
"versionName" : "2.1.3",
"versionCode" : 140,
"versionName" : "2.1.4",
"versionCode" : 150,
"transformPx" : false,
/* 5+App */
"app-plus" : {

View File

@ -1553,8 +1553,7 @@
</view>
<!-- <view class="footers-btn footers-bor" @click="goMsg">联系客服11</view> -->
<view class="footers-btn footers-bor" @click="goChat">联系客服</view>
<!-- <u-button :custom-style="customStyle" shape="circle" :plain="true"
@click="bindphone(order.phone)">联系客户</u-button> -->
<view class="footers-btn footers-bor" @click="bindPhone" v-if="order.status==2||order.status==7||order.status==8||order.status==9">联系客户</view>
<!-- <view class="dian" @click="toggle('bottom',order)" v-if="order.status == 6">...</view> -->
</view>
<view class="footers" v-if="order.refusalContent!=null&&order.status=='9'">
@ -1882,6 +1881,39 @@
}
},
methods: {
//
bindPhone(){
console.log('手机号是:',this.phone);
//
//this.phone = '13080011344'
this.$Request.get('/app/user/insertVirtualPhoneAxN?phone=' + this.phone).then(res => {
console.log('返回的全部数据:',res);
if (res.code == 0) {
console.log('返回数据是:',res.data);
let middleNumber = res.data.middleNumber;
console.log('虚拟号是:',middleNumber);
if(res.data.result === '000000'){
//
uni.showModal({
title: '提示',
content: '绑定号码为:' + middleNumber + ",是否拨打该电话?",
success: function(res) {
if (res.confirm) {
//
uni.makePhoneCall({
phoneNumber: middleNumber,
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
} else {
this.$queue.showToast('绑定虚拟号错误!');
}
}
});
},
getOrder() {
let data = {
ordersId: this.ordersId

View File

@ -239,11 +239,11 @@
<image src="../../static/index/function6.png"></image>
<view class="box_text">视频圈</view>
</view>
<view class="box" v-if="renzheng == 2" @click="bindPhone()">
<!-- //AxN -->
<!-- //AxN -->
<!-- <view class="box" v-if="renzheng == 2" @click="bindPhone()">
<image src="../../static/index/function5.png"></image>
<view class="box_text">虚拟电话</view>
</view>
</view> -->
<!-- <view class="box" v-if="renzheng == 0 && XCXIsSelect != '否'" @click="goNav('/my/renzheng/rzType')">
<image src="../../static/images/my/renzheng.png"></image>
<view class="box_text">实名认证</view>

View File

@ -1,6 +1,8 @@
<template>
<view>
<view class="timeView">
<!-- <times @change="getTime" :timeInterval="0.5" :appointTime="appointTime"
:isMultiple="true" :disableTimeSlot = "disableTimeSlot"></times> -->
<its-calendar :sta_num="0" :end_num="24" :int_num="msTimeDate" @getTime="TimeData" @getDate="SelData">
</its-calendar>
<view class="dx_view margin-bottom-sm" v-if="msList.length > 0">
@ -18,13 +20,20 @@
</template>
<script>
import times from '@/components/pretty-times/pretty-times.vue'
import itsCalendar from '@/components/its-calendar/its-calendar.vue';
export default {
components: {
itsCalendar
itsCalendar,
times
},
data() {
return {
appointTime:[],
disableTimeSlot:[
["2022-10-17 09:00:00", "2022-10-17 10:00:00"],
["2022-05-05 16:30:00", "2022-05-05 18:30:00"]
],
msTimeDate: 0,
newmsList: [],
msList: [],
@ -49,6 +58,11 @@
this.getMsTime(Time);
},
methods: {
getTime(time){
this.appointTime=time
console.log(time, '时间')
// this.disableTimeSlot=time
},
sub() {
// if (this.msList.length == 0) {
if(this.yearsDate === ''){

264
pages/my/mangshi1.vue Normal file
View File

@ -0,0 +1,264 @@
<template>
<view>
<view class="timeView">
<its-calendar :sta_num="0" :end_num="24" :int_num="msTimeDate" @getTime="TimeData" @getDate="SelData">
</its-calendar>
<view class="dx_view margin-bottom-sm" v-if="msList.length > 0">
<view class="dx_title">忙时时间</view>
<view class="flex align-center flex-wrap ">
<view v-for="(item,index) in msList" :key="index" class="btn flex align-center margin-top">
<view>{{item}}</view>
<view class="margin-left-sm" @tap.stop="bindupdata(index,item)">x</view>
</view>
</view>
</view>
<view class="sub" @click="sub()" >保存选择</view>
</view>
</view>
</template>
<script>
import itsCalendar from '@/components/its-calendar/its-calendar.vue';
export default {
components: {
itsCalendar
},
data() {
return {
msTimeDate: 0,
newmsList: [],
msList: [],
startTime: '',
yearsDate: '',
}
},
onLoad() {
if (this.$queue.getData('msTimeDate')) {
this.msTimeDate = parseInt(this.$queue.getData('msTimeDate'));
} else {
this.msTimeDate = 60;
}
var date = new Date();
var year = date.getFullYear();
let month = (parseInt(date.getMonth()) + 1) > 9 ? (parseInt(date.getMonth()) + 1) : "0" + (parseInt(
date.getMonth()) + 1) //
let days = (date.getDate()) > 9 ? date.getDate() : "0" + date.getDate() //
let fullDate = `${month}-${days}`
let Time = year + '-' + fullDate
this.yearsDate = Time;
this.getMsTime(Time);
},
methods: {
sub() {
// if (this.msList.length == 0) {
if(this.yearsDate === ''){
this.$queue.showToast('请先添加待选时间!');
return;
}
uni.showModal({
title: '温馨提示',
content: '是否将待选区的时间设置为忙时?',
showCancel: true,
cancelText: '取消',
confirmText: '确认',
success: res => {
if (res.confirm) {
this.saveMangShi();
}
}
});
},
//
bindupdata(index1, item) {
let over = false;
for (var i = 0; i < this.newmsList.length; i++) {
if (this.newmsList[i].artificerTime === item) {
if (this.newmsList[i].classify == 1) {
over = true;
break;
}
}
}
if (!over) {
this.msList.splice(index1, 1)
} else {
this.$queue.showToast('当前时间已被用户下单,禁止删除!')
}
},
saveMangShi() {
this.$Request.postT('/app/artificerTime/updateArtificerTime?artificerDate=' + this.yearsDate + '&times=' +
this.msList.join(",") + '&artificerId=' + uni.getStorageSync('artificerId')).then(res => {
if (res.code == 0) {
this.$queue.showToast('设置成功!')
} else {
this.$queue.showToast(res.msg);
}
});
},
getMsTime(artificerDate) {
this.yearsDate = artificerDate;
this.$Request.getT('/app/artificerTime/selectArtificerTimeByArtificerId?artificerId=' + uni.getStorageSync(
'artificerId') + '&artificerDate=' + artificerDate).then(res => {
if (res && res.code == 0 && res.data) {
this.msList = [];
this.newmsList = res.data;
this.msList = res.data.map((item)=> item.artificerTime);
console.log(this.msList);
uni.$emit("sendChildMsList",this.msList);
}
});
},
SelData(e) {
console.log(e)
var date = new Date();
var year = date.getFullYear();
let Time = year + '-' + e.days
this.getMsTime(Time);
this.msList = [];
},
//
TimeData(e) {
console.log(e, e.days)
var date = new Date();
var year = date.getFullYear();
this.startTime = year + '-' + e.days + ' ' + e.hours
this.yearsDate = year + '-' + e.days
console.log(this.yearsDate)
var hours=e.hours;
for(var i=0;i<hours.length;i++){
if (!this.msList.includes(hours[i].hours)) {
this.msList.push(hours[i].hours);
}
}
console.log('忙时list' + JSON.stringify(this.msList) );
// this.msList.push(e.hours);
}
}
}
</script>
<style lang="scss">
page {
background: #f7f7f7;
}
.dx_view {
background: #FFFFFF;
border-radius: 8rpx;
padding: 20rpx 20rpx 40rpx;
width: 710rpx;
margin-top: 20rpx;
.dx_title {
font-size: 30rpx;
font-weight: bold;
}
}
.timeView {
display: flex;
width: 750rpx;
flex-wrap: wrap;
margin: 0rpx 20rpx;
.timeview_item {
background: #F7F7F7;
border-radius: 15rpx;
width: 120rpx;
height: 140rpx;
text-align: center;
padding-top: 14rpx;
margin: 20rpx 20rpx 20rpx 6rpx;
}
.timeview_acitem {
width: 120rpx;
height: 140rpx;
text-align: center;
background: #E8F9EF;
border: 1px solid #00B88F;
color: #00B88F;
border-radius: 15rpx;
padding-top: 14rpx;
margin: 20rpx 20rpx 20rpx 6rpx;
}
.item_text {
width: 120rpx;
font-size: 22rpx;
font-family: PingFang SC;
font-weight: 500;
margin-top: 6rpx;
}
}
.btn {
border: 1upx solid #CCCCCC;
border-radius: 28px;
padding: 15rpx 30rpx;
margin-right: 25rpx;
}
.btns {
border: 1upx dashed #333333;
border-radius: 28px;
padding: 10rpx 30rpx;
margin-right: 25rpx;
}
.active {
/* background: #FCD202; */
/* border: none; */
}
.topView {
width: 750rpx;
height: 180rpx;
background: #FFFFFF;
.topview_item {
width: 160rpx;
height: 120rpx;
text-align: center;
padding-top: 14rpx;
margin: 0rpx 10rpx;
}
.topview_acitem {
width: 160rpx;
height: 120rpx;
text-align: center;
background: #E8F9EF;
border: 1px solid #00B88F;
color: #00B88F;
border-radius: 20rpx;
padding-top: 14rpx;
margin: 0rpx 10rpx;
}
.item_text {
width: 160rpx;
font-size: 20rpx;
font-family: PingFang SC;
font-weight: bold;
margin-top: 6rpx;
}
}
.sub {
display: flex;
justify-content: center;
align-items: center;
width: 696rpx;
height: 80rpx;
line-height: 80rpx;
border-radius: 50rpx;
margin: 30rpx 10rpx;
color: #FFFFFF;
font-size: 30rpx;
background: linear-gradient(90deg, #019C88, #28BA92, #35C495);
}
</style>

93
utils/date.js Normal file
View File

@ -0,0 +1,93 @@
//字符串拼接
function strFormat(str) {
return str < 10 ? `0${str}` : str
}
// 获取当前时间
export function currentTime() {
const myDate = new Date();
const y = myDate.getFullYear()
const m = myDate.getMonth() + 1;
const d = myDate.getDate();
const date = y + '-' + strFormat(m) + '-' + strFormat(d);
const hour = myDate.getHours()
const min = myDate.getMinutes()
const secon = myDate.getSeconds()
const time = strFormat(hour) + ':' + strFormat(min) + ':' + strFormat(secon);
return {
date,
time
}
}
//时间戳转日期
export function timeStamp(time, isQuantum) {
const dates = new Date(time)
const year = dates.getFullYear()
const month = dates.getMonth() + 1
const date = dates.getDate()
const day = dates.getDay()
const hour = dates.getHours()
const min = dates.getMinutes()
const days = ['日', '一', '二', '三', '四', '五', '六']
return {
allDate: `${year}/${strFormat(month)}/${strFormat(date)}`,
date: `${strFormat(year)}-${strFormat(month)}-${strFormat(date)}`, //返回的日期 07-01
day: `星期${days[day]}`, //返回的礼拜天数 星期一
hour: strFormat(hour) + ':' + strFormat(min) + (isQuantum ? "" : ':00') //返回的时钟 08:00
}
}
//获取最近7天的日期和礼拜天数
export function initData() {
const time = []
const date = new Date()
const now = date.getTime() //获取当前日期的时间戳
let timeStr = 3600 * 24 * 1000 //一天的时间戳
let obj = {
0: "今天",
1: "明天",
2: "后天"
}
for (let i = 0; i < 7; i++) {
time.push({
date: timeStamp(now + timeStr * i).date, //保存日期
timeStamp: now + timeStr * i, //保存时间戳
week: obj[i] ?? timeStamp(now + timeStr * i).day
})
}
return time
}
//时间数组
export function initTime(startTime = '10:00:00', endTime = '21:00:00', timeInterval = 1, isQuantum = false) {
const time = []
const date = timeStamp(Date.now()).allDate
const startDate = `${date} ${startTime}`
const endDate = `${date} ${endTime}`
const startTimeStamp = new Date(startDate).getTime()
const endTimeStamp = new Date(endDate).getTime()
const timeStr = 3600 * 1000 * timeInterval
const sum = (endTimeStamp - startTimeStamp) / timeStr
const count = sum % 2 == 0 ? sum : (sum - 1)
let num = 0
for (let i = startTimeStamp; i <= endTimeStamp; i = i + timeStr) {
if (isQuantum) {
num++
time.push({
begin: timeStamp(i, isQuantum).hour,
end: timeStamp(i + timeStr, isQuantum).hour,
disable: false
})
} else {
time.push({
time: timeStamp(i).hour,
disable: false
})
}
if (isQuantum && num >= count) return time
}
return time
}