绘智AI相机

main
gongdi 11 months ago
parent 98a0236762
commit e8639604be

@ -1,9 +1,8 @@
<script setup lang="ts">
import { onLaunch } from "@dcloudio/uni-app";
import { wxLogin } from "@/utils/commonUtil.ts";
// import { wxLogin } from "@/utils/commonUtil.ts";
onLaunch(() => {
wxLogin();
//wxLogin();
});
</script>
<style></style>

@ -8,3 +8,48 @@ export const getWxId = (params: any) => {
data: params,
});
};
//获取首页热门推荐
export const getHotList = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxGetTjModelList",
data: params,
});
};
//获取作品数据
export const getWorkList = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxGetTaskImage",
data: params,
});
};
//金豆消耗记录
export const getChangeRecord = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxGetJournal",
data: params,
});
};
//获取制作同款model图片
export const getModelToMake = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxGetModelPrompt",
data: params,
});
};
//获取历史相
export const getImgHistory = (params: any) => {
return http({
method: "POST",
url: "/QingLong/HuiYa/wxUserImgHistory",
data: params,
});
};

@ -1,5 +1,7 @@
import { createSSRApp } from "vue";
import App from "./App.vue";
import "./style/common.scss";
export function createApp() {
const app = createSSRApp(App);
return {

@ -12,7 +12,9 @@
{
"path": "pages/home/home",
"style": {
"navigationBarTitleText": "绘智AI相机"
"navigationBarTitleText": "绘智AI相机",
"navigationBarBackgroundColor": "#707070",
"navigationBarTextStyle": "white"
}
},
{
@ -28,7 +30,50 @@
}
}
],
"subPackages": [
{
"root": "pages/make",
"pages": [
{
"path": "make",
"style": {
"navigationBarTitleText": "制作同款"
}
}
]
},
{
"root": "pages/my/agreement",
"pages": [
{
"path": "payAgree",
"style": {
"navigationBarTitleText": "支付协议"
}
},
{
"path": "privacyAgree",
"style": {
"navigationBarTitleText": "隐私协议"
}
}
]
},
{
"root": "pages/my/changeRecord",
"pages": [
{
"path": "changeRecord",
"style": {
"navigationBarTitleText": "变更记录"
}
}
]
}
],
"tabBar": {
"color": "#999999",
"selectedColor": "#3663e4",
"list": [
{
"text": "首页",

@ -0,0 +1,139 @@
import { reactive, watch } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { getHotList } from "@/apis/api";
import { wxLogin, saveImgCache } from "@/utils/commonUtil";
export default function () {
const data: any = reactive({
hotList: [],
modelId: "",
token: "",
imgList: [],
imgUrl: "",
pageNum: 1,
pageSize: 12,
totalPage: 0,
});
watch(
() => data.modelId,
(n) => {
if (n) {
//先查本地缓存 [{modelId:1,imgList:[url1,url2,...]},{modelId:2,imgList:[url1,url2,...]},...]
const imgCache = uni.getStorageSync("imgCache");
if (imgCache) {
const cacheModel = imgCache.find((item: any) => item.modelId == n);
if (cacheModel) {
data.imgList = cacheModel.imgList;
} else {
selectCloudList(n);
}
} else {
selectCloudList(n);
}
}
}
);
function selectCloudList(n: any) {
const selectModel = data.hotList.find((item: any) => item.model_id == n);
const imgList = [];
if (selectModel) {
imgList.push(selectModel.img_url);
selectModel.listImg.forEach((item: any) => {
imgList.push(item.img_url);
});
data.imgList = imgList;
saveImgCache(n, imgList);
}
}
//切换分类
function changeModelId(modelId: any) {
data.modelId = modelId;
}
onShow(() => {
init();
});
const init = async () => {
const info: any = await wxLogin();
data.token = info.token;
getHotListFn();
};
//获取热门推荐
function getHotListFn() {
const param = {
page: data.pageNum,
limit: data.pageSize,
token: data.token,
};
getHotList(param).then((res: any) => {
if (res.success) {
const dataInfo = res.data;
data.totalPage = dataInfo.totalPage;
data.hotList = dataInfo.list;
data.modelId =
data.hotList && data.hotList.length > 0
? data.hotList[0].model_id
: "";
} else {
uni.showToast({
icon: "none",
title: "热门推荐获取失败!",
});
}
});
}
function changeList() {
data.pageNum = data.pageNum == data.totalPage ? 1 : data.pageNum + 1;
getHotListFn();
}
const toUpload = () => {
uni.chooseImage({
count: 1,
success: (res) => {
console.log(res);
},
complete: (res) => {
console.log("complete", res);
data.imgUrl = res.tempFilePaths[0];
},
});
};
function loadImg() {
console.log("加载完成");
}
//到制作同款页面
function toMake(index: number) {
const model = data.hotList.find((item: any) => {
return item.model_id == data.modelId;
});
let promptId = "";
if (model) {
if (index == 0) {
promptId = model.prompt_id;
} else {
promptId = model.listImg[index - 1].prompt_id;
}
}
uni.navigateTo({
url: "/pages/make/make?modelId=" + data.modelId + "&promptId=" + promptId,
});
}
return {
data,
toUpload,
changeList,
changeModelId,
loadImg,
toMake,
};
}

@ -1,20 +1,210 @@
<template>
<uni-card title="首页"> </uni-card>
<button @click="getDataList()"></button>
<view class="home-container">
<view class="home-content">
<view class="banner"></view>
<view class="content">
<view class="part-row border-radius"></view>
<view class="part-col border-radius"></view>
<view class="part-col border-radius"></view>
<view class="part-col border-radius"></view>
<view class="part-col border-radius"></view>
<view class="part-row large border-radius">
<view class="title">其他应用</view>
<view class="other-content">
<view class="app-item">
<view class="app-item-img border-radius"></view>
<view class="app-item-title">AI写作</view>
</view>
<view class="app-item">
<view class="app-item-img border-radius"></view>
<view class="app-item-title">AI音乐</view>
</view>
<view class="app-item">
<view class="app-item-img border-radius"></view>
<view class="app-item-title">AI视频</view>
</view>
</view>
</view>
<view class="part-row large border-radius">
<view class="title">
热门推荐
<view class="change-list" @click="changeList"
>换一批<uni-icons type="refreshempty"
/></view>
</view>
<view class="hot-list">
<view
class="hot-model border-radius"
v-for="item in data.hotList"
@click="changeModelId(item.model_id)"
:key="item.model_id"
>{{ item.model_name }}</view
>
</view>
<view class="img-content">
<view class="first-img border-radius" @click="toMake(0)">
<image
style="width: 100%; height: 100%"
:src="data.imgList[0]"
mode="scaleToFill"
/>
</view>
<view class="other-imgs">
<view class="other-img border-radius" @click="toMake(1)"
><image
style="width: 100%; height: 100%"
lazy-load
:src="data.imgList[1]"
mode="scaleToFill"
/></view>
<view class="other-img border-radius" @click="toMake(2)"
><image
style="width: 100%; height: 100%"
lazy-load
:src="data.imgList[2]"
mode="scaleToFill"
/></view>
<view class="other-img border-radius" @click="toMake(3)"
><image
style="width: 100%; height: 100%"
lazy-load
:src="data.imgList[3]"
mode="scaleToFill"
/></view>
<view class="other-img border-radius" @click="toMake(4)"
><image
style="width: 100%; height: 100%"
lazy-load
:src="data.imgList[4]"
mode="scaleToFill"
/></view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
onLoad() {
console.log("主页");
},
methods: {
getDataList() {
const token = uni.getStorageSync("token");
console.log("token:", token);
},
},
};
<script setup lang="ts">
import getData from "./home";
const { data, changeList, changeModelId, toMake } = getData();
</script>
<style></style>
<style scoped lang="scss">
.home-container {
width: 100%;
height: 100%;
background-color: #707070;
position: relative;
.home-content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow-y: scroll;
.content {
width: 100%;
height: auto;
padding: 0 $uni-spacing-col-base;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
.part-row {
width: 100%;
height: 220rpx;
background-color: white;
margin-bottom: $uni-spacing-col-base;
}
.large {
height: auto;
min-height: 280rpx;
.title {
width: 100%;
display: flex;
align-items: center;
height: 80rpx;
padding: 0 $uni-spacing-row-base;
margin-bottom: $uni-spacing-col-base;
justify-content: space-between;
box-sizing: border-box;
.change-list {
font-size: $uni-font-size-sm;
color: $uni-text-color-grey;
}
}
.hot-list {
display: flex;
flex-wrap: wrap;
justify-content: space-evenly;
padding: 0 $uni-spacing-col-base;
.hot-model {
background-color: $uni-border-color;
padding: 10rpx 30rpx;
font-size: $uni-font-size-sm;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: $uni-spacing-col-base;
margin-right: 2px;
}
}
.img-content {
width: 100%;
height: auto;
display: flex;
padding: $uni-spacing-row-base;
box-sizing: border-box;
justify-content: space-between;
.first-img {
width: calc(50% - 10rpx);
height: 500rpx;
border: 1px solid $uni-border-color;
}
.other-imgs {
width: calc(50% - 10rpx);
height: 500rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-content: space-between;
.other-img {
width: calc(50% - 10rpx);
height: 240rpx;
border: 1px solid $uni-border-color;
}
}
}
.other-content {
width: 100%;
height: auto;
display: flex;
justify-content: space-evenly;
.app-item {
width: 100rpx;
height: 150rpx;
.app-item-img {
width: 100rpx;
height: 100rpx;
border: 1px solid $uni-border-color;
}
.app-item-title {
width: 100rpx;
height: 50rpx;
line-height: 50rpx;
text-align: center;
font-size: $uni-font-size-sm;
}
}
}
}
.part-col {
width: calc(50% - 10rpx);
height: 260rpx;
background-color: white;
margin-bottom: $uni-spacing-col-base;
}
}
}
}
</style>

@ -0,0 +1,27 @@
import { reactive } from "vue";
export default function () {
const data: any = reactive({
boxLeft: 85, // move-box的left值
});
function clickMove(e: any) {
const touch = e.touches[0];
let pageX = touch.pageX;
if (pageX < 0) {
pageX = 0;
}
if (pageX > 170) {
pageX = 170;
}
data.boxLeft = pageX;
e.preventDefault();
}
return {
data,
clickMove,
};
}

@ -0,0 +1,70 @@
<template>
<view class="image-compare">
<view
class="image-container-bottom"
:style="{ width: data.boxLeft + 'px' }"
>
<image class="repair-img" src="../../static/logo.png" />
</view>
<view class="image-container-top">
<image class="repair-img" src="../../static/user.jpg" />
</view>
<view
class="drag-container move-box"
@touchmove="clickMove"
:style="{ left: data.boxLeft + 'px' }"
>
<view class="drag-line">
<image
style="width: 100%; height: 100%"
class="repair-img"
src="../../static/logo.png"
/>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import getData from "./convert";
const { data, clickMove } = getData();
</script>
<style scoped lang="scss">
.image-compare {
width: 170px;
height: 250px;
display: flex;
position: relative;
.image-container-bottom {
width: 85px;
height: 250px;
z-index: 999;
overflow: hidden;
.repair-img {
width: 170px;
height: 250px;
}
}
.image-container-top {
width: 170px;
height: 250px;
position: absolute;
top: 0;
right: 0;
.repair-img {
width: 100%;
height: 100%;
}
}
.drag-container {
width: 2px;
height: 250px;
background-color: red;
position: absolute;
.drag-line {
width: 20px;
height: 20px;
}
}
}
</style>

@ -0,0 +1,95 @@
import { reactive } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { getModelToMake, getImgHistory } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const data: any = reactive({
moduleId: "",
promptId: "",
token: token,
modelImg: "", //模版图片
modelTitle: "", //模版标题
memoList: [], //模版描述
starNum: 0, //消耗金豆数量
pageNum: 1,
pageSize: 10,
totalPage: 0,
imgHistoryList: [],
loadContent: {
contentdown: "点击加载更多",
contentrefresh: "正在加载...",
contentnomore: "没有更多数据了~",
},
loadStatus: "more",
});
onLoad((options: any) => {
data.moduleId = options.modelId;
data.promptId = options.promptId;
getModelToMakeFn();
getImgHistoryFn();
});
//获取模板数据
function getModelToMakeFn() {
const param = {
model_id: data.moduleId,
prompt_id: data.promptId,
token: data.token,
};
getModelToMake(param).then((res: any) => {
if (res.success) {
data.modelImg = res.img_url;
data.modelTitle = res.record.model_name;
data.starNum = res.record.star;
const memo = res.record.memo;
if (memo && memo !== "") {
data.memoList = memo.split("。");
}
} else {
uni.showToast({
icon: "none",
title: "数据获取失败!",
});
}
});
}
//获取历史相册
function getImgHistoryFn() {
const param = {
page: data.pageNum,
limit: data.pageSize,
token: data.token,
};
getImgHistory(param).then((res: any) => {
if (res.success) {
data.imgHistoryList = res.data;
// changeLoadStatus();
} else {
//changeLoadStatus();
uni.showToast({
icon: "none",
title: "历史相册数据获取失败!",
});
}
});
}
//改变底部loading状态
// function changeLoadStatus() {
// if (data.pageNum == data.totalPage || data.totalPage == 0) {
// data.loadStatus = "no-more";
// } else {
// data.loadStatus = "more";
// }
// }
//立即制作
function toMake() {}
return {
data,
toMake,
};
}

