Browse Source

feature:1.0:添加自定义标签功能

feature-1.0
Penny 3 years ago
parent
commit
80041b0973
  1. 1
      App.vue
  2. 9
      api/userInfo.js
  3. 7
      pages.json
  4. 4
      pages/index/banner.vue
  5. 263
      pages/index/upload/customSign.vue
  6. 119
      pages/index/upload/upload.vue
  7. 9
      pages/userInfo/userInfo.vue

1
App.vue

@ -25,7 +25,6 @@
background-color: $uni-bg-color;
}
/* #endif */
.example-info {
font-size: 14px;
color: #333;

9
api/userInfo.js

@ -187,5 +187,14 @@ export function getCreatorInfoFansLike(creatorId) {
})
}
// 艺术家自定义标签
export function creatorSign(data) {
return request({
url: `${serviceTitle}${prefix}/creatorSign`,
method: 'post',
data
})
}

7
pages.json

@ -16,6 +16,13 @@
}
}, {
"path": "pages/index/upload/customSign",
"style": {
"navigationBarTitleText": "自定义标签",
"enablePullDownRefresh": false
}
},
{
"path": "pages/index/material/material",
"style": {
"navigationBarTitleText": "素材管理",

4
pages/index/banner.vue

@ -1,6 +1,6 @@
<template>
<view>
我是banner页面
<view class="uni-wrap">
我是banner
</view>
</template>

263
pages/index/upload/customSign.vue

@ -0,0 +1,263 @@
<template>
<view class="container">
<view class="head">
<view>
<uni-group mode="card">
<uni-icons custom-prefix="iconfont" type="icon-dengpao" :color="primaryColor" size="20"></uni-icons><text class="textstyle text-white"></text><br/>
<text class="textstyle">1. 艺术家们可在下方列表选择一个标签当作自定义标签的父标签</text><br/>
<text class="textstyle">2. 自定义标签的父标签一次仅可选择一个</text><br/>
<text class="textstyle">3. 自定义标签长度最长8个字符</text><br/>
<text class="textstyle">4. 一次性推荐最多创建5个自定义标签</text><br/>
<text class="textstyle">5. 每个标签顿号隔开太阳</text><br/>
<text class="textstyle">6. 自定义标签审核通过后即有机会展示在图片上传界面</text><br/>
<text class="textstyle">7. 大胆发挥你们的想象尽情开始创作吧</text><br/>
</uni-group>
</view>
<view>
<uni-group mode="card">
<view class="section-content">
<view class="segmented-control">
<uni-data-checkbox mode="tag" v-model="signListSelected" :localdata="signList" @change="selectedSign" max="1"></uni-data-checkbox>
</view>
</view>
</uni-group>
<uni-group mode="card">
<uni-forms validate-trigger='blur' :modelValue="signCustomList" label-position="top" labelWidth="80" ref="form">
<uni-forms-item label="标签名" required name="name">
<uni-easyinput v-model="signCustomList.name" placeholder="请选择一个父标签并输入自定义标签名" :clearable="false" :inputBorder="false" trim="all" :maxlength="50"/>
</uni-forms-item>
</uni-forms>
</uni-group>
<view>
<button class="confirmBtn" size="default" @click="$noMultipleClicks(creatorSign)">确定添加</button>
</view>
</view>
</view>
</view>
</template>
<script>
import {
getSignList
} from '@/api/index.js'
import {
creatorSign
} from '@/api/userInfo.js'
export default {
data() {
return {
primaryColor: '#0b6375',
signList:[],
signListSelected: undefined,
noClick:true, //
signCustomList:{
name: undefined
},
rules:{
name:{
rules: [{
required: true,
errorMessage: '请输入自定义标签'
}]
}
}
}
},
mounted() {
//
this.$refs.form.setRules(this.rules);
},
created() {
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo) {
console.log('havent userInfo')
uni.showModal({
content: '艺术家账户过期,请重新登录!',
showCancel: false,
success() {
//
uni.reLaunch({
url: '/pages/login/login'
});
}
});
} else {
this.userInfo = userInfo;
console.log('have userInfo')
}
this.getSignList();
},
methods: {
//
selectedSign(e){
let that = this;
that.signListSelected = e.detail.value;
//console.log('that.signListSelected',that.signListSelected);
},
//
async getSignList(){
let that = this;
const res = await getSignList({})
if (res.data.code === 200) {
for (let s of res.data.data) {
let signObject = {}
signObject.text = "#" +s.name
signObject.value = s.id
that.signList.push(signObject)
}
} else {
uni.showModal({
content: '标签列表加载失败!',
showCancel: false
});
}
},
//
creatorSign(){
const that = this;
if(that.signCustomList.name == null || that.signCustomList.name == '' || that.signCustomList.name == "" || that.signCustomList.name == undefined){
uni.showModal({
content: '请输入自定义标签名!',
showCancel: false
});
}else if(that.signListSelected == null || that.signListSelected == undefined){
uni.showModal({
content: '请选择父标签后再编辑!',
showCancel: false
});
}else{
uni.showLoading({
title: "添加中",
mask: true,
success() {
let param = {
name: that.signCustomList.name,
parentId: that.signListSelected
}
creatorSign(param).then(res =>{
if (res.data.code === 200) {
uni.hideLoading();
//
that.signCustomList.name = undefined,
that.signListSelected = undefined,
//
uni.reLaunch({
url: '/pages/index/upload/upload',
success() {
uni.showToast({
title: '添加成功!',
icon: 'success',
duration: 1500
})
}
});
}else{
uni.hideLoading();
uni.showModal({
content: res.data.msg,
showCancel: false,
success() {
//
that.signCustomList.name = undefined
}
});
}
});
}
});
}
}
}
}
</script>
<style lang="scss" scoped>
.container {
width: 670rpx;
height: 100vh;
margin: 0 auto;
position: relative;
}
.textstyle{
font-size: 26rpx;
color: $uni-secondary-color;
padding-top: 10rpx;
padding-bottom: 40rpx;
}
.text-white {
color: $uni-white !important;
}
.section-content {
width: 654rpx;
margin: 0 auto;
}
.segmented-control {
::v-deep .checklist-box {
border: none !important;
background: none !important;
margin-right: 0 !important;
}
::v-deep .checklist-text {
color: $uni-secondary-color !important;
font-size: 24rpx !important;
}
::v-deep .is-checked .checklist-text {
color: $uni-primary !important;
font-size: 24rpx !important;
}
::v-deep .is-disable .checklist-text {
color: $uni-base-color !important;
font-size: 24rpx !important;
}
}
.head {
::v-deep .uni-group--card {
margin: 0 0 40rpx 0 !important;
background: $uni-bg-base-color;
}
::v-deep .uni-tag {
border-width: 2rpx !important;
}
::v-deep .uni-forms-item__label {
color: $uni-white;
}
::v-deep input {
background: $uni-bg-base-color !important;
border: 0 !important;
color: $uni-white !important;
}
::v-deep .uni-file-picker__header {
.file-title {
font-size: 24rpx;
color: #999;
}
.file-count {
font-size: 24rpx;
color: #999;
}
}
}
</style>

119
pages/index/upload/upload.vue

@ -1,42 +1,49 @@
<template>
<view class="page-content">
<uni-section title="选择图片分类上传" type="circle">
</uni-section>
<view class="section-content">
<view class="type-choice-comp">
<view class="type-item uni-secondary-color" v-for="(val, i) in typeList"
:index="i" :key="i"
:class="typeCurrent === i ? 'type-active' : ''"
@click="$noMultipleClicks(onClickType,{currentIndex: i})"
>
<view class="type-text">{{val}}</view>
</view>
</view>
<uni-file-picker limit="9" title="最多选择9张图片"
:file-extname="fileExtname" mode="grid"
file-mediatype="image"
@success="successHandler"
@fail="failHandler"
@delete="deleteHandler"
:autoUpload="false"
@select="selectHandler"
:disabled="checkUpload">
</uni-file-picker>
<view class="uploadNum">今日还可上传次数<span class="uploadText"> {{ getUploadNum }} </span>已上传次数<span class="uploadText"> {{ uploadedNum }} </span></view>
</view>
<uni-section title="是否原创" subTitle="非原创则视为网络图片" type="circle">
<view class="original-item-list">
<uni-data-checkbox multiple v-model="original" :localdata="originalList" :selectedColor="primaryColor" :selectedTextColor="primaryColor"></uni-data-checkbox>
</view>
</uni-section>
<uni-section title="选择图片标签" subTitle="最多选择3个" type="circle">
</uni-section>
<view class="section-content">
<view class="segmented-control">
<uni-data-checkbox mode="tag" multiple v-model="signListSelected" :localdata="signList" @change="selectedSign" max="3"></uni-data-checkbox>
</view>
</view>
<button class="upLoadBtn" size="default" :loading="loadingFlag" @click="$noMultipleClicks(commit)" :disabled="checkUpload">点击上传</button>
<uni-section title="选择图片分类上传" type="circle">
</uni-section>
<view class="section-content">
<view class="type-choice-comp">
<view class="type-item uni-secondary-color" v-for="(val, i) in typeList"
:index="i" :key="i"
:class="typeCurrent === i ? 'type-active' : ''"
@click="$noMultipleClicks(onClickType,{currentIndex: i})">
<view class="type-text">{{val}}</view>
</view>
</view>
<uni-file-picker limit="9" title="最多选择9张图片"
:file-extname="fileExtname" mode="grid"
file-mediatype="image"
@success="successHandler"
@fail="failHandler"
@delete="deleteHandler"
:autoUpload="false"
@select="selectHandler"
:disabled="checkUpload">
</uni-file-picker>
<view class="uploadNum">今日还可上传次数<span class="uploadText"> {{ getUploadNum }} </span>已上传次数<span class="uploadText"> {{ uploadedNum }} </span></view>
</view>
<uni-section title="是否原创" subTitle="非原创则视为网络图片" type="circle">
<view class="original-item-list">
<uni-data-checkbox multiple v-model="original" :localdata="originalList" :selectedColor="primaryColor" :selectedTextColor="primaryColor"></uni-data-checkbox>
</view>
</uni-section>
<view class="sign-box">
<uni-section title="选择图片标签" subTitle="最多选择3个" type="circle" class="sign-item">
</uni-section>
<view class="sign-item-box">
<button plain="true" size="mini" type="default" class="sign-item-tag" @click="linkTo">自定义标签</button>
</view>
</view>
<view class="section-content">
<view class="segmented-control">
<uni-data-checkbox mode="tag" multiple v-model="signListSelected" :localdata="signList" @change="selectedSign" max="3" class="check-box"></uni-data-checkbox>
</view>
</view>
<button class="upLoadBtn" size="default" :loading="loadingFlag" @click="$noMultipleClicks(commit)" :disabled="checkUpload" >点击上传</button>
</view>
</template>
@ -107,6 +114,13 @@
},
methods: {
//
linkTo(){
uni.navigateTo({
url: '/pages/index/upload/customSign'
});
},
//
async getSignList(){
let that = this;
@ -375,10 +389,36 @@
}
.sign-box{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
width:750rpx;
.sign-item{
z-index: 0;
width: 300rpx;
}
.sign-item-box{
margin-right: 50rpx;
margin-top: 15rpx;
z-index: 0;
.sign-item-tag{
color: #fff;
}
.custom-sign{
z-index: 0;
}
}
}
.section-content {
width: 654rpx;
margin: 0 auto;
}
.type-choice-comp {
@ -442,6 +482,7 @@
.segmented-control {
::v-deep .checklist-box {
border: none !important;
background: none !important;
@ -474,9 +515,9 @@
color: $uni-btn-text-color;
border-radius: 20rpx;
font-size: 28rpx;
z-index: 0;
}
}
</style>

9
pages/userInfo/userInfo.vue

@ -14,6 +14,9 @@
<view class="username uni-white">
{{userInfo.name}}
</view>
<view class="scanCode uni-white">
<view>搜索码 {{userInfo.scanCode}}</view>
</view>
<view class="user-info uni-secondary-color">
<view class="nums-item">粉丝 <span class="num-span uni-white">{{creatorFansLikeInfo.fansNum}}</span> </view>
<view class="nums-item">点赞 <span class="num-span uni-white">{{creatorFansLikeInfo.likeNum}}</span> </view>
@ -239,6 +242,12 @@ page {
font-weight: 600;
}
.scanCode{
font-size: 30rpx;
line-height: 60rpx;
font-weight: 100;
}
.user-info {
display: flex;
justify-content: flex-start;

Loading…
Cancel
Save