绘智AI相机

main
gongdi 11 months ago
parent 19fc9009e3
commit 515a5a6680

@ -62,3 +62,30 @@ export const makeImg = (params: any) => {
data: params,
});
};
//获取金豆数量 https://www.hzkjai.com/QingLong/HuiYa/wxGetUserJinDou
export const getJinDouNum = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxGetUserJinDou",
data: params,
});
};
//删除作品图片 https://www.hzkjai.com/QingLong/HuiYa/wxDeleteImage
export const deleteImage = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxDeleteImage",
data: params,
});
};
//ai写作 https://www.hzkjai.com/QingLong/HuiYa/wxWenToWen
export const aiWriting = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxWenToWen",
data: params,
});
};

@ -31,6 +31,39 @@
}
],
"subPackages": [
{
"root": "pages/home/aiWriting",
"pages": [
{
"path": "aiWriting",
"style": {
"navigationBarTitleText": "AI写作"
}
}
]
},
{
"root": "pages/home/aiMusic",
"pages": [
{
"path": "aiMusic",
"style": {
"navigationBarTitleText": "AI音乐"
}
}
]
},
{
"root": "pages/home/aiVideo",
"pages": [
{
"path": "aiVideo",
"style": {
"navigationBarTitleText": "AI视频"
}
}
]
},
{
"root": "pages/make",
"pages": [

@ -0,0 +1,117 @@
import { reactive, ref } 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: "小红书" },
{ id: 2, value: "微信朋友圈" },
];
const sizeValueRnage = [
{ id: 100, value: "100字" },
{ id: 150, value: "150字" },
{ id: 200, value: "200字" },
{ id: 250, value: "250字" },
{ id: 300, value: "300字" },
];
const data: any = reactive({
token: token,
safeBottom: safeAreaInsets?.bottom,
btnLoading: false,
describe: "", //描述
inputValueLength: 0, //内容长度
platform: 1, //平台 1 小红书 2 微信朋友圈
platformStr: "小红书",
platformIndex: 0, //平台索引
sizeValue: 100, //字数 100 150 200 250 300
sizeIndex: 0, //字数索引
sizeStr: "100字", //字数
aiResult: "", //生成结果
});
//输入内容改变
function inputChange(e: any) {
data.inputValueLength = parseInt(e.length);
}
//选择器改变
function platformChange(e: any) {
const value = e.detail.value;
data.platformIndex = parseInt(value);
data.platform = platFormRange[parseInt(value)].id;
data.platformStr = platFormRange[parseInt(value)].value;
}
//选择器改变
function sizeValueChange(e: any) {
const value = e.detail.value;
data.sizeIndex = parseInt(value);
data.sizeValue = sizeValueRnage[parseInt(value)].id;
data.sizeStr = sizeValueRnage[parseInt(value)].value;
}
//立即生成
function toMake() {
if (data.describe == "") {
uni.showToast({
title: "请输入写作内容描述",
icon: "none",
duration: 2000,
});
return;
}
const param = {
token: data.token,
prompt: data.describe,
limit: data.sizeValue,
platform_id: data.platform,
};
data.btnLoading = true;
uni.showLoading({
title: "生成中...",
mask: true,
});
aiWriting(param).then((res: any) => {
uni.hideLoading();
data.btnLoading = false;
if (res.success) {
data.aiResult = res.message;
} else {
uni.showToast({
title: "生成失败",
icon: "none",
duration: 2000,
});
}
});
}
//复制文本
function toCopy() {
uni.setClipboardData({
data: data.aiResult,
success: (res: any) => {
uni.showToast({
title: "复制成功",
icon: "none",
duration: 2000,
});
},
});
}
return {
data,
toMake,
inputChange,
pickerPopup,
platFormRange,
platformChange,
sizeValueRnage,
sizeValueChange,
toCopy,
};
}

