类似闹钟,只输入小时 分钟,判断年月日

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>guildhot</title>

<link rel="stylesheet" href="./css/pulic.css">

<link rel="stylesheet" href="./css/my-guildSet.css"/>

<link rel="stylesheet" href="./css/iosSelect.css" />

</head>

<body>

<div id="app" v-cloak>

<div class="content">

<form action="" method="">

<div class="item-select flex" @click="checkSelect('live')">

<p>{{liveName}}</p>

<span></span>

</div>

<div class="start-box flex">

<div class="start-title">

-选择开始时间段-

</div>

<div class="start-time flex">

<div class="time-box flex" @click="checkSelect('start')">

<span class="time-hour">{{startHour}}</span>

<span class="time-icon flex">:</span>

<span class="time-minute">{{startMinute}}</span>

</div>

</div>

</div>

<!--  -->

<div class="start-box flex">

<div class="start-title">

-选择结束时间段-

</div>

<div class="start-time flex">

<div class="time-box flex" @click="checkSelect('end')">

<span class="time-hour">{{endHour}}</span>

<span class="time-icon flex">:</span>

<span class="time-minute">{{endMinute}}</span>

</div>

</div>

</div>

<!--  -->

<div class="confirm" @click="sumbit">

确认

</div>

</form>

</div>

<!--  -->

<div class="container">

</div>

</div>

<script src="./js/public.js"></script>

<script src="./js/vue.js"></script>

<script src="./js/iosSelect.js"></script>

<script type="text/javascript">

