249 lines
6.8 KiB
Vue
249 lines
6.8 KiB
Vue
<template>
|
|
<view style="position: relative;">
|
|
<image src="../../static/image/banner_bg.png" style="width: 100%; position: absolute;" mode="widthFix"></image>
|
|
<view class="content" :style="'paddingTop: '+systemBarHeight + 'px; height:' +subtractedHeight+'px'">
|
|
|
|
<view class=""
|
|
style="display: flex; flex-direction: row; height: 45rpx; width: 100%; align-items: center; justify-content: space-between;"
|
|
:style="{ marginTop: systemBarHeight + 'px' }">
|
|
|
|
<img src="/static/image/ic_music.png" style="width: 165.28rpx; height: 40.97rpx; margin-left: 36rpx;"
|
|
alt="" />
|
|
</view>
|
|
|
|
<view class="" style="display: flex; justify-content: start; width: 100%; margin-top: 59rpx;">
|
|
<text style="font-size: 33rpx; color: white; margin-left: 33rpx;">歌词生歌</text>
|
|
</view>
|
|
|
|
|
|
<view class="" style="margin-top: 33rpx;">
|
|
|
|
|
|
<view class=""
|
|
style="background-image: linear-gradient(to left, #a541ffFF, #3fbbfeFF); padding: 1rpx; border-radius: 20rpx;">
|
|
<view class=""
|
|
style="width: 623.33rpx; height: 272.22rpx; padding: 30rpx 30rpx 70rpx 30rpx; border-radius: 20rpx; background-color: #221f35FF;">
|
|
<textarea type="text" style="color: white; width: 100%;" v-model="musicPrompt"
|
|
placeholder="描述歌词的场景" maxlength="500" @input="sumfontnum" />
|
|
<view style="text-align: end; color: white; " class="input_holder"><text
|
|
style="color: white;">{{fontNum}}</text>/500</view>
|
|
|
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="" style="display: flex; justify-content: start; width: 100%; margin-top: 59rpx;">
|
|
<text style="font-size: 33rpx; color: white; margin-left: 33rpx;">音乐风格</text>
|
|
</view>
|
|
|
|
<view class="" style="margin-left: 33rpx; margin-right: 33rpx; display: flex; flex-wrap: wrap;">
|
|
|
|
<view class="" v-for="(item,index) in typeData" @click="clickStyle(index,item.genreName)"
|
|
style="padding: 1rpx; border-radius: 50rpx; margin-top: 25rpx; margin-right: 30rpx;"
|
|
:style="setStyleBg(index)">
|
|
<view class="" style="padding: 6rpx 40rpx 6rpx 40rpx; background-color: #0E0A10FF;
|
|
height: 66.67rpx; display: flex; align-items: center; justify-content: center; border-radius: 50rpx;">
|
|
<text style=" font-size: 29rpx; color: #B5B5B5FF;">{{item.genreName}}</text>
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="" style="display: flex; justify-content: start; width: 100%; margin-top: 59rpx;">
|
|
<text style="font-size: 33rpx; color: white; margin-left: 33rpx;">音乐名称</text>
|
|
</view>
|
|
|
|
<view class=""
|
|
style="width: 683.33rpx; margin-left: 33rpx; margin-right: 33rpx; margin-top: 33rpx; background-image: linear-gradient(to left, #a541ffFF, #3fbbfeFF); padding: 1rpx; border-radius:20rpx;">
|
|
|
|
<view class=""
|
|
style="border-radius:20rpx; background-color: #0E0A10FF; width: 100%; height: 89.58rpx; display: flex; justify-content: center;">
|
|
<input class="uni-input" placeholder="请输入歌名" cursor-color="#FFFFFF" v-model="songTitle"
|
|
style="width: 100%; height: 100%; padding-left: 20rpx; color: white;" />
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="" @click="createMusic()"
|
|
style="width: 683.33rpx; height: 83.33rpx; margin-left: 33rpx; margin-right: 33rpx; margin-top: 50rpx;
|
|
background-image: linear-gradient(to left, #a541ffFF, #3fbbfeFF); padding: 1rpx; border-radius:50rpx; display: flex; align-items: center; justify-content: center;">
|
|
|
|
<text style="font-size: 40rpx; color: white;">立即生成</text>
|
|
|
|
</view>
|
|
<view>
|
|
<!-- 输入框示例 -->
|
|
<uni-popup ref="inputDialog" type="center" background-color="#333333">
|
|
<uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="" placeholder="请输入内容"
|
|
@confirm="dialogInputConfirm"></uni-popup-dialog>
|
|
</uni-popup>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
AppServer
|
|
} from '../../modules/api/AppServer';
|
|
export default {
|
|
data() {
|
|
return {
|
|
systemBarHeight: 0,
|
|
subtractedHeight: 0,
|
|
fontNum: 0,
|
|
musicPrompt: '',
|
|
typeData: [],
|
|
styleIndex: 0,
|
|
songTitle: '',
|
|
genreName: ''
|
|
}
|
|
},
|
|
|
|
onLoad() {
|
|
this.systemBarHeight = getApp().globalData.statusBarHeight;
|
|
this.subtractedHeight = getApp().globalData.windowHeight;
|
|
|
|
this.getMusicGenresInfo();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
sumfontnum(e) {
|
|
this.fontNum = e.detail.cursor
|
|
},
|
|
|
|
clickStyle(index, data) {
|
|
this.styleIndex = index;
|
|
if (data == "自定义") {
|
|
this.$refs.inputDialog.open();
|
|
} else {
|
|
this.genreName = data;
|
|
}
|
|
},
|
|
|
|
//获取音乐风格
|
|
getMusicGenresInfo() {
|
|
var that = this;
|
|
var appserver = new AppServer();
|
|
appserver.GetUserMusicGenresList().then(data => {
|
|
console.log("getMusicGenresInfo", data.data);
|
|
that.typeData = data.data;
|
|
that.genreName = data.data[0].genreName;
|
|
that.typeData.push({
|
|
"genreName": "自定义",
|
|
"orderId": -1,
|
|
"genreType": -1
|
|
})
|
|
});
|
|
},
|
|
|
|
//自定义风格
|
|
createUserMusicGenres(genreName) {
|
|
var that = this;
|
|
var appserver = new AppServer();
|
|
appserver.CreateUserMusicGenres(genreName).then(data => {
|
|
console.log("createUserMusicGenres", data.data);
|
|
if (data.data) {
|
|
this.getMusicGenresInfo();
|
|
}
|
|
});
|
|
},
|
|
|
|
//创建音乐
|
|
createMusic() {
|
|
if (this.musicPrompt == "") {
|
|
uni.showToast({
|
|
title: '提示词不能为空',
|
|
icon: 'error',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
if (this.songTitle == "") {
|
|
uni.showToast({
|
|
title: '歌曲名称不能为空',
|
|
icon: 'error',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
|
|
uni.showLoading({
|
|
title: '加载中'
|
|
});
|
|
|
|
|
|
var that = this;
|
|
var appserver = new AppServer();
|
|
appserver.CreateMusic(this.genreName, this.musicPrompt, this.songTitle).then(data => {
|
|
console.log("CreateMusic", data.data);
|
|
uni.hideLoading();
|
|
if (data.code == 0) {
|
|
uni.navigateTo({
|
|
url: '/pages/create/CreateInfoPage?id=' + data.data
|
|
});
|
|
} else {
|
|
uni.showToast({
|
|
title: data.message,
|
|
icon: 'error',
|
|
duration: 2000
|
|
});
|
|
}
|
|
|
|
});
|
|
},
|
|
|
|
|
|
//设置背景
|
|
setStyleBg(index) {
|
|
if (this.styleIndex == index) {
|
|
return {
|
|
backgroundImage: "linear-gradient(to left, #a541ffFF, #3fbbfeFF)"
|
|
}
|
|
} else {
|
|
return {
|
|
backgroundImage: "linear-gradient(to left, #919191FF, #919191FF)"
|
|
}
|
|
}
|
|
},
|
|
|
|
dialogInputConfirm(value) {
|
|
if (value == "") {
|
|
uni.showToast({
|
|
title: '输入不能为空',
|
|
icon: 'error',
|
|
duration: 2000
|
|
});
|
|
return;
|
|
}
|
|
this.createUserMusicGenres(value)
|
|
// this.typeData.unshift(value);
|
|
// this.styleIndex = 0;
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.content {
|
|
width: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
background-color: #0E0A10;
|
|
}
|
|
|
|
input {
|
|
caret-color: #fff;
|
|
}
|
|
</style> |