MyFansInfo.vue 8.7 KB
Newer Older
1 2 3 4 5 6
<template>
	<div>
		<el-container>
			<el-main>
				<el-form :inline="true" :model="formInline" class="demo-form-inline">
					<el-form-item>
7 8 9 10
						<el-input size="small" clearable v-model="formInline.userName" placeholder="请输入用户名" @keydown.enter.native="userPage"></el-input>
					</el-form-item>
					<el-form-item>
						<el-select size="small" v-model="formInline.relationType" multiple placeholder="请选择关系类型" @change="fansInfoPage">
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
							<el-option v-for="type in relationType" :key="type" :label="type" :value="type"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item>
						<el-button size="small" type="primary" @click="fansInfoPage">查询</el-button>
					</el-form-item>
					<el-form-item>
						<el-button size="small" type="primary" @click="prepareSyncFansInfo">同步粉丝</el-button>
						<el-dialog title="提示" :visible.sync="syncFansInfoDialogVisible" width="30%" :before-close="handleClose">
							<span>确认同步粉丝吗?</span>
							<span slot="footer" class="dialog-footer">
								<el-button @click="syncFansInfoDialogVisible = false">取 消</el-button>
								<el-button type="primary" @click.prevent="syncFansInfo()">确 定</el-button>
							</span>
						</el-dialog>
					</el-form-item>
					<el-form-item>
						<el-button size="small" type="primary" @click="prepareSyncFollowInfo">同步关注</el-button>
						<el-dialog title="提示" :visible.sync="syncFollowInfoDialogVisible" width="30%" :before-close="handleClose">
							<span>确认同步关注吗?</span>
							<span slot="footer" class="dialog-footer">
								<el-button @click="syncFollowInfoDialogVisible = false">取 消</el-button>
								<el-button type="primary" @click.prevent="syncFollowInfo()">确 定</el-button>
							</span>
						</el-dialog>
					</el-form-item>
					<el-form-item>
						<el-button size="small" type="primary" @click="prepareCancleFollowInfo">取消关注</el-button>
						<el-dialog title="提示" :visible.sync="cancleFollowInfoDialogVisible" width="30%" :before-close="handleClose">
							<span>确认取消关注吗?</span>
							<span slot="footer" class="dialog-footer">
								<el-button @click="cancleFollowInfoDialogVisible = false">取 消</el-button>
								<el-button type="primary" @click.prevent="cancleFollowInfo()">确 定</el-button>
							</span>
						</el-dialog>
					</el-form-item>
47 48 49 50 51 52 53 54 55 56
					<el-form-item>
						<el-button size="small" type="primary" @click="prepareCancleNoArticle">取消关注无文章</el-button>
						<el-dialog title="提示" :visible.sync="noArticleDialogVisible" width="30%" :before-close="handleClose">
							<span>确认取消关注无文章吗?</span>
							<span slot="footer" class="dialog-footer">
								<el-button @click="noArticleDialogVisible = false">取 消</el-button>
								<el-button type="primary" @click.prevent="cancleFansNoArticle()">确 定</el-button>
							</span>
						</el-dialog>
					</el-form-item>
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
				</el-form>
				<el-table border :data="fansInfoList" v-loading="loading">
					<el-table-column prop="id" label="序号" width="100" sortable></el-table-column>
					<el-table-column prop="userName" label="用户名" show-overflow-tooltip></el-table-column>

					<el-table-column prop="nickName" label="用户昵称" show-overflow-tooltip>
						<template slot-scope="scope">
							<a :href="scope.row.blogUrl" target="_blank">{{ scope.row.nickName }}</a>
						</template>
					</el-table-column>

					<el-table-column prop="relationType" label="关系" show-overflow-tooltip></el-table-column>
				</el-table>
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[8, 50, 100, 200, 400]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination>
			</el-main>
			<el-backtop class="backtop"></el-backtop>
		</el-container>
	</div>
</template>

