magicsound/pages/create/createpage.vue
2024-09-19 17:25:38 +08:00

188 lines
5.6 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="inputData"
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)"
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}}</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="toCreateInfo()"
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>
export default {
data() {
var typeData = ['爵士', '民谣', '流行', '古风', '车载', '摇滚', '自定义'];
return {
systemBarHeight: 0,
subtractedHeight: 0,
fontNum: 0,
inputData: '',
typeData,
styleIndex: 0,
songTitle: ''
}
},
onLoad() {
this.getStatusBarHeight();
this.getSubtractedHeight();
},
methods: {
// 获取状态栏高度的方法
getStatusBarHeight: function() {
var that = this;
uni.getSystemInfo({
success: function(res) {
that.systemBarHeight = res.statusBarHeight
}
});
},
getSubtractedHeight() {
const systemInfo = uni.getSystemInfoSync();
const screenWidth = systemInfo.screenWidth;
const windowHeight = systemInfo.windowHeight;
console.log("windowHeight", windowHeight);
// 将167rpx转换为px
const rpxToPx = (rpx) => (rpx * screenWidth) / 750;
// this.subtractedHeight = windowHeight - rpxToPx(167);
this.subtractedHeight = windowHeight;
console.log("subtractedHeight", this.subtractedHeight);
},
sumfontnum(e) {
this.fontNum = e.detail.cursor
},
clickStyle(index, data) {
this.styleIndex = index;
if (data == "自定义") {
this.$refs.inputDialog.open();
}
},
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) {
this.typeData.unshift(value);
this.styleIndex = 0;
},
toCreateInfo() {
uni.navigateTo({
url: '/pages/create/CreateInfoPage'
});
}
}
}
</script>
<style>
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
background-color: #0E0A10;
}
input {
caret-color: #fff;
}
</style>