|
|
@ -1,7 +1,7 @@ |
|
|
|
<template> |
|
|
|
<!-- 新建作品页面 --> |
|
|
|
<view class="create-novel"> |
|
|
|
<navbar title="新建作品" leftClick @leftClick="$utils.navigateBack" /> |
|
|
|
<navbar :title="id ? '设置作品' : '新建作品'" leftClick @leftClick="$utils.navigateBack" /> |
|
|
|
|
|
|
|
<view class="form-container"> |
|
|
|
<!-- 封面信息 --> |
|
|
@ -10,7 +10,7 @@ |
|
|
|
<view class="upload-cover"> |
|
|
|
<view class="sub-title">上传封面</view> |
|
|
|
<view class="cover-box" @click="chooseCover"> |
|
|
|
<image v-if="formData.Image" :src="formData.Image" mode="aspectFill" class="cover-image"> |
|
|
|
<image v-if="formData.image" :src="formData.image" mode="aspectFill" class="cover-image"> |
|
|
|
</image> |
|
|
|
<view v-else class="upload-placeholder"> |
|
|
|
<text class="plus">+</text> |
|
|
@ -27,19 +27,42 @@ |
|
|
|
<text class="required">*</text> |
|
|
|
<text class="label">作品名称</text> |
|
|
|
</view> |
|
|
|
<input type="text" v-model="formData.name" placeholder="请输入" |
|
|
|
<input shopClass="text" v-model="formData.name" placeholder="请输入" |
|
|
|
placeholder-class="input-placeholder" /> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="form-item"> |
|
|
|
<view style="display: flex;"> |
|
|
|
<text class="required">*</text> |
|
|
|
<text class="label">作品类型</text> |
|
|
|
<text class="label">作品分类</text> |
|
|
|
</view> |
|
|
|
<view class=""> |
|
|
|
<!-- 原有的picker方案 --> |
|
|
|
<!-- <view class="category-select" @click="showCategoryPicker = true"> |
|
|
|
<text v-if="formData.shopClass" class="selected-category">{{selectedCategoryName}}</text> |
|
|
|
<text v-else class="placeholder">请选择</text> |
|
|
|
</view> |
|
|
|
|
|
|
|
<uv-picker |
|
|
|
:show="showCategoryPicker" |
|
|
|
:columns="[categoryList]" |
|
|
|
@confirm="confirmCategory" |
|
|
|
@cancel="showCategoryPicker = false" |
|
|
|
></uv-picker> --> |
|
|
|
|
|
|
|
<!-- 新的标签选择方案 --> |
|
|
|
<view class="category-tags"> |
|
|
|
<view |
|
|
|
v-for="(item, index) in categoryList" |
|
|
|
:key="index" |
|
|
|
class="category-tag" |
|
|
|
:class="{ active: formData.shopClass == item.id }" |
|
|
|
@click="selectCategory(item)" |
|
|
|
> |
|
|
|
{{item.title}} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<input type="text" |
|
|
|
disabled |
|
|
|
v-model="formData.type" placeholder="请输入" |
|
|
|
placeholder-class="input-placeholder" /> |
|
|
|
</view> |
|
|
|
|
|
|
|
<view class="form-item"> |
|
|
@ -72,20 +95,20 @@ |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 书籍信息 --> |
|
|
|
<view class="section" v-if="formData.id"> |
|
|
|
<view class="section"> |
|
|
|
<view class="section-title">书籍信息</view> |
|
|
|
<view class="form-item"> |
|
|
|
<text class="label">书号</text> |
|
|
|
<text class="value">9999993339393</text> |
|
|
|
<text class="value">{{ formData.id || '_' }}</text> |
|
|
|
</view> |
|
|
|
<view class="form-item"> |
|
|
|
<text class="label">总字数</text> |
|
|
|
<text class="value">99999999</text> |
|
|
|
<text class="value">{{ formData.num || '_' }}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 提交按钮 --> |
|
|
|
<view class="submit-btn" @click="submitForm">提交申请</view> |
|
|
|
<view class="submit-btn" @click="submitForm">{{ id ? '保存' : "提交申请" }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
@ -95,13 +118,16 @@ |
|
|
|
data() { |
|
|
|
return { |
|
|
|
formData: { |
|
|
|
Image: '', |
|
|
|
title: '', |
|
|
|
type: '1', |
|
|
|
image: '', |
|
|
|
name: '', |
|
|
|
shopClass: '', |
|
|
|
details: '', |
|
|
|
status: '0' // 默认连载 |
|
|
|
}, |
|
|
|
id: 0 |
|
|
|
id: 0, |
|
|
|
// showCategoryPicker: false, |
|
|
|
categoryList: [], |
|
|
|
// selectedCategoryName: '' |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
@ -109,6 +135,9 @@ |
|
|
|
this.id = options.id |
|
|
|
this.getBookInfo() |
|
|
|
} |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
this.getCategoryList() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
|
|
|
@ -128,13 +157,24 @@ |
|
|
|
|
|
|
|
this.$Oss.ossUpload(res.tempFilePaths[0]) |
|
|
|
.then(url => { |
|
|
|
this.formData.Image = url |
|
|
|
this.formData.image = url |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
// 获取分类列表 |
|
|
|
async getCategoryList() { |
|
|
|
const data = await this.$fetch('getCategoryList') |
|
|
|
this.categoryList = data |
|
|
|
}, |
|
|
|
|
|
|
|
// 选择分类 |
|
|
|
selectCategory(item) { |
|
|
|
this.formData.shopClass = item.id |
|
|
|
}, |
|
|
|
|
|
|
|
// 提交表单 |
|
|
|
async submitForm() { |
|
|
|
if (!this.formData.name) { |
|
|
@ -144,9 +184,9 @@ |
|
|
|
}) |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.formData.type) { |
|
|
|
if (!this.formData.shopClass) { |
|
|
|
uni.showToast({ |
|
|
|
title: '请输入作品类型', |
|
|
|
title: '请选择作品分类', |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
return |
|
|
@ -162,12 +202,16 @@ |
|
|
|
// 构建作品数据 |
|
|
|
const workData = { |
|
|
|
name: this.formData.name, |
|
|
|
Image: this.formData.Image, |
|
|
|
type: this.formData.type, |
|
|
|
image: this.formData.image, |
|
|
|
shopClass: this.formData.shopClass, |
|
|
|
details: this.formData.details, |
|
|
|
status: this.formData.status || 0, |
|
|
|
} |
|
|
|
|
|
|
|
if(this.id){ |
|
|
|
workData.id = this.id |
|
|
|
} |
|
|
|
|
|
|
|
await this.$fetch('saveOrUpdateBook', workData) |
|
|
|
|
|
|
|
// 延迟返回上一页 |
|
|
@ -240,6 +284,8 @@ |
|
|
|
.form-item { |
|
|
|
margin-bottom: 30rpx; |
|
|
|
position: relative; |
|
|
|
border-bottom: 1rpx solid #00000012; |
|
|
|
padding-bottom: 10rpx; |
|
|
|
|
|
|
|
&:last-child { |
|
|
|
margin-bottom: 0; |
|
|
@ -260,13 +306,10 @@ |
|
|
|
input, |
|
|
|
textarea { |
|
|
|
width: 100%; |
|
|
|
height: 80rpx; |
|
|
|
background-color: #F5F5F5; |
|
|
|
border-radius: 8rpx; |
|
|
|
padding: 20rpx; |
|
|
|
font-size: 28rpx; |
|
|
|
color: #333; |
|
|
|
box-sizing: border-box; |
|
|
|
position: relative; |
|
|
|
z-index: 1; |
|
|
|
} |
|
|
@ -323,6 +366,22 @@ |
|
|
|
font-size: 28rpx; |
|
|
|
color: #999; |
|
|
|
} |
|
|
|
|
|
|
|
.category-tags { |
|
|
|
display: flex; |
|
|
|
gap: 10rpx; |
|
|
|
|
|
|
|
.category-tag { |
|
|
|
padding: 8rpx 16rpx; |
|
|
|
background-color: #F5F5F5; |
|
|
|
border-radius: 8rpx; |
|
|
|
|
|
|
|
&.active { |
|
|
|
background-color: #001351; |
|
|
|
color: #FFFFFF; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|