绘智AI相机

main
gongdi 11 months ago
parent 515a5a6680
commit 529086f842

@ -89,3 +89,30 @@ export const aiWriting = (params: any) => {
data: params,
});
};
//ai音乐 https://www.hzkjai.com/QingLong/HuiYa/wxWenToMusic
export const aiMusic = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxWenToMusic",
data: params,
});
};
//ai视频 https://www.hzkjai.com/QingLong/HuiYa/wxWenToVideo
export const aiVideo = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxWenToVideo",
data: params,
});
};
//生成订单 https://www.hzkjai.com/QingLong/HuiYa/createOrderV3
export const createOrder = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/createOrderV3",
data: params,
});
};

@ -102,6 +102,17 @@
}
}
]
},
{
"root": "pages/my/recharge",
"pages": [
{
"path": "recharge",
"style": {
"navigationBarTitleText": "充值中心"
}
}
]
}
],
"tabBar": {

@ -0,0 +1,59 @@
import { reactive } from "vue";
import { aiMusic } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const { safeAreaInsets } = uni.getSystemInfoSync();
const data: any = reactive({
token: token,
safeBottom: safeAreaInsets?.bottom,
btnLoading: false,
describe: "", //描述
inputValueLength: 0, //内容长度
});
//输入内容改变
function inputChange(e: any) {
data.inputValueLength = parseInt(e.length);
}
//立即生成
function toMake() {
if (data.describe == "") {
uni.showToast({
title: "请输入音乐内容描述",
icon: "none",
duration: 2000,
});
return;
}
const param = {
token: data.token,
prompt: data.describe,
};
data.btnLoading = true;
uni.showLoading({
title: "生成中...",
mask: true,
});
aiMusic(param).then((res: any) => {
uni.hideLoading();
data.btnLoading = false;
if (res.success) {
data.aiResult = res.message;
} else {
uni.showToast({
title: res.message,
icon: "none",
duration: 2000,
});
}
});
}
return {
data,
toMake,
inputChange,
};
}

@ -1 +1,144 @@
<template>ai音乐</template>
<template>
<view
class="aiwriting-container"
:style="'padding-bottom:' + data.safeBottom + 'px'"
>
<view class="content">
<view class="writing-content border-radius">
<view class="title">
音乐内容描述
<view class="jin-dou-style">
消耗200
<image
style="width: 32rpx; height: 32rpx"
src="../../static/jd.png"
mode="scaleToFill"
/>
</view>
</view>
<uni-easyinput
:inputBorder="false"
autoHeight
:maxlength="200"
v-model="data.describe"
type="textarea"
@input="inputChange"
placeholder="请输入音乐内容描述"
/>
<view class="num-style"
>{{ data.inputValueLength ? data.inputValueLength : 0 }}/200</view
>
</view>
<view class="example-content">
<view class="example-title">
<view class="flag"></view>
演示样例</view
>
<view class="writing-content border-radius">
<view class="title"> 音乐描述一首关于整夜跳舞的流行歌曲 </view>
<view class="video-example">
<video
style="width: 100%; height: 100%"
:show-fullscreen-btn="false"
src="http://hzkc.oss-cn-beijing.aliyuncs.com/Images/temp/demoMusic.mp4"
controls
></video>
</view>
</view>
</view>
</view>
<button
:disabled="data.btnLoading"
:loading="data.btnLoading"
class="make-btn-style"
@click="toMake"
>
立即生成
</button>
</view>
</template>
<script setup lang="ts">
import getData from "./aiMusic";
const { data, toMake, inputChange } = getData();
</script>
<style lang="scss" scoped>
.aiwriting-container {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: $uni-spacing-col-base;
.content {
width: 100%;
height: calc(100% - 92rpx);
padding-bottom: $uni-spacing-col-base;
overflow-y: scroll;
box-sizing: border-box;
.writing-content {
width: 100%;
height: auto;
background-color: white;
box-sizing: border-box;
padding: $uni-spacing-col-base;
margin-bottom: $uni-spacing-col-base;
.title {
width: 100%;
height: 80rpx;
font-size: $uni-font-size-lg;
font-weight: bold;
border-bottom: 1px solid $uni-border-color;
display: flex;
justify-content: space-between;
align-items: center;
padding-right: $uni-spacing-col-base;
box-sizing: border-box;
margin-bottom: $uni-spacing-col-base;
.jin-dou-style {
color: #ffd100;
}
}
.result-content {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.num-style {
width: 100%;
display: flex;
justify-content: flex-end;
align-items: center;
font-size: $uni-font-size-sm;
color: $uni-text-color-disable;
}
.video-example {
width: 100%;
height: 300rpx;
}
}
.example-content {
width: 100%;
height: auto;
.example-title {
width: 100%;
height: 50rpx;
display: flex;
align-items: center;
font-size: $uni-font-size-lg;
font-weight: bold;
margin-bottom: 10rpx;
.flag {
width: 10rpx;
height: 35rpx;
border-radius: 10rpx;
background-color: $uni-color-primary;
margin-right: 10rpx;
}
}
}
}
.make-btn-style {
width: 100%;
height: 92rpx;
line-height: 92rpx;
}
}
</style>

@ -0,0 +1,59 @@
import { reactive } from "vue";
import { aiVideo } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const { safeAreaInsets } = uni.getSystemInfoSync();
const data: any = reactive({
token: token,
safeBottom: safeAreaInsets?.bottom,
btnLoading: false,
describe: "", //描述
inputValueLength: 0, //内容长度
});
//输入内容改变
function inputChange(e: any) {
data.inputValueLength = parseInt(e.length);
}
//立即生成
function toMake() {
if (data.describe == "") {
uni.showToast({
title: "请输入视频内容描述",
icon: "none",
duration: 2000,
});
return;
}
const param = {
token: data.token,
prompt: data.describe,
};
data.btnLoading = true;
uni.showLoading({
title: "生成中...",
mask: true,
});
aiVideo(param).then((res: any) => {
uni.hideLoading();
data.btnLoading = false;
if (res.success) {
data.aiResult = res.message;
} else {
uni.showToast({
title: res.message,
icon: "none",
duration: 2000,
});
}
});
}
return {
data,
toMake,
inputChange,
};
}

