123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <!-- 公告管理 -->
- <template>
- <view class="notice">
- <view class="btn-add">
- <image
- src="../../../static/images/addicon.png"
- class="addicon"
- @tap="topage('add')"
- ></image>
- </view>
- <view class="notice-content">
- <view class="item" v-for="item in noticeList" :key="item.id">
- <view class="notice-top">
- <view class="title">{{ item.shopName }}</view>
- <image mode="aspectFill" :src="item.icon" class="picture"></image>
- <view class="detail">
- <text class="txt">{{ item.title }}</text>
- <text class="time">{{ item.time.substring(0, 10) }}</text>
- </view>
- </view>
- <view class="notice-btns">
- <!-- <view class="up btn">置顶</view> -->
- <view class="edit btn" @tap="topage(item.id)">编辑</view>
- <view class="delete btn" @tap="deleteNotice(item.id)">删除</view>
- </view>
- </view>
- </view>
- <uni-load-more :status="more"> </uni-load-more>
- </view>
- </template>
- <script>
- import Header from '../../components/header';
- export default {
- name: 'notice',
- components: {
- Header,
- },
- data() {
- //这里存放数据
- return {
- title: '公告管理',
- more: 'loading',
- params: {
- mid: 53,
- pageNo: 1,
- pageSize: 3,
- type: '2',
- },
- noticeList: [],
- };
- },
- // 下拉刷新
- onPullDownRefresh() {
- this.more = 'loading'
- this.params.pageNo = 1;
- this.getNoticeList();
- },
- // 上拉加载
- onReachBottom() {
- if (this.more != 'noMore') {
- this.params.pageNo ++
- this.getNoticeListMoare();
- }
- console.log(this.more);
- },
- onShow() {
- this.getShopMessage();
- this.getNoticeList();
- },
- //方法集合
- methods: {
- // 编辑
- topage(id) {
- this.$mRouter.push({ route: '/pages/index/setting/editnotice?id=' + id });
- },
- // 商家信息
- async getShopMessage() {
- await this.$http.get('/getUserInfo').then(async (res) => {
- if (res.data) {
- this.params.mid = res.data.id;
- }
- });
- },
- // 公告列表
- async getNoticeList() {
- console.log(this.more);
- await this.$http.post('/news/list', this.params).then(async (res) => {
- if (res.data.list.length > 0) {
- console.log(res);
- this.noticeList = res.data.list;
- if (res.data.nextPage === 0) {
- this.more = 'noMore';
- }
- } else {
- this.more = 'noMore';
- }
- uni.stopPullDownRefresh();
- });
- },
- // 加载更多
- async getNoticeListMoare() {
- let arr = [];
- await this.$http.post('/news/list', this.params).then(async (res) => {
- if (res.data.list.length > 0) {
- console.log('more');
- console.log(res);
- arr = res.data.list;
- this.noticeList = this.noticeList.concat(arr);
- if (res.data.nextPage === 0) {
- this.more = 'noMore';
- }
- } else {
- this.more = 'noMore';
- return;
- }
- });
- },
- // 删除
- deleteNotice(id) {
- let _self = this;
- uni.showModal({
- content: '是否删除该条公告?',
- success: (confirmRes) => {
- if (confirmRes.confirm) {
- _self.more = 'loading'
- _self.$http.delete('/news/del/' + id).then(async (res) => {
- if (res.code === 200 && res.msg === 'OK') {
- _self.$mHelper.toast('删除成功');
- _self.params.pageNo = 1;
- _self.getNoticeList();
- }
- });
- }
- },
- });
- }
- },
- };
- </script>
- <style lang='scss' scoped>
- .btn-add {
- position: fixed;
- right: 33upx;
- top: 20upx;
- z-index: 100;
- .addicon {
- width: 48upx;
- height: 48upx;
- }
- }
- .notice-content {
- background-color: #f4f4f4;
- padding: 15upx 33upx;
- .item {
- background-color: #fff;
- border-radius: 10upx;
- padding: 20upx;
- margin-bottom: 25upx;
- .notice-top {
- .title {
- padding: 20upx;
- color: #2f2f2f;
- font-size: 28upx;
- }
- .picture {
- width: 100%;
- height: 350upx;
- border-radius: 20upx;
- }
- .detail {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 20upx;
- .txt {
- flex: 1;
- font-size: 30upx;
- color: $titleColor;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .time {
- width: 143upx;
- color: #9ea9a3;
- font-size: 26upx;
- }
- }
- }
- .notice-btns {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 20upx;
- .btn {
- width: 200upx;
- height: 70upx;
- border: 1px solid #ccc;
- border-radius: 10upx;
- text-align: center;
- line-height: 70upx;
- margin-left: 60upx;
- &:first-child {
- margin-left: 0;
- }
- }
- .edit {
- background-color: #fff;
- }
- .delete {
- background-color: #ff6a5e;
- color: #fff;
- border:none;
- }
- }
- }
- }
- </style>
|