@ -0,0 +1,169 @@
<template>
<view class="make-container">
<view class="content">
<view class="model-content border-radius">
<view class="model-image border-radius">
<image :src="data.modelImg" style="width: 100%; height: 100%"></image>
</view>
<view class="model-info">
<view class="model-title">{{ data.modelTitle }}</view>
<view class="model-tips">
<uni-icons
type="info-filled"
class="tips-icon"
color=""
size="20"
/>
<text>注意事项</text>
</view>
<view class="tips-content">
<view class="memo-tips" v-for="memo in data.memoList" :key="memo">{{
memo
}}</view>
</view>
<view class="bot-right">
<text>{{ "消耗:" + data.starNum }}</text>
<image
style="width: 28rpx; height: 28rpx"
src="../../static/jd.png"
mode="scaleToFill"
/>
</view>
</view>
</view>
<view class="part-title">
<view class="flag"></view>
上传照片
</view>
<button class="make-btn-style">
<uni-icons type="plusempty" color="" size="24" />
</button>
<view class="part-title">
<view class="flag"></view>
历史相册
</view>
<view class="img-history">
<image
v-for="img in data.imgHistoryList"
:key="img.source_img_url"
:src="img.source_img_url"
style="width: 160rpx; height: 160rpx"
/>
</view>
</view>
<button @click="toMake" class="make-btn-style">立即制作</button>
</view>
</template>
<script setup lang="ts">
import getData from "./make";
const { data, toMake } = getData();
</script>
<style scoped lang="scss">
.make-container {
width: 100%;
height: 100%;
position: relative;
padding: $uni-spacing-col-base;
box-sizing: border-box;
.content {
width: 100%;
height: calc(100% - 112rpx);
.model-content {
width: 100%;
height: 550rpx;
background-color: white;
padding: $uni-spacing-col-base;
box-sizing: border-box;
display: flex;
margin-bottom: $uni-spacing-col-base;
.model-image {
width: 340rpx;
height: 100%;
overflow: hidden;
}
.model-info {
flex: 1;
height: 100%;
padding-left: $uni-spacing-col-base;
box-sizing: border-box;
position: relative;
.model-title {
width: 100%;
font-size: $uni-font-size-lg;
font-weight: bold;
margin-bottom: 10rpx;
display: flex;
flex-wrap: wrap;
}
.model-tips {
width: 100%;
height: 50rpx;
display: flex;
align-items: center;
color: $uni-color-warning;
margin: 10rpx 0;
.tips-icon {
margin-left: -5rpx;
}
text {
font-weight: bold;
}
}
.tips-content {
width: 100%;
height: auto;
font-size: $uni-font-size-base;
color: $uni-text-color-grey;
.memo-tips {
width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap;
margin-bottom: 10rpx;
}
}
.bot-right {
position: absolute;
bottom: 0;
right: 0;
color: #ffd100;
font-size: $uni-font-size-base;
font-weight: bold;
}
}
}
.part-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;
}
}
.img-history {
width: 100%;
height: auto;
background-color: white;
padding: $uni-spacing-col-base;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}
.make-btn-style {
width: 100%;
height: 92rpx;
line-height: 92rpx;
margin-bottom: $uni-spacing-col-base;
}
}
</style>