<script>
import ApiService from '../../api/ApiService'
export default {
80
    name: 'MyTripletDayInfo',
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
    data() {
        return {
            formInline: {
                relationType: [],
                userName: '',
            },
            relationType: ['互关', '粉丝', '已关注'],
            // 用户列表数据
            fansInfoList: [],
            loading: false,
            syncFansInfoDialogVisible: false,
            syncFollowInfoDialogVisible: false,
            cancleFollowInfoDialogVisible: false,
            noArticleDialogVisible: false,
            elementui_page_component_key: 0,
            currentPage: Number(localStorage.getItem('csdnFansInfoPage')) || 1,
            pageSize: 9,
            total: 0,
        }
    },
102

103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
    watch: {
        'formInline.relationType'(newVal, oldVal) {
            if (newVal !== oldVal) {
                this.currentPage = 1
                localStorage.setItem('csdnFansInfoPage', this.currentPage)
                this.fansInfoPage()
            }
        },
        'formInline.userName'(newVal, oldVal) {
            if (newVal !== oldVal) {
                this.currentPage = 1
                localStorage.setItem('csdnFansInfoPage', this.currentPage)
                this.fansInfoPage()
            }
        },
        // 监听currentPage的变化,将新值保存到localStorage中
        currentPage(newPage) {
            localStorage.setItem('csdnFansInfoPage', newPage.toString())
        },
    },
    created() {
        //获取问题类型的枚举
        this.fansInfoPage()
    },
    mounted() {
        this.currentPage = 1
    },
    methods: {
        prepareSyncFansInfo() {
            this.syncFansInfoDialogVisible = true
        },
        prepareCancleNoArticle() {
            this.noArticleDialogVisible = true
        },
        prepareSyncFollowInfo() {
            this.syncFollowInfoDialogVisible = true
        },
        prepareCancleFollowInfo() {
            this.cancleFollowInfoDialogVisible = true
        },
        handleClose(done) {
            this.$confirm('确认关闭?')
                .then((_) => {
                    done()
                })
                .catch((_) => {})
        },
        async fansInfoPage() {
            this.loading = true
            const { data: res } = await ApiService.fansInfoPage(this.currentPage, this.pageSize, this.formInline)
            if (res.code === 200) {
                this.total = res.result.totalElements
                this.fansInfoList = res.result.content
            }
            this.loading = false
        },
159

160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
        async syncFansInfo() {
            this.loading = true
            this.syncFansInfoDialogVisible = false
            const { data: res } = await ApiService.syncFansInfo()
            if (res.code === 200) {
                this.fansInfoPage()
            }
            this.loading = false
        },
        async cancleFansNoArticle() {
            this.loading = true
            this.noArticleDialogVisible = false
            const { data: res } = await ApiService.cancleFansNoArticle()
            if (res.code === 200) {
                this.fansInfoPage()
            }
            this.loading = false
        },
178

179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
        async syncFollowInfo() {
            this.loading = true
            this.syncFollowInfoDialogVisible = false
            const { data: res } = await ApiService.syncFollowInfo()
            if (res.code === 200) {
                this.fansInfoPage()
            }
            this.loading = false
        },
        async cancleFollowInfo() {
            this.loading = true
            this.cancleFollowInfoDialogVisible = false
            const { data: res } = await ApiService.cancleFollowInfo()
            if (res.code === 200) {
                this.fansInfoPage()
            }
            this.loading = false
        },
        refreshPage() {
            //获取问题类型的枚举
            this.fansInfoPage()
            location.reload()
        },
        handleCurrentChange(currentPage) {
            this.currentPage = currentPage
            this.fansInfoPage()
        },
        handleSizeChange(currentSize) {
            this.pageSize = currentSize
            this.fansInfoPage()
        },
    },
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
}
</script>

<style lang="less" scoped>
.el-header {
	background-color: #b3c0d1;
	color: #333;
	line-height: 60px;
}

.el-aside {
	color: #333;
}

.pagination {
	margin-top: 16px;
	text-align: right;
}
.header-button-item {
	margin-right: 15px;
	font-size: 20px;
}

.red-title {
	line-height: 24px;
	font-size: 18px;
	color: red;
}

.backtop {
	position: fixed;
	bottom: 50px;
	right: 50px;
	height: 40px;
	width: 40px;
	line-height: 40px;
	text-align: center;
	border-radius: 20px;
	background-color: #007aff;
	color: #fff;
	cursor: pointer;
	z-index: 999;
}
.custom-textarea {
	width: 100%;
	text-align: left;
}
.backtop:hover {
	background-color: #0050a0;
}
</style>