<!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>