@ -0,0 +1,69 @@
<!-- 支付协议 -->
<template>
<view class="agreement-container">
<view class="title">微信小程序支付协议</view>
<view class="s-title">介绍</view>
<view class="content"
>您正在使用的微信小程序以下简称本小程序是由绘智科技提供我们在此小程序中提供各类功能服务部分功能服务需要您支付一定的费用</view
>
<view class="s-title">支付方式</view>
<view class="content"
>本小程序中的功能服务的支付方式为微信支付购买服务后费用将无法退还</view
>
<view class="s-title">价格</view>
<view class="content"
>服务的价格将在购买前明确告知并在您确认购买后从您的微信支付账户中扣除</view
>
<view class="s-title">服务内容</view>
<view class="content"
>您支付的费用是对我们提供的功能服务的报酬具体服务内容将在购买服务前明确告知</view
>
<view class="s-title">退款政策</view>
<view class="content"
>除非法律明确规定或本协议另有规定否则一旦购买费用将不予退还</view
>
<view class="s-title">法律责任</view>
<view class="content"
>本小程序在法律允许的范围内对因使用支付服务产生的任何直接间接附带的损失不承担责任</view
>
<view class="s-title">协议变更</view>
<view class="content"
>我们保留随时修改本隐私协议的权利修改后的协议将在本小程序内公布</view
>
<view class="connection">客服QQ:10402852</view>
</view>
</template>
<style lang="scss" scoped>
.agreement-container {
width: 100%;
height: 100%;
overflow-y: scroll;
padding: $uni-spacing-col-base;
box-sizing: border-box;
.title {
text-align: center;
font-size: 36rpx;
font-weight: bold;
}
.s-title {
font-size: 32rpx;
font-weight: bolder;
margin: 10rpx 0 0 20rpx;
}
.content {
font-size: 28rpx;
margin: 10rpx 0 0 20rpx;
}
.connection {
font-size: 32rpx;
text-align: end;
margin: 100rpx 20rpx 0 0;
font-weight: bold;
}
}
</style>