@ -1 +1,144 @@
<template>ai视频</template>
<template>
<view
class="aiwriting-container"
:style="'padding-bottom:' + data.safeBottom + 'px'"
>
<view class="content">
<view class="writing-content border-radius">
<view class="title">
视频内容描述
<view class="jin-dou-style">
消耗200
<image
style="width: 32rpx; height: 32rpx"
src="../../static/jd.png"
mode="scaleToFill"
/>
</view>
</view>
<uni-easyinput
:inputBorder="false"
autoHeight
:maxlength="200"
v-model="data.describe"
type="textarea"
@input="inputChange"
placeholder="请输入视频内容描述"
/>
<view class="num-style"
>{{ data.inputValueLength ? data.inputValueLength : 0 }}/200</view
>
</view>
<view class="example-content">
<view class="example-title">
<view class="flag"></view>
演示样例</view
>
<view class="writing-content border-radius">
<view class="title"> 视频描述1个女孩走在街上 </view>
<view class="video-example">
<video
style="width: 100%; height: 100%"
:show-fullscreen-btn="false"
src="http://hzkc.oss-cn-beijing.aliyuncs.com/Images/temp/demoVideo.mp4"
controls
></video>
</view>
</view>
</view>
</view>
<button
:disabled="data.btnLoading"
:loading="data.btnLoading"
class="make-btn-style"
@click="toMake"
>
立即生成
</button>
</view>
</template>
<script setup lang="ts">
import getData from "./aiVideo";
const { data, toMake, inputChange } = getData();
</script>
<style lang="scss" scoped>
.aiwriting-container {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: $uni-spacing-col-base;
.content {
width: 100%;
height: calc(100% - 92rpx);
padding-bottom: $uni-spacing-col-base;
overflow-y: scroll;
box-sizing: border-box;
.writing-content {
width: 100%;
height: auto;
background-color: white;
box-sizing: border-box;
padding: $uni-spacing-col-base;
margin-bottom: $uni-spacing-col-base;
.title {
width: 100%;
height: 80rpx;
font-size: $uni-font-size-lg;
font-weight: bold;
border-bottom: 1px solid $uni-border-color;
display: flex;
justify-content: space-between;
align-items: center;
padding-right: $uni-spacing-col-base;
box-sizing: border-box;
margin-bottom: $uni-spacing-col-base;
.jin-dou-style {
color: #ffd100;
}
}
.result-content {
width: 100%;
display: flex;
flex-wrap: wrap;
}
.num-style {
width: 100%;
display: flex;
justify-content: flex-end;
align-items: center;
font-size: $uni-font-size-sm;
color: $uni-text-color-disable;
}
.video-example {
width: 100%;
height: 300rpx;
}
}
.example-content {
width: 100%;
height: auto;
.example-title {
width: 100%;
height: 50rpx;
display: flex;
align-items: center;
font-size: $uni-font-size-lg;
font-weight: bold;
margin-bottom: 10rpx;
.flag {
width: 10rpx;
height: 35rpx;
border-radius: 10rpx;
background-color: $uni-color-primary;
margin-right: 10rpx;
}
}
}
}
.make-btn-style {
width: 100%;
height: 92rpx;
line-height: 92rpx;
}
}
</style>

