Skip to content

Commit

Permalink
✨ feat: 3.0 她来了
Browse files Browse the repository at this point in the history
  • Loading branch information
Chadwuo committed Apr 17, 2024
1 parent 0143af6 commit e1b788e
Show file tree
Hide file tree
Showing 14 changed files with 1,507 additions and 1,267 deletions.
8 changes: 4 additions & 4 deletions src/alicloud/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MPServerless from '@alicloud/mpserverless-sdk';
import options from '~/alicloud/dev.json';
import MPServerless from '@alicloud/mpserverless-sdk'
import options from '~/alicloud/releases.json'

const mpserverless = new MPServerless(wx, options);
const mpserverless = new MPServerless(wx, options)

export default mpserverless;
export default mpserverless
264 changes: 140 additions & 124 deletions src/pages/book/detail.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,96 @@
<script setup>
import { page } from '~/alicloud/services/giftReceive'
import { hasMourningWords } from '~/utils/index'
const book = ref({
date: {},
})
const giftList = ref([])
const pagination = ref({
pageNo: 1,
pageSize: 20,
loading: false,
})
const search = ref({
keyword: '',
showAction: false,
})
const loadMoreStatus = ref('loadmore')
const popup = ref(null)
onLoad((option) => {
book.value = { ...router.getQueryParse(option) }
loadData()
uni.$on('giftInEditPageUpdate', () => {
loadData()
})
})
onUnload(() => {
uni.$off('giftInEditPageUpdate')
})
onReachBottom(() => {
if (loadMoreStatus.value === 'loading' || loadMoreStatus.value === 'nomore')
return
loadMoreStatus.value = 'loading'
pagination.value.pageNo++
loadData()
})
function loadData() {
const { pageSize, pageNo } = pagination.value
page({
bookId: book.value._id,
keyword: search.value.keyword,
pageSize,
pageNo,
}).then((res) => {
if (res.success) {
giftList.value = pageNo === 1 ? res.result : [...giftList.value, ...res.result]
loadMoreStatus.value = res.result.length < pageSize ? 'nomore' : 'loadmore'
}
})
}
function searchOk() {
loadData()
}
function searchCancel() {
search.value = {
keyword: '',
showAction: false,
}
loadData()
}
function handleInfoClick() {
popup.value.open()
}
function handleGiftClick(e) {
const { _id, money, attendance, remarks, friendInfo } = e
router.push({
path: '/pages/giftIn/edit',
query: { _id, money, attendance, remarks, friendName: friendInfo.name },
})
}
</script>

<template>
<div class="h-full flex flex-col">
<div class="px-5 pt-3 pb-5 space-y-3 bg-white rounded-b-2xl">
<uv-search placeholder="请输入搜索内容" v-model="search.keyword" :showAction="search.showAction" actionText="取消"
@focus="search.showAction = true" @custom="searchCancel" @search="searchOk">
</uv-search>
<div class="flex justify-between items-center">
<div class="rounded-b-2xl bg-white px-5 pb-5 pt-3 space-y-3">
<uv-search
v-model="search.keyword" placeholder="请输入搜索内容" :show-action="search.showAction" action-text="取消"
@focus="search.showAction = true" @custom="searchCancel" @search="searchOk"
/>
<div class="flex items-center justify-between">
<div>
<div class="font-bold text-lg" :class="[hasMourningWords(book.title) ? 'text-gray' : 'text-red']">{{
book.title }}</div>
<div class="text-sm text-gray mt-1">
<div class="text-lg font-bold" :class="[hasMourningWords(book.title) ? 'text-gray' : 'text-red']">
{{
book.title }}
</div>
<div class="mt-1 text-sm text-gray">
<span>{{ book.date.lunar_month }} {{ book.date.lunar_day }} {{ book.date.lunar_year }}</span>
<span class="ml-2">({{ book.date.value }}) </span>
</div>
Expand All @@ -18,88 +100,97 @@
@click="router.push(`/pages/book/edit?id=${book._id}`)">
</uv-button> -->
<div class="py-2 pl-2" @click="router.push(`/pages/book/edit?id=${book._id}`)">
<div class="i-carbon-edit"></div>
<div class="i-carbon-edit" />
</div>
<div class="py-2 pl-2" @click="router.push(`/pages/giftIn/edit?bookId=${book._id}`)">
<div class="i-carbon-add-alt"></div>
<div class="i-carbon-add-alt" />
</div>
</div>
</div>
<div class="flex items-center">
<div class="i-mingcute-wallet-2-line mr-1"></div>
<div class="text-sm font-bold">礼金:</div>
<uv-count-to customStyle="font-weight: 700;font-size: 1.25rem;line-height: 1.75rem;" :startVal="0"
:endVal="book.giftTotal">
</uv-count-to>
<div class="ml-auto text-gray py-2 pl-2" @click="handleInfoClick">
<div class="i-carbon-information-filled"></div>
<div class="flex items-end">
<div class="i-mingcute-wallet-2-line p-1" />
<div class="text-sm font-bold">
礼金:<span class="text-xl">{{ book.giftTotal }}</span>
</div>
<div class="ml-auto py-2 pl-2 text-gray" @click="handleInfoClick">
<div class="i-carbon-information-filled" />
</div>
</div>
<div class="grid gap-5 grid-cols-4 divide-x">
<div class="grid grid-cols-4 gap-5 divide-x">
<div class="text-center">
<div class="text-lg font-bold text-black">
<div class="text-lg text-black font-bold">
{{ book.giftCount }}
</div>
<div class="text-xs text-gray flex justify-center items-center space-x-1">
<div class="i-carbon-home"></div>
<div class="flex items-center justify-center text-xs text-gray space-x-1">
<div class="i-carbon-home" />
<div>亲友</div>
</div>
</div>
<div class="text-center">
<div class="text-lg font-bold text-black">
<div class="text-lg text-black font-bold">
{{ book.attendanceTotal }}
</div>
<div class="text-xs text-gray flex justify-center items-center space-x-1">
<div class="i-carbon-pedestrian-family"></div>
<div class="flex items-center justify-center text-xs text-gray space-x-1">
<div class="i-carbon-pedestrian-family" />
<div>出席</div>
</div>
</div>
<div class="text-gray text-sm text-center">
<div class="text-lg font-bold text-black">
<div class="text-center text-sm text-gray">
<div class="text-lg text-black font-bold">
{{ book.cost }}
</div>
<div class="text-xs text-gray flex justify-center items-center space-x-1">
<div class="i-carbon:sprout"></div>
<div class="flex items-center justify-center text-xs text-gray space-x-1">
<div class="i-carbon:sprout" />
<div>支出</div>
</div>
</div>
<div class="text-gray text-sm text-center">
<div class="text-lg font-bold text-black">
<div class="text-center text-sm text-gray">
<div class="text-lg text-black font-bold">
{{ book.giftTotal - book.cost }}
</div>
<div class="text-xs text-gray flex justify-center items-center space-x-1">
<div class="i-carbon-wallet"></div>
<div class="flex items-center justify-center text-xs text-gray space-x-1">
<div class="i-carbon-wallet" />
<div>合计</div>
</div>
</div>
</div>
</div>