@ -0,0 +1,65 @@
<!-- 隐私协议 -->
<template>
<view class="agreement-container">
<view class="title">微信小程序隐私协议</view>
<view class="s-title">介绍</view>
<view class="content"
>您正在使用的微信小程序以下简称本小程序是由我们提供的我们在此小程序中提供人像照片转卡通照片的功能服务此功能服务需要您上传一张人像照片</view
>
<view class="s-title">数据收集</view>
<view class="content"
>在您使用本小程序的过程中我们将收集您上传的人像照片数据我们收集这些数据是为了提供和改善我们的服务</view
>
<view class="s-title">数据使用</view>
<view class="content"
>我们承诺我们收集的数据仅用于提供和改善我们的服务不会公开也不会用于其它用途</view
>
<view class="s-title">数据保护</view>
<view class="content"
>我们将采取一切合理必要的措施来保护您的数据防止未经您许可的访问使用或泄露</view
>
<view class="s-title">用户权利</view>
<view class="content"
>您有权随时查看更正和删除我们持有的您的数据如果您有任何问题可以随时联系我们</view
>
<view class="s-title">协议变更</view>
<view class="content"
>我们保留随时修改本隐私协议的权利修改后的协议将在本小程序内公布</view
>
<view class="connection">客服QQ:10402852</view>
</view>
</template>
<style lang="scss" scoped>
.agreement-container {
width: 100%;
height: 100%;
overflow-y: scroll;
padding: $uni-spacing-col-base;
box-sizing: border-box;
.title {
text-align: center;
font-size: 36rpx;
font-weight: bold;
}
.s-title {
font-size: 32rpx;
font-weight: bolder;
margin: 10rpx 0 0 20rpx;
}
.content {
font-size: 28rpx;
margin: 10rpx 0 0 20rpx;
}
.connection {
font-size: 32rpx;
text-align: end;
margin: 100rpx 20rpx 0 0;
font-weight: bold;
}
}
</style>

