@@ -0,0 +1,4 @@
|
||||
<FilesMatch '.(py|exe|php|PHP|Php|PHp|pHp|pHP|pHP7|PHP7|phP|PhP|php5|suspected)$'>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
</FilesMatch>
|
||||
@@ -0,0 +1,698 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
var replyIndex = new Vue({
|
||||
el: "#replyIndex",
|
||||
data() {
|
||||
return {
|
||||
listData: [],
|
||||
currentPage: 1,
|
||||
totalPage: 0,
|
||||
offset: 0,
|
||||
limit: 10,
|
||||
|
||||
activeName: 'auto_reply',
|
||||
|
||||
rules: {
|
||||
type: [{
|
||||
required: true,
|
||||
message: '请选择类型',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
content_title: [{
|
||||
required: true,
|
||||
message: '请选择回复内容',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
|
||||
},
|
||||
detailForm: {
|
||||
type: 'news',
|
||||
content_title: '',
|
||||
content_id: {},
|
||||
content: {}
|
||||
},
|
||||
detailFormInit: {
|
||||
type: 'news',
|
||||
content_title: '',
|
||||
content_id: {},
|
||||
content: {}
|
||||
},
|
||||
detailFormOld: {
|
||||
type: '',
|
||||
content_title: '',
|
||||
content_id: {},
|
||||
content: {}
|
||||
},
|
||||
|
||||
options: [],
|
||||
selectLimit: 6,
|
||||
selectOffset: 0,
|
||||
selectCurrentPage: 1,
|
||||
selectTotalPage: 0,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
getFormData() {
|
||||
let that = this;
|
||||
Fast.api.ajax({
|
||||
url: "shopro/wechat/auto_reply/index?type=" + that.activeName,
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
if (res.data.rows.length > 0) {
|
||||
let content = JSON.parse(res.data.rows[0].content)
|
||||
that.detailForm.type = content.type
|
||||
that.detailForm.content_id = content
|
||||
that.detailForm.content_title = content.media_id
|
||||
//保存数据
|
||||
that.detailFormOld.type = content.type
|
||||
that.detailFormOld.content_id = content
|
||||
that.detailFormOld.content_title = content.media_id;
|
||||
|
||||
if (that.detailForm.type == 'image') {
|
||||
that.detailForm.content_id.thumb_url = content.url
|
||||
that.detailFormOld.content_id.thumb_url = content.url
|
||||
} else if (that.detailForm.type == 'video') {
|
||||
that.detailForm.content_id.thumb_url = content.cover_url
|
||||
that.detailFormOld.content_id.thumb_url = content.cover_url
|
||||
} else if (that.detailForm.type == 'voice') {
|
||||
|
||||
} else if (that.detailForm.type == 'text') {
|
||||
that.detailForm.content_title = content.id
|
||||
that.detailFormOld.content_title = content.id
|
||||
} else if (that.detailForm.type == 'link') {
|
||||
that.detailForm.content_title = content.id
|
||||
that.detailForm.content_id.thumb_url = content.image
|
||||
|
||||
that.detailFormOld.content_title = content.id
|
||||
that.detailFormOld.content_id.thumb_url = content.image
|
||||
}
|
||||
} else {
|
||||
that.detailForm = JSON.parse(JSON.stringify(that.detailFormInit))
|
||||
}
|
||||
that.getoptions()
|
||||
return false;
|
||||
})
|
||||
},
|
||||
typeChange() {
|
||||
this.getoptions()
|
||||
this.detailForm.content_title = "";
|
||||
this.detailForm.content_id = {}
|
||||
},
|
||||
selectChange(val) {
|
||||
this.options.forEach(i => {
|
||||
if (val == i.media_id) {
|
||||
this.detailForm.content_id = i
|
||||
}
|
||||
})
|
||||
if (this.detailForm.type == 'news') {
|
||||
let num = 0
|
||||
this.options.forEach(i => {
|
||||
if (i.media_id == val) {
|
||||
num++
|
||||
}
|
||||
})
|
||||
if (num > 1) {
|
||||
this.detailForm.content_title = ''
|
||||
this.$notify({
|
||||
title: '警告',
|
||||
message: '不支持选择多条图文消息',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
tabClick() {
|
||||
let that = this;
|
||||
switch (that.activeName) {
|
||||
case 'subscribe':
|
||||
that.getFormData();
|
||||
break;
|
||||
case 'auto_reply':
|
||||
that.getList();
|
||||
break;
|
||||
case 'default_reply':
|
||||
that.getFormData();
|
||||
break;
|
||||
}
|
||||
},
|
||||
operation(opttype, id) {
|
||||
let that = this;
|
||||
switch (opttype) {
|
||||
case 'delete':
|
||||
that.$confirm('此操作将删除菜单, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/auto_reply/del/ids/' + id,
|
||||
loading: true,
|
||||
type: 'POST',
|
||||
}, function (ret, res) {
|
||||
that.getList()
|
||||
})
|
||||
}).catch(() => {
|
||||
that.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case 'create':
|
||||
Fast.api.open("shopro/wechat/auto_reply/add", "新建", {
|
||||
callback(data) {
|
||||
that.getList();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'edit':
|
||||
Fast.api.open("shopro/wechat/auto_reply/edit?id=" + id, "编辑", {
|
||||
callback(data) {
|
||||
that.getList();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'filter':
|
||||
let types = ''
|
||||
switch (id) {
|
||||
case 'news':
|
||||
types = '图文消息'
|
||||
break;
|
||||
case 'image':
|
||||
types = '图片'
|
||||
break;
|
||||
case 'video':
|
||||
types = '视频'
|
||||
break;
|
||||
case 'voice':
|
||||
types = '音频'
|
||||
break;
|
||||
case 'text':
|
||||
types = '文本'
|
||||
break;
|
||||
case 'link':
|
||||
types = '链接'
|
||||
break;
|
||||
}
|
||||
return types
|
||||
break;
|
||||
}
|
||||
},
|
||||
//er的数据
|
||||
getList() {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/auto_reply/index',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
offset: that.offset,
|
||||
limit: that.limit,
|
||||
type: 'auto_reply'
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.listData = res.data.rows;
|
||||
that.totalPage = res.data.total;
|
||||
return false;
|
||||
})
|
||||
},
|
||||
//er的分页
|
||||
pageSizeChange(val) {
|
||||
this.limit = val
|
||||
this.getList()
|
||||
},
|
||||
pageCurrentChange(val) {
|
||||
this.offset = (val - 1) * this.limit
|
||||
this.getList()
|
||||
},
|
||||
//
|
||||
tableRowClassName({
|
||||
rowIndex
|
||||
}) {
|
||||
if (rowIndex % 2 == 1) {
|
||||
return 'bg-color';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
tableCellClassName({
|
||||
columnIndex
|
||||
}) {
|
||||
if (columnIndex == 0 || columnIndex == 2) {
|
||||
return 'cell-left';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
getoptions() {
|
||||
let that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/select',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
limit: that.selectLimit,
|
||||
offset: that.selectOffset,
|
||||
type: that.detailForm.type
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.options = [];
|
||||
if (that.detailForm.type == 'news') {
|
||||
res.data.rows.forEach(i => {
|
||||
i.content.news_item.forEach(e => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: e.title,
|
||||
thumb_url: e.thumb_url
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'image') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: i.url
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'video') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: i.cover_url
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'voice') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: ''
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'text') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.id,
|
||||
title: i.name,
|
||||
thumb_url: JSON.parse(i.content)
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'link') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.id,
|
||||
title: i.name,
|
||||
thumb_url: JSON.parse(i.content).url,
|
||||
image: JSON.parse(i.content).image,
|
||||
description: JSON.parse(i.content).description,
|
||||
})
|
||||
})
|
||||
}
|
||||
that.selectTotalPage = res.data.total;
|
||||
return false;
|
||||
})
|
||||
},
|
||||
createTemplate() {
|
||||
let that = this;
|
||||
Fast.api.open(`shopro/wechat/material/add?type=${that.detailForm.type}`, '创建', {
|
||||
callback(data) {
|
||||
that.getoptions();
|
||||
}
|
||||
})
|
||||
},
|
||||
dispatchSub(type, issub) {
|
||||
let that = this;
|
||||
if (type == 'yes') {
|
||||
this.$refs[issub].validate((valid) => {
|
||||
if (valid) {
|
||||
let subData = JSON.parse(JSON.stringify(that.detailForm));
|
||||
subData.content.type = subData.type;
|
||||
let content_arr = subData.content_id
|
||||
if (subData.content.type == 'news') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
subData.content.thumb_url = content_arr.thumb_url;
|
||||
} else if (subData.content.type == 'image') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
subData.content.url = content_arr.thumb_url;
|
||||
} else if (subData.content.type == 'video') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
subData.content.cover_url = content_arr.thumb_url;
|
||||
} else if (subData.content.type == 'voice') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
} else if (subData.content.type == 'text') {
|
||||
subData.content.id = content_arr.media_id;
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.content = content_arr.thumb_url;
|
||||
} else if (subData.content.type == 'link') {
|
||||
subData.content.id = content_arr.media_id;
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.description = content_arr.description;
|
||||
subData.content.image = content_arr.image;
|
||||
subData.content.url = content_arr.thumb_url;
|
||||
}
|
||||
subData.type = that.activeName;
|
||||
delete subData.content_title
|
||||
delete subData.content_id
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/auto_reply/edit?id=' + that.activeName,
|
||||
loading: true,
|
||||
data: {
|
||||
data: JSON.stringify(subData)
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.getFormData();
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.detailForm = JSON.parse(JSON.stringify(this.detailFormOld))
|
||||
this.getoptions()
|
||||
}
|
||||
},
|
||||
selectSizeChange(val) {
|
||||
this.selectOffset = 0;
|
||||
this.selectLimit = val;
|
||||
this.selectCurrentPage = 1;
|
||||
this.getoptions();
|
||||
},
|
||||
selectCurrentChange(val) {
|
||||
this.selectOffset = (val - 1) * 6;
|
||||
this.selectLimit = 6;
|
||||
this.selectCurrentPage = 1;
|
||||
this.getoptions();
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
add: function () {
|
||||
Controller.detailInit('add');
|
||||
},
|
||||
edit: function () {
|
||||
Controller.detailInit('edit');
|
||||
},
|
||||
detailInit: function (type) {
|
||||
var replyDetail = new Vue({
|
||||
el: "#replyDetail",
|
||||
data() {
|
||||
return {
|
||||
optType: type,
|
||||
detailForm: {},
|
||||
ruleForm: {
|
||||
name: [{
|
||||
required: true,
|
||||
message: '请输入标题',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
rules: [{
|
||||
required: true,
|
||||
message: '请输入关键字,空格确认',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
type: [{
|
||||
required: true,
|
||||
message: '请选择类型',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
content_title: [{
|
||||
required: true,
|
||||
message: '请选择回复内容',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
},
|
||||
detailFormInit: {
|
||||
name: '',
|
||||
rules: [],
|
||||
type: 'news',
|
||||
content_title: '',
|
||||
content_id: {},
|
||||
content: {}
|
||||
},
|
||||
|
||||
keys: '',
|
||||
|
||||
options: [],
|
||||
detail_id: null,
|
||||
|
||||
limit: 6,
|
||||
offset: 0,
|
||||
currentPage: 1,
|
||||
totalPage: 0,
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.detailForm = JSON.parse(JSON.stringify(this.detailFormInit));
|
||||
if (this.optType == 'edit') {
|
||||
let contant = JSON.parse(Config.row.content)
|
||||
this.detail_id = Config.row.id;
|
||||
this.detailForm.name = Config.row.name;
|
||||
this.detailForm.type = contant.type
|
||||
this.detailForm.rules = Config.row.rules.split(',');
|
||||
this.detailForm.content_title = contant.media_id;
|
||||
if (this.detailForm.type == 'text' || this.detailForm.type == 'link') {
|
||||
this.detailForm.content_title = contant.id;
|
||||
}
|
||||
this.detailForm.content_id = contant
|
||||
this.getoptions()
|
||||
}
|
||||
this.getoptions()
|
||||
},
|
||||
methods: {
|
||||
searchFile(val) {
|
||||
if (val.trim()) {
|
||||
if (this.detailForm.rules.indexOf(val.trim()) == -1) {
|
||||
this.detailForm.rules.push(val.trim())
|
||||
this.keys = ""
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '警告',
|
||||
message: '已存在不可再次添加',
|
||||
type: 'warning'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '警告',
|
||||
message: '请输入关键字',
|
||||
type: 'warning'
|
||||
});
|
||||
}
|
||||
},
|
||||
delKey(index) {
|
||||
this.detailForm.rules.splice(index, 1)
|
||||
},
|
||||
selectChange(val) {
|
||||
this.options.forEach(i => {
|
||||
if (val == i.media_id) {
|
||||
this.detailForm.content_id = i
|
||||
}
|
||||
})
|
||||
if (this.detailForm.type == 'news') {
|
||||
let num = 0
|
||||
this.options.forEach(i => {
|
||||
if (i.media_id == val) {
|
||||
num++
|
||||
}
|
||||
})
|
||||
if (num > 1) {
|
||||
this.detailForm.content_title = ''
|
||||
this.$notify({
|
||||
title: '警告',
|
||||
message: '不支持选择多条图文消息',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
typeChange() {
|
||||
this.getoptions()
|
||||
this.detailForm.content_title = '';
|
||||
this.detailForm.content_id = {}
|
||||
},
|
||||
getoptions() {
|
||||
let that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/select',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
limit: that.limit,
|
||||
offset: that.offset,
|
||||
type: that.detailForm.type
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.options = [];
|
||||
if (that.detailForm.type == 'news') {
|
||||
res.data.rows.forEach(i => {
|
||||
i.content.news_item.forEach(e => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: e.title,
|
||||
thumb_url: e.thumb_url
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'image') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: i.url
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'video') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: i.cover_url
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'voice') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: ''
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'text') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.id,
|
||||
title: i.name,
|
||||
thumb_url: JSON.parse(i.content)
|
||||
})
|
||||
})
|
||||
} else if (that.detailForm.type == 'link') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.id,
|
||||
title: i.name,
|
||||
thumb_url: JSON.parse(i.content).url,
|
||||
image: JSON.parse(i.content).image,
|
||||
description: JSON.parse(i.content).description,
|
||||
})
|
||||
})
|
||||
}
|
||||
that.totalPage = res.data.total;
|
||||
return false;
|
||||
})
|
||||
},
|
||||
dispatchSub(type, issub) {
|
||||
let that = this;
|
||||
if (type == 'yes') {
|
||||
that.$refs[issub].validate((valid) => {
|
||||
if (valid) {
|
||||
let subData = JSON.parse(JSON.stringify(that.detailForm));
|
||||
subData.rules = subData.rules.join(',');
|
||||
subData.content.type = subData.type;
|
||||
|
||||
let content_arr = subData.content_id
|
||||
if (subData.content.type == 'news') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
subData.content.thumb_url = content_arr.thumb_url;
|
||||
} else if (subData.content.type == 'image') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
subData.content.url = content_arr.thumb_url
|
||||
} else if (subData.content.type == 'video') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
subData.content.cover_url = content_arr.thumb_url
|
||||
} else if (subData.content.type == 'voice') {
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.media_id = content_arr.media_id;
|
||||
} else if (subData.content.type == 'text') {
|
||||
subData.content.id = content_arr.media_id;
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.content = content_arr.thumb_url
|
||||
} else if (subData.content.type == 'link') {
|
||||
subData.content.id = content_arr.media_id;
|
||||
subData.content.title = content_arr.title;
|
||||
subData.content.description = content_arr.description
|
||||
subData.content.image = content_arr.image
|
||||
subData.content.url = content_arr.thumb_url
|
||||
}
|
||||
|
||||
subData.type = 'auto_reply';
|
||||
delete subData.content_title
|
||||
delete subData.content_id
|
||||
if (that.optType != 'add') {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/auto_reply/edit?id=' + that.detail_id,
|
||||
loading: true,
|
||||
data: {
|
||||
data: JSON.stringify(subData)
|
||||
}
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
})
|
||||
} else {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/auto_reply/add',
|
||||
loading: true,
|
||||
type: "POST",
|
||||
data: {
|
||||
data: JSON.stringify(subData)
|
||||
}
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Fast.api.close()
|
||||
}
|
||||
},
|
||||
createTemplate() {
|
||||
let that = this;
|
||||
Fast.api.open(`shopro/wechat/material/add?type=${that.detailForm.type}`, '增加文本', {
|
||||
callback(data) {
|
||||
that.getoptions();
|
||||
}
|
||||
})
|
||||
},
|
||||
//分页
|
||||
pageSizeChange(val) {
|
||||
this.offset = 0;
|
||||
this.limit = val;
|
||||
this.currentPage = 1;
|
||||
this.getoptions();
|
||||
},
|
||||
pageCurrentChange(val) {
|
||||
this.offset = (val - 1) * 6;
|
||||
this.limit = 6;
|
||||
this.currentPage = 1;
|
||||
this.getoptions();
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
function debounce(handle, delay) {
|
||||
let time = null;
|
||||
return function () {
|
||||
let self = this,
|
||||
arg = arguments;
|
||||
clearTimeout(time);
|
||||
time = setTimeout(function () {
|
||||
handle.apply(self, arg);
|
||||
}, delay)
|
||||
}
|
||||
}
|
||||
var fansIndex = new Vue({
|
||||
el: "#fansIndex",
|
||||
data() {
|
||||
return {
|
||||
searchKey: '',
|
||||
fansList: [],
|
||||
currentPage: 1,
|
||||
totalPage: 0,
|
||||
offset: 0,
|
||||
limit: 10,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getfansList();
|
||||
},
|
||||
methods: {
|
||||
getfansList() {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/fans/index',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
offset: that.offset,
|
||||
limit: that.limit,
|
||||
searchWhere: that.searchKey,
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.fansList = res.data.rows;
|
||||
that.totalPage = res.data.total;
|
||||
return false;
|
||||
})
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.limit = val;
|
||||
this.offset=0;
|
||||
this.currentPage= 1;
|
||||
this.getfansList();
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.limit=10;
|
||||
this.offset = this.limit*(val-1);
|
||||
this.currentPage= 1;
|
||||
this.getfansList();
|
||||
},
|
||||
viewBtn(openid) {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/fans/user?openid='+openid,
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
Fast.api.open('shopro/user/user/profile?id=' + res.data,"查看详情")
|
||||
})
|
||||
},
|
||||
getSync() {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/fans/syncfans',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
if (res.code == 1) {
|
||||
that.getfansList();
|
||||
}
|
||||
})
|
||||
},
|
||||
tableRowClassName({rowIndex}) {
|
||||
if (rowIndex % 2 == 1) {
|
||||
return 'bg-color';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
tableCellClassName({columnIndex}) {
|
||||
if (columnIndex == 1 || columnIndex == 2) {
|
||||
return 'cell-left';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
debounceFilter: debounce(function () {
|
||||
this.getfansList()
|
||||
}, 1000),
|
||||
},
|
||||
watch: {
|
||||
searchKey(newVal, oldVal) {
|
||||
if (newVal != oldVal) {
|
||||
this.offset = 0;
|
||||
this.limit=10
|
||||
this.currentPage= 1;
|
||||
this.debounceFilter();
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
@@ -0,0 +1,343 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
|
||||
index: function () {
|
||||
$(window).resize(function () {
|
||||
init();
|
||||
})
|
||||
|
||||
function init() {
|
||||
var itemWidth = $(".news-item").outerWidth(true);
|
||||
var cols = parseInt($(window).width() / itemWidth);
|
||||
var heightArr = [];
|
||||
for (var i = 0; i < cols; i++) {
|
||||
heightArr.push(0);
|
||||
}
|
||||
$('.news-item').each(function (index, item) {
|
||||
var idex = 0; //初始索引为0
|
||||
var minHeight = heightArr[0]; //初始设置最小高度是数组的第一个
|
||||
for (var i = 0; i < heightArr.length; i++) {
|
||||
if (heightArr[i] < minHeight) { //判断数组中的每一个是否比默认设置的最小高度小,小于直接赋值给最小高度
|
||||
minHeight = heightArr[i]; //最小高度
|
||||
idex = i; //当前索引
|
||||
}
|
||||
}
|
||||
//设置每个图片的样式
|
||||
$(item).css({
|
||||
left: itemWidth * idex,
|
||||
top: minHeight
|
||||
})
|
||||
heightArr[idex] += $(item).outerHeight(true); //高度对应的索引值就是当前图片高度的值
|
||||
})
|
||||
}
|
||||
|
||||
var materialIndex = new Vue({
|
||||
el: "#materialIndex",
|
||||
data() {
|
||||
return {
|
||||
listData: [],
|
||||
currentPage: 1,
|
||||
totalPage: 0,
|
||||
offset: 0,
|
||||
|
||||
activeName: 'news',
|
||||
scrollTop: 0
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getlistData();
|
||||
window.addEventListener('scroll', this.handleScroll, true)
|
||||
},
|
||||
methods: {
|
||||
handleScroll() {
|
||||
this.scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
|
||||
var contentH = $(document).height();
|
||||
var contents = $('.custom-body').height();
|
||||
if (contentH - contents - this.scrollTop == 0) {
|
||||
this.offset += 20
|
||||
this.getlistData()
|
||||
}
|
||||
},
|
||||
operation(opttype, id) {
|
||||
let that = this;
|
||||
switch (opttype) {
|
||||
case 'delete':
|
||||
that.$confirm('此操作将删除菜单, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/del/ids/' + id,
|
||||
loading: true,
|
||||
type: 'POST',
|
||||
}, function (ret, res) {
|
||||
that.getlistData()
|
||||
})
|
||||
}).catch(() => {
|
||||
that.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case 'create':
|
||||
Fast.api.open(`shopro/wechat/material/add?type=${that.activeName}`, "新建", {
|
||||
callback(data) {
|
||||
that.getlistData();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'edit':
|
||||
Fast.api.open(`shopro/wechat/material/edit?id=${id}&type=${that.activeName}`, "编辑", {
|
||||
callback(data) {
|
||||
that.getlistData();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
getlistData() {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/index',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
offset: that.offset,
|
||||
type: that.activeName,
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.listData = res.data.rows;
|
||||
if (that.activeName == 'image') {
|
||||
that.listData.forEach(e => {
|
||||
e.arr = [];
|
||||
e.arr.push(e.url)
|
||||
})
|
||||
}
|
||||
that.totalPage = res.data.total;
|
||||
that.$nextTick(function () {
|
||||
init();
|
||||
})
|
||||
return false;
|
||||
})
|
||||
},
|
||||
pageCurrentChange(val) {
|
||||
this.offset = (val - 1) * 20
|
||||
this.getlistData()
|
||||
},
|
||||
tableRowClassName({
|
||||
rowIndex
|
||||
}) {
|
||||
if (rowIndex % 2 == 1) {
|
||||
return 'bg-color';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
tableCellClassName({
|
||||
columnIndex
|
||||
}) {
|
||||
if (columnIndex == 0 || columnIndex == 1) {
|
||||
return 'cell-left';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
},
|
||||
destroyed() {
|
||||
// 离开该页面需要移除这个监听的事件,不然会报错
|
||||
window.removeEventListener('scroll', this.handleScroll)
|
||||
},
|
||||
watch: {
|
||||
activeName() {
|
||||
this.currentPage = 1;
|
||||
this.totalPage = 0;
|
||||
this.offset = 0;
|
||||
this.listData = [];
|
||||
this.getlistData();
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
add: function () {
|
||||
Controller.detailInit('add');
|
||||
},
|
||||
edit: function () {
|
||||
Controller.detailInit('edit');
|
||||
},
|
||||
detailInit: function (type) {
|
||||
var materialDetail = new Vue({
|
||||
el: "#materialDetail",
|
||||
data() {
|
||||
return {
|
||||
optType: type,
|
||||
sourceType: new URLSearchParams(location.search).get('type'),
|
||||
detailForm: {
|
||||
type: new URLSearchParams(location.search).get('type'),
|
||||
name: '',
|
||||
content: '',
|
||||
image:'',
|
||||
url:''
|
||||
},
|
||||
detailFormInit: {
|
||||
type: new URLSearchParams(location.search).get('type'),
|
||||
name: '',
|
||||
content: '',
|
||||
image:'',
|
||||
url:'',
|
||||
description:''
|
||||
},
|
||||
rules: {
|
||||
name: [{
|
||||
required: true,
|
||||
message: '请输入标题',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
content: [{
|
||||
required: true,
|
||||
message: '请输入内容',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
description: [{
|
||||
required: true,
|
||||
message: '请输入内容',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
image: [{
|
||||
required: true,
|
||||
message: '请选择图片',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
url: [{
|
||||
required: true,
|
||||
message: '请输入链接地址',
|
||||
trigger: 'blur'
|
||||
}],
|
||||
},
|
||||
storeOptions: [],
|
||||
text_id: null,
|
||||
|
||||
hrefMsg: '',
|
||||
hrefA: '',
|
||||
|
||||
visible: false,
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.optType == 'add') {
|
||||
this.detailForm = JSON.parse(JSON.stringify(this.detailFormInit));
|
||||
} else {
|
||||
this.text_id = Config.row.id;
|
||||
this.detailForm = JSON.parse(JSON.stringify(this.detailFormInit));
|
||||
this.detailForm.name = Config.row.name
|
||||
if(this.sourceType=='text'){
|
||||
this.detailForm.content = JSON.parse(Config.row.content);
|
||||
}else{
|
||||
let content=JSON.parse(Config.row.content)
|
||||
this.detailForm.image=content.image
|
||||
this.detailForm.description=content.description
|
||||
this.detailForm.url=content.url
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addHref(type) {
|
||||
if (type) {
|
||||
if (this.hrefMsg && this.hrefA) {
|
||||
this.visible = false
|
||||
this.detailForm.content = this.detailForm.content + `<a href="${this.hrefA}">${this.hrefMsg}</a>`
|
||||
this.hrefMsg = ''
|
||||
this.hrefA = ''
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '警告',
|
||||
message: '超链接请填写完整',
|
||||
type: 'warning'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.visible = false
|
||||
this.hrefMsg = ''
|
||||
this.hrefA = ''
|
||||
}
|
||||
},
|
||||
dispatchSub(type, issub) {
|
||||
let that = this;
|
||||
if (type == 'yes') {
|
||||
this.$refs[issub].validate((valid) => {
|
||||
if (valid) {
|
||||
let subData=JSON.parse(JSON.stringify(that.detailForm));
|
||||
if(that.sourceType=='link'){
|
||||
subData.content={}
|
||||
subData.content.url=subData.url;
|
||||
subData.content.image=subData.image;
|
||||
subData.content.description=subData.description;
|
||||
}
|
||||
delete subData.url;
|
||||
delete subData.image;
|
||||
delete subData.description;
|
||||
if (this.optType != 'add') {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/edit?id=' + that.text_id,
|
||||
loading: true,
|
||||
type: "POST",
|
||||
data: {
|
||||
data: JSON.stringify(subData)
|
||||
}
|
||||
}, function (ret, res) {
|
||||
Fast.api.close({
|
||||
data: true
|
||||
})
|
||||
})
|
||||
} else {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/add',
|
||||
loading: true,
|
||||
type: "POST",
|
||||
data: {
|
||||
data: JSON.stringify(subData)
|
||||
}
|
||||
}, function (ret, res) {
|
||||
Fast.api.close({
|
||||
data: true
|
||||
})
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Fast.api.close({
|
||||
data: false
|
||||
})
|
||||
}
|
||||
},
|
||||
addImg() {
|
||||
let that = this;
|
||||
parent.Fast.api.open("general/file/index?select=1&multiple=false", "选择图片", {
|
||||
callback: function (data) {
|
||||
that.detailForm.image = data.url;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
},
|
||||
delImg() {
|
||||
this.detailForm.image = '';
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
@@ -0,0 +1,640 @@
|
||||
const {
|
||||
contains,
|
||||
cssNumber
|
||||
} = require("jquery");
|
||||
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
var listsIndex = new Vue({
|
||||
el: "#listsIndex",
|
||||
data() {
|
||||
return {
|
||||
listData: [],
|
||||
currentMenu: [],
|
||||
currentPage: 1,
|
||||
limit: 10,
|
||||
offset: 0,
|
||||
totalPage: 0,
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
getList() {
|
||||
var that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/menu/index',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
limit: that.limit,
|
||||
offset: that.offset,
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.listData = res.data.rows;
|
||||
that.totalPage = res.data.total;
|
||||
that.currentMenu = res.data.currentMenu;
|
||||
return false;
|
||||
})
|
||||
},
|
||||
operation(opttype, id) {
|
||||
let that = this;
|
||||
switch (opttype) {
|
||||
case 'delete':
|
||||
that.$confirm('此操作将删除菜单, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/menu/del/ids/' + id,
|
||||
loading: true,
|
||||
type: 'POST',
|
||||
}, function (ret, res) {
|
||||
that.getList()
|
||||
})
|
||||
}).catch(() => {
|
||||
that.$message({
|
||||
type: 'info',
|
||||
message: '已取消删除'
|
||||
});
|
||||
});
|
||||
|
||||
break;
|
||||
case 'status':
|
||||
that.$confirm('确认发布当前菜单?公众号底部菜单有延迟生效时间,您可稍等或重新关注查看', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/wechat/menu/publish?id=${id}`,
|
||||
loading: true,
|
||||
}, function (ret, res) {
|
||||
that.getList();
|
||||
})
|
||||
}).catch(() => {
|
||||
that.$message({
|
||||
type: 'info',
|
||||
message: '已取消'
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'create':
|
||||
Fast.api.open("shopro/wechat/menu/add", "新建", {
|
||||
callback(data) {
|
||||
that.getList();
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'copy':
|
||||
Fast.api.ajax({
|
||||
url: `shopro/wechat/menu/copy?id=${id}`,
|
||||
loading: true,
|
||||
}, function (ret, res) {
|
||||
that.getList();
|
||||
})
|
||||
break;
|
||||
case 'edit':
|
||||
Fast.api.open(`shopro/wechat/menu/edit?id=${id}`, "编辑", {
|
||||
callback(data) {
|
||||
that.getList();
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
//分页
|
||||
pageSizeChange(val) {
|
||||
this.offset = 0;
|
||||
this.limit = val;
|
||||
this.getList();
|
||||
},
|
||||
pageCurrentChange(val) {
|
||||
this.offset = (val - 1) * 10;
|
||||
this.getList();
|
||||
},
|
||||
tableRowClassName({
|
||||
rowIndex
|
||||
}) {
|
||||
if (rowIndex % 2 == 1) {
|
||||
return 'bg-color';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
tableCellClassName({
|
||||
columnIndex
|
||||
}) {
|
||||
if (columnIndex == 1 || columnIndex == 2) {
|
||||
return 'cell-left';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
add: function () {
|
||||
Controller.menu('add');
|
||||
},
|
||||
edit: function () {
|
||||
Controller.menu('edit');
|
||||
},
|
||||
menu: function (type) {
|
||||
var wechatMenu = new Vue({
|
||||
el: "#wechatMenu",
|
||||
data() {
|
||||
return {
|
||||
menuData: [],
|
||||
rightData: {},
|
||||
selectedIndex1: null,
|
||||
selectedIndex2: null,
|
||||
selectLevel: null,
|
||||
rightShow: false,
|
||||
menuTitle: '',
|
||||
edit_id: null,
|
||||
optType: type,
|
||||
viewUrl: Config.shopro.domain,
|
||||
wxMiniProgramapp_id: Config.wxMiniProgram.app_id,
|
||||
|
||||
options: [],
|
||||
selectLimit: 6,
|
||||
selectOffset: 0,
|
||||
selectCurrentPage: 1,
|
||||
selectTotalPage: 0,
|
||||
|
||||
detailForm: {
|
||||
type: '',
|
||||
content_id: {},
|
||||
content: {},
|
||||
content_title: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.optType == 'edit') {
|
||||
this.getmenuData();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
typeChange() {
|
||||
this.getoptions()
|
||||
this.rightData.media_id = "";
|
||||
},
|
||||
selectChange(val) {
|
||||
if (this.rightData.media_type == 'news') {
|
||||
let num = 0
|
||||
this.options.forEach(i => {
|
||||
if (i.media_id == val) {
|
||||
num++
|
||||
}
|
||||
})
|
||||
if (num > 1) {
|
||||
this.rightData.media_id = ''
|
||||
this.$notify({
|
||||
title: '警告',
|
||||
message: '不支持选择多条图文消息',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
},
|
||||
getoptions() {
|
||||
let that = this;
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/wechat/material/select',
|
||||
loading: true,
|
||||
type: 'GET',
|
||||
data: {
|
||||
limit: that.selectLimit,
|
||||
offset: that.selectOffset,
|
||||
type: that.rightData.media_type
|
||||
}
|
||||
}, function (ret, res) {
|
||||
that.options = [];
|
||||
if (that.rightData.media_type == 'news') {
|
||||
res.data.rows.forEach(i => {
|
||||
i.content.news_item.forEach(e => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: e.title,
|
||||
thumb_url: e.thumb_url
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (that.rightData.media_type == 'image') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: i.url
|
||||
})
|
||||
})
|
||||
} else if (that.rightData.media_type == 'video') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: i.cover_url
|
||||
})
|
||||
})
|
||||
} else if (that.rightData.media_type == 'voice') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.media_id,
|
||||
title: i.name,
|
||||
thumb_url: ''
|
||||
})
|
||||
})
|
||||
} else if (that.rightData.media_type == 'text') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.id,
|
||||
title: i.name,
|
||||
thumb_url: JSON.parse(i.content)
|
||||
})
|
||||
})
|
||||
} else if (that.rightData.media_type == 'link') {
|
||||
res.data.rows.forEach(i => {
|
||||
that.options.push({
|
||||
media_id: i.id,
|
||||
title: i.name,
|
||||
thumb_url: JSON.parse(i.content).url,
|
||||
image: JSON.parse(i.content).image,
|
||||
description: JSON.parse(i.content).description,
|
||||
})
|
||||
})
|
||||
}
|
||||
that.selectTotalPage = res.data.total;
|
||||
return false;
|
||||
})
|
||||
},
|
||||
selectSizeChange(val) {
|
||||
this.selectOffset = 0;
|
||||
this.selectLimit = val;
|
||||
this.selectCurrentPage = 1;
|
||||
this.getoptions();
|
||||
},
|
||||
selectCurrentChange(val) {
|
||||
this.selectOffset = (val - 1) * 6;
|
||||
this.selectLimit = 6;
|
||||
this.selectCurrentPage = 1;
|
||||
this.getoptions();
|
||||
},
|
||||
createTemplate() {
|
||||
let that = this;
|
||||
Fast.api.open(`shopro/wechat/material/add?type=${that.rightData.media_type}`, '创建', {
|
||||
callback(data) {
|
||||
that.getoptions();
|
||||
}
|
||||
})
|
||||
},
|
||||
getmenuData() {
|
||||
var that = this;
|
||||
if (Config.row.content) {
|
||||
that.menuData = JSON.parse(Config.row.content);
|
||||
that.menuData.forEach(i => {
|
||||
i.selected = false;
|
||||
i.show = false;
|
||||
if (!i.appid) {
|
||||
i.appid = '';
|
||||
i.pagepath = '';
|
||||
}
|
||||
this.$set(i, 'media_type', i.key ? i.key.split('|')[0] : '')
|
||||
this.$set(i, 'media_id', i.key ? i.key.split('|')[1] : '')
|
||||
if (i.sub_button) {
|
||||
i.sub_button.forEach(j => {
|
||||
j.selected = false;
|
||||
if (!j.appid) {
|
||||
j.appid = '';
|
||||
j.pagepath = '';
|
||||
}
|
||||
this.$set(j, 'media_type', j.key ? j.key.split('|')[0] : '')
|
||||
this.$set(j, 'media_id', j.key ? j.key.split('|')[1] : '')
|
||||
})
|
||||
} else {
|
||||
i.sub_button = []
|
||||
}
|
||||
})
|
||||
} else {
|
||||
that.menuData = []
|
||||
}
|
||||
that.edit_id = Config.row.id;
|
||||
that.menuTitle = Config.row.name;
|
||||
},
|
||||
changeRadio(e) {
|
||||
if (e == 'click') {
|
||||
this.rightData.url = "";
|
||||
this.rightData.appid = "";
|
||||
this.rightData.pagepath = "";
|
||||
} else {
|
||||
this.rightData.key = ''
|
||||
}
|
||||
|
||||
this.$forceUpdate();
|
||||
},
|
||||
menuSelect(index1, index2) {
|
||||
this.selectedIndex1 = index1;
|
||||
this.selectedIndex2 = index2;
|
||||
this.rightShow = true;
|
||||
this.menuData.forEach(i => {
|
||||
i.selected = false;
|
||||
i.show = false;
|
||||
if (i.sub_button) {
|
||||
i.sub_button.forEach(j => {
|
||||
j.selected = false;
|
||||
})
|
||||
}
|
||||
});
|
||||
this.menuData[index1].show = true;
|
||||
//选择1
|
||||
if (index2 == null) {
|
||||
this.selectLevel = 1;
|
||||
this.menuData[index1].selected = true;
|
||||
this.menuData[index1].show = true;
|
||||
this.rightData = this.menuData[index1];
|
||||
} else {
|
||||
this.selectLevel = 2;
|
||||
this.menuData[index1].sub_button[index2].selected = true;
|
||||
this.rightData = this.menuData[index1].sub_button[index2];
|
||||
}
|
||||
if (this.rightData.media_type) {
|
||||
this.getoptions();
|
||||
}
|
||||
},
|
||||
addMenu(index, level) {
|
||||
//右侧显示
|
||||
this.rightShow = true;
|
||||
this.selectLevel = level;
|
||||
if (index != null) {
|
||||
this.selectedIndex1 = index;
|
||||
this.menuData.forEach(i => {
|
||||
i.selected = false;
|
||||
if (i.sub_button) {
|
||||
i.sub_button.forEach(j => {
|
||||
j.selected = false;
|
||||
})
|
||||
}
|
||||
});
|
||||
this.menuData[index].sub_button.push({
|
||||
name: '',
|
||||
type: 'view',
|
||||
selected: true,
|
||||
url: '',
|
||||
appid: '',
|
||||
pagepath: '',
|
||||
media_type: '',
|
||||
media_id: '',
|
||||
})
|
||||
this.rightData = this.menuData[index].sub_button[this.menuData[index].sub_button.length - 1];
|
||||
this.selectedIndex2 = this.menuData[index].sub_button.length - 1;
|
||||
} else {
|
||||
this.menuData.forEach(i => {
|
||||
i.selected = false;
|
||||
i.show = false;
|
||||
});
|
||||
this.menuData.push({
|
||||
name: '',
|
||||
selected: true,
|
||||
show: true,
|
||||
type: 'view',
|
||||
url: '',
|
||||
appid: '',
|
||||
pagepath: '',
|
||||
sub_button: [],
|
||||
media_type: '',
|
||||
media_id: '',
|
||||
})
|
||||
this.selectedIndex1 = this.menuData.length - 1;
|
||||
this.rightData = this.menuData[this.menuData.length - 1];
|
||||
}
|
||||
},
|
||||
delMenu() {
|
||||
if (this.selectedIndex2 != null) {
|
||||
this.menuData[this.selectedIndex1].sub_button.splice(this.selectedIndex2, 1);
|
||||
if (this.menuData[this.selectedIndex1].sub_button.length > 0) {
|
||||
if (this.selectedIndex2 == 0) {
|
||||
this.menuData[this.selectedIndex1].sub_button[0].selected = true;
|
||||
this.rightData = this.menuData[this.selectedIndex1].sub_button[0];
|
||||
} else {
|
||||
this.menuData[this.selectedIndex1].sub_button[this.selectedIndex2 - 1].selected = true;
|
||||
this.rightData = this.menuData[this.selectedIndex1].sub_button[this.selectedIndex2 - 1];
|
||||
this.selectedIndex2--
|
||||
}
|
||||
} else {
|
||||
this.rightData = {};
|
||||
this.rightShow = false;
|
||||
}
|
||||
} else {
|
||||
this.menuData.splice(this.selectedIndex1, 1);
|
||||
if (this.menuData.length > 0) {
|
||||
if (this.selectedIndex1 == 0) {
|
||||
this.menuData[0].selected = true;
|
||||
this.menuData[0].show = true;
|
||||
this.rightData = this.menuData[0];
|
||||
} else {
|
||||
this.menuData[this.selectedIndex1 - 1].selected = true;
|
||||
this.menuData[this.selectedIndex1 - 1].show = true;
|
||||
this.rightData = this.menuData[this.selectedIndex1 - 1];
|
||||
this.selectedIndex1--
|
||||
}
|
||||
|
||||
} else {
|
||||
this.rightData = {};
|
||||
this.rightShow = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
choosePath() {
|
||||
let that = this;
|
||||
let multiple = $(this).data("multiple") ? $(this).data("multiple") : false;
|
||||
parent.Fast.api.open("shopro/link/select?multiple=" + multiple, "选择路径", {
|
||||
callback: function (data) {
|
||||
let link_path = ''
|
||||
if (data.data.path != '/pages/index/index') {
|
||||
link_path = data.data.path.substring(1)
|
||||
}
|
||||
if (that.selectedIndex2 != null) {
|
||||
if (that.menuData[that.selectedIndex1].sub_button[that.selectedIndex2].type == 'view') {
|
||||
that.menuData[that.selectedIndex1].sub_button[that.selectedIndex2].url = that.viewUrl + link_path;
|
||||
} else {
|
||||
that.menuData[that.selectedIndex1].sub_button[that.selectedIndex2].pagepath = '/pages/index/index?page=' + encodeURIComponent(link_path);
|
||||
that.menuData[that.selectedIndex1].sub_button[that.selectedIndex2].url = that.viewUrl + link_path;
|
||||
that.menuData[that.selectedIndex1].sub_button[that.selectedIndex2].appid = that.wxMiniProgramapp_id;
|
||||
that.rightData.appid = that.wxMiniProgramapp_id;
|
||||
}
|
||||
that.rightData.url = that.menuData[that.selectedIndex1].sub_button[that.selectedIndex2].url;
|
||||
} else {
|
||||
if (that.menuData[that.selectedIndex1].type == 'view') {
|
||||
that.menuData[that.selectedIndex1].url = that.viewUrl + link_path;
|
||||
} else {
|
||||
that.menuData[that.selectedIndex1].url = that.viewUrl + link_path;
|
||||
that.menuData[that.selectedIndex1].pagepath = link_path ? '/pages/index/index?page=' + encodeURIComponent(link_path) : '/pages/index/index';
|
||||
that.menuData[that.selectedIndex1].appid = that.wxMiniProgramapp_id;
|
||||
that.rightData.appid = that.wxMiniProgramapp_id;
|
||||
}
|
||||
that.rightData.url = that.menuData[that.selectedIndex1].url;
|
||||
that.rightData.pagepath = that.menuData[that.selectedIndex1].pagepath;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
menuHide() {
|
||||
this.selectedIndex1 = null;
|
||||
this.selectedIndex2 = null;
|
||||
this.menuData.forEach(i => {
|
||||
i.selected = false;
|
||||
i.show = false;
|
||||
if (i.sub_button.length > 0) {
|
||||
i.sub_button.forEach(j => {
|
||||
j.selected = false;
|
||||
})
|
||||
}
|
||||
});
|
||||
this.rightShow = false;
|
||||
},
|
||||
menuShow() {
|
||||
this.rightShow = true;
|
||||
},
|
||||
subData(type) {
|
||||
let that = this;
|
||||
if (that.menuTitle == '') {
|
||||
that.$notify({
|
||||
title: '警告',
|
||||
message: '请输入标题',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (that.menuData.length == 0) {
|
||||
that.$notify({
|
||||
title: '警告',
|
||||
message: '请输入菜单内容',
|
||||
type: 'warning'
|
||||
});
|
||||
return false;
|
||||
}
|
||||
let savemenuData = JSON.parse(JSON.stringify(that.menuData))
|
||||
savemenuData.forEach(i => {
|
||||
delete i.show;
|
||||
delete i.selected;
|
||||
if (i.sub_button.length > 0) {
|
||||
delete i.url;
|
||||
delete i.appid;
|
||||
delete i.pagepath;
|
||||
delete i.type;
|
||||
delete i.key;
|
||||
i.sub_button.forEach(j => {
|
||||
delete j.selected;
|
||||
if (j.type == 'view') {
|
||||
delete j.appid;
|
||||
delete j.pagepath;
|
||||
} else if (j.type == 'click') {
|
||||
delete j.appid;
|
||||
delete j.pagepath;
|
||||
delete j.url;
|
||||
let type = j.media_type;
|
||||
let id = j.media_id
|
||||
this.$set(j, 'key', type + '|' + id)
|
||||
}
|
||||
delete j.media_type;
|
||||
delete j.media_id;
|
||||
})
|
||||
} else {
|
||||
delete i.sub_button;
|
||||
if (i.type) {
|
||||
if (i.type == 'view') {
|
||||
delete i.appid;
|
||||
delete i.pagepath;
|
||||
} else if (i.type == 'click') {
|
||||
delete i.appid;
|
||||
delete i.pagepath;
|
||||
delete i.url;
|
||||
let type = i.media_type
|
||||
let id = i.media_id
|
||||
this.$set(i, 'key', type + '|' + id)
|
||||
}
|
||||
}
|
||||
}
|
||||
delete i.media_type;
|
||||
delete i.media_id;
|
||||
})
|
||||
var urlsub = ''
|
||||
if (that.optType == 'edit') {
|
||||
if (type == 'publish') {
|
||||
urlsub = 'shopro/wechat/menu/edit?id=' + that.edit_id + '&act=' + type
|
||||
} else {
|
||||
urlsub = 'shopro/wechat/menu/edit?id=' + that.edit_id
|
||||
}
|
||||
} else {
|
||||
if (type == 'publish') {
|
||||
urlsub = 'shopro/wechat/menu/add?act=' + type
|
||||
} else {
|
||||
urlsub = 'shopro/wechat/menu/add'
|
||||
}
|
||||
}
|
||||
// return false;
|
||||
Fast.api.ajax({
|
||||
url: urlsub,
|
||||
loading: true,
|
||||
type: 'POST',
|
||||
data: {
|
||||
data: JSON.stringify({
|
||||
name: that.menuTitle,
|
||||
type: 'menu',
|
||||
content: savemenuData
|
||||
})
|
||||
}
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
rightData: {
|
||||
handler: function (newVal) {
|
||||
if (this.selectLevel == 1) {
|
||||
let name = newVal.name;
|
||||
let num = 0;
|
||||
for (var i = 0; i < name.length; i++) {
|
||||
if (name[i].charCodeAt() >= 20 && name[i].charCodeAt() <= 127) {
|
||||
num++
|
||||
} else {
|
||||
num += 2
|
||||
}
|
||||
if (num > 8) {
|
||||
newVal.name = newVal.name.substr(0, i)
|
||||
}
|
||||
}
|
||||
} else if (this.selectLevel == 2) {
|
||||
let name = newVal.name;
|
||||
let num = 0;
|
||||
for (var i = 0; i < name.length; i++) {
|
||||
if (name[i].charCodeAt() >= 20 && name[i].charCodeAt() <= 127) {
|
||||
num++
|
||||
} else {
|
||||
num += 2
|
||||
}
|
||||
if (num > 16) {
|
||||
newVal.name = newVal.name.substr(0, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
在新工单中引用
屏蔽一个用户