@ -0,0 +1,173 @@
<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">
消耗10
<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="param-content border-radius">
<view class="param-row">
<text>类型</text>
<view class="grey-font">
<picker
mode="selector"
:value="data.platformIndex"
:range="platFormRange"
range-key="value"
@change="platformChange"
>
<text>{{ data.platformStr }}</text>
<uni-icons type="right" color="" size="16" />
</picker>
</view>
</view>
<view class="param-row">
<text>字数</text>
<view class="grey-font">
<picker
mode="selector"
:value="data.sizeIndex"
:range="sizeValueRnage"
range-key="value"
@change="sizeValueChange"
>
<text>{{ data.sizeStr }}</text>
<uni-icons type="right" color="" size="16" />
</picker>
</view>
</view>
</view>
<view
v-if="data.aiResult && data.aiResult !== ''"
class="writing-content border-radius"
>
<view class="title"> 结果 </view>
<view class="result-content">{{ data.aiResult }}</view>
<view class="num-style" @click="toCopy"></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 "./aiWriting";
const {
data,
toMake,
inputChange,
platFormRange,
sizeValueRnage,
platformChange,
sizeValueChange,
toCopy,
} = 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;
.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;
}
}
.param-content {
width: 100%;
height: auto;
background-color: white;
margin: $uni-spacing-col-base 0;
padding: 0 $uni-spacing-col-base;
box-sizing: border-box;
.param-row {
width: 100%;
height: 80rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid $uni-border-color;
.grey-font {
color: $uni-text-color-grey;
}
}
:last-child {
border-bottom: none;
}
}
}
.make-btn-style {
width: 100%;
height: 92rpx;
line-height: 92rpx;
}
}
</style>