@ -0,0 +1,71 @@
import { reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { getChangeRecord } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const data: any = reactive({
pageNum: 1,
pageSize: 10,
totalPage: 0,
recordList: [],
token: token,
loadContent: {
contentdown: "点击加载更多",
contentrefresh: "正在加载...",
contentnomore: "没有更多数据了~",
},
loadStatus: "more",
});
onShow(() => {
data.recordList = [];
getChangeRecordFn();
});
//获取金豆变更记录
function getChangeRecordFn() {
const param = {
page: data.pageNum,
limit: data.pageSize,
token: data.token,
};
getChangeRecord(param).then((res: any) => {
if (res.success) {
const dataInfo = res.data;
data.totalPage = dataInfo.totalPage;
data.recordList.push(...dataInfo.list);
changeLoadStatus();
} else {
changeLoadStatus();
uni.showToast({
icon: "none",
title: "数据获取失败!",
});
}
});
}
//改变底部loading状态
function changeLoadStatus() {
if (data.pageNum == data.totalPage || data.totalPage == 0) {
data.loadStatus = "no-more";
} else {
data.loadStatus = "more";
}
}
//更新页面数据
function toUpdateList() {
if (data.loadStatus === "more") {
data.loadStatus = "loading";
data.pageNum += 1;
getChangeRecordFn();
}
}
return {
data,
toUpdateList,
};
}

