Files
peko-admin-web/src/views/room/HomeRecommView.vue
2024-04-28 10:26:23 +08:00

174 lines
7.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<section>
<div class="box box-primary">
<div class="box-header">首页热门推荐</div>
<div class="box-body">
<section class="content">
<div id="table"></div>
<div id="toolbar">
<button id="add" class="btn btn-default">
<i class="glyphicon glyphicon-plus"></i>增加
</button>
</div>
</section>
</div>
</div>
</section>
<!-- .content -->
</template>
<script>
import TableHelper from '@/utils/bootstrap-table-helper';
var isEdit = false;
export default {
name: "HomeRecommView",
setup() {
return {};
},
created() {
this.$nextTick(function () {
this.initData();
});
},
methods: {
initData() {
$(function () {
$('#table').bootstrapTable('destroy');
$('#table').bootstrapTable({
columns: [
{ field: 'tmp', title: 'ID', align: 'center', checkbox: true },
{ field: 'roomid', title: '房间ID', align: 'center', width: '5%' },
{ field: 'title', title: '房间名', align: 'center', width: '10%' },
{ field: 'roomtag', title: '标签', align: 'center', width: '5%' },
{ field: 'avatar', title: '头像', align: 'center', width: '10%' },
{ field: 'back_pic', title: '背景图', width: '10%' },
{
field: 'valid', title: '状态', align: 'center', width: '5%', formatter: function (val, row, index) {
if (val == true) {
return '开';
}
return '闭';
}
},
{
field: 'type', title: '类型', align: 'center', width: '5%', formatter: function (val, row, index) {
if (val == 1) {
return '竞拍房';
}
return '悬赏房';
}
},
{
field: 'isermit_room', title: '是否牌照房', align: 'center', width: '5%', formatter: function (val, row, index) {
if (val == 1) {
return '牌照房';
}
return '非牌照房';
}
},
{
field: 'id', title: '操作', align: 'center', width: '20%', formatter: function (val, row, index) {
return "<button class='btn btn-sm btn-success opt-edit' data-id=" + val + ">编辑</button>&nbsp;&nbsp;" +
"<button class='btn btn-sm btn-danger opt-del' data-id=" + val + ">删除</button>";
}
}
],
cache: false,
striped: true,
showRefresh: true,
pageSize: 10,
pagination: true,
pageList: [1, 10, 20, 30, 50],
search: true,
sidePagination: "server", //表示服务端请求
//设置为undefined可以获取pageNumberpageSizesearchTextsortNamesortOrder
//设置为limit可以获取limit, offset, search, sort, order
queryParamsType: "undefined",
queryParams: function queryParams(params) { //设置查询参数
var param = {
pageNumber: params.pageNumber,
pageSize: params.pageSize,
searchText: params.searchText
};
return param;
},
toolbar: '#toolbar',
url: '/admin/menu/getlist',
onLoadSuccess: function () { //加载成功时执行
console.log("load success");
},
onLoadError: function () { //加载失败时执行
console.log("load fail");
}
});
$('#btnScan').click(function () {
console.log("star===>>" + $("#ernos").text() + ", " + $("#ernos").val());
if (!$('#ernos').val()) {
$("#tipMsg").text("请输入平台号");
$("#tipModal").modal('show');
return;
}
$.ajax({
type: "post",
url: "/admin/goldcoin/userinfo",
data: { "ernos": $("#ernos").val() },
dataType: "json",
success: function (json) {
if (json.code == 200) {
var str = '';
for (var i = 0; i < json.data.length; i++) {
var bean = json.data[i];
str += "<tr>\n" +
" <th style=\"width: 100px\"><img src='" + bean.avatar + "' width='50'/></th>\n" +
" <th style='width:200px;'>" + bean.erbanNo + "</th>\n" +
" <th>" + bean.nick + "</th>\n" +
" </tr>";
}
$('#tbody').html(str);
}
}
})
});
$("#btnGive").click(function () {
isEdit = true;
var ernos = $("#ernos").val();
var type = $('#type').val();
var num = $('#num').val();
if (!$('#ernos').val()) {
$("#tipMsg").text("请输入平台号");
$("#tipModal").modal('show');
return;
}
$.ajax({
type: "post",
url: "/admin/goldcoin/give",
data: { 'ernos': ernos, 'type': type, 'num': num },
dataType: "json",
success: function (json) {
if (json.code == 200) {
$("#tipMsg").text("赠送钻石成功");
$("#tipModal").modal('show');
} else {
$("#tipMsg").text("赠送钻石出错errorCode: " + json.code);
$("#tipModal").modal('show');
}
},
error: function (json) {
$("#tipMsg").text("赠送钻石出错,网络出错");
$("#tipModal").modal('show');
}
});
});
});
}
},
};
</script>
<style scoped></style>