@ -4,10 +4,11 @@ import { getHotList } from "@/apis/api";
import { wxLogin, saveImgCache } from "@/utils/commonUtil";
export default function () {
const token = uni.getStorageSync("token");
const data: any = reactive({
hotList: [],
modelId: "",
token: "",
token: token,
imgList: [],
imgUrl: "",
pageNum: 1,
@ -53,17 +54,26 @@ export default function () {
data.modelId = modelId;
}
function initPage() {
data.hotList = [];
data.modelId = "";
data.imgList = [];
data.imgUrl = "";
data.pageNum = 1;
data.pageSize = 12;
data.totalPage = 0;
}
onShow(() => {
init();
});
const init = async () => {
const info: any = await wxLogin();
data.pageNum = 1;
data.totalPage = 0;
data.token = info.token;
data.hotList = [];
data.modelId = "";
if (!token) {
const info: any = await wxLogin();
data.token = info.token;
}
initPage();
getHotListFn();
};
@ -74,7 +84,11 @@ export default function () {
limit: data.pageSize,
token: data.token,
};
uni.showLoading({
title: "加载中...",
});
getHotList(param).then((res: any) => {
uni.hideLoading();
if (res.success) {
const dataInfo = res.data;
data.totalPage = dataInfo.totalPage;
@ -115,10 +129,34 @@ export default function () {
});
}
//ai写作
function toAiWriting() {
uni.navigateTo({
url: "/pages/home/aiWriting/aiWriting",
});
}
//ai音乐
function toAiMusic() {
uni.navigateTo({
url: "/pages/home/aiMusic/aiMusic",
});
}
//ai视频
function toAiVideo() {
uni.navigateTo({
url: "/pages/home/aiVideo/aiVideo",
});
}
return {
data,
changeList,
changeModelId,
toMake,
toAiWriting,
toAiMusic,
toAiVideo,
};
}

@ -11,15 +11,15 @@
<view class="part-row large border-radius">
<view class="title">其他应用</view>
<view class="other-content">
<view class="app-item">
<view class="app-item" @click="toAiWriting">
<view class="app-item-img border-radius"></view>
<view class="app-item-title">AI写作</view>
</view>
<view class="app-item">
<view class="app-item" @click="toAiMusic">
<view class="app-item-img border-radius"></view>
<view class="app-item-title">AI音乐</view>
</view>
<view class="app-item">
<view class="app-item" @click="toAiVideo">
<view class="app-item-img border-radius"></view>
<view class="app-item-title">AI视频</view>
</view>
@ -42,6 +42,7 @@
>
</view>
<view class="img-content">
<!-- + '?x-oss-process=image/resize,w_200,limit_0' -->
<view class="first-img border-radius" @click="toMake(0)">
<image
style="width: 100%; height: 100%"
@ -87,7 +88,15 @@
</template>
<script setup lang="ts">
import getData from "./home";
const { data, changeList, changeModelId, toMake } = getData();
const {
data,
changeList,
changeModelId,
toMake,
toAiWriting,
toAiMusic,
toAiVideo,
} = getData();
</script>
<style scoped lang="scss">
.home-container {

@ -1,14 +1,42 @@
import { reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { getJinDouNum } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const data: any = reactive({
startX: 0, // touchstart时的touch.clientX
moveX: 0, // touchmove时的touch.clientX
boxLeft: 85, // move-box的left值
imgLeftWidth: 85,
imgRightWidth: 85,
token: token,
});
onShow(() => {
getJinDouNumFn();
});
//获取金豆数据
function getJinDouNumFn() {
const param = {
token: data.token,
};
uni.showLoading({
title: "加载中...",
});
getJinDouNum(param).then((res: any) => {
uni.hideLoading();
if (res.success) {
data.jinDouNum = res.jd_count;
} else {
uni.showToast({
icon: "none",
title: "金豆获取失败!",
});
}
});
}
function logout() {
uni.removeStorageSync("token");
uni.removeStorageSync("id");

@ -1,13 +1,13 @@
import { reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { getWorkList } from "@/apis/api";
import { onShow, onHide } from "@dcloudio/uni-app";
import { getWorkList, deleteImage } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const data: any = reactive({
pageNum: 1,
pageSize: 10,
totalPage: 0,
imageList: [{}, {}, {}, {}, {}],
imageList: [],
token: token,
loadContent: {
contentdown: "点击加载更多",
@ -15,13 +15,21 @@ export default function () {
contentnomore: "没有更多数据了~",
},
loadStatus: "more",
isPreviewing: false, // 用于标记是否正在预览图片
imgId: "",
});
onShow(() => {
function initPage() {
data.pageNum = 1;
data.totalPage = 0;
data.imageList = [];
getWorkListFn();
}
onShow(() => {
if (!data.isPreviewing) {
initPage();
getWorkListFn();
}
});
//获取作品数据
@ -31,7 +39,11 @@ export default function () {
limit: data.pageSize,
token: data.token,
};
uni.showLoading({
title: "加载中...",
});
getWorkList(param).then((res: any) => {
uni.hideLoading();
if (res.success) {
const dataInfo = res.data;
data.totalPage = dataInfo.totalPage;
@ -65,8 +77,99 @@ export default function () {
}
}
//图片预览
function imgPreview(imgUrl: string) {
if (imgUrl && imgUrl !== "") {
let arr: any = [];
data.imageList.forEach((item: any) => {
if (item.target_img_url) {
arr.push(item.target_img_url);
}
});
let index = arr.findIndex((value: any) => value == imgUrl);
uni.previewImage({
current: index,
urls: arr,
success: () => {
data.isPreviewing = true;
},
fail: () => {
data.isPreviewing = false;
},
complete: () => {
// 无论成功或者失败预览完成后都将其置为false
data.isPreviewing = true;
},
// longPressActions: {
// itemList: ["发送给朋友", "保存图片", "收藏"],
// success: function (data) {
// console.log(
// "选中了第" +
// (data.tapIndex + 1) +
// "个按钮,第" +
// (data.index + 1) +
// "张图片"
// );
// },
// fail: function (err) {
// console.log(err.errMsg);
// },
// },
});
}
}
//删除图片
function toDelete(imgId: any) {
data.imgId = imgId;
uni.showModal({
title: "提示",
content: "确定要删除吗?",
success: (res) => {
if (res.confirm) {
uni.showLoading({
title: "删除中...",
});
deleteImageFn();
// const param = {
// token: data.token,
// target_img_url: data.imageList[data.imageList.length - 1].target_img_url,
// };
// getWorkList(param).then((res: any) => {
// uni.hideLoading();
// })
}
},
});
}
function deleteImageFn() {
const param = {
id: data.imgId,
token: data.token,
};
deleteImage(param).then((res: any) => {
uni.hideLoading();
if (res.success) {
initPage();
getWorkListFn();
} else {
uni.showToast({
icon: "none",
title: "删除失败!",
});
}
});
}
onHide(() => {
data.isPreviewing = false;
});
return {
data,
toUpdateList,
imgPreview,
toDelete,
};
}

@ -11,7 +11,21 @@
v-for="item in data.imageList"
:key="item.id"
>
<image :src="item.source_img_url" style="width: 100%; height: 100%" />
<!-- + '?x-oss-process=image/resize,w_150,limit_0' -->
<image
:src="item.target_img_url"
style="width: 100%; height: 100%"
@click="imgPreview(item.target_img_url)"
mode="scaleToFill"
lazy-load
/>
<uni-icons
type="trash"
color=""
size="24"
class="img-del"
@click="toDelete(item.id)"
/>
</view>
<uni-load-more
class="load-more-container"
@ -25,7 +39,7 @@
<script setup lang="ts">
import getData from "./works";
const { data, toUpdateList } = getData();
const { data, toUpdateList, imgPreview, toDelete } = getData();
</script>
<style lang="scss" scoped>
@ -49,6 +63,13 @@ const { data, toUpdateList } = getData();
height: 500rpx;
border: 1px solid $uni-border-color;
margin-bottom: $uni-spacing-col-base;
position: relative;
.img-del {
position: absolute;
right: 10rpx;
top: 10rpx;
color: $uni-text-color-disable;
}
}
}
}

Loading…
Cancel
Save