@ -0,0 +1,90 @@
<template>
<view class="change-record-container">
<scroll-view
scroll-y
enable-flex
class="works-scroll-container"
@scrolltolower="toUpdateList"
>
<view
class="record-info"
v-for="record in data.recordList"
:key="record.id"
>
<!-- 动作充值 -->
<view v-if="record.type_id == 1">
<view class="row-style">动作充值</view>
<view class="row-style">时间{{ record.happen_time }}</view>
<view class="row-style">充值金额{{ record.total }} </view>
<view class="row-style"
>充值后金豆数{{ record.after_jd_count }} </view
>
<view class="row-style"
>充值前金豆数{{ record.before_jd_count }} </view
>
</view>
<!-- 动作金豆消耗 -->
<view v-if="record.type_id == 2">
<view class="row-style">动作金豆消耗</view>
<view class="row-style">时间{{ record.happen_time }}</view>
<view class="row-style">本次消耗金豆{{ record.jd_count }} </view>
<view class="row-style"
>消耗后金豆数{{ record.after_jd_count }} </view
>
<view class="row-style"
>消耗前金豆数{{ record.before_jd_count }} </view
>
</view>
<!-- 动作生成失败金豆返回 -->
<view v-if="record.type_id == 3">
<view class="row-style">动作生成失败金豆返回</view>
<view class="row-style">时间{{ record.happen_time }}</view>
<view class="row-style">本次返回金豆{{ record.jd_count }} </view>
<view class="row-style"
>返回后金豆数{{ record.after_jd_count }} </view
>
<view class="row-style"
>返回前金豆数{{ record.before_jd_count }} </view
>
</view>
</view>
<uni-load-more
class="load-more-container"
:status="data.loadStatus"
:contentText="data.loadContent"
@clickLoadMore="toUpdateList"
/>
</scroll-view>
</view>
</template>
<script lang="ts" setup>
import getData from "./changeRecord";
const { data, toUpdateList } = getData();
</script>
<style lang="scss" scoped>
.change-record-container {
width: 100%;
height: 100%;
position: relative;
.works-scroll-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
padding: $uni-spacing-col-base;
box-sizing: border-box;
.record-info {
width: 100%;
border-bottom: 1px solid $uni-border-color;
margin-bottom: $uni-spacing-col-base;
.row-style {
width: 100%;
height: 50rpx;
display: flex;
align-items: center;
}
}
}
}
</style>

