我们发布啦

This commit is contained in:
张乐
2020-08-13 16:12:57 +08:00
parent a3e1c38d27
commit c0cec49f41
1885 changed files with 376936 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
<template>
<div>
<router-view />
</div>
</template>
<script>
export default {
}
</script>
<style lang="sass" scoped>
</style>

View File

@@ -0,0 +1,15 @@
<template>
<div>
<router-view />
</div>
</template>
<script>
export default {
}
</script>
<style lang="sass" scoped>
</style>

View File

@@ -0,0 +1,13 @@
<template>
</template>
<script>
export default {
name: "routineTemplate"
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,15 @@
<template>
<div>
<router-view />
</div>
</template>
<script>
export default {
}
</script>
<style lang="sass" scoped>
</style>

View File

@@ -0,0 +1,626 @@
<template>
<div class="divBox">
<el-card class="box-card">
<router-link v-show="$route.path.indexOf('keyword') !== -1" :to="{path: '/appSetting/publicAccount/wxReply/keyword'}">
<el-button size="mini" class="mr20 mb20" icon="el-icon-back">返回</el-button>
</router-link>
<el-row :gutter="30" v-loading="loading">
<el-col v-bind="grid" class="acea-row">
<div class="left mb15 ml40">
<img class="top" src="@/assets/imgs/mobilehead.png">
<img class="bottom" src="@/assets/imgs/mobilefoot.png">
<div class="centent">
<div class="time-wrapper"><span class="time">9:36</span></div>
<div v-if="formValidate.type !== 'news'" class="view-item text-box clearfix">
<div class="avatar fl"><img src="@/assets/imgs/head.gif"></div>
<div class="box-content fl">
<span
v-if="formValidate.type === 'text'"
v-text="formValidate.contents.content"
/>
<div v-if="formValidate.contents.mediaId" class="box-content_pic">
<img v-if="formValidate.type === 'image'" :src="formValidate.contents.srcUrl">
<i class="el-icon-service" v-else></i>
</div>
</div>
</div>
<div v-if="formValidate.type === 'news'">
<div class="newsBox">
<!--<div class="news_pic mb15" style="backgroundImage: url('@/assets/imgs/mobilefoot.png');backgroundSize:'100% 100%'}" />-->
<div class="news_pic mb15" :style="{backgroundImage: 'url(' + (formValidate.contents.articleData.imageInput?formValidate.contents.articleData.imageInput[0]:'') + ')',backgroundSize:'100% 100%'}" />
<span class="news_sp">{{ formValidate.contents.articleData.title }}</span>
</div>
<!--<div v-for="(j, i) in formValidate.contents.list" :key="i">-->
<!--<div v-if="i === 0">-->
<!--<div class="news_pic mb15" :style="{backgroundImage: 'url(' + (j.image_input) + ')',backgroundSize:'100% 100%'}" />-->
<!--<span class="news_sp">{{ j.title }}</span>-->
<!--</div>-->
<!--<div v-else class="news_cent">-->
<!--<span v-if="j.synopsis" class="news_sp1">{{ j.title }}</span>-->
<!--<div v-if="j.image_input.length!==0" class="news_cent_img"><img :src="j.image_input"></div>-->
<!--</div>-->
<!--</div>-->
</div>
</div>
</div>
</el-col>
<el-col :xl="11" :lg="12" :md="14" :sm="22" :xs="22">
<div class="box-card right ml50">
<el-form
ref="formValidate"
:model="formValidate"
:rules="ruleValidate"
label-width="100px"
class="mt20"
@submit.native.prevent
>
<el-form-item v-if="$route.path.indexOf('keyword') !== -1" label="关键字:" prop="val">
<div class="arrbox">
<el-tag
v-for="(item, index) in labelarr"
:key="index"
type="success"
closable
class="mr5"
:disable-transitions="false"
@close="handleClose(item)"
>{{ item }}
</el-tag>
<el-input
v-model="val"
size="mini"
class="arrbox_ip"
placeholder="输入后回车"
style="width: 90%;"
@change="addlabel"
/>
</div>
</el-form-item>
<el-form-item label="规则状态:">
<el-radio-group v-model="formValidate.status">
<el-radio :label="true">启用</el-radio>
<el-radio :label="false">禁用</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="消息类型:" prop="type">
<el-select
v-model="formValidate.type"
placeholder="请选择规则状态"
style="width: 90%;"
@change="RuleFactor(formValidate.type)"
>
<el-option label="文字消息" value="text">文字消息</el-option>
<el-option label="图片消息" value="image">图片消息</el-option>
<el-option label="图文消息" value="news">图文消息</el-option>
<el-option label="声音消息" value="voice">声音消息</el-option>
</el-select>
</el-form-item>
<el-form-item v-if="formValidate.type === 'text'" label="规则内容:" prop="content">
<el-input
v-model="formValidate.contents.content"
placeholder="请填写规则内容"
style="width: 90%;"
@input="change($event)"
/>
</el-form-item>
<el-form-item v-if="formValidate.type === 'news'" label="选取图文:">
<el-button size="mini" type="primary" @click="changePic">选择图文消息</el-button>
</el-form-item>
<el-form-item
v-if="formValidate.type === 'image' || formValidate.type === 'voice'"
:label="formValidate.type === 'image'?'图片地址:':'语音地址:'"
prop="mediaId"
>
<div class="acea-row row-middle">
<el-input
v-model="formValidate.contents.mediaId"
readonly="readonly"
placeholder="default size"
style="width: 75%;"
class="mr10"
/>
<el-upload
class="upload-demo mr10 mb15"
action
:http-request="handleUploadForm"
:headers="myHeaders"
:show-file-list="false"
multiple
>
<el-button size="mini" type="primary">点击上传</el-button>
</el-upload>
</div>
<span v-show="formValidate.type === 'image'">文件最大2Mb支持bmp/png/jpeg/jpg/gif格式</span>
<span v-show="formValidate.type === 'voice'">文件最大2Mb支持mp3/wma/wav/amr格式,播放长度不超过60s</span>
</el-form-item>
</el-form>
</div>
<el-col :span="24">
<div class="acea-row row-center">
<el-button
type="primary"
class="ml50"
@click="submenus('formValidate')"
>保存并发布
</el-button>
</div>
</el-col>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
import { getToken } from '@/utils/auth'
import { replySaveApi, replyEditApi, replyInfoApi, replyListApi, keywordsInfoApi, replyUpdateApi } from '@/api/wxApi'
import { fileImageApi } from '@/api/systemSetting'
export default {
name: 'Index',
components: { },
data() {
const validateContent = (rule, value, callback) => {
if (this.formValidate.type === 'text') {
if (this.formValidate.contents.content === '') {
callback(new Error('请填写规则内容'))
} else {
callback()
}
}
}
const validateSrc = (rule, value, callback) => {
if (this.formValidate.type === 'image' && this.formValidate.contents.mediaId === '') {
callback(new Error('请上传'))
} else {
callback()
}
}
const validateVal = (rule, value, callback) => {
if (this.labelarr.length === 0) {
callback(new Error('请输入后回车'))
} else {
callback()
}
}
return {
loading: false,
visible: false,
grid: {
xl: 7,
lg: 12,
md: 10,
sm: 24,
xs: 24
},
delfromData: {},
isShow: false,
maxCols: 3,
scrollerHeight: '600',
contentTop: '130',
contentWidth: '98%',
modals: false,
val: '',
formatImg: ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
formatVoice: ['mp3', 'wma', 'wav', 'amr'],
header: {},
formValidate: {
status: true,
type: '',
keywords: '',
contents: {
content: '',
articleData:{},
mediaId: '',
srcUrl: '',
articleId: null
},
id: null
},
ruleValidate: {
val: [
{ required: true, validator: validateVal, trigger: 'blur' }
],
type: [
{ required: true, message: '请选择消息类型', trigger: 'change' }
],
content: [
{ required: true, validator: validateContent, trigger: 'blur' }
],
mediaId: [
{ required: true, validator: validateSrc, trigger: 'change' }
]
},
labelarr: [],
myHeaders: { 'X-Token': getToken() }
}
},
computed: {
fileUrl() {
return https + `/wechat/reply/upload/image`
},
voiceUrl() {
return https + `/wechat/reply/upload/voice`
},
httpsURL() {
return process.env.VUE_APP_BASE_API.replace('api/', '')
}
},
watch: {
$route(to, from) {
if (this.$route.params.id) {
// this.formValidate.keywords = this.$route.params.key
this.details()
} else {
// this.labelarr = []
// this.$refs['formValidate'].resetFields()
}
}
},
mounted() {
if (this.$route.params.id) {
this.details()
}
if (this.$route.path.indexOf('keyword') === -1) {
this.followDetails()
}
},
methods: {
change (e) {
this.$forceUpdate()
},
// 上传
handleUploadForm(param){
const formData = new FormData()
formData.append('media', param.file)
let loading = this.$loading({
lock: true,
text: '上传中,请稍候...',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
fileImageApi(formData, {type: this.formValidate.type === 'image'?'image':'voice'}).then(res => {
loading.close()
this.formValidate.contents.mediaId = res.mediaId
this.formValidate.contents.srcUrl = res.url
this.$message.success('上传成功')
}).catch(() => {
loading.close()
})
},
changePic() {
const _this = this
this.$modalArticle(function(row) {
_this.formValidate.contents.articleData ={
title: row.title,
imageInput : row.imageInput
}
_this.formValidate.contents.articleId = row.id
})
},
handleClosePic() {
this.visible = false
},
// 详情
details() {
this.loading = true
replyInfoApi({id:this.$route.params.id}).then(async res => {
const info = res || null
this.formValidate = {
status: info.status,
type: info.type,
keywords: info.keywords,
id: info.id,
contents: {
content: JSON.parse(info.data).content,
mediaId: JSON.parse(info.data).mediaId,
srcUrl: JSON.parse(info.data).srcUrl
}
}
this.labelarr = info.keywords.split(',') || []
this.loading = false
}).catch(() => {
this.loading = false
})
},
// 关注回复,无效关键词详情
followDetails() {
this.loading = true
keywordsInfoApi({ keywords: this.$route.path.indexOf('follow') !== -1 ? 'subscribe' : 'default'}).then(async res => {
const info = res || null
this.formValidate = {
status: info.status,
type: info.type,
keywords: info.keywords,
data: '',
id: info.id,
contents: {
content: JSON.parse(info.data).content || '',
mediaId: JSON.parse(info.data).mediaId || '',
srcUrl: JSON.parse(info.data).srcUrl || '',
articleData: JSON.parse(info.data).articleData || {},
}
}
this.loading = false
}).catch(() => {
this.loading = false
// if (res.message === '数据不存在') return
// this.$message.error(res.message)
})
},
// 下拉选择
RuleFactor(type) {
switch (type) {
case 'text':
this.formValidate.contents.mediaId = ''
this.formValidate.contents.srcUrl = ''
this.formValidate.contents.articleData = {}
break
case 'news':
this.formValidate.contents.mediaId = ''
this.formValidate.contents.content = ''
this.formValidate.contents.srcUrl = ''
this.formValidate.contents.articleData = {}
break
default:
this.formValidate.contents.content = ''
this.formValidate.contents.mediaId = ''
this.formValidate.contents.articleData = {}
}
// this.$refs['formValidate'].resetFields();
},
handleClose(tag) {
const index = this.labelarr.indexOf(tag)
this.labelarr.splice(index, 1)
},
addlabel() {
const count = this.labelarr.indexOf(this.val)
if (count === -1) {
this.labelarr.push(this.val)
}
this.val = ''
},
// 保存
submenus(name) {
this.$refs[name].validate((valid) => {
if (valid) {
this.formValidate.keywords = this.labelarr.join(',')
this.formValidate.data = JSON.stringify(this.formValidate.contents)
if (this.$route.path.indexOf('keyword') !== -1) {
this.$route.params.id ? replyUpdateApi({id:this.$route.params.id}, this.formValidate).then(async res => {
this.operation()
}).catch(res => {
this.$message.error(res.message)
}) : replySaveApi(this.formValidate).then(async res => {
this.operation()
}).catch(res => {
this.$message.error(res.message)
})
} else {
this.$route.path.indexOf('follow') !== -1 ? this.formValidate.keywords = 'subscribe' : this.formValidate.keywords ='default'
replyUpdateApi({id:this.formValidate.id}, this.formValidate).then(async res => {
this.$message.success('操作成功')
})
}
} else {
return false
}
})
},
// 保存成功操作
operation() {
this.$modalSure('继续添加').then(() => {
setTimeout(() => {
this.labelarr = []
this.val = ''
this.$refs['formValidate'].resetFields()
this.formValidate.contents.mediaId = ''
}, 1000)
}).catch(() => {
setTimeout(() => {
this.$router.push({ path: `/publicAccount/wxReply/keyword` })
}, 500)
})
}
}
}
</script>
<style scoped lang="scss">
.newsBox{
background: #fff;
}
.arrbox {
background-color: white;
font-size: 12px;
border: 1px solid #dcdee2;
border-radius: 6px;
margin-bottom: 0px;
padding:0 5px;
text-align: left;
box-sizing: border-box;
width: 90%;
}
.news_sp{
font-size: 12px;
color: #000000;
background: #fff;
width: 100%;
height: 38px;
line-height: 38px;
padding: 0 12px;
box-sizing: border-box;
display: block;
}
.arrbox_ip {
font-size: 12px;
border: none;
box-shadow: none;
outline: none;
background-color: transparent;
padding: 0;
margin: 0;
width: auto !important;
max-width: inherit;
min-width: 80px;
vertical-align: top;
color: #34495e;
margin: 2px;
}
.left {
min-width: 390px;
min-height: 550px;
position: relative;
padding-left: 40px;
}
.top {
position: absolute;
top: 0px;
}
.bottom {
position: absolute;
bottom: 0px;
}
.centent {
background: #F4F5F9;
min-height: 545px;
width: 320px;
padding: 15px;
box-sizing: border-box;
}
.right {
background: #fff;
min-height: 300px;
}
.box-content {
position: relative;
max-width: 60%;
min-height: 40px;
margin-left: 15px;
padding: 10px;
box-sizing: border-box;
border: 1px solid #ccc;
word-break: break-all;
word-wrap: break-word;
line-height: 1.5;
border-radius: 5px;
}
.box-content_pic {
width: 100%;
}
.box-content_pic img {
width: 100%;
height: auto;
}
.box-content:before {
content: '';
position: absolute;
left: -13px;
top: 11px;
display: block;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 10px solid #ccc;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.box-content:after {
content: '';
content: '';
position: absolute;
left: -12px;
top: 11px;
display: block;
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-top: 10px solid #f5f5f5;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.time-wrapper {
margin-bottom: 10px;
text-align: center;
margin-top: 62px;
}
.time {
display: inline-block;
color: #f5f5f5;
background: rgba(0, 0, 0, .3);
padding: 3px 8px;
border-radius: 3px;
font-size: 12px;
}
.text-box {
display: flex;
}
.avatar {
width: 40px;
height: 40px;
}
.avatar img {
width: 100%;
height: 100%;
}
.modelBox{
.ivu-modal-body{
padding: 0 16px 16px 16px !important;
}
}
.news_pic{
width: 100%;
height: 150px;
overflow: hidden;
position: relative;
background-size: 100%;
background-position: center center;
border-radius: 5px 5px 0 0;
padding: 10px;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.news_cent{
width: 100%;
height: auto;
background: #fff;
border-top: 1px dashed #eee;
display: flex;
padding: 10px;
box-sizing: border-box;
justify-content: space-between;
.news_sp1{
font-size: 12px;
color: #000000;
width: 71%;
}
.news_cent_img{
width: 81px;
height: 46px;
border-radius: 6px;
overflow: hidden;
img{
width: 100%;
height: 100%;
}
}
}
</style>

View File

@@ -0,0 +1,3 @@
<template>
<router-view />
</template>

View File

@@ -0,0 +1,156 @@
<template>
<div class="divBox">
<el-card class="box-card">
<div slot="header" class="clearfix">
<div class="container">
<el-form size="small" :inline="true">
<el-form-item label="回复类型:">
<el-select v-model="tableFrom.type" placeholder="请选择类型" @change="seachList" class="selWidth">
<el-option label="文本消息" value="text"></el-option>
<el-option label="图片消息" value="image"></el-option>
<el-option label="图文消息" value="news"></el-option>
<el-option label="音频消息" value="voice"></el-option>
</el-select>
</el-form-item>
<el-form-item label="关键字:">
<el-input v-model="tableFrom.keywords" placeholder="请输入关键字" class="selWidth" size="small">
<el-button slot="append" icon="el-icon-search" size="small" @click="seachList" />
</el-input>
</el-form-item>
</el-form>
<router-link :to="{path: '/appSetting/publicAccount/wxReply/keyword/save'}">
<el-button size="small" type="primary">添加关键字</el-button>
</router-link>
</div>
</div>
<el-table
v-loading="listLoading"
:data="tableData.data"
style="width: 100%"
size="small"
highlight-current-row
>
<el-table-column
prop="id"
label="ID"
width="60"
/>
<el-table-column
prop="keywords"
label="关键字"
min-width="150"
/>
<el-table-column
label="回复类型"
min-width="100"
>
<template slot-scope="scope">
<span>{{ scope.row.type | keywordStatusFilter}}</span>
</template>
</el-table-column>
<el-table-column
prop="status"
label="是否显示"
min-width="100"
>
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
:active-value="true"
:inactive-value="false"
@change="onchangeIsShow(scope.row)"
/>
</template>
</el-table-column>
<el-table-column label="操作" min-width="100">
<template slot-scope="scope">
<router-link :to="{path: '/appSetting/publicAccount/wxReply/keyword/save/' + scope.row.id}">
<el-button type="text" size="small">编辑</el-button>
</router-link>
<el-button type="text" size="small" @click="handleDelete(scope.row.id, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="block">
<el-pagination
:page-sizes="[20, 40, 60, 80]"
:page-size="tableFrom.limit"
:current-page="tableFrom.page"
layout="total, sizes, prev, pager, next, jumper"
:total="tableData.total"
@size-change="handleSizeChange"
@current-change="pageChange"
/>
</div>
</el-card>
</div>
</template>
<script>
import { replyListApi, replyDeleteApi, replyUpdateApi } from '@/api/wxApi'
import { getToken } from '@/utils/auth'
export default {
name: 'WechatKeyword',
data() {
return {
tableData: {
data: [],
total: 0
},
tableFrom: {
page: 1,
limit: 20,
keywords: '',
type: ''
},
listLoading: true
}
},
created() {
this.getList()
},
methods: {
seachList() {
this.tableFrom.page = 1
this.getList()
},
onchangeIsShow(row) {
replyUpdateApi(row.id, row).then(() => {
this.$message.success('修改成功')
})
},
// 列表
getList() {
this.listLoading = true
replyListApi(this.tableFrom).then(res => {
this.tableData.data = res.list
this.tableData.total = res.total
this.listLoading = false
}).catch(res => {
this.listLoading = false
})
},
pageChange(page) {
this.tableFrom.page = page
this.getList()
},
handleSizeChange(val) {
this.tableFrom.limit = val
this.getList()
},
// 删除
handleDelete(id, idx) {
this.$modalSure().then(() => {
replyDeleteApi(id).then(() => {
this.$message.success('删除成功')
this.getList()
})
})
}
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,422 @@
<template>
<div class="divBox">
<el-card class="box-card">
<el-row :gutter="30">
<el-col v-bind="grid" class="left mb15 ml40">
<div>
<img class="top" src="@/assets/imgs/mobilehead.png">
<img class="bottom" src="@/assets/imgs/mobilefoot.png">
<div
style="background: #F4F5F9; min-height: 438px; position: absolute;
top: 63px; width: 320px; "
/>
<div class="textbot">
<div v-for="(item,indx) in list" :key="indx" class="li" :class="{active:item === formValidate}">
<div>
<div class="add" @click="add(item,indx)">
<i class="el-icon-plus" />
<div class="arrow" />
</div>
<div class="tianjia">
<div
v-for="(j,index) in item.sub_button"
:key="index"
class="addadd menuBox"
:class="{active:j === formValidate}"
@click="gettem(j,index,indx)"
>
<el-tooltip class="item" effect="dark" :content="j.name" placement="top-start">
<el-button>{{ j.name || '二级菜单' }}</el-button>
</el-tooltip>
</div>
</div>
</div>
<div class="text menuBox" @click="gettem(item,indx,null)">
<el-tooltip class="item" effect="dark" :content="item.name" placement="top-start">
<el-button>{{ item.name || '一级菜单' }}</el-button>
</el-tooltip>
</div>
</div>
<div v-show="list.length < 3" class="li">
<div class="text" @click="addtext"><i class="el-icon-plus" /></div>
</div>
</div>
</div>
</el-col>
<el-col :xl="11" :lg="12" :md="22" :sm="22" :xs="22">
<div v-if="checkedMenuId !== null">
<div class="dividerTitle acea-row row-between row-bottom">
<span class="title">菜单信息</span>
<el-button slot="extra" size="small" type="danger" @click="deltMenus">删除</el-button>
<el-divider />
</div>
<el-col :span="24" class="userAlert">
<div class="box-card right">
<el-alert
class="mb15"
title="已添加子菜单,仅可设置菜单名称"
type="success"
show-icon
/>
<el-form ref="formValidate" :model="formValidate" :rules="ruleValidate" label-width="100px" class="mt20">
<el-form-item label="菜单名称" prop="name">
<el-input v-model="formValidate.name" placeholder="请填写菜单名称" class="spwidth" />
</el-form-item>
<el-form-item label="规则状态" prop="type">
<el-select v-model="formValidate.type" placeholder="请选择规则状态" class="spwidth">
<el-option value="click" label="关键字">关键字</el-option>
<el-option value="view" label="跳转网页">跳转网页</el-option>
<el-option value="miniprogram" label="小程序">小程序</el-option>
</el-select>
</el-form-item>
<div v-if="formValidate.type === 'click'">
<el-form-item label="关键字" prop="key">
<el-input v-model="formValidate.key" placeholder="请填写关键字" class="spwidth" />
</el-form-item>
</div>
<div v-if="formValidate.type === 'miniprogram'">
<el-form-item label="appid" prop="appid">
<el-input v-model="formValidate.appid" placeholder="请填写appid" class="spwidth" />
</el-form-item>
<el-form-item label="备用网页" prop="pagepath">
<el-input v-model="formValidate.pagepath" placeholder="请填写备用网页" class="spwidth" />
</el-form-item>
<el-form-item label="小程序路径" prop="url">
<el-input v-model="formValidate.url" placeholder="请填写小程序路径" class="spwidth" />
</el-form-item>
</div>
<div v-if="formValidate.type === 'view'">
<el-form-item label="跳转地址" prop="url">
<el-input v-model="formValidate.url" placeholder="请填写跳转地址" class="spwidth" />
</el-form-item>
</div>
</el-form>
</div>
</el-col>
</div>
<el-col v-if="isTrue" :span="24">
<el-button size="mini" type="primary" style="display: block;margin: 10px auto;" @click="submenus('formValidate')">保存并发布</el-button>
</el-col>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
import { wechatMenuApi, wechatMenuAddApi } from '@/api/wxApi'
export default {
name: 'WechatMenus',
data() {
return {
grid: {
xl: 8,
lg: 8,
md: 8,
sm: 8,
xs: 24
},
grid2: {
xl: 16,
lg: 16,
md: 16,
sm: 16,
xs: 24
},
modal2: false,
formValidate: {
name: '',
type: 'click',
appid: '',
url: '',
key: '',
pagepath: '',
id: 0
},
ruleValidate: {
name: [
{ required: true, message: '请填写菜单名称', trigger: 'blur' }
],
key: [
{ required: true, message: '请填写关键字', trigger: 'blur' }
],
appid: [
{ required: true, message: '请填写appid', trigger: 'blur' }
],
pagepath: [
{ required: true, message: '请填写备用网页', trigger: 'blur' }
],
url: [
{ required: true, message: '请填写跳转地址', trigger: 'blur' }
],
type: [
{ required: true, message: '请选择规则状态', trigger: 'change' }
]
},
parentMenuId: null,
list: [],
checkedMenuId: null,
isTrue: false,
isAsync: false
}
},
mounted() {
this.getMenus()
if (this.list.length) {
this.formValidate = this.list[this.activeClass]
} else {
return this.formValidate
}
},
methods: {
// 添加一级字段函数
defaultMenusData() {
return {
type: 'click',
name: '',
sub_button: []
}
},
// 添加二级字段函数
defaultChildData() {
return {
type: 'click',
name: ''
}
},
// 获取 菜单
getMenus() {
wechatMenuApi({ isAsync:this.isAsync }).then(async res => {
const data = res.menu
this.list = data.button
})
},
// 点击保存提交
submenus(name) {
if (this.isTrue && !this.checkedMenuId && this.checkedMenuId !== 0) {
this.putData()
} else {
this.$refs[name].validate((valid) => {
if (valid) {
this.putData()
} else {
if (!this.check()) return false
}
})
}
},
// 新增data
putData() {
const data = {
button: this.list
}
wechatMenuAddApi(data).then(async res => {
this.$message.success('提交成功')
this.checkedMenuId = null
this.formValidate = {}
this.isTrue = false
})
},
// 点击元素
gettem(item, index, pid) {
this.checkedMenuId = index
this.formValidate = item
this.parentMenuId = pid
this.isTrue = true
},
// 增加二级
add(item, index) {
if (!this.check()) return false
if (item.sub_button.length < 5) {
const data = this.defaultChildData()
const id = item.sub_button.length
item.sub_button.push(data)
this.formValidate = data
this.checkedMenuId = id
this.parentMenuId = index
this.isTrue = true
}
},
// 增加一级
addtext() {
if (!this.check()) return false
const data = this.defaultMenusData()
const id = this.list.length
this.list.push(data)
this.formValidate = data
this.checkedMenuId = id
this.parentMenuId = null
this.isTrue = true
},
// 判断函数
check: function() {
const reg = /[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/
if (this.checkedMenuId === null) return true
if (!this.isTrue) return true
if (!this.formValidate.name) {
this.$message.warning('请输入按钮名称!')
return false
}
if (this.formValidate.type === 'click' && !this.formValidate.key) {
this.$message.warning('请输入关键字!')
return false
}
if (this.formValidate.type === 'view' && !(reg.test(this.formValidate.url))) {
this.$message.warning('请输入正确的跳转地址!')
return false
}
if (this.formValidate.type === 'miniprogram' &&
(!this.formValidate.appid ||
!this.formValidate.pagepath ||
!this.formValidate.url)) {
this.$message.warning('请填写完整小程序配置!')
return false
}
return true
},
// 删除
deltMenus() {
if (this.isTrue) {
this.$modalSure().then(() => {
this.del()
})
} else {
this.$message.warning('请选择菜单!')
}
},
// 确认删除
del() {
this.parentMenuId === null ? this.list.splice(this.checkedMenuId, 1) : this.list[this.parentMenuId].sub_button.splice(this.checkedMenuId, 1)
this.parentMenuId = null
this.formValidate = {
name: '',
type: 'click',
appid: '',
url: '',
key: '',
pagepath: '',
id: 0
}
this.isTrue = true
this.modal2 = false
this.checkedMenuId = null
this.$refs['formValidate'].resetFields()
}
}
}
</script>
<style scoped lang="scss">
.menuBox{
/deep/.el-button{
border: none;
background: bottom;
padding: 0 !important;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
width: 100%;
}
}
*{
-moz-user-select: none; /*火狐*/
-webkit-user-select: none; /*webkit浏览器*/
-ms-user-select: none; /*IE10*/
-khtml-user-select: none; /*早期浏览器*/
user-select: none;
}
.title{
margin-bottom: -19px !important;
padding-bottom: 17px !important;
}
.left {
min-width: 390px;
min-height: 550px;
position: relative;
padding-left: 40px;
}
.top {
position: absolute;
top: 0px;
}
.bottom {
position: absolute;
bottom: 0px;
}
.textbot {
position: absolute;
bottom: 0px;
left: 59px;
width: 100%;
}
.active {
border: 1px solid #44B549 !important;
color: #44B549 !important;
}
.li {
float: left;
width: 93px;
line-height: 48px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
text-align: center;
cursor: pointer;
color: #999;
position: relative;
}
.text{
height: 50px;
overflow:hidden;
text-overflow:ellipsis;
white-space:nowrap;
}
.text:hover {
color: #000;
}
.add {
position: absolute;
bottom: 65px;
width: 100%;
line-height: 48px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
}
.arrow {
position: absolute;
bottom: -16px;
left: 36px;
/* 圆角的位置需要细心调试哦 */
width: 0;
height: 0;
font-size: 0;
border: solid 8px;
border-color:#fff #F4F5F9 #F4F5F9 #F4F5F9;
}
.tianjia {
position: absolute;
bottom: 115px;
width: 100%;
line-height: 48px;
background: #FAFAFA;
}
.addadd {
width: 100%;
line-height: 48px;
border: 1px solid #E7E7EB;
background: #FAFAFA;
height: 48px;
padding: 0 5px;
box-sizing: border-box;
}
.right {
background: #fff;
min-height: 400px;
}
.spwidth{
width: 100%;
}
</style>

View File

@@ -0,0 +1,226 @@
<template>
<div class="divBox">
<el-card class="box-card">
<div slot="header" class="clearfix">
<div class="container">
<el-form size="small" :inline="true" label-width="100px">
<el-form-item label="状态:">
<el-select v-model="tableFrom.status" placeholder="请选择状态" clearable class="selWidth">
<el-option :label="item.label" :value="item.value" v-for="(item, index) in switchData" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="类型:">
<el-select v-model="tableFrom.type" placeholder="请选择类型" clearable class="selWidth">
<el-option label="订阅消息" value="0"></el-option>
<el-option label="模板消息" value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item label="模板名称:">
<el-input v-model="tableFrom.name" placeholder="请输入模板名称" class="selWidth" size="small"></el-input>
</el-form-item>
<el-form-item label="微信模板ID">
<el-input v-model="tableFrom.tempId" placeholder="请输入微信模板ID" class="selWidth" size="small"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="seachList" size="small">查询</el-button>
</el-form-item>
</el-form>
<el-button type="primary" @click="add" size="small">添加模板消息</el-button>
</div>
</div>
<el-table
v-loading="listLoading"
:data="tableData.data"
style="width: 100%"
size="mini"
class="table"
highlight-current-row
>
<el-table-column
label="ID"
width="80"
prop="id"
/>
<el-table-column
prop="tempId"
label="模板ID"
min-width="340"
/>
<el-table-column
prop="name"
label="模板名"
min-width="150"
/>
<el-table-column
label="回复内容"
min-width="200"
>
<template slot-scope="scope">
<span v-for="(item, index) in scope.row.content.split('\n')" :key="index" style="display: block">{{item}}</span>
</template>
</el-table-column>
<el-table-column
label="状态"
width="100"
>
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
class="demo"
active-text="开启"
inactive-text="关闭"
:active-value="1"
:inactive-value="0"
@click.native="onchangeIsShow(scope.row)"
/>
</template>
</el-table-column>
<el-table-column
prop="createTime"
label="添加时间"
min-width="150"
/>
<el-table-column label="操作" min-width="150" fixed="right" align="center">
<template slot-scope="scope">
<el-button type="text" size="small" @click="edit(scope.row)">编辑</el-button>
<el-button type="text" size="small" @click="handleDelete(scope.row, scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
<div class="block">
<el-pagination
:page-sizes="[20, 40, 60, 80]"
:page-size="tableFrom.limit"
:current-page="tableFrom.page"
layout="total, sizes, prev, pager, next, jumper"
:total="tableData.total"
@size-change="handleSizeChange"
@current-change="pageChange"
/>
</div>
</el-card>
<!--编辑-->
<el-dialog
title="编辑订单"
:visible.sync="dialogVisible"
width="500px"
:before-close="handleClose">
<zb-parser
v-if="dialogVisible"
:form-id="105"
:is-create="isCreate"
:edit-data="editData"
@submit="handlerSubmit"
/>
</el-dialog>
</div>
</template>
<script>
import * as constants from '@/utils/constants.js'
import { wechatTemplateListApi, wechatTemplateStatusApi, wechatTemplateSaveApi, wechatTemplateUpdateApi, wechatTemplateDeleteApi} from '@/api/wxApi'
import zbParser from '@/components/FormGenerator/components/parser/ZBParser'
export default {
name: "Templates",
components: { zbParser },
data() {
return {
labelPosition:'right',
isCreate: 0,
editData: {},
dialogVisible: false,
switchData: constants.switchStatus,
tableFrom: {
page: 1,
limit: 20,
status: '',
name: '',
type: this.$route.path.indexOf('routineTemplate') !== -1? '0' :'1',
tempId: ''
},
tableData: {
data: [],
total: 0
},
listLoading: true,
tempId: null
}
},
mounted() {
this.getList()
},
methods: {
seachList() {
this.tableFrom.page = 1
this.getList()
},
// 订单删除
handleDelete(row, idx) {
this.$modalSure().then(() => {
wechatTemplateDeleteApi( row.id ).then(() => {
this.$message.success('删除成功')
this.tableData.data.splice(idx, 1)
})
})
},
handleClose() {
this.dialogVisible = false
this.editData = {}
},
handlerSubmit(formValue) {
this.isCreate === 0 ? wechatTemplateSaveApi(formValue).then(data => {
this.$message.success('新增成功')
this.dialogVisible = false
this.editData = {}
this.getList()
}) : wechatTemplateUpdateApi(this.tempId, formValue).then(data => {
this.$message.success('编辑成功')
this.dialogVisible = false
this.getList()
})
},
add() {
this.dialogVisible = true
},
edit(row) {
this.tempId = row.id
this.dialogVisible = true
this.isCreate = 1
this.editData = JSON.parse(JSON.stringify(row))
},
// 列表
getList() {
this.listLoading = true
wechatTemplateListApi(this.tableFrom).then(res => {
this.tableData.data = res.list || []
this.tableData.total = res.total
this.listLoading = false
}).catch(() => {
this.listLoading = false
})
},
pageChange(page) {
this.tableFrom.page = page
this.getList()
},
handleSizeChange(val) {
this.tableFrom.limit = val
this.getList()
},
// 修改状态
onchangeIsShow(row) {
wechatTemplateStatusApi(row.id, {status: row.status}).then(() => {
this.$message.success('修改成功')
this.getList()
})
}
}
}
</script>
<style scoped lang="scss">
.selWidth {
width: 350px;
}
</style>