@ -1,9 +1,8 @@
import { reactive, ref } from "vue";
import { reactive } from "vue";
import { aiWriting } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const { safeAreaInsets } = uni.getSystemInfoSync();
const pickerPopup: any = ref(null);
const platFormRange = [
{ id: 1, value: "小红书" },
@ -81,7 +80,7 @@ export default function () {
data.aiResult = res.message;
} else {
uni.showToast({
title: "生成失败",
title: res.message,
icon: "none",
duration: 2000,
});
@ -107,7 +106,6 @@ export default function () {
data,
toMake,
inputChange,
pickerPopup,
platFormRange,
platformChange,
sizeValueRnage,

@ -69,7 +69,7 @@ export default function () {
});
const init = async () => {
if (!token) {
if (!data.token || data.token == "") {
const info: any = await wxLogin();
data.token = info.token;
}
@ -98,10 +98,18 @@ export default function () {
? data.hotList[0].model_id
: "";
} else {
uni.showToast({
icon: "none",
title: "热门推荐获取失败!",
});
if (res.message.indexOf("token过期") > -1) {
uni.removeStorageSync("token");
uni.removeStorageSync("id");
uni.removeStorageSync("imgCache");
data.token = "";
init();
} else {
uni.showToast({
icon: "none",
title: "热门推荐获取失败!",
});
}
}
});
}
@ -138,16 +146,26 @@ export default function () {
//ai音乐
function toAiMusic() {
uni.navigateTo({
url: "/pages/home/aiMusic/aiMusic",
//敬请期待
uni.showToast({
icon: "none",
title: "敬请期待!",
});
// uni.navigateTo({
// url: "/pages/home/aiMusic/aiMusic",
// });
}
//ai视频
function toAiVideo() {
uni.navigateTo({
url: "/pages/home/aiVideo/aiVideo",
//敬请期待
uni.showToast({
icon: "none",
title: "敬请期待!",
});
// uni.navigateTo({
// url: "/pages/home/aiVideo/aiVideo",
// });
}
return {

@ -64,11 +64,19 @@ export default function () {
});
}
//到充值中心
function toRecharge() {
uni.navigateTo({
url: "/pages/my/recharge/recharge",
});
}
return {
data,
logout,
toPayAgree,
toPrivacyAgree,
toChangeRecord,
toRecharge,
};
}

@ -1,6 +1,8 @@
<template>
<view class="my-container">
<view class="banner"></view>
<view class="banner">
<view @click="toRecharge"></view>
</view>
<view class="item-list">
<view class="row-item border-radius" @click="toChangeRecord">
<text>金豆变更记录</text>
@ -23,7 +25,8 @@
</template>
<script setup lang="ts">
import getData from "./my";
const { data, logout, toPayAgree, toPrivacyAgree, toChangeRecord } = getData();
const { data, logout, toPayAgree, toPrivacyAgree, toChangeRecord, toRecharge } =
getData();
</script>
<style scoped lang="scss">

@ -0,0 +1,133 @@
import { reactive } from "vue";
import { createOrder } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const { safeAreaInsets } = uni.getSystemInfoSync();
const { screenWidth } = uni.getWindowInfo();
const payList = [
{ id: 1, rmb: 1, jinDou: 10 },
{ id: 2, rmb: 5, jinDou: 50 },
{ id: 3, rmb: 10, jinDou: 100 },
{ id: 4, rmb: 20, jinDou: 200 },
{ id: 5, rmb: 50, jinDou: 500 },
];
const data = reactive({
safeBottom: safeAreaInsets?.bottom,
btnLoading: false,
itemWidth: Math.floor((screenWidth - 40) / 3), //支付按钮适配宽度
paySelect: 1, //默认1元 索引
payRmb: 1, //默认1元
token: token,
});
//支付协议
function toPayAgree() {
uni.navigateTo({
url: "/pages/my/agreement/payAgree",
});
}
//更改支付金额
function changePaytemp(info: any) {
data.paySelect = info.id;
data.payRmb = info.rmb;
}
//确认支付
const toPay = async () => {
data.btnLoading = true;
uni.showLoading({
title: "请稍等...",
});
const order: any = await createOrderFn();
if (order === "支付失败") {
data.btnLoading = false;
uni.hideLoading();
uni.showToast({
icon: "none",
title: "支付失败!",
});
} else {
const provider: any = await getProviderFn();
if (provider === "服务商获取失败") {
data.btnLoading = false;
uni.hideLoading();
uni.showToast({
icon: "none",
title: "服务商获取失败!",
});
} else {
const orderInfo = {
rmb: data.payRmb,
};
uni.requestPayment({
provider: provider[0],
orderInfo: orderInfo, //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
timeStamp: order.timeStamp,
nonceStr: order.nonceStr,
package: order.packageValue,
signType: order.signType,
paySign: order.paySign,
success: (res: any) => {
data.btnLoading = false;
uni.hideLoading();
uni.showToast({
icon: "none",
title: "支付成功!",
});
},
fail: (res: any) => {
data.btnLoading = false;
uni.hideLoading();
uni.showToast({
icon: "none",
title: "支付失败!",
});
},
});
}
}
};
//服务提供商
function getProviderFn() {
return new Promise((resolve, reject) => {
uni.getProvider({
service: "payment",
success: (res: any) => {
resolve(res.provider);
},
fail: (res: any) => {
reject("服务商获取失败");
},
});
});
}
//创建订单
function createOrderFn() {
const param = {
token: data.token,
total: data.payRmb,
};
return new Promise((resolve, reject) => {
createOrder(param).then((res: any) => {
if (res.success) {
resolve(res.result);
} else {
reject("支付失败");
}
});
});
}
return {
data,
toPayAgree,
toPay,
payList,
changePaytemp,
};
}

@ -0,0 +1,151 @@
<template>
<view
class="recharge-container"
:style="'padding-bottom:' + data.safeBottom + 'px'"
>
<view class="content">
<view class="title">
<view class="flag"></view>
充值套餐
</view>
<view class="pay-list">
<view
:style="
'width:' + data.itemWidth + 'px; height:' + data.itemWidth + 'px'
"
v-for="(item, index) in payList"
:class="
'pay-item border-radius ' +
(item.id === data.paySelect ? ' active' : '') +
((index + 1) % 3 === 0 ? ' margin-right-none' : '')
"
@click="changePaytemp(item)"
:key="item.id"
>
<view class="item-row">
<text>¥ </text>
<text class="font-weight">{{ item.rmb }}</text>
<text class="font-small"> </text>
</view>
<view class="item-row">
<image
style="width: 32rpx; height: 32rpx"
src="../../static/jd.png"
mode="scaleToFill"
/>
<text class="font-weight">{{ item.jinDou }}</text>
<text class="font-small"> 金豆</text>
</view>
</view>
</view>
</view>
<button
:disabled="data.btnLoading"
:loading="data.btnLoading"
class="make-btn-style"
@click="toPay"
>
确认协议并支付 <text>{{ data.payRmb + " 元" }}</text>
</button>
<view class="pay-document"
>支付前请阅读<text class="to-document" @click="toPayAgree"
>支付协议</text
></view
>
</view>
</template>
<script setup lang="ts">
import getData from "./recharge";
const { data, toPay, toPayAgree, payList, changePaytemp } = getData();
</script>
<style lang="scss" scoped>
.recharge-container {
width: 100%;
height: 100%;
padding: $uni-spacing-col-base;
box-sizing: border-box;
.content {
width: 100%;
height: calc(100% - 132rpx);
padding-bottom: $uni-spacing-col-base;
overflow-y: scroll;
box-sizing: border-box;
.title {
width: 100%;
height: 50rpx;
display: flex;
align-items: center;
font-size: $uni-font-size-lg;
font-weight: bold;
margin-bottom: 10rpx;
.flag {
width: 10rpx;
height: 35rpx;
border-radius: 10rpx;
background-color: $uni-color-primary;
margin-right: 10rpx;
}
}
.pay-list {
width: 100%;
height: auto;
padding: $uni-spacing-col-base 0;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
.pay-item {
padding: $uni-spacing-col-base;
box-sizing: border-box;
margin-right: $uni-spacing-col-base;
border: 1px solid $uni-border-color;
margin-bottom: $uni-spacing-col-base;
font-size: $uni-font-size-lg;
.item-row {
width: 100%;
height: 50%;
border-bottom: 1px dashed $uni-border-color;
display: flex;
align-items: center;
justify-content: center;
.font-small {
font-size: $uni-font-size-sm;
margin-left: 5rpx;
}
.font-weight {
font-weight: bold;
margin-left: 5rpx;
}
}
:last-child {
border-bottom: none;
}
}
.margin-right-none {
margin-right: 0;
}
.active {
background-color: #f8f3ff;
border-color: #b8acda;
}
}
}
.make-btn-style {
width: 100%;
height: 92rpx;
line-height: 92rpx;
margin-bottom: 10rpx;
}
.pay-document {
width: 100%;
height: 30rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: $uni-font-size-sm;
.to-document {
color: $uni-color-primary;
}
}
}
</style>
Loading…
Cancel
Save