@ -0,0 +1,46 @@
import { reactive } from "vue";
export default function () {
const data: any = reactive({
startX: 0, // touchstart时的touch.clientX
moveX: 0, // touchmove时的touch.clientX
boxLeft: 85, // move-box的left值
imgLeftWidth: 85,
imgRightWidth: 85,
});
function logout() {
uni.removeStorageSync("token");
uni.removeStorageSync("id");
uni.removeStorageSync("imgCache");
}
//支付协议
function toPayAgree() {
uni.navigateTo({
url: "/pages/my/agreement/payAgree",
});
}
//隐私协议
function toPrivacyAgree() {
uni.navigateTo({
url: "/pages/my/agreement/privacyAgree",
});
}
//金豆变更记录
function toChangeRecord() {
uni.navigateTo({
url: "/pages/my/changeRecord/changeRecord",
});
}
return {
data,
logout,
toPayAgree,
toPrivacyAgree,
toChangeRecord,
};
}

@ -1,9 +1,53 @@
<template>
我的
<view class="my-container">
<view class="banner"></view>
<view class="item-list">
<view class="row-item border-radius" @click="toChangeRecord">
<text>金豆变更记录</text>
<uni-icons type="right" color="" size="16" />
</view>
<view class="row-item border-radius" @click="toPayAgree">
<text>支付协议</text>
<uni-icons type="right" color="" size="16" />
</view>
<view class="row-item border-radius" @click="toPrivacyAgree">
<text>隐私协议</text>
<uni-icons type="right" color="" size="16" />
</view>
<view class="row-item border-radius">
<text>退出</text>
<uni-icons type="right" color="" size="16" />
</view>
</view>
</view>
</template>
<script>
<script setup lang="ts">
import getData from "./my";
const { data, logout, toPayAgree, toPrivacyAgree, toChangeRecord } = getData();
</script>
<style>
</style>
<style scoped lang="scss">
.my-container {
width: 100%;
height: 100%;
position: relative;
font-size: $uni-font-size-base;
.item-list {
width: 100%;
height: auto;
padding: 0 $uni-spacing-col-base;
box-sizing: border-box;
}
.row-item {
width: 100%;
height: 80rpx;
background-color: white;
display: flex;
align-items: center;
justify-content: space-between;
padding: $uni-spacing-col-lg $uni-spacing-col-base;
box-sizing: border-box;
margin-top: $uni-spacing-col-lg;
}
}
</style>

