Init project

This commit is contained in:
lifizer
2023-09-20 21:49:33 +08:00
parent 85a5989c96
commit c9ceac9f37
710 changed files with 125705 additions and 0 deletions
+198
View File
@@ -0,0 +1,198 @@
<template>
<view class="page-info-publish">
<view class="tab-box flex jc-center">
<text :class="{'active':tabIndex==index}" v-for="(item,index) in tabData" :key="item"
@click="changeTab(index)">{{item.label}}</text>
</view>
<form @submit="formSubmit">
<view class="form-item">
<view class="title">标题:</view>
<input v-model="title" type="text" placeholder="请输入动态标题..."
placeholder-style="font-size:24rpx;color:#C2C5CC;" />
</view>
<view class="form-item">
<textarea class="content-style" v-model="content" placeholder="请输入动态内容..."
placeholder-style="font-size:24rpx;color:#C2C5CC;" />
</view>
<view class="form-item" v-if="showUpload">
<tm-upload :dataList="picsArray" :upload_img_wh="uploadImgWH" :upload_max="uploadMax" :url="uploadUrl" :type='uploadType'
:header="uploadHeader" @change="uploadedImgChange" />
</view>
<view class="form-btn">
<button form-type="submit">发布</button>
</view>
</form>
</view>
</template>
<script>
import tmUpload from '@/pagesInn/components/tm-upload/tm-upload.vue';
import {
VUE_APP_API_URL
} from "@/config";
import {
postHotelNewsAdd
} from "@/api/inn.js";
export default {
components: {
tmUpload
},
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
uploadUrl: VUE_APP_API_URL + '/api/upload',
uploadType: 'image',
uploadCount: 9,
uploadImgWH: (750 - 3 * 16 - 2 * 32) / 3.0,
uploadHeader: {
Authorization: "Bearer " + this.$store.getters.token
},
uploadedFilesArray: [],
uploadMax:10,
picsArray: [],
showUpload:true,
hotelId: 0,
tabData: [{
label: "图文动态",
type: "NT_TEXT",
uploadType: "image",
uploadCount: 9
},
{
label: "视频动态",
type: "NT_VIDEO",
uploadType: "video",
uploadCount: 1
}
],
tabIndex: 0,
title: "",
content: ""
}
},
onLoad(option) {
this.hotelId = option.hotelId;
},
methods: {
changeTab(index) {
this.tabIndex = index;
this.showUpload=false;
this.uploadType= this.tabData[index].uploadType;
this.uploadCount= this.tabData[index].uploadCount;
setTimeout(()=>{
this.showUpload=true;
},100)
},
//文件上传结果
uploadedImgChange: function(uploadedFilesList) {
this.uploadedFilesArray = uploadedFilesList;
},
formSubmit(e) {
if (this.title.length == 0) {
this.$dialog.error("请输入动态标题");
return;
}
if (this.content.length == 0) {
this.$dialog.error("请输入动态内容");
return;
}
if (this.uploadedFilesArray.length == 0) {
this.$dialog.error("请上传动态图片或视频");
return;
}
let param = {
hotelId: this.hotelId,
name: this.title,
content: this.content,
type: this.tabData[this.tabIndex].type,
resources: this.uploadedFilesArray.join(",")
};
uni.showLoading();
postHotelNewsAdd(param).then(res => {
uni.hideLoading();
this.$dialog.toast({
mes: "发布成功!"
});
setTimeout(() => {
this.$yrouter.back();
}, 1000);
}).catch((err) => {
uni.hideLoading();
this.$dialog.error(err.msg);
})
}
}
}
</script>
<style lang="scss">
.page-info-publish {
font-size: 28rpx;
.tab-box {
padding: 30rpx;
background: #fff;
line-height: 1;
.active {
background: #0DC5C5;
color: #fff;
}
text {
padding: 8rpx 10rpx;
border: 1rpx solid #0DC5C5;
color: #0DC5C5;
}
text:first-child {
border-radius: 8rpx 0 0 8rpx;
}
text:last-child {
border-radius: 0 8rpx 8rpx 0;
}
}
.form-item {
padding: 30rpx;
background: #fff;
.content-style {
height: 200rpx;
color: #C2C5CC;
font-size: 28rpx;
}
}
.form-btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
button {
height: 80rpx;
line-height: 80rpx;
border-radius: 0;
background: #0DC5C5;
color: #fff;
font-size: 28rpx;
}
}
}
</style>