fireflysg-wxapp/pages/my/publishList.js

321 lines
7.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/my/publish.js
import request from '../../utils/request'
Page({
/**
* 页面的初始数据
*/
data: {
currentTab: 0,
list: [],
pageNum: 1,
pageSize: 10,
pageNum1: 1,
listData: [],
shopInfo: {}
},
swichNav(e) {
this.setData({
pageNum: 1,
pageNum1: 1,
list: [],
listData: [],
shopInfo: {},
currentTab: e.target.dataset.current
})
if (this.data.currentTab == 3) {
this.getVedio()
} else {
this.getData(e.target.dataset.current)
}
},
listTap(e) {
const id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/vedio/detail?id=' + id
})
},
// 编辑
editEvent(param) {
const id = param.currentTarget.dataset.id
let url = ''
if (this.data.currentTab == 0) {
url = '/pages/article/publish?id=' + id
} else if (this.data.currentTab == 1) {
url = '/pages/article/publish1?id=' + id
} else {
url = '/pages/article/publish2?id=' + id
}
wx.navigateTo({
url: url
})
},
// 删除
delete(param) {
const id = param.currentTarget.dataset.id
// 删除文章发布
if (this.data.currentTab == 0) {
let data = {
id: id
}
request._post('/firefly/article/delete', data,
res => {
if (res.retCode == 0) {
setTimeout(() => {
wx.showToast({
title: '删除成功',
icon: 'none',
duration: 2000
})
}, 200);
this.setData({
pageNum: 1,
list: []
})
this.getData()
}
})
}
// 删除商品发布
if (this.data.currentTab == 1) {
let data = {
goodsId: id
}
request._post('/firefly/goods/delete', data,
res => {
if (res.retCode == 0) {
setTimeout(() => {
wx.showToast({
title: '删除成功',
icon: 'none',
duration: 2000
})
}, 200);
this.setData({
pageNum: 1,
list: []
})
this.getData()
}
})
}
// 删除商家发布
if (this.data.currentTab == 2) {
let data = {
storeId: id
}
request._post('/firefly/store/delete', data,
res => {
if (res.retCode == 0) {
setTimeout(() => {
wx.showToast({
title: '删除成功',
icon: 'none',
duration: 2000
})
}, 200);
this.setData({
pageNum: 1,
shopInfo: {}
})
this.getData()
}
})
}
if (this.data.currentTab == 3) {
let data = {
id: id
}
request._post('/firefly/video/delete', data,
res => {
if (res.retCode == 0) {
setTimeout(() => {
wx.showToast({
title: '删除成功',
icon: 'none',
duration: 2000
})
}, 200);
this.setData({
pageNum1: 1,
listData: []
})
this.getVedio()
}
})
}
},
getVedio() {
const data = {
"keyword": "", // 搜索关键字,视频标题,可选参数
"categoryId": 1, //分类 Id可选参数
"pageNum": this.data.pageNum1,
"pageSize": 10 // ⻚⼤⼩,可选参数
}
request._post('/firefly/video/list', data,
res => {
if (res.retCode == 0) {
if (res.body.length > 0) {
var listdata = this.data.listData
listdata.push.apply(listdata, res.body)
this.setData({
listData: listdata,
pageNum1: ++res.pageInfo.pageNum
})
} else {
if (this.data.pageNum1 == res.pageInfo.pages) {
setTimeout(() => {
wx.showToast({
title: '没有更多数据',
icon: 'none',
duration: 2000
})
}, 200);
}
}
}
})
},
getData() {
let that = this
// 文章发布
if (this.data.currentTab == 0) {
const data = {
categoryId: 0,
keyword: '',
pageNum: this.data.pageNum,
pageSize: this.data.pageSize
}
request._post('/firefly/article/my/list', data,
res => {
if (res.retCode == 0) {
if (res.body.length > 0) {
var listdata = that.data.list
listdata.push.apply(listdata, res.body)
that.setData({
list: listdata,
pageNum: ++res.pageInfo.pageNum
})
} else {
if (that.data.pageNum != 1) {
setTimeout(() => {
wx.showToast({
title: '没有更多数据',
icon: 'none',
duration: 2000
})
}, 200);
}
}
}
})
}
// 商品发布
if (this.data.currentTab == 1) {
const data = {
keyword: "", // 搜索关键字,商家名称,可选参数
categoryId: 0, //分类 Id可选参数
startDate: "", // 开始时间,可选参数
endDate: "", // 结束时间,可选参数
orderBy: 1, //排序1-发布降序排序;2-发布升序排序,可选参数
pageNum: this.data.pageNum,
pageSize: this.data.pageSize
}
request._post('/firefly/goods/my/list', data,
res => {
if (res.retCode == 0) {
if (res.body) {
var listdata = that.data.list
listdata.push.apply(listdata, res.body)
console.log(listdata)
that.setData({
list: listdata,
pageNum: ++res.pageInfo.pageNum
})
} else {
if (that.data.pageNum != 1) {
setTimeout(() => {
wx.showToast({
title: '没有更多数据',
icon: 'none',
duration: 2000
})
}, 200);
}
}
}
})
}
// 商家发布
if (this.data.currentTab == 2) {
const data = {}
request._post('/firefly/store/my', data,
res => {
if (res.retCode == 0) {
if (res.body) {
that.setData({
shopInfo: res.body,
})
}
}
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getData()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})