Skip to content

Commit

Permalink
Merge pull request #67 from Chadwuo/dev
Browse files Browse the repository at this point in the history
v4.1.0
  • Loading branch information
Chadwuo authored Feb 18, 2025
2 parents 0a2396a + bce833e commit ffd79f7
Show file tree
Hide file tree
Showing 24 changed files with 363 additions and 248 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"eslint": "^9.16.0",
"lint-staged": "^15.2.10",
"miniprogram-api-typings": "^4.0.1",
"sass": "^1.78.0",
"sass": "1.78.0",
"simple-git-hooks": "^2.11.1",
"typescript": "~5.5.4",
"unocss": "^0.64.0",
Expand Down
5 changes: 2 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
onLaunch(async () => {
try {
const authStore = useAuthStore()
if (!authStore.isLogin) {
if (!authStore.isLogin)
await authStore.login()
await authStore.getUserInfo()
}
await authStore.getUserInfo()
}
catch (error) {
console.error(error)
Expand Down
3 changes: 2 additions & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './modules/friend'
export * from './modules/giftIn'
export * from './modules/giftOut'
export * from './modules/statistics'
export * from './modules/subscriptionPlan'
export * from './modules/user'
export * from './modules/userFamily'
export * from './modules/wechatPay'
export * from './modules/wechat'
15 changes: 0 additions & 15 deletions src/api/modules/auth.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
import { request } from '../request'

/**
* Login
*
* @param code Code
*/
export function apiLoginPost(code: string) {
return request<Api.LoginToken>({
url: 'wx-open/login',
method: 'POST',
data: {
jsCode: code,
},
})
}

/** Get user info */
export function apiUserInfoGet() {
return request<Api.LoginUser>({
Expand Down
7 changes: 7 additions & 0 deletions src/api/modules/subscriptionPlan.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { request } from '../request'

export function apiSubscriptionPlanGet() {
return request<Api.SubscriptionPlan>({
url: 'subscription-plan',
})
}
8 changes: 7 additions & 1 deletion src/api/modules/user.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { request } from '../request'

export function apiUserNickNamePut(data: any) {
return request({
return request<boolean>({
url: 'user/nick-name',
method: 'PUT',
data,
})
}

export function apiUserSubscriptionGet() {
return request<Api.UserSubscription>({
url: 'user/user-subscription',
})
}
Empty file.
19 changes: 19 additions & 0 deletions src/api/modules/wechat.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { request } from '../request'

export function apiWxOpenLoginPost(code: string) {
return request<Api.LoginToken>({
url: 'wx-open/login',
method: 'POST',
data: {
jsCode: code,
},
})
}

export function apiWxPayCreatePayPost(data: any) {
return request<Api.WechatPayTransactionOutput>({
url: 'wx-pay/pay-transaction',
method: 'POST',
data,
})
}
9 changes: 0 additions & 9 deletions src/api/modules/wechatPay.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function request<T>(options: UniApp.RequestOptions) {
fail(err) {
uni.showToast({
icon: 'none',
title: '网络错误,换个网络试试',
title: '网络错误,请稍后再试!',
})
reject(err)
},
Expand Down
60 changes: 22 additions & 38 deletions src/pages/book/edit.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<script setup lang="ts">
const calendarRef = ref<any>(null)
const dataSource = ref<Api.GiftBook>({})
const validInput = computed(() => {
return dataSource.value?.date && dataSource.value?.title
})
const formRef = ref()
const loading = ref(false)
onLoad((option) => {
Expand All @@ -19,25 +17,26 @@ onLoad((option) => {
})
const onSubmit = async () => {
const { valid } = await formRef.value.validate()
if (!valid)
return
loading.value = true
if (dataSource.value.id) {
const res = await apiGiftBookPut(dataSource.value)
if (res.succeeded) {
uni.navigateBack()
uni.showToast({
title: '更新成功',
icon: 'success',
icon: 'none',
})
setTimeout(() => {
uni.navigateBack()
}, 600)
}
}
else {
const res = await apiGiftBookPost(dataSource.value)
if (res.succeeded) {
uni.showToast({
title: '新增成功',
icon: 'success',
icon: 'none',
})
uni.redirectTo({
url: `/pages/book/detail?id=${res.data}`,
Expand All @@ -61,36 +60,21 @@ const openCalendar = () => {

<template>
<div class="mx-3">
<div class="rounded-2xl bg-white p-5">
<uv-form label-position="left" label-width="60">
<uv-form-item label="日期" @click="openCalendar">
<uv-input v-model="dataSource.date" disabled disabled-color="#ffffff" border="none" placeholder="请选择日期" />
<template #right>
<uv-icon name="arrow-right" />
</template>
</uv-form-item>
<uv-form-item label="名称">
<uv-input v-model="dataSource.title" border="none" placeholder="礼簿名称" />
</uv-form-item>
<uv-form-item label="成本">
<uv-input v-model="dataSource.cost" border="none" placeholder="宴席、伴手礼等费用" type="number" />
</uv-form-item>
<uv-form-item label="备注">
<uv-input v-model="dataSource.remarks" border="none" placeholder="请输入内容" />
</uv-form-item>
<uv-form-item>
<div class="mt-3 text-xs text-gray">
一场宴席活动中,用来登记所有来宾贺礼的名册,称为礼簿。
</div>
</uv-form-item>
<uv-form-item>
<div class="w-full">
<wd-button block :loading="loading" loading-color="#F87171" :disabled="!validInput" @click="onSubmit">
保存
</wd-button>
</div>
</uv-form-item>
</uv-form>
<div class="rounded-2xl bg-white p-2 py-5">
<wd-form ref="formRef" :model="dataSource">
<wd-input v-model="dataSource.date" label="日期" prop="date" placeholder="请选择日期" suffix-icon="calendar" readonly :rules="[{ required: true, message: '请选择日期' }]"
@click="openCalendar"
/>
<wd-input v-model="dataSource.title" label="名称" prop="title" placeholder="礼簿名称" clearable :rules="[{ required: true, message: '请填写礼簿名称' }]" />
<wd-input v-model="dataSource.cost" label="成本" prop="cost" type="number" placeholder="宴席、伴手礼等费用" />
<wd-input v-model="dataSource.remarks" label="备注" placeholder="请输入内容" />
</wd-form>
<div class="my-3 text-xs text-gray">
一场宴席活动中,用来登记所有来宾贺礼的名册,称为礼簿。
</div>
<wd-button block :loading="loading" @click="onSubmit">
保存
</wd-button>
</div>
<uv-calendars ref="calendarRef" lunar color="#F87171" confirm-color="#F87171" :date="dataSource.date"
@confirm="confirmCalendar"
Expand Down
9 changes: 5 additions & 4 deletions src/pages/friend/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,11 @@ const handleFriendDel = () => {
<div class="text-lg font-bold">
{{ friend.name }}
</div>
<div class="mt-1 text-sm text-gray">
关系:{{ friend.relation }}
<div class="mt-1 flex items-center text-sm text-gray">
关系:
<wd-tag v-if="friend.tag" type="primary" mark>
{{ friend.tag }}
</wd-tag>
</div>
<div class="mt-1 text-sm text-gray">
备注:{{ friend.remarks }}
Expand Down Expand Up @@ -184,7 +187,6 @@ const handleFriendDel = () => {
{{ statisticsData.happyTotal }}
</div>
<div class="flex items-center justify-center text-sm text-gray space-x-1">
<div class="i-icon-park-outline-income" />
<div>收礼({{ statisticsData.happyCount }})</div>
</div>
</div>
Expand All @@ -193,7 +195,6 @@ const handleFriendDel = () => {
{{ statisticsData.sadTotal }}
</div>
<div class="flex items-center justify-center text-sm text-gray space-x-1">
<div class="i-icon-park-outline:expenses" />
<div>送礼({{ statisticsData.sadCount }})</div>
</div>
</div>
Expand Down
67 changes: 26 additions & 41 deletions src/pages/friend/edit.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { friendCategory } from '@/constants/app'
const columns = friendCategory.map(i => ({ name: i, value: i }))
const columns = friendCategory.map(i => ({ label: i, value: i }))
const dataSource = ref<Api.Friend>({})
onLoad((option) => {
if (option?.id) {
Expand All @@ -14,54 +14,39 @@ onLoad((option) => {
})
}
})
const validInput = computed(() => {
return dataSource.value.name
})
const loading = ref(false)
const formRef = ref()
const onSubmit = async () => {
loading.value = true
const api = dataSource.value.id ? apiFriendPut : apiFriendPost
const res = await api(dataSource.value)
if (res.succeeded) {
uni.showToast({
title: `${dataSource.value.id ? '更新' : '新增'}成功`,
icon: 'success',
})
uni.navigateBack()
const { valid } = await formRef.value.validate()
if (valid) {
loading.value = true
const api = dataSource.value.id ? apiFriendPut : apiFriendPost
const res = await api(dataSource.value)
if (res.succeeded) {
uni.navigateBack()
uni.showToast({
title: `${dataSource.value.id ? '更新' : '新增'}成功`,
icon: 'none',
})
}
loading.value = false
}
loading.value = false
}
</script>

<template>
<div class="mx-3">
<div class="rounded-2xl bg-white p-4">
<uv-form label-position="left" label-width="60">
<uv-form-item label="姓名">
<uv-input v-model="dataSource.name" border="none" placeholder="请输入姓名" />
</uv-form-item>
<uv-form-item label="关系">
<!-- <uv-input v-model="dataSource.relation" border="none" placeholder="请输入内容" /> -->
<wd-radio-group v-model="dataSource.relation" cell shape="button">
<wd-radio v-for="item in columns" :key="item.value" :value="item.value">
{{ item.name }}
</wd-radio>
</wd-radio-group>
</uv-form-item>
<uv-form-item label="备注">
<uv-input v-model="dataSource.remarks" border="none" placeholder="请输入内容" />
</uv-form-item>

<uv-form-item>
<div class="w-full">
<wd-button block :loading="loading" :disabled="!validInput" @click="onSubmit">
保存
</wd-button>
</div>
</uv-form-item>
</uv-form>
<div class="rounded-2xl bg-white p-2 py-5">
<wd-form ref="formRef" :model="dataSource">
<wd-input v-model="dataSource.name" label="姓名" prop="name" clearable placeholder="请输入姓名"
:rules="[{ required: true, message: '请填写亲友姓名' }]"
/>
<wd-select-picker v-model="dataSource.tag" type="radio" label="标签" :columns="columns" />
<wd-input v-model="dataSource.remarks" label="备注" placeholder="请输入内容" />
</wd-form>
<wd-button block :loading="loading" @click="onSubmit">
保存
</wd-button>
</div>
</div>
</template>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/friend/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const columns = [
const friendsList = ref<Array<{ index: string, data: Array<Api.Friend> }>>()
const search = ref({
keyword: '',
relation: '',
tag: '',
showAction: false,
})
const loadData = async () => {
apiFriendListGet({
keyword: search.value.keyword,
relation: search.value.relation,
tag: search.value.tag,
}).then((res) => {
if (res.succeeded) {
// 根据首字母firstLetter进行分组
Expand Down Expand Up @@ -47,7 +47,7 @@ onPullDownRefresh(async () => {
})
const onTabsClick = (item: any) => {
search.value.relation = item.value
search.value.tag = item.value
loadData()
}
Expand All @@ -58,7 +58,7 @@ function searchOk() {
function searchCancel() {
search.value = {
keyword: '',
relation: '',
tag: '',
showAction: false,
}
loadData()
Expand Down
Loading

0 comments on commit ffd79f7

Please sign in to comment.