@ -0,0 +1,70 @@
import { reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { getWorkList } from "@/apis/api";
export default function () {
const token = uni.getStorageSync("token");
const data: any = reactive({
pageNum: 1,
pageSize: 10,
totalPage: 0,
imageList: [],
token: token,
loadContent: {
contentdown: "点击加载更多",
contentrefresh: "正在加载...",
contentnomore: "没有更多数据了~",
},
loadStatus: "more",
});
onShow(() => {
data.imageList = [];
getWorkListFn();
});
//获取作品数据
function getWorkListFn() {
const param = {
page: data.pageNum,
limit: data.pageSize,
token: data.token,
};
getWorkList(param).then((res: any) => {
if (res.success) {
const dataInfo = res.data;
data.totalPage = dataInfo.totalPage;
data.imageList.push(...dataInfo.list);
changeLoadStatus();
} else {
changeLoadStatus();
uni.showToast({
icon: "none",
title: "数据获取失败!",
});
}
});
}
//更新页面数据
function toUpdateList() {
if (data.loadStatus === "more") {
data.loadStatus = "loading";
data.pageNum += 1;
getWorkListFn();
}
}
//改变底部loading状态
function changeLoadStatus() {
if (data.pageNum == data.totalPage || data.totalPage == 0) {
data.loadStatus = "no-more";
} else {
data.loadStatus = "more";
}
}
return {
data,
toUpdateList,
};
}

@ -1,9 +1,54 @@
<template>
作品
<view class="works-container">
<scroll-view
scroll-y
enable-flex
class="works-scroll-container"
@scrolltolower="toUpdateList"
>
<view
class="work-image border-radius"
v-for="item in data.imageList"
:key="item.id"
>
</view>
<uni-load-more
class="load-more-container"
:status="data.loadStatus"
:contentText="data.loadContent"
@clickLoadMore="toUpdateList"
/>
</scroll-view>
</view>
</template>
<script>
<script setup lang="ts">
import getData from "./works";
const { data, toUpdateList } = getData();
</script>
<style>
</style>
<style lang="scss" scoped>
.works-container {
width: 100%;
height: 100%;
position: relative;
.works-scroll-container {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
padding: $uni-spacing-col-base;
box-sizing: border-box;
flex-wrap: wrap;
justify-content: space-between;
.work-image {
width: calc(50% - 10rpx);
height: 500rpx;
border: 1px solid $uni-border-color;
margin-bottom: $uni-spacing-col-base;
}
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

@ -0,0 +1,24 @@
page {
width: 100%;
height: 100%;
background-color: #f5f5f5;
box-sizing: border-box;
font-size: $uni-font-size-base;
}
.border-radius {
border-radius: 20rpx;
overflow: hidden;
}
.banner {
width: 100%;
height: 200rpx;
}
.load-more-container {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

@ -41,7 +41,7 @@ $uni-border-color: #c8c7cc;
/* 文字尺寸 */
$uni-font-size-sm: 12px;
$uni-font-size-base: 14px;
$uni-font-size-lg: 16;
$uni-font-size-lg: 16px;
/* 图片尺寸 */
$uni-img-size-sm: 20px;
@ -61,7 +61,7 @@ $uni-spacing-row-lg: 15px;
/* 垂直间距 */
$uni-spacing-col-sm: 4px;
$uni-spacing-col-base: 8px;
$uni-spacing-col-base: 10px;
$uni-spacing-col-lg: 12px;
/* 透明度 */
@ -73,4 +73,4 @@ $uni-font-size-title: 20px;
$uni-color-subtitle: #555; //
$uni-font-size-subtitle: 18px;
$uni-color-paragraph: #3f536e; //
$uni-font-size-paragraph: 15px;
$uni-font-size-paragraph: 15px;

@ -1,34 +1,76 @@
import { getWxId } from "../apis/api.js";
//登录获取、持久化 id token
export function wxLogin() {
uni.login({
success(res) {
if (res.code) {
getWxId({
code: res.code,
}).then((wxInfo: any) => {
if (wxInfo.success) {
uni.setStorageSync("token", wxInfo.token);
uni.setStorageSync("id", wxInfo.id);
} else {
uni.showToast({
icon: "fail",
title: "用户信息获取失败!",
});
}
});
} else {
return new Promise((resolve, reject) => {
uni.login({
success(res) {
if (res.code) {
getWxId({
code: res.code,
}).then((wxInfo: any) => {
if (wxInfo.success) {
uni.setStorageSync("token", wxInfo.token);
uni.setStorageSync("id", wxInfo.id);
resolve(wxInfo);
} else {
uni.showToast({
icon: "fail",
title: "用户信息获取失败!",
});
reject();
}
});
} else {
uni.showToast({
icon: "fail",
title: "登录失败!",
});
reject();
}
},
fail() {
uni.showToast({
icon: "fail",
title: "登录失败!",
});
}
},
fail() {
uni.showToast({
icon: "fail",
title: "登录失败!",
});
},
reject();
},
});
});
}
//图片本地缓存处理 imgCache [{modelId:1,imgList:[url1,url2,...]},{modelId:2,imgList:[url1,url2,...]},...]
export function saveImgCache(modelId: any, imgList: any) {
Promise.all([
pro(imgList[0]),
pro(imgList[1]),
pro(imgList[2]),
pro(imgList[3]),
pro(imgList[4]),
]).then((res) => {
const imgCache = uni.getStorageSync("imgCache");
if (imgCache && imgCache.length > 0) {
imgCache.push({ modelId: modelId, imgList: res });
uni.setStorageSync("imgCache", imgCache);
} else {
uni.setStorageSync("imgCache", [{ modelId: modelId, imgList: res }]);
}
});
}
//转存本地路径
const pro = (url: string) => {
return new Promise((resolve) => {
uni.downloadFile({
url: url,
success: (res: any) => {
uni.getFileSystemManager().saveFile({
tempFilePath: res.tempFilePath,
success: (saveRes: any) => {
resolve(saveRes.savedFilePath);
},
});
},
});
});
};

Loading…
Cancel
Save