|
|
// pages/index/release/release.js
|
|
|
const app=getApp()
|
|
|
const app = getApp()
|
|
|
Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
classify: ['11', '22'],
|
|
|
classify: [],
|
|
|
current: 0,
|
|
|
max: 20,
|
|
|
max2: 200,
|
|
|
release_time: ['今天(周三)', '今天(周三)', '今天(周三)'],
|
|
|
max3: 100,
|
|
|
release_time: [],
|
|
|
currentTime: 0,
|
|
|
relsese_state: false,
|
|
|
release_time2: [{
|
|
|
time: '今天(周三)',
|
|
|
relsese_state: false
|
|
|
}, {
|
|
|
time: '今天(周三)',
|
|
|
relsese_state: false
|
|
|
}, , {
|
|
|
time: '今天(周三)',
|
|
|
relsese_state: false
|
|
|
}, ],
|
|
|
more_state:false,
|
|
|
images:[],
|
|
|
styles:[],
|
|
|
title:'',
|
|
|
text:'',
|
|
|
relsese_state1: -1,
|
|
|
release_time2: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '012:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', ],
|
|
|
more_state: false,
|
|
|
images: [],
|
|
|
styles: [],
|
|
|
title: '',
|
|
|
text: '',
|
|
|
imgInfo: '',
|
|
|
img_state: false,
|
|
|
tempUrl: [],
|
|
|
time_info: '定时发送',
|
|
|
open_time: '',
|
|
|
temp_time2: '',
|
|
|
temp_time: '',
|
|
|
list_id:0,
|
|
|
|
|
|
},
|
|
|
|
|
|
setTitle(e) {
|
...
|
...
|
@@ -47,17 +49,55 @@ Page({ |
|
|
if (len > this.data.max2) return;
|
|
|
this.setData({
|
|
|
number: len,
|
|
|
text:content
|
|
|
text: content
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setImgText(e) {
|
|
|
var content = e.detail.value;
|
|
|
this.setData({
|
|
|
imgInfo: content
|
|
|
})
|
|
|
var len = parseInt(content.length);
|
|
|
if (len > this.data.max) return;
|
|
|
this.setData({
|
|
|
imgInfoNum: len //当前字数
|
|
|
});
|
|
|
},
|
|
|
|
|
|
goCheck() {
|
|
|
var index = wx.getStorageSync('index')
|
|
|
var images = this.data.images
|
|
|
var tempUrl = this.data.tempUrl
|
|
|
var imgInfo = this.data.imgInfo
|
|
|
images[index].text = imgInfo
|
|
|
console.log(images)
|
|
|
this.setData({
|
|
|
img_state: false,
|
|
|
images: images
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//分类
|
|
|
setClassify(e) {
|
|
|
var index=e.currentTarget.dataset.index
|
|
|
var classify=this.data.classify
|
|
|
classify[index].state=!(classify[index].state)
|
|
|
var index = e.currentTarget.dataset.index
|
|
|
var classify = this.data.classify
|
|
|
classify[index].state = !(classify[index].state)
|
|
|
this.setData({
|
|
|
classify:classify
|
|
|
classify: classify
|
|
|
})
|
|
|
},
|
|
|
|
|
|
getStyleId(){
|
|
|
var styles = this.data.styles
|
|
|
var classify = this.data.classify
|
|
|
for(var i=0;i<classify;i++){
|
|
|
if(classify[i].state){
|
|
|
styles.push(classify[i].id)
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
|
styles: styles
|
|
|
})
|
|
|
},
|
|
|
|
...
|
...
|
@@ -68,8 +108,8 @@ Page({ |
|
|
app.post(url, param).then((res) => {
|
|
|
if (res.data.code == 20000) {
|
|
|
var classify = res.data.data.list
|
|
|
for(var i=0;i<classify.length;i++){
|
|
|
classify[i].state=false
|
|
|
for (var i = 0; i < classify.length; i++) {
|
|
|
classify[i].state = false
|
|
|
}
|
|
|
that.setData({
|
|
|
classify: classify,
|
...
|
...
|
@@ -80,10 +120,12 @@ Page({ |
|
|
|
|
|
//选择发布时间
|
|
|
selectTime(e) {
|
|
|
const self = this;
|
|
|
const that = this;
|
|
|
const current = e.currentTarget.dataset.index;
|
|
|
self.setData({
|
|
|
currentTime: current
|
|
|
var lastMonth = this.data.lastMonth
|
|
|
that.setData({
|
|
|
currentTime: current,
|
|
|
temp_time2: lastMonth[current]
|
|
|
});
|
|
|
},
|
|
|
|
...
|
...
|
@@ -91,9 +133,68 @@ Page({ |
|
|
setTime(e) {
|
|
|
const index = e.currentTarget.dataset.index;
|
|
|
var release_time2 = this.data.release_time2
|
|
|
release_time2[index].relsese_state = !(release_time2[index].relsese_state)
|
|
|
var relsese_state1 = this.data.relsese_state1
|
|
|
if (relsese_state1 == index) {
|
|
|
return false
|
|
|
} else {
|
|
|
this.setData({
|
|
|
relsese_state1: index,
|
|
|
temp_time: release_time2[index]
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
getTime() {
|
|
|
var date = new Date()
|
|
|
var week = date.getDay()
|
|
|
var info = "";
|
|
|
var year = date.getFullYear()
|
|
|
var month = date.getMonth()
|
|
|
var day = date.getDate()
|
|
|
var hours = date.getHours()
|
|
|
var minutes = date.getMinutes()
|
|
|
var seconds = date.getSeconds()
|
|
|
var release_time = this.data.release_time
|
|
|
|
|
|
if (week == 0) {
|
|
|
info = "周日";
|
|
|
} else if (week == 1) {
|
|
|
info = "周一";
|
|
|
} else if (week == 2) {
|
|
|
info = "周二";
|
|
|
} else if (week == 3) {
|
|
|
info = "周三";
|
|
|
} else if (week == 4) {
|
|
|
info = "周四";
|
|
|
} else if (week == 5) {
|
|
|
info = "周五";
|
|
|
} else if (week == 6) {
|
|
|
info = "周六";
|
|
|
}
|
|
|
|
|
|
var lastMonth = [];
|
|
|
for (var i = 0; i < 30; i++) {
|
|
|
lastMonth.push(new Date(new Date()
|
|
|
.setDate(new Date().getDate() + i))
|
|
|
.toLocaleString().substring(0, 9))
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
release_time2: release_time2
|
|
|
release_time: release_time,
|
|
|
lastMonth: lastMonth,
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
tempTime() {
|
|
|
var lastMonth = this.data.lastMonth
|
|
|
var currentTime = this.data.currentTime
|
|
|
var time = lastMonth[currentTime]
|
|
|
var temp_time = this.data.temp_time
|
|
|
var open_time = time + ' ' + temp_time
|
|
|
console.log(open_time)
|
|
|
this.setData({
|
|
|
open_time: open_time
|
|
|
})
|
|
|
},
|
|
|
|
...
|
...
|
@@ -107,6 +208,7 @@ Page({ |
|
|
this.setData({
|
|
|
relsese_state: false
|
|
|
})
|
|
|
this.tempTime()
|
|
|
},
|
|
|
|
|
|
//上传图片
|
...
|
...
|
@@ -199,39 +301,50 @@ Page({ |
|
|
})
|
|
|
},
|
|
|
|
|
|
goEdit(e){
|
|
|
var index=e.currentTarget.dataset.index
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/index/brief/brief?index='+index,
|
|
|
goEdit(e) {
|
|
|
var index = e.currentTarget.dataset.index
|
|
|
var url = e.currentTarget.dataset.url
|
|
|
wx.setStorageSync('index', index)
|
|
|
this.setData({
|
|
|
img_state: true,
|
|
|
index: index,
|
|
|
url: url
|
|
|
})
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/index/brief/brief?index=' + index + '&url=' + url,
|
|
|
// })
|
|
|
},
|
|
|
|
|
|
showMore(){
|
|
|
showMore() {
|
|
|
this.setData({
|
|
|
more_state:!(this.data.more_state)
|
|
|
more_state: !(this.data.more_state)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
setOpen(e){
|
|
|
setOpen(e) {
|
|
|
wx.showToast({
|
|
|
title: '设置成功',
|
|
|
})
|
|
|
this.setData({
|
|
|
open:e.currentTarget.dataset.open
|
|
|
open: e.currentTarget.dataset.open,
|
|
|
more_state:false
|
|
|
})
|
|
|
},
|
|
|
|
|
|
tempClassify(){
|
|
|
tempClassify() {
|
|
|
var classify = this.data.classify
|
|
|
var styles=[]
|
|
|
var styles = []
|
|
|
for (var i = 0; i < classify.length; i++) {
|
|
|
if (classify[i].state){
|
|
|
if (classify[i].state) {
|
|
|
styles.push(classify[i].id)
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
|
styles:styles
|
|
|
styles: styles
|
|
|
})
|
|
|
},
|
|
|
|
|
|
submitInfo(){
|
|
|
submitInfo() {
|
|
|
this.tempClassify()
|
|
|
let url = '/home/index/fashion'
|
|
|
let params = {
|
...
|
...
|
@@ -241,7 +354,7 @@ Page({ |
|
|
styles: this.data.styles,
|
|
|
open_time: this.data.open_time,
|
|
|
open: this.data.open,
|
|
|
img: this.data.img
|
|
|
img: JSON.stringify(this.data.images)
|
|
|
}
|
|
|
let header = {
|
|
|
"XX-Token": wx.getStorageSync('token'),
|
...
|
...
|
@@ -250,17 +363,23 @@ Page({ |
|
|
app.post(url, params, header).then((res) => {
|
|
|
console.log(res)
|
|
|
if (res.data.code == 20000) {
|
|
|
|
|
|
wx.navigateBack({
|
|
|
dalta:1
|
|
|
})
|
|
|
}
|
|
|
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
this.getStyle()
|
|
|
this.getTime()
|
|
|
},
|
|
|
|
|
|
/**
|
...
|
...
|
|