let app = new Vue({

el: '#app',

data: {

liveList:[],

/*

liveList: [{

value: '元气少女',

id: 86,

}, {

value: '王者荣耀',

id: 2,

}, ],*/

liveID: 0,

liveName: '选择主播',

hourList: [{

value: '00',

id: 1

}, {

value: '01',

id: 2

}, {

value: '02',

id: 3

}, {

value: '03',

id: 4

}, {

value: '04',

id: 5

}, {

value: '05',

id: 6

}, {

value: '06',

id: 7

}, {

value: '07',

id: 8

}, {

value: '08',

id: 9

}, {

value: '09',

id: 10

}, {

value: '10',

id: 11

}, {

value: '11',

id: 12

}, {

value: '12',

id: 13

}, {

value: '13',

id: 14

}, {

value: '14',

id: 15

}, {

value: '15',

id: 16

}, {

value: '16',

id: 17

}, {

value: '17',

id: 18

}, {

value: '18',

id: 19

}, {

value: '19',

id: 20

}, {

value: '20',

id: 21

}, {

value: '21',

id: 22

}, {

value: '22',

id: 23

}, {

value: '23',

id: 24

}, ],

minuteList: [{

value: '00',

id: 1

}, {

value: '05',

id: 2

}, {

value: '10',

id: 3

}, {

value: '15',

id: 4

}, {

value: '20',

id: 5

}, {

value: '25',

id: 6

}, {

value: '30',

id: 7

}, {

value: '35',

id: 8

}, {

value: '40',

id: 9

}, {

value: '45',

id: 10

}, {

value: '50',

id: 11

}, {

value: '55',

id: 12

}, {

value: '59',

id: 13

}, ],

startHour: '00',

startMinute: '00',

startHourID: 0,

startMinuteID: 0,

endHour: '00',

endMinute: '00',

endHourID: 0,

endMinuteID: 0,

token: '',

unionId:0,

page:1,

type:0,//1为语聊2为直播

},

created() {

const that = this

getUserToken().then((response) => {

that.token = response

})

let timestamp = Date.parse(new Date());

let nowTime = this.getLocalTime(timestamp)

},

watch: {

token: function() {

this.getData()

},

},

mounted() {

//this.getData()

},

methods: {

getData() {

let that = this;

this.unionId = getUrlValue(value = 'id')

setajax({

url: '/index.php/api/Union/union_detail',

headers: {

token: that.token

},

data: {

union_id: that.unionId

},

success: function(res) {

that.type = res.data.typelist

}

})

//返回公会成员列表

setajax({

url:'/index.php/api/Union/union_nember_list',

data:{

union_id:that.unionId,

page:that.page

},

headers:{

token:that.token

},

success:function(res){

console.log(res)

if(res.data != null){

that.form = res.data

}

let newArr=[];

for(let i =0;i<res.data.data.length;i++){

let vote = {};

vote.key = res.data.data[i].usersid

vote.value = res.data.data[i].nickname

newArr.push(vote)

}

that.liveList = newArr;

this.$forceUpdate()

},

})

},

getLocalTime(nS) {   

    return new Date(parseInt(nS) * 1)

},

timeDecide(){

/*新增*/

//判断新选择时间是发生在今天还是明天

let year = new Date().getFullYear()

let month = new Date().getMonth() +1

let date = new Date().getDate()

let hour = new Date().getHours()

//开始的年,月,日

let Setyear

let Setmonth

let SetDate

let SetHour

if(hour>this.startHour){

Setyear = year

//alert("开始时间发生在明天")

if(month==1||month==3||month==5||month==7||month==8||month==10){

if(date==31){

Setmonth = month+1

SetDate = 1;

}else{

Setmonth = month

SetDate = date+1;

}

}else if(month==4||month==6||month==9||month==11){

if(date==30){

Setmonth = month+1

SetDate = 1;

}else{

Setmonth = month

SetDate = date+1;

}

}else if(month==12){

if(date==31){

Setyear = year+1

Setmonth = 1

SetDate = 1;

}else{

Setmonth = month

SetDate = date+1;

}

}else if(month==2){

if(year%100!=0&&year%4==0||year%400==0){

//alert("是闰年")

if(date==29){

Setmonth = month+1;

SetDate = 1;

}else{

Setmonth = month;

SetDate = date+1;

}

}else{

//alert("不是闰年")

if(month==2&&date==28){

Setmonth = month+1;

SetDate = 1;

}else{

Setmonth = month;

SetDate = date+1;

}

}

}

}else if(hour==this.startHour){

let minute = new Date().getMinutes()

if(minute+2>this.startMinute){//发生在这个小时

Setyear = year

Setmonth = month;

SetDate = date;

}else{

//alert("直播发生在下个小时")

if(hour==23){

//下一天

Setyear = year

Setmonth = month;

SetDate = date+1;

}else{//今天

Setyear = year

Setmonth = month;

SetDate = date;

}

}

}else if(hour<this.startHour){

//alert("直播发生在今天")

Setyear = year

Setmonth = month;

SetDate = date;

}

//结束的年,月,日

let SetFinishYear

let SetFinishmonth

let SetFinishDate

let SetFinishHour

//判定结束时间在开始的那一天还是开始后的一天

if(this.startHour>this.endHour){//开始时间大于结束时间,确定结束时间在开始后的一天

SetFinishYear = year

//alert("结束时间在开始后的那一天")

if(Setmonth==1||Setmonth==3||Setmonth==5||Setmonth==7||Setmonth==8||Setmonth==10){

if(SetDate==31){

SetFinishmonth = Setmonth+1

SetFinishDate = 1;

}else{

SetFinishmonth = Setmonth

SetFinishDate = SetDate+1;

}

}else if(Setmonth==4||Setmonth==6||Setmonth==9||Setmonth==11){

if(SetDate==30){

SetFinishmonth = Setmonth+1

SetFinishDate = 1;

}else{

SetFinishmonth = Setmonth

SetFinishDate = SetDate+1;

}

}else if(Setmonth==12){

if(SetDate==31){

SetFinishYear = year+1

SetFinishmonth = 1

SetFinishDate = 1;

}else{

SetFinishmonth = Setmonth

SetFinishDate = SetDate+1;

}

}else if(Setmonth==2){

if(year%100!=0&&year%4==0||year%400==0){

//alert("是闰年")

if(SetDate==29){

SetFinishmonth = Setmonth+1;

SetFinishDate = 1;

}else{

SetFinishmonth = Setmonth;

SetFinishDate = SetDate+1;

}

}else{

//alert("不是闰年")

if(Setmonth==2&&SetDate==28){

SetFinishmonth = Setmonth+1;

SetFinishDate = 1;

}else{

SetFinishmonth = Setmonth;

SetFinishDate = SetDate+1;

}

}

}

}else if(this.endHour==this.startHour){

if(this.startMinute+2>this.endMinute){//发生在这个小时

SetFinishYear = Setyear

SetFinishmonth = Setmonth;

SetFinishDate = SetDate;

}else{

//alert("直播发生在下个小时")

if(this.startHour==23){

//下一天

SetFinishYear = Setyear

SetFinishmonth = Setmonth;

SetFinishDate = SetDate+1;

}else{//今天

SetFinishYear = Setyear

SetFinishmonth = Setmonth;

SetFinishDate = SetDate;

}

}

}else if(this.startHour<this.endHour){

//alert("结束发生在开始的那一天")

SetFinishYear = Setyear

SetFinishmonth = Setmonth;

SetFinishDate = SetDate;

}

/*

alert(Setyear)

alert(Setmonth)

alert(SetDate)

alert(this.startHour)

alert(this.startMinute)

alert(SetFinishYear)

alert(SetFinishmonth)

alert(SetFinishDate)

alert(this.endHour)

alert(this.endMinute)*/

let start_time={

year:Setyear,

month:Setmonth,

date:SetDate,

hour:parseInt(this.startHour),

minute:parseInt(this.startMinute)

}

let end_time={

year:SetFinishYear,

month:SetFinishmonth,

date:SetFinishDate,

hour:parseInt(this.endHour),

minute:parseInt(this.endMinute)

}

let timeInfo={start_time:start_time,end_time:end_time}

return timeInfo

},

sumbit(){

const that = this

let timeInfo = this.timeDecide()

/*

alert("当前输出的用户id")

alert(this.liveID)

alert(that.unionId)

alert(that.liveID)

alert(timeInfo.start_time.month)

alert(timeInfo.end_time.hour)

alert(that.type)*/

if(timeInfo.start_time.hour==timeInfo.end_time.hour&&timeInfo.start_time.minute==timeInfo.end_time.minute){

showTip("开始时间与结束时间不能在同一时间")

setTimeout(()=>{

return;

},1000)

}else{

let strStart_time = `${timeInfo.start_time.year}-${timeInfo.start_time.month}-${timeInfo.start_time.date} ${timeInfo.start_time.hour}:${timeInfo.start_time.minute}:00`

let strFinish_time = `${timeInfo.end_time.year}-${timeInfo.end_time.month}-${timeInfo.end_time.date} ${timeInfo.end_time.hour}:${timeInfo.end_time.minute}:00`

setajax({

url: '/index.php/api/Union/recommendAnchor',

headers: {

token: that.token

},

data: {

union_id: that.unionId,

anchor_usersid:that.liveID,

start_time:strStart_time,

end_time:strFinish_time,

type:that.type

},

success: function(res) {

if(res.code ==200){

showTip('已成功推送主播上热门')

let setData = {

status: true

}

setTimeout(() => {

getbridge('wPageBack', setData, function() {})

}, 2000)

}

},

error:function(err){

alert(err)

}

})

}

},

checkSelect(name) {

const that = this

console.log(name)

let titleName = {

live: '选择主播',

start: '选择开始时间',

end: '选择结束时间'

},

num = 1,

arr = [],

options = {

container: '.container',

title: titleName[name],

itemHeight: 50,

itemShowCount: 5,

showAnimate: true,

showLoading: true,

addClassName: 'iosSelectStyle',

};

if (name == 'live') {

arr = [that.liveList]

options.oneLevelId = that.liveID

options.callback = function(select) {

that.liveName = select.value

that.liveID = select.key

}

that.createSelect(num, arr, options)

} else {

let hour = name + 'Hour',

minute = name + 'Minute',

hourId = name + 'HourID',

minuteId = name + 'MinuteID';

num = 2

arr = [that.hourList, that.minuteList]

options.oneLevelId = that[hourId]

options.twoLevelId = that[minuteId]

options.callback = function(selectHour, selectMinute) {

that[hour] = selectHour.value

that[hourId] = selectHour.id

that[minute] = selectMinute.value

that[minuteId] = selectMinute.id

}

that.createSelect(num, arr, options)

}

},

createSelect(num, arr, options) {

const that = this

let selectShow = new IosSelect(num, [...arr], options)

}

}

})

</script>

</body>

</html>

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 205,132评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 87,802评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 151,566评论 0 338
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,858评论 1 277
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,867评论 5 368
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,695评论 1 282
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,064评论 3 399
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,705评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 42,915评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,677评论 2 323
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,796评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,432评论 4 322
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,041评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,992评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,223评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,185评论 2 352
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,535评论 2 343