Commit ae70a2d4 authored by guoyou's avatar guoyou

banner设置

parent 24782dec
<template> <template>
<div class="app-container calendar-list-container" v-loading.body="showLoadingBody"> <div class="app-container calendar-list-container" v-loading.body="showLoadingBody">
<div class="filter-container" ref="filter-container"> <div class="filter-container" ref="filter-container">
<el-button class="filter-item" style="margin-left: 10px;" @click="handleCreate" <el-button
type="primary" icon="edit">添加 class="filter-item"
</el-button> style="margin-left: 10px;"
</div> @click="handleCreate"
<el-table :key='tableKey' :data="list" border fit highlight-current-row type="primary"
style="width: 100%"> icon="edit"
<el-table-column >添加</el-button>
type="index" </div>
align="center" label="序号" width="98">
</el-table-column> <el-table :key="tableKey" :data="list" border fit highlight-current-row style="width: 100%">
<el-table-column width="160" align="center" label="标题"> <el-table-column type="index" align="center" label="序号" width="98"></el-table-column>
<template scope="scope"> <el-table-column width="160" align="center" label="标题">
<span>{{scope.row.title}}</span> <template scope="scope">
</template> <span>{{scope.row.title}}</span>
</el-table-column> </template>
<el-table-column width="180" align="center" label="类型"> </el-table-column>
<template scope="scope"> <el-table-column width="180" align="center" label="类型">
<span>{{scope.row.type==0?"app首页":scope.row.type==1?"app旅游页":scope.row.type==2?"租车":scope.row.type==3?"个人中心":scope.row.type==4?"小程序首页":scope.row.type==5?'发现':scope.row.type}}</span> <template scope="scope">
</template> <span>{{scope.row.type==0?"app首页":scope.row.type==1?"app旅游页":scope.row.type==2?"租车":scope.row.type==3?"个人中心":scope.row.type==4?"小程序首页":scope.row.type==5?'发现':scope.row.type}}</span>
</el-table-column> </template>
<!--location 1:推荐 2:拍拍 3:短视频 4:问答--> </el-table-column>
<el-table-column width="100" align="center" label="位置"> <!--location 1:推荐 2:拍拍 3:短视频 4:问答-->
<template scope="scope"> <el-table-column width="100" align="center" label="位置">
<span>{{scope.row.location==0?"所有页面":scope.row.location==1?"推荐":scope.row.location==2?"拍拍":scope.row.location==3?"短视频":scope.row.location==4?"问答": scope.row.location}}</span> <template scope="scope">
</template> <span>{{scope.row.location==0?"所有页面":scope.row.location==1?"推荐":scope.row.location==2?"拍拍":scope.row.location==3?"短视频":scope.row.location==4?"问答": scope.row.location}}</span>
</el-table-column> </template>
<el-table-column width="250" align="center" label="banner图"> </el-table-column>
<template scope="scope"> <el-table-column width="250" align="center" label="banner图">
<img :src="scope.row.cover" style="width:100%;max-height:100px;"> <template scope="scope">
</template> <img :src="scope.row.cover" style="width:100%;max-height:100px;" />
</el-table-column> </template>
<el-table-column align="center" label="安卓跳转"> </el-table-column>
<template scope="scope"> <el-table-column align="center" label="安卓跳转">
<span>{{scope.row.url}}</span> <template scope="scope">
</template> <span>{{scope.row.url}}</span>
</el-table-column> </template>
<el-table-column align="center" label="ios跳转"> </el-table-column>
<template scope="scope"> <el-table-column align="center" label="ios跳转">
<span>{{scope.row.iosUrl}}</span> <template scope="scope">
</template> <span>{{scope.row.iosUrl}}</span>
</el-table-column> </template>
<el-table-column align="center" label="小程序跳转"> </el-table-column>
<template scope="scope"> <el-table-column align="center" label="小程序跳转">
<span>{{scope.row.appletUrl}}</span> <template scope="scope">
</template> <span>{{scope.row.appletUrl}}</span>
</el-table-column> </template>
<el-table-column align="center" width="150" label="操作"> </el-table-column>
<template scope="scope"> <el-table-column align="center" width="150" label="操作">
<el-button size="small" class="el-button el-button--text el-button--small" @click="handleUpdate(scope.row)">编辑 <template scope="scope">
</el-button> <el-button
<el-button class="el-button el-button--text el-button--small" style="color:red;" size="small" @click="deleteHandler(scope.row)">删除</el-button> size="small"
</template> class="el-button el-button--text el-button--small"
</el-table-column> @click="handleUpdate(scope.row)"
</el-table> >编辑</el-button>
<div v-show="!listLoading" class="pagination-container"> <el-button
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" class="el-button el-button--text el-button--small"
:current-page.sync="listQuery.pageNo" :page-sizes="[10,20,30, 50]" :page-size="listQuery.pageSize" style="color:red;"
layout="total, sizes, prev, pager, next, jumper" :total="total"></el-pagination> size="small"
</div> @click="deleteHandler(scope.row)"
<!-- banner modal弹窗 --> >删除</el-button>
<el-dialog :title="modalTitle" :visible.sync="bannerDialogVisible"> </template>
<el-form :model="form" :rules="rules" ref="form" label-width="90px"> </el-table-column>
<el-form-item label="标题" prop="title"> </el-table>
<el-input v-model="form.title" placeholder="请输入标题"></el-input> <div v-show="!listLoading" class="pagination-container">
</el-form-item> <el-pagination
<!--0-app首页,1-app旅游页;2-租车--> @size-change="handleSizeChange"
<el-form-item label="类型" prop="type"> @current-change="handleCurrentChange"
<el-radio class="radio" v-model="form.type" label="0">app首页</el-radio> :current-page.sync="listQuery.pageNo"
<el-radio class="radio" v-model="form.type" label="1">app旅游页</el-radio> :page-sizes="[10,20,30, 50]"
<el-radio class="radio" v-model="form.type" label="2">租车</el-radio> :page-size="listQuery.pageSize"
<el-radio class="radio" v-model="form.type" label="3">个人中心</el-radio> layout="total, sizes, prev, pager, next, jumper"
<el-radio class="radio" v-model="form.type" label="4">小程序首页</el-radio> :total="total"
<el-radio class="radio" v-model="form.type" label="5">发现</el-radio> ></el-pagination>
</el-form-item> </div>
<!--location 1:推荐 2:拍拍 3:短视频 4:问答--> <!-- banner modal弹窗 -->
<el-form-item label="位置" prop="location" v-if="form.type == 5"> <el-dialog :title="modalTitle" :visible.sync="bannerDialogVisible" @close="closePop">
<el-radio class="radio" v-model="form.location" label="0">所有页面</el-radio> <el-form :model="form" :rules="rules" ref="form" label-width="90px">
<el-radio class="radio" v-model="form.location" label="1">推荐</el-radio> <el-form-item label="标题" prop="title">
<el-radio class="radio" v-model="form.location" label="2">拍拍</el-radio> <el-input v-model="form.title" placeholder="请输入标题"></el-input>
<el-radio class="radio" v-model="form.location" label="3">短视频</el-radio> </el-form-item>
<el-radio class="radio" v-model="form.location" label="4">问答</el-radio> <!--0-app首页,1-app旅游页;2-租车-->
</el-form-item> <el-form-item label="类型" prop="type">
<!--BASE_API + --> <el-radio class="radio" v-model="form.type" label="0">app首页</el-radio>
<el-form-item label="banner图" prop="cover" :style="{display:'block'}"> <el-radio class="radio" v-model="form.type" label="1">app旅游页</el-radio>
<el-upload <el-radio class="radio" v-model="form.type" label="2">租车</el-radio>
class="avatar-uploader" <el-radio class="radio" v-model="form.type" label="3">个人中心</el-radio>
:action="BASE_API+'/api/universal/file/app/unauth/admin/upload'" <el-radio class="radio" v-model="form.type" label="4">小程序首页</el-radio>
:show-file-list="false" <el-radio class="radio" v-model="form.type" label="5">发现</el-radio>
:headers="getHeaderWithToken" </el-form-item>
:on-success="handleAvatarSuccess"> <!--location 1:推荐 2:拍拍 3:短视频 4:问答-->
<img v-if="$utils.isString(form.cover) && !$utils.isEmpty(form.cover)" :src="form.cover" style="width:500px;max-height:300px;"> <el-form-item label="位置" prop="location" v-if="form.type == 5">
<i v-else class="el-icon-plus avatar-uploader-icon" style="lineHeight:100px;width:500px;height: 100px;"></i> <el-radio class="radio" v-model="form.location" label="0">所有页面</el-radio>
</el-upload> <el-radio class="radio" v-model="form.location" label="1">推荐</el-radio>
</el-form-item> <el-radio class="radio" v-model="form.location" label="2">拍拍</el-radio>
<el-form-item> <el-radio class="radio" v-model="form.location" label="3">短视频</el-radio>
建议尺寸:1080*630 <el-radio class="radio" v-model="form.location" label="4">问答</el-radio>
</el-form-item> </el-form-item>
<el-form-item label="安卓跳转链接"> <!--BASE_API + -->
<el-input v-model="form.url" placeholder="请输入跳转链接"></el-input> <el-form-item label="banner图" prop="cover" :style="{display:'block'}">
</el-form-item> <el-upload
<el-form-item label="ios跳转链接"> class="avatar-uploader"
<el-input v-model="form.iosUrl" placeholder="请输入ios跳转链接"></el-input> :action="BASE_API+'/api/universal/file/app/unauth/admin/upload'"
</el-form-item> :show-file-list="false"
<el-form-item label="小程序跳转链接"> :headers="getHeaderWithToken"
<el-input v-model="form.appletUrl" placeholder="请输入ios跳转链接"></el-input> :on-success="handleAvatarSuccess"
</el-form-item> >
</el-form> <img
<div slot="footer" class="dialog-footer"> v-if="$utils.isString(form.cover) && !$utils.isEmpty(form.cover)"
<el-button @click="cancelHandel">取 消</el-button> :src="form.cover"
<el-button v-if="modalTitle=='创建'" type="primary" @click="create('form')">确 定</el-button> style="width:500px;max-height:300px;"
<el-button v-else type="primary" @click="update('form')">确 定</el-button> />
</div> <i
</el-dialog> v-else
</div> class="el-icon-plus avatar-uploader-icon"
style="lineHeight:100px;width:500px;height: 100px;"
></i>
</el-upload>
</el-form-item>
<el-form-item>建议尺寸:1080*630</el-form-item>
<el-form-item label="安卓跳转链接" prop="url">
<el-input v-model="form.url" placeholder="请输入跳转链接"></el-input>
</el-form-item>
<el-form-item label="ios跳转链接" prop="iosUrl">
<el-input v-model="form.iosUrl" placeholder="请输入ios跳转链接"></el-input>
</el-form-item>
<el-form-item label="小程序跳转链接" prop="appletUrl">
<el-input v-model="form.appletUrl" placeholder="请输入ios跳转链接"></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelHandel">取 消</el-button>
<el-button v-if="modalTitle=='创建'" type="primary" @click="create('form')">确 定</el-button>
<el-button v-else type="primary" @click="update('form')">确 定</el-button>
</div>
</el-dialog>
</div>
</template> </template>
<script> <script>
import 'static/css/uploadImg.css';// 引入图片上传组件对话框 import 'static/css/uploadImg.css' // 引入图片上传组件对话框
import { import { formatDate } from 'utils/dateFormattor'
formatDate
} from 'utils/dateFormattor';
import { import {
toEast8Date, toEast8Date,
deepCopyDate, deepCopyDate,
newEast8Date, newEast8Date,
convertDate2Str convertDate2Str
} from 'utils/dateUtils'; } from 'utils/dateUtils'
import { import { getBannerList, editBanner, addBanner, delBanner } from 'api/tourManage'
getBannerList,
editBanner,
addBanner,
delBanner
} from 'api/tourManage';
import rsCode from '../../utils/rsCode'; import rsCode from '../../utils/rsCode'
import {mapGetters} from 'vuex'; import { mapGetters } from 'vuex'
import { import { getToken } from '../../utils/auth'
getToken
} from '../../utils/auth';
import Element1 from "../admin/menu/components/element"; import Element1 from '../admin/menu/components/element'
import ElRow from "element-ui/packages/row/src/row"; import ElRow from 'element-ui/packages/row/src/row'
import ElCol from "element-ui/packages/col/src/col"; import ElCol from 'element-ui/packages/col/src/col'
import {objDeepCopy} from "../../utils"
export default { export default {
name: 'tourManage', name: 'tourManage',
components: { components: {
ElCol, ElCol,
ElRow, ElRow,
Element1 Element1
}, },
data() { data() {
return { return {
tableKey:0, tableKey: 0,
modalTitle: "创建", modalTitle: '创建',
BASE_API: process.env.BASE_API, BASE_API: process.env.BASE_API,
bannerDialogVisible: false,//添加、编辑弹框 bannerDialogVisible: false, //添加、编辑弹框
showLoadingBody: false, showLoadingBody: false,
form: { form: {
title: "", title: '',
url: "", url: '',
cover:"", cover: '',
type: "0", type: '0',
location: "0", location: '0',
iosUrl:'', iosUrl: '',
appletUrl:'' appletUrl: null
}, },
listQuery: { listQuery: {
pageNo: 1, pageNo: 1,
pageSize: 20 pageSize: 20
}, },
rules: { rules: {
title: { title: {
type: 'string', type: 'string',
required: true, required: true,
message: '请输入标题', message: '请输入标题',
trigger: 'blur' trigger: 'blur'
}, },
type:{ type: {
type: 'string', type: 'string',
required: true, required: true,
message: '请选择banner类型', message: '请选择banner类型',
trigger: 'blur' trigger: 'blur'
}, },
location:{ location: {
type: "string", type: 'string',
required: true, required: true,
message: '请选择位置类型', message: '请选择位置类型',
trigger: 'blur' trigger: 'blur'
}, },
cover: { cover: {
type: 'string', type: 'string',
required: true, required: true,
message: '请上传图片', message: '请上传图片'
}, }
}, },
list: null, isRead: false,
total: null, list: null,
listLoading: true, total: null,
inline: true, listLoading: true,
banner_btn_edit: false,//编辑 inline: true,
banner_btn_add: false,//添加 banner_btn_edit: false, //编辑
} tableInfo:{},
}, banner_btn_add: false //添加
created() { }
this.getList(); },
this.banner_btn_edit = true;//this.elements['tourManage:btn_edit']; created() {
this.banner_btn_add = true;//this.elements['tourManage:btn_add']; this.getList()
}, this.banner_btn_edit = true //this.elements['tourManage:btn_edit'];
computed: { this.banner_btn_add = true //this.elements['tourManage:btn_add'];
...mapGetters([ },
'elements', computed: {
'belong2Type' ...mapGetters(['elements', 'belong2Type']),
]), getHeaderWithToken() {
getHeaderWithToken() { return { Authorization: getToken() }
return {Authorization: getToken()}; }
}, },
}, methods: {
methods: { handleSizeChange(val) {
handleSizeChange(val) { this.listQuery.pageSize = val
this.listQuery.pageSize = val; this.getList()
this.getList(); },
}, handleCurrentChange(val) {
handleCurrentChange(val) { this.listQuery.pageNo = val
this.listQuery.pageNo = val; this.getList()
this.getList(); },
}, /**
/** * 添加
* 添加 * */
* */ handleCreate() {
handleCreate() { this.cleanForm()
this.cleanForm(); this.modalTitle = '创建'
this.modalTitle = '创建'; this.bannerDialogVisible = true
this.bannerDialogVisible = true; },
}, closePop() {
/** this.cleanForm()
* 操作-编辑 },
* */ /**
handleUpdate(row) { * 操作-编辑
this.modalTitle = '编辑'; * */
this.cleanForm(); handleUpdate(row) {
this.form = row; console.log(objDeepCopy);
this.bannerDialogVisible = true;
}, this.modalTitle = '编辑'
/** this.form = objDeepCopy(row)
* 弹框-取消 this.bannerDialogVisible = true
* */ },
cancelHandel(){ /**
this.cleanForm(); * 弹框-取消
this.bannerDialogVisible = false; * */
}, cancelHandel() {
/** this.cleanForm()
* 清空表单 this.bannerDialogVisible = false
* */ },
cleanForm() { /**
this.form = { * 清空表单
title: "", * */
cover: "", cleanForm() {
url:"", this.form = {
type: "0", title: '',
location: "0", cover: '',
iosUrl:'', url: '',
appletUrl:'' type: '0',
} location: '0',
}, iosUrl: '',
showImgDialog(drivingLicensePath) { appletUrl: null
this.licenceSrcUrl = this.getDrivingLicenseUrl(drivingLicensePath); }
this.dialogForm4LicenceVisible = true; },
}, showImgDialog(drivingLicensePath) {
/** this.licenceSrcUrl = this.getDrivingLicenseUrl(drivingLicensePath)
* 获取banner列表数据 this.dialogForm4LicenceVisible = true
* */ },
getList() { /**
this.listLoading = true; * 获取banner列表数据
getBannerList(this.listQuery).then(response => { * */
let totalCountRs = undefined; getList() {
let listRs = undefined; this.listLoading = true
if (!this.$utils.isEmpty(response.data.data) && this.$utils.isInteger(response.data.totalCount)) { getBannerList(this.listQuery).then(response => {
listRs = response.data.data; let totalCountRs = undefined
response.data.data.map(function(item){ let listRs = undefined
item.type = item.type+""; if (
item.location = item.location?item.location+"": "0"; !this.$utils.isEmpty(response.data.data) &&
item.visible2 = false; this.$utils.isInteger(response.data.totalCount)
}); ) {
totalCountRs = response.data.totalCount; listRs = response.data.data
} response.data.data.map(function(item) {
this.listLoading = false; item.type = item.type + ''
this.list = listRs; item.location = item.location ? item.location + '' : '0'
this.total = totalCountRs; item.visible2 = false
}); })
}, totalCountRs = response.data.totalCount
/** }
* 创建 this.listLoading = false
* */ this.list = listRs
create(formName) { this.total = totalCountRs
const set = this.$refs; })
set[formName].validate(valid => { },
if (valid) { /**
addBanner(this.form) * 创建
.then(response => { * */
if (response.status === 200) { create(formName) {
this.bannerDialogVisible = false; const set = this.$refs
this.getList(); set[formName].validate(valid => {
this.$notify({ if (valid) {
title: '成功', addBanner(this.form).then(response => {
message: '创建成功', if (response.status === 200) {
type: 'success', this.bannerDialogVisible = false
duration: 2000 this.getList()
}); this.$notify({
} else { title: '成功',
this.$notify({ message: '创建成功',
title: '失败', type: 'success',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!', duration: 2000
type: 'error', })
duration: 2000 } else {
}); this.$notify({
} title: '失败',
}); message: rsCode.msg[response.code]
} else { ? rsCode.msg[response.code]
return false; : '操作失败!',
} type: 'error',
}); duration: 2000
}, })
/** }
* 编辑-更新 })
* */ } else {
update(formName) { return false
const set = this.$refs; }
set[formName].validate(valid => { })
if (valid) { },
editBanner(this.form).then(response => { /**
if (response.status === 200) { * 编辑-更新
this.bannerDialogVisible = false; * */
this.getList(); update(formName) {
this.$notify({ const set = this.$refs
title: '成功', set[formName].validate(valid => {
message: '编辑成功', if (valid) {
type: 'success', editBanner(this.form).then(response => {
duration: 2000 if (response.status === 200) {
}); this.bannerDialogVisible = false
this.getList(); this.getList()
} else { this.$notify({
this.$notify({ title: '成功',
title: '失败', message: '编辑成功',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!', type: 'success',
type: 'error', duration: 2000
duration: 2000 })
}); this.getList()
} } else {
}); this.$notify({
} else { title: '失败',
return false; message: rsCode.msg[response.code]
} ? rsCode.msg[response.code]
}); : '操作失败!',
}, type: 'error',
/** duration: 2000
* 上传图片 })
* @param file }
* @returns {boolean} })
*/ } else {
beforeAvatarUpload(file) { return false
const isJPG = file.type === 'image/jpeg' || file.type === 'image/gif'; }
const isLt2M = file.size / 1024 / 1024 < 10; })
},
/**
* 上传图片
* @param file
* @returns {boolean}
*/
beforeAvatarUpload(file) {
const isJPG =
file.type === 'image/jpeg' || file.type === 'image/gif'
const isLt2M = file.size / 1024 / 1024 < 10
if (!isJPG) { if (!isJPG) {
this.$message.error('上传图片只能是 JPG/GIF 格式!'); this.$message.error('上传图片只能是 JPG/GIF 格式!')
} }
if (!isLt2M) { if (!isLt2M) {
this.$message.error('上传图片大小不能超过 10MB!'); this.$message.error('上传图片大小不能超过 10MB!')
} }
this.showLoadingBody = true; this.showLoadingBody = true
return isJPG && isLt2M; return isJPG && isLt2M
}, },
handleAvatarSuccess(res, file) { handleAvatarSuccess(res, file) {
this.form.cover = res.data; this.form.cover = res.data
this.showLoadingBody = false; this.showLoadingBody = false
}, },
/** /**
* 操作-删除 * 操作-删除
* */ * */
deleteHandler(row) { deleteHandler(row) {
this.$confirm('确定删除吗?', '提示', { this.$confirm('确定删除吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
delBanner(row.id).then(response => { delBanner(row.id).then(response => {
if (response.status === 200) { if (response.status === 200) {
this.$notify({ this.$notify({
title: '成功', title: '成功',
message: '删除成功', message: '删除成功',
type: 'success', type: 'success',
duration: 2000 duration: 2000
}); })
this.getList(); this.getList()
} else { } else {
this.$notify({ this.$notify({
title: '删除失败', title: '删除失败',
message: rsCode.msg[response.code] ? rsCode.msg[response.code] : '操作失败!', message: rsCode.msg[response.code]
type: 'error', ? rsCode.msg[response.code]
duration: 2000 : '操作失败!',
}); type: 'error',
} duration: 2000
}); })
}) }
}, })
getUrl(drivingLicensePath) { })
return process.env.BASE_API + },
'/vehicle/vehicleInfo/download/drivingLicense?realFileRelPath=' + encodeURI(drivingLicensePath); getUrl(drivingLicensePath) {
}, return (
} process.env.BASE_API +
} '/vehicle/vehicleInfo/download/drivingLicense?realFileRelPath=' +
encodeURI(drivingLicensePath)
)
}
}
}
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment