174 lines
5.3 KiB
JavaScript
174 lines
5.3 KiB
JavaScript
// pages/mine/setting/columnsetting.js
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
curIndex: 0,
|
|
menuList: [],
|
|
imgUrl: app.urls.baseImgUrl,
|
|
inputColumnName: '',
|
|
isShowInput: false,
|
|
curId: '',
|
|
curIndex: 0,
|
|
curIdx: 0
|
|
},
|
|
onLoad: function (options) {
|
|
this.getColumnList()
|
|
try {
|
|
var isFrist = wx.getStorageSync('isFirst')
|
|
if (isFrist) {
|
|
|
|
} else {
|
|
wx.setStorage({
|
|
key: 'isFirst',
|
|
data: true
|
|
})
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '点击列表条目名称可以自定义栏目名称,点击开关可以控制是否在首页展示该条目.',
|
|
showCancel: false,
|
|
success(res) {
|
|
|
|
}
|
|
})
|
|
}
|
|
} catch (err) {
|
|
console.log('获取失败')
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '点击列表条目名称可以自定义栏目名称,点击开关可以控制是否在首页展示该条目.',
|
|
showCancel: false,
|
|
success(res) {
|
|
|
|
}
|
|
})
|
|
}
|
|
},
|
|
getColumnList() {
|
|
wx.showLoading({
|
|
title: '加载中...',
|
|
})
|
|
var _self = this
|
|
app.http.get(app.urls.getMineColumnList, {
|
|
header: {
|
|
token: app.globalData.token
|
|
}
|
|
})
|
|
.then(res => {
|
|
var data = res.data
|
|
wx.hideLoading({})
|
|
data.forEach(it => {
|
|
it.configColumnList.sort((a, b) => a.configColumnOrder - b.configColumnOrder)
|
|
})
|
|
_self.setData({
|
|
menuList: data
|
|
})
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading({})
|
|
})
|
|
},
|
|
//保存我的栏目是否显示
|
|
doSaveColumnDisplay(e) {
|
|
// configColumnId
|
|
var id = e.currentTarget.dataset.id
|
|
var index = e.currentTarget.dataset.index
|
|
var idx = e.currentTarget.dataset.idx
|
|
console.log(id + '===' + idx + '===' + index)
|
|
var _self = this
|
|
wx.showLoading({
|
|
title: '保存中...',
|
|
})
|
|
app.http.post(app.urls.doSaveColumnDisplay, {
|
|
header: {
|
|
token: app.globalData.token
|
|
},
|
|
data: {
|
|
configColumnId: id
|
|
}
|
|
})
|
|
.then(res => {
|
|
wx.hideLoading({})
|
|
var setMode = _self.data.menuList[index].configColumnList[idx].configColumnSet
|
|
if (setMode == '0') {
|
|
setMode = '1'
|
|
} else {
|
|
setMode = '0'
|
|
}
|
|
_self.data.menuList[index].configColumnList[idx].configColumnSet = setMode
|
|
_self.setData({
|
|
menuList: _self.data.menuList
|
|
})
|
|
})
|
|
.catch(err => {
|
|
console.log(err)
|
|
wx.hideLoading({})
|
|
wx.showToast({
|
|
title: '保存失败',
|
|
icon: 'error'
|
|
})
|
|
})
|
|
},
|
|
//保存我的栏目名称
|
|
doSaveColumnName() {
|
|
var _self = this
|
|
wx.showLoading({
|
|
title: '修改中...',
|
|
})
|
|
app.http.post(app.urls.doSaveColumnName, {
|
|
header: {
|
|
token: app.globalData.token
|
|
},
|
|
data: {
|
|
configColumnId: _self.data.curId,
|
|
configColumnName: _self.data.inputColumnName
|
|
}
|
|
})
|
|
.then(res => {
|
|
wx.hideLoading({})
|
|
_self.data.menuList[_self.data.curIndex].configColumnList[_self.data.curIdx].configColumnRemark = _self.data.menuList[_self.data.curIndex].configColumnList[_self.data.curIdx].configColumnName
|
|
_self.data.menuList[_self.data.curIndex].configColumnList[_self.data.curIdx].configColumnName = _self.data.inputColumnName
|
|
// 刷新数据
|
|
_self.setData({
|
|
menuList: _self.data.menuList,
|
|
inputColumnName: '',
|
|
})
|
|
})
|
|
.catch(err => {
|
|
wx.hideLoading({})
|
|
wx.showToast({
|
|
title: '修改失败',
|
|
icon: 'error'
|
|
})
|
|
})
|
|
},
|
|
showInput(e) {
|
|
var id = e.currentTarget.dataset.id //栏目
|
|
var index = e.currentTarget.dataset.index //栏目组
|
|
var idx = e.currentTarget.dataset.idx //栏目
|
|
this.setData({
|
|
isShowInput: true,
|
|
curId: id,
|
|
curIndex: index,
|
|
curIdx: idx
|
|
})
|
|
},
|
|
//保存自定义栏目名称
|
|
addName(e) {
|
|
var _self = this
|
|
_self.setData({
|
|
isShowInput: false,
|
|
})
|
|
_self.doSaveColumnName()
|
|
},
|
|
//栏目名称输入监听
|
|
textInput(e) {
|
|
this.setData({
|
|
inputColumnName: e.detail.value
|
|
})
|
|
},
|
|
onHide(e) {
|
|
this.setData({
|
|
isShowInput: false
|
|
})
|
|
}
|
|
}) |