196 lines
5.5 KiB
Vue
196 lines
5.5 KiB
Vue
<template>
|
|
<ai-list class="Learning">
|
|
<ai-title
|
|
slot="title"
|
|
title="消息推送"
|
|
isShowBottomBorder>
|
|
</ai-title>
|
|
<template slot="content">
|
|
<ai-search-bar>
|
|
<template #left>
|
|
<el-button type="primary" @click="getQRCodeUrl(), isShow = true">绑定公众号</el-button>
|
|
</template>
|
|
<template #right>
|
|
</template>
|
|
</ai-search-bar>
|
|
<ai-table
|
|
:tableData="tableData"
|
|
:col-configs="colConfigs"
|
|
:total="total"
|
|
:current.sync="search.current"
|
|
:size.sync="search.size"
|
|
style="margin-top: 8px;"
|
|
@getList="getList">
|
|
<el-table-column slot="send" label="是否发送通知" align="center">
|
|
<template v-slot="{ row }">
|
|
<el-switch
|
|
active-value="1"
|
|
inactive-value="0"
|
|
@change="e => onChange(row.id, e)"
|
|
v-model="row.isSend">
|
|
</el-switch>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column slot="options" label="操作" align="center" fixed="right" width="140px">
|
|
<template v-slot="{ row }">
|
|
<div class="table-options">
|
|
<el-button type="text" @click="edit(row)">修改姓名</el-button>
|
|
<el-button type="text" @click="remove(row)">删除</el-button>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
</ai-table>
|
|
<AiDialog
|
|
title="扫码绑定微信公众号"
|
|
:visible.sync="isShow"
|
|
:close-on-click-modal="false"
|
|
customFooter
|
|
width="380px">
|
|
<img style="width: 300px" :src="qrcode" />
|
|
<div class="dialog-footer" slot="footer">
|
|
<el-button @click="isShow = false">取消</el-button>
|
|
<el-button @click="getList(), isShow = false" type="primary">我已扫码</el-button>
|
|
</div>
|
|
</AiDialog>
|
|
<AiDialog
|
|
title="修改姓名"
|
|
:visible.sync="isShowForm"
|
|
:close-on-click-modal="false"
|
|
width="580px"
|
|
@close="form.name = '', id = ''"
|
|
@confirm="onConfirm">
|
|
<el-form :model="form" ref="form" label-width="100px">
|
|
<el-form-item label="姓名" prop="name" :rules="[{required: true, message: '请输入姓名', trigger: 'blur'}]">
|
|
<el-input v-model="form.name" placeholder="请输入姓名"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
</AiDialog>
|
|
</template>
|
|
</ai-list>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data () {
|
|
return {
|
|
colConfigs: [
|
|
{ prop: 'name', label: '姓名', align: 'left' },
|
|
{ slot: 'send' },
|
|
{ prop: 'createTime', label: '绑定时间', align: 'center' },
|
|
],
|
|
tableData: [],
|
|
total: 0,
|
|
qrcode: '',
|
|
isShow: false,
|
|
search: {
|
|
current: 1,
|
|
size: 10
|
|
},
|
|
form: {
|
|
name: ''
|
|
},
|
|
isShowForm: false,
|
|
sence: '',
|
|
id: ''
|
|
}
|
|
},
|
|
|
|
created () {
|
|
this.getQRCodeUrl()
|
|
this.getList()
|
|
},
|
|
|
|
methods: {
|
|
onChange (id, isSend) {
|
|
console.log(isSend)
|
|
this.$http.post(`/api/malluser/updateWxuserInfo`, {
|
|
id,
|
|
isSend: isSend
|
|
}).then(res => {
|
|
if (res.code === 0) {
|
|
this.$message.success('操作成功')
|
|
this.getList()
|
|
}
|
|
})
|
|
},
|
|
|
|
onConfirm () {
|
|
this.$refs.form.validate((valid) => {
|
|
if (valid) {
|
|
this.$http.post('/api/malluser/updateWxuserInfo', {
|
|
id: this.id,
|
|
name: this.form.name
|
|
}).then(res => {
|
|
if (res.code === 0) {
|
|
this.isShowForm = false
|
|
this.getList()
|
|
this.$message.success('编辑成功')
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
|
|
edit (e) {
|
|
this.id = e.id
|
|
this.form.name = e.name
|
|
this.isShowForm = true
|
|
},
|
|
|
|
remove (e) {
|
|
this.$confirm('确定要删除该条数据?', '温馨提示', {
|
|
type: 'warning'
|
|
}).then(() => {
|
|
this.$http.post(`/api/malluser/delWxuser?id=${e.id}`).then(res => {
|
|
if (res.code == 0) {
|
|
this.$message.success('删除成功!')
|
|
this.getList()
|
|
}
|
|
})
|
|
})
|
|
},
|
|
|
|
collection (id, isFavorite) {
|
|
this.$confirm(isFavorite === '0' ? '确定收藏该文章?' : '确定取消收藏?', '温馨提示', {
|
|
confirmButtonText: '确定',
|
|
callback: action => {
|
|
if (action === 'confirm') {
|
|
this.$http.post(isFavorite === '0' ? `/api/learning/addFavorite?id=${id}` : `/api/learning/delFavorite?id=${id}`).then(res => {
|
|
if (res.code === 0) {
|
|
this.$message.success(isFavorite === '1' ? '取消成功' : '收藏成功')
|
|
this.getList()
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
|
|
getQRCodeUrl () {
|
|
this.$http.post('/api/malluser/getQRCodeUrl').then(res => {
|
|
if (res.code === 0) {
|
|
this.qrcode = res.data.picUrl
|
|
this.sence = res.data.sence
|
|
}
|
|
})
|
|
},
|
|
|
|
getList () {
|
|
this.$http.post('/api/malluser/getWxuserList', null, {
|
|
params: {
|
|
...this.search
|
|
}
|
|
}).then(res => {
|
|
if (res.code === 0) {
|
|
this.tableData = res.data
|
|
this.total = res.data.length
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
</style>
|