通知中心

This commit is contained in:
duan 2024-08-12 15:54:16 +08:00
parent b1bf21ccad
commit 1e52030f5e
5 changed files with 301 additions and 7 deletions

42
src/api/notifications.js Normal file
View File

@ -0,0 +1,42 @@
import request from "@/utils/request";
// 推送店铺消息开关
export function shopState(data) {
return request({
url: "/api/msg/shopState",
method: "put",
data
});
}
export function msgall(params) {
return request({
url: "/api/msg/all",
method: "get",
params
});
}
export function msginfo(data) {
return request({
url: '/api/msg/info',
method: 'put',
data
})
}
export function state(params) {
return request({
url: "/api/msg/state",
method: "get",
params
});
}
export function delmsg(ids) {
return request({
url: '/api/msg',
method: 'delete',
data: ids
})
}

View File

@ -428,7 +428,14 @@ export function findActivate(params) {
params
});
}
// 获取店铺会员二维码
export function getwxacode(data) {
return request({
url: `/shop/storage/getwxacode`,
method: "post",
data
});
}
/**
* 商家用户列表
* @returns

View File

@ -1,13 +1,177 @@
<template>
<div class="notifications">
123
<div class="app-container">
<div class="head-container">
<el-row :gutter="20">
<el-col :span="3">
店铺推送 <el-switch v-model="alldata.allState" :active-value="1" :inactive-value="0"
@change="changeEvent(alldata.allState, '')"></el-switch>
</el-col>
<el-col :span="3">
耗材: <el-switch v-model="alldata.conState" :active-value="1" :inactive-value="0"
@change="changeEvent(alldata.conState, 1)"></el-switch>
</el-col>
<el-col :span="3">
操作商品: <el-switch v-model="alldata.opeState" :active-value="1" :inactive-value="0"
@change="changeEvent(alldata.opeState, 2)"></el-switch>
</el-col>
<el-col :span="3">
商品库存 <el-switch v-model="alldata.stockState" :active-value="1" :inactive-value="0"
@change="changeEvent(alldata.stockState, 0)"></el-switch>
</el-col>
</el-row>
</div>
<div class="head-container" id="table_drag">
<el-table ref="table" :data="tableData.data" v-loading="tableData.loading" row-key="id">
<el-table-column label="头像">
<template v-slot="scope">
<div class="shop_info">
<el-image :src="scope.row.avatar"
style="width: 50px;height: 50px;border-radius: 4px;background-color: #efefef;">
<div class="img_error" slot="error">
<i class="icon el-icon-document-delete"></i>
</div>
</el-image>
</div>
</template>
</el-table-column>
<el-table-column label="昵称" prop="nickname"> </el-table-column>
<el-table-column label="商品库存" prop="createdAt">
<template v-slot="scope">
<el-switch v-model="scope.row.proState" :active-value="1" :inactive-value="0"
@change="changeHot(scope.row.proState, 0, scope.row.openId)"></el-switch>
</template>
</el-table-column>
<el-table-column label="耗材" prop="createdAt">
<template v-slot="scope">
<el-switch v-model="scope.row.conState" :active-value="1" :inactive-value="0"
@change="changeHot(scope.row.conState, 1, scope.row.openId)"></el-switch>
</template>
</el-table-column>
<el-table-column label="操作商品" prop="createdAt">
<template v-slot="scope">
<el-switch v-model="scope.row.opeState" :active-value="1" :inactive-value="0"
@change="changeHot(scope.row.opeState, 2, scope.row.openId)"></el-switch>
</template>
</el-table-column>
<el-table-column label="操作" width="200">
<template v-slot="scope">
<el-popconfirm title="确定解绑吗?" @confirm="delTableHandle(scope.row.openId)">
<el-button type="text" slot="reference">解绑</el-button>
</el-popconfirm>
</template>
</el-table-column>
</el-table>
</div>
<div class="head-container">
<el-pagination :total="tableData.total" :current-page="tableData.page + 1" :page-size="tableData.size"
@current-change="paginationChange" layout="total, sizes, prev, pager, next, jumper"></el-pagination>
</div>
</div>
</template>
<script>
import { msgall, msginfo, shopState, state, delmsg } from '@/api/notifications'
export default {
data(){
return {}
data() {
return {
test: "1",
tableData: {
data: [],
page: 1,
size: 30,
loading: false,
total: 0
},
alldata: {
allState: 0,
conState: 0,
opeState: 0,
stockState: 0,
}
}
},
mounted() {
this.getTableData()
this.getlist()
},
methods: {
async getlist() {
let res = await state({
shopId: localStorage.getItem('shopId'),
})
this.alldata = res
},
async changeEvent(state, type) {
let res = await shopState({
shopId: localStorage.getItem('shopId'),
type,
state
})
},
//
async changeHot(row, index, openId) {
// index 0 1 2
let obj = {
shopId: localStorage.getItem('shopId'),
type: index,
state: row, openId
}
let res = await msginfo(obj)
this.$message.success('修改成功!')
this.getTableData()
},
//
paginationChange(e) {
this.tableData.page = e - 1
this.getTableData()
},
//
async getTableData() {
try {
this.tableData.loading = true
const res = await msgall({
page: this.tableData.page,
size: this.tableData.size,
shopId: localStorage.getItem('shopId')
})
this.tableData.loading = false
this.tableData.data = res.records
this.tableData.total = res.total
} catch (error) {
console.log(error)
}
},
//
async delTableHandle(ids) {
try {
await delmsg({
shopId: localStorage.getItem('shopId'),
openId: ids
})
this.getTableData()
} catch (error) {
console.log(error)
}
},
}
}
</script>
</script>
<style scoped lang="scss">
.shop_info {
display: flex;
.info {
flex: 1;
padding-left: 8px;
display: flex;
flex-direction: column;
.tag_wrap {
display: flex;
}
}
}
</style>

View File

@ -15,6 +15,9 @@
<el-button type="primary" icon="el-icon-plus" @click="$refs.addActive.show()">
添加活动
</el-button>
<el-button type="primary" icon="el-icon-plus" @click="$refs.downloadQR.show()">
下载会员充值二维码
</el-button>
</div>
<div class="head-container">
<el-table :data="tableData.data" v-loading="tableData.loading">
@ -51,17 +54,19 @@
@current-change="paginationChange" layout="total"></el-pagination>
</div>
<addActive ref="addActive" @success="getTableData" />
<QR ref="downloadQR"></QR>
</div>
</template>
<script>
import handselTypes from './handselTypes'
import addActive from './components/addActive'
import QR from './components/downloadQR.vue'
import { findActivate, modityActivate } from '@/api/shop'
import dayjs from 'dayjs'
export default {
components: {
addActive
addActive,QR
},
data() {
return {

View File

@ -0,0 +1,76 @@
<template>
<div class="downloadQR" v-show="isshow">
<div class="box">
<img :src="imgUrl" style="width: 300px;height: 300px;" alt="">
<div class="btnStyle">
<el-button type="primary" @click="isshow = false">取消</el-button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a :href="imgUrl"><el-button type="primary" @click="downImg">下载</el-button></a>
</div>
</div>
</div>
</template>
<script>
import { getwxacode } from '@/api/shop'
export default {
data() {
return {
isshow: false,
imgUrl: ""
}
},
mounted() {
this.getlist()
},
methods: {
show() {
this.isshow = true
},
async getlist() {
let res = await getwxacode({
shopId: localStorage.getItem('shopId')
})
this.imgUrl = res
}, downImg() {
// window.location.href()
window.URL.revokeObjectURL(this.imgUrl)
}
}
}
</script>
<style scoped lang="scss">
.downloadQR {
display: flex;
justify-content: center;
align-items: center;
background-color: rgba($color: #000000, $alpha: .6);
width: 100%;
height: 100%;
position: fixed;
left: 0;
top: 0;
z-index: 9999;
.box {
padding: 20px;
border-radius: 3px;
height: 400px;
width: 340px;
background-color: #fff;
display: flex;
// align-items: center;
// justify-content: center;
flex-direction: column;
}
.btnStyle {
margin-top: 20px;
text-align: center;
}
}
</style>