support archive moment to exist journal
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
/* pages/main/journal-list/index.wxss */
|
||||
@ -1,66 +0,0 @@
|
||||
// pages/main/journal-list/index.ts
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
@ -1,2 +0,0 @@
|
||||
<!--pages/main/journal-list/index.wxml-->
|
||||
<text>pages/main/journal-list/index.wxml</text>
|
||||
@ -1,10 +1,15 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"t-cell": "tdesign-miniprogram/cell/cell",
|
||||
"t-popup": "tdesign-miniprogram/popup/popup",
|
||||
"t-radio": "tdesign-miniprogram/radio/radio",
|
||||
"t-dialog": "tdesign-miniprogram/dialog/dialog",
|
||||
"t-navbar": "tdesign-miniprogram/navbar/navbar",
|
||||
"t-button": "tdesign-miniprogram/button/button",
|
||||
"t-checkbox": "tdesign-miniprogram/checkbox/checkbox",
|
||||
"t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
|
||||
"journal-list": "../../../components/journal-list/index",
|
||||
"t-radio-group": "tdesign-miniprogram/radio-group/radio-group"
|
||||
}
|
||||
},
|
||||
"styleIsolation": "shared"
|
||||
}
|
||||
@ -102,66 +102,87 @@
|
||||
}
|
||||
}
|
||||
|
||||
.t-popup--bottom {
|
||||
padding-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.archive-popup {
|
||||
|
||||
.container {
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
background: var(--td-bg-color-container);
|
||||
flex-direction: column;
|
||||
border-top-left-radius: 16rpx;
|
||||
border-top-right-radius: 16rpx;
|
||||
|
||||
&.select-journal {
|
||||
max-height: 80vh;
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&.form {
|
||||
|
||||
.content {
|
||||
padding: 16rpx 32rpx;
|
||||
|
||||
.section {
|
||||
width: 100%;
|
||||
margin-top: 1.5rem;
|
||||
|
||||
.label {
|
||||
color: var(--theme-text-secondary);
|
||||
}
|
||||
|
||||
&.type {
|
||||
display: flex;
|
||||
|
||||
.radio {
|
||||
margin-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
&.time {
|
||||
display: flex;
|
||||
|
||||
.picker {
|
||||
margin-right: .25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 116rpx;
|
||||
|
||||
border-bottom: 1px solid var(--td-component-stroke);
|
||||
|
||||
.title {
|
||||
flex: 1;
|
||||
color: var(--td-text-color-primary);
|
||||
font-size: 36rpx;
|
||||
text-align: center;
|
||||
font-weight: 600;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.placeholder {
|
||||
width: 128rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin: 0 .5rem;
|
||||
|
||||
|
||||
&.back,
|
||||
&.cancel {
|
||||
color: var(--td-text-color-secondary);
|
||||
}
|
||||
|
||||
&.confirm {
|
||||
color: var(--theme-success);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 16rpx 32rpx;
|
||||
|
||||
.section {
|
||||
width: 100%;
|
||||
margin-top: 1.5rem;
|
||||
|
||||
.label {
|
||||
color: var(--theme-text-secondary);
|
||||
}
|
||||
|
||||
&.type {
|
||||
display: flex;
|
||||
|
||||
.radio {
|
||||
margin-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
&.time {
|
||||
display: flex;
|
||||
|
||||
.picker {
|
||||
margin-right: .25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ type MD5Result = {
|
||||
md5: string;
|
||||
}
|
||||
|
||||
type ArchiveStep = "select-type" | "select-journal" | "form";
|
||||
|
||||
interface MomentData {
|
||||
list: Item[];
|
||||
type: string;
|
||||
@ -42,6 +44,8 @@ interface MomentData {
|
||||
uploadProgress: number;
|
||||
isAuthLocation: boolean;
|
||||
isVisibleArchivePopup: boolean;
|
||||
archiveStep: ArchiveStep;
|
||||
selectedJournalId: number | null;
|
||||
}
|
||||
|
||||
Page({
|
||||
@ -60,7 +64,9 @@ Page({
|
||||
uploadTotal: "0 MB",
|
||||
uploadProgress: 0,
|
||||
isAuthLocation: false,
|
||||
isVisibleArchivePopup: false
|
||||
isVisibleArchivePopup: false,
|
||||
archiveStep: "select-type",
|
||||
selectedJournalId: null
|
||||
},
|
||||
async onLoad() {
|
||||
this.fetch();
|
||||
@ -163,7 +169,7 @@ Page({
|
||||
preview(e: WechatMiniprogram.BaseEvent) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
const total = this.data.list.length;
|
||||
|
||||
|
||||
const startIndex = Math.max(0, index - 25);
|
||||
const endIndex = Math.min(total, startIndex + 50);
|
||||
const newCurrentIndex = index - startIndex;
|
||||
@ -240,7 +246,7 @@ Page({
|
||||
});
|
||||
// 过滤文件
|
||||
const filterPath = md5Results.filter(item => filterMD5Result.indexOf(item.md5) !== -1)
|
||||
.map(item => item.path);
|
||||
.map(item => item.path);
|
||||
files = files.filter(file => filterPath.indexOf(file.tempFilePath) !== -1);
|
||||
if (files.length === 0) {
|
||||
wx.hideLoading();
|
||||
@ -295,7 +301,7 @@ Page({
|
||||
});
|
||||
uploadResolve(result.data[0].id);
|
||||
} else {
|
||||
uploadReject(new Error(`文件上传失败: ${result?.message || '未知错误'}`));
|
||||
uploadReject(new Error(`文件上传失败: ${result?.message || "未知错误"}`));
|
||||
}
|
||||
},
|
||||
fail: (err) => uploadReject(new Error(`文件上传失败: ${err.errMsg}`))
|
||||
@ -375,6 +381,47 @@ Page({
|
||||
}
|
||||
})
|
||||
},
|
||||
showArchivePopup() {
|
||||
this.setData({
|
||||
isVisibleArchivePopup: true,
|
||||
archiveStep: "select-type",
|
||||
selectedJournalId: null
|
||||
});
|
||||
},
|
||||
onArchiveToNew() {
|
||||
this.setData({
|
||||
archiveStep: "form",
|
||||
selectedJournalId: null
|
||||
});
|
||||
},
|
||||
onArchiveToExisting() {
|
||||
this.setData({
|
||||
archiveStep: "select-journal",
|
||||
selectedJournalId: null
|
||||
});
|
||||
},
|
||||
onJournalListSelect(e: any) {
|
||||
const { id } = e.detail;
|
||||
this.setData({
|
||||
selectedJournalId: id
|
||||
});
|
||||
},
|
||||
onJournalListConfirm() {
|
||||
if (this.data.selectedJournalId) {
|
||||
this.archiveChecked();
|
||||
}
|
||||
},
|
||||
onJournalListCancel() {
|
||||
this.setData({
|
||||
archiveStep: "select-type",
|
||||
selectedJournalId: null
|
||||
});
|
||||
},
|
||||
onNewJournalBack() {
|
||||
this.setData({
|
||||
archiveStep: "select-type"
|
||||
});
|
||||
},
|
||||
toggleArchivePopup() {
|
||||
this.setData({
|
||||
isVisibleArchivePopup: !this.data.isVisibleArchivePopup
|
||||
@ -434,22 +481,26 @@ Page({
|
||||
fail: handleFail
|
||||
});
|
||||
});
|
||||
const archiveData: any = {
|
||||
type: this.data.type,
|
||||
idea: this.data.idea,
|
||||
lat: this.data.location?.lat,
|
||||
lng: this.data.location?.lng,
|
||||
location: this.data.location?.text,
|
||||
pusher: openId,
|
||||
thumbIds: this.data.list.filter(item => item.checked).map(item => item.id)
|
||||
};
|
||||
// 如果选择了已存在的记录,添加 id 参数
|
||||
if (this.data.selectedJournalId) {
|
||||
archiveData.id = this.data.selectedJournalId;
|
||||
}
|
||||
wx.request({
|
||||
url: `${config.url}/journal/moment/archive`,
|
||||
method: "POST",
|
||||
header: {
|
||||
Key: wx.getStorageSync("key")
|
||||
},
|
||||
data: {
|
||||
type: this.data.type,
|
||||
idea: this.data.idea,
|
||||
createdAt: Date.parse(`${this.data.date} ${this.data.time}`),
|
||||
lat: this.data.location?.lat,
|
||||
lng: this.data.location?.lng,
|
||||
location: this.data.location?.text,
|
||||
pusher: openId,
|
||||
thumbIds: this.data.list.filter(item => item.checked).map(item => item.id)
|
||||
},
|
||||
data: archiveData,
|
||||
success: async (resp: any) => {
|
||||
if (resp.data && resp.data.code === 20000) {
|
||||
Events.emit("JOURNAL_REFRESH");
|
||||
@ -458,11 +509,12 @@ Page({
|
||||
idea: "",
|
||||
list: [],
|
||||
hasChecked: false,
|
||||
isArchiving: false
|
||||
isArchiving: false,
|
||||
selectedJournalId: undefined,
|
||||
isVisibleArchivePopup: false
|
||||
});
|
||||
await Toolkit.sleep(1000);
|
||||
this.fetch();
|
||||
this.toggleArchivePopup();
|
||||
} else {
|
||||
wx.showToast({ title: "归档失败", icon: "error" });
|
||||
this.setData({
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
class="btn archive"
|
||||
theme="primary"
|
||||
plain="true"
|
||||
bind:tap="toggleArchivePopup"
|
||||
bind:tap="showArchivePopup"
|
||||
disabled="{{isSubmitting || list.length === 0 || !hasChecked}}"
|
||||
>归档已选</t-button>
|
||||
</view>
|
||||
@ -87,18 +87,44 @@
|
||||
usingCustomNavbar
|
||||
bind:visible-change="onArchivePopupVisibleChange"
|
||||
>
|
||||
<view class="container">
|
||||
<!-- 选择归档方式 -->
|
||||
<view wx:if="{{archiveStep === 'select-type'}}" class="container select-type">
|
||||
<view class="header">
|
||||
<t-button
|
||||
class="btn cancel"
|
||||
aria-role="button"
|
||||
bind:tap="toggleArchivePopup"
|
||||
variant="text"
|
||||
>取消</t-button>
|
||||
<view class="title">归档已选项</view>
|
||||
<view class="title">归档到</view>
|
||||
<view class="placeholder"></view>
|
||||
</view>
|
||||
<t-cell-group class="content">
|
||||
<t-cell
|
||||
title="新纪录"
|
||||
leftIcon="bookmark-add"
|
||||
arrow
|
||||
bind:tap="onArchiveToNew"
|
||||
/>
|
||||
<t-cell
|
||||
title="已存在记录"
|
||||
leftIcon="view-list"
|
||||
arrow
|
||||
bind:tap="onArchiveToExisting"
|
||||
/>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<!-- 归档表单 -->
|
||||
<view wx:if="{{archiveStep === 'form'}}" class="container form">
|
||||
<view class="header">
|
||||
<t-button
|
||||
class="btn back"
|
||||
bind:tap="onNewJournalBack"
|
||||
variant="text"
|
||||
>返回</t-button>
|
||||
<view class="title">归档到新纪录</view>
|
||||
<t-button
|
||||
class="btn confirm"
|
||||
aria-role="button"
|
||||
theme="primary"
|
||||
bind:tap="archiveChecked"
|
||||
variant="text"
|
||||
>确定</t-button>
|
||||
@ -138,4 +164,30 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 选择已存在记录 -->
|
||||
<view wx:if="{{archiveStep === 'select-journal'}}" class="container select-journal">
|
||||
<view class="header">
|
||||
<t-button
|
||||
class="btn back"
|
||||
bind:tap="onJournalListCancel"
|
||||
variant="text"
|
||||
>返回</t-button>
|
||||
<view class="title">归档到已存在记录</view>
|
||||
<t-button
|
||||
class="btn confirm"
|
||||
bind:tap="onJournalListConfirm"
|
||||
theme="primary"
|
||||
variant="text"
|
||||
disabled="{{!selectedJournalId}}"
|
||||
>确定</t-button>
|
||||
</view>
|
||||
<view class="content">
|
||||
<journal-list
|
||||
visible="{{archiveStep === 'select-journal'}}"
|
||||
type="{{type}}"
|
||||
selectedId="{{selectedJournalId}}"
|
||||
bind:select="onJournalListSelect"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
Reference in New Issue
Block a user