<div class="my-auto" v-if="giftList.length == 0">
<uv-empty></uv-empty>
<div v-if="giftList.length === 0" class="my-auto">
<uv-empty />
</div>
<div class="my-5 space-y-3 bg-white rounded-2xl">
<div class="my-5 rounded-2xl bg-white space-y-3">
<div v-for="gift in giftList" :key="gift._id" @click="handleGiftClick(gift)">
<div class="flex justify-around items-center h-18">
<div class="h-18 flex items-center justify-around">
<div>
<div class="text-lg">{{ gift.friendInfo.name }}</div>
<div class="text-gray text-sm">出席:{{ gift.attendance || 0 }} 人</div>

<div class="text-lg">
{{ gift.friendInfo.name }}
</div>
<div class="text-sm text-gray">
出席:{{ gift.attendance || 0 }} 人
</div>
</div>
<div class="text-right">
<div class="font-bold text-lg" :class="[hasMourningWords(book.title) ? 'text-gray' : 'text-red']"><span
class="text-sm">¥</span>{{ gift.money }}</div>
<div class="text-gray text-sm">礼金</div>
<div class="text-lg font-bold" :class="[hasMourningWords(book.title) ? 'text-gray' : 'text-red']">
<span
class="text-sm"
>¥</span>{{ gift.money }}
</div>
<div class="text-sm text-gray">
礼金
</div>
</div>
</div>
</div>

<uv-load-more loadingIcon="circle" :status="loadMoreStatus" v-if="loadMoreStatus == 'loading'" />
<uv-load-more v-if="loadMoreStatus === 'loading'" loading-icon="circle" :status="loadMoreStatus" />
</div>

<uv-popup ref="popup" mode="bottom" round="10" closeable>
<div class="px-5 pt-4">
<div class="text-center font-bold">名词解释</div>
<div class="text-center font-bold">
名词解释
</div>
<div class="mt-5 text-sm space-y-1">
<div><span class="font-bold">礼金:</span> <span>指所有礼金收入的总和</span></div>
<div><span class="font-bold">亲友:</span> <span>表示人情往来次数,需预先备好伴手礼以表心意</span></div>
Expand All @@ -112,88 +203,13 @@
</div>
</template>

<script setup>
import { page } from '~/alicloud/services/giftReceive'
import { hasMourningWords } from '~/utils/index'
const book = ref({
date: {}
})
const giftList = ref([])
onLoad((option) => {
book.value = { ...router.getQueryParse(option) }
loadData()
uni.$on('gift_in_edit_page_update', () => {
loadData()
})
})
onUnload(() => {
uni.$off('gift_in_edit_page_update')
console.log('book detail page unload');
})
const loadMoreStatus = ref('loadmore')
onReachBottom(() => {
if (loadMoreStatus.value === 'loading' || loadMoreStatus.value === 'nomore') {
return
}
loadMoreStatus.value = 'loading'
pagination.value.pageNo++
loadData()
})
const pagination = ref({
pageNo: 1,
pageSize: 20,
loading: false,
})
const loadData = () => {
const { pageSize, pageNo } = pagination.value
page({
bookId: book.value._id,
keyword: search.value.keyword,
pageSize,
pageNo
}).then(res => {
if (res.success) {
giftList.value = pageNo === 1 ? res.result : [...giftList.value, ...res.result]
loadMoreStatus.value = res.result.length < pageSize ? 'nomore' : 'loadmore'
}
})
}
const search = ref({
keyword: '',
showAction: false
})
const searchOk = () => {
loadData()
}
const searchCancel = () => {
search.value = {
keyword: '',
showAction: false
}
loadData()
}
const popup = ref(null)
const handleInfoClick = () => {
popup.value.open()
}
const handleGiftClick = (e) => {
const { _id, money, attendance, remarks, friendInfo, bookId } = e
router.push({
path: '/pages/giftIn/edit',
query: { _id, money, attendance, remarks, friendName: friendInfo.name }
})
}
</script>

<style lang="scss" scoped></style>

<route lang="json">{
<route lang="json">
{
"layout": "blank",
"style": {
"navigationBarTitleText": "详情"
}
}</route>
}
</route>
Loading

0 comments on commit e1b788e

Please sign in to comment.