diff --git a/modules/Account/app/Models/Bill.php b/modules/Account/app/Models/Bill.php
index c95562a..2e8c32b 100644
--- a/modules/Account/app/Models/Bill.php
+++ b/modules/Account/app/Models/Bill.php
@@ -2,11 +2,11 @@
namespace Modules\Account\Models;
-use Illuminate\Database\Eloquent\Model;
+use App\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Casts\Attribute;
-class Bill extends Model
+class Bill extends BaseModel
{
use SoftDeletes;
@@ -17,6 +17,7 @@ class Bill extends Model
'type',
'amount',
'category',
+ 'payment_method',
'remark',
'bill_date'
];
@@ -25,7 +26,8 @@ class Bill extends Model
protected function casts(): array
{
return [
- 'bill_date' => 'date',
+ 'date' => 'datetime:Y-m-d',
+ 'bill_date' => 'datetime:Y-m-d',
'created_at' => 'datetime:Y-m-d H:i:s',
'updated_at' => 'datetime:Y-m-d H:i:s',
'deleted_at' => 'datetime:Y-m-d H:i:s',
diff --git a/modules/Account/app/Services/BillService.php b/modules/Account/app/Services/BillService.php
index d26a4ba..c1434a2 100644
--- a/modules/Account/app/Services/BillService.php
+++ b/modules/Account/app/Services/BillService.php
@@ -99,10 +99,11 @@ class BillService
'amount' => (float)$bill->amount,
'category' => $bill->category,
'category_id' => $this->getCategoryId($bill->category, $bill->type),
+ 'payment_method' => $bill->payment_method,
'remark' => $bill->remark,
'date' => $bill->bill_date,
'bill_date' => $bill->bill_date,
- 'created_at' => $bill->created_at->format('Y-m-d H:i:s'),
+ 'created_at' => $bill->created_at,
'user' => $bill->user,
'family' => $bill->family
];
@@ -162,6 +163,7 @@ class BillService
'type' => 'required|in:income,expense',
'amount' => 'required|numeric|min:0.01',
'category_id' => 'required|integer',
+ 'payment_method' => 'nullable|string|in:微信,支付宝,银行卡,现金,其他',
'remark' => 'nullable|string|max:255',
'date' => 'required|date',
'family_id' => 'nullable|integer|exists:account_families,id'
@@ -241,6 +243,7 @@ class BillService
'type' => 'required|in:income,expense',
'amount' => 'required|numeric|min:0.01',
'category_id' => 'required|integer',
+ 'payment_method' => 'nullable|string|in:微信,支付宝,银行卡,现金,其他',
'remark' => 'nullable|string|max:255',
'date' => 'required|date',
'family_id' => 'nullable|integer|exists:account_families,id'
@@ -303,19 +306,8 @@ class BillService
}
// 转换数据格式以匹配前端
- return [
- 'id' => $bill->id,
- 'type' => $bill->type,
- 'amount' => (float)$bill->amount,
- 'category' => $bill->category,
- 'category_id' => $this->getCategoryId($bill->category, $bill->type),
- 'remark' => $bill->remark,
- 'date' => $bill->bill_date,
- 'bill_date' => $bill->bill_date,
- 'created_at' => $bill->created_at->format('Y-m-d H:i:s'),
- 'user' => $bill->user,
- 'family' => $bill->family
- ];
+ $bill->category_id = $this->getCategoryId($bill->category, $bill->type);
+ return $bill;
}
/**
diff --git a/modules/Account/database/migrations/2025_01_19_000001_add_payment_method_to_bills_table.php b/modules/Account/database/migrations/2025_01_19_000001_add_payment_method_to_bills_table.php
new file mode 100644
index 0000000..49aa2d7
--- /dev/null
+++ b/modules/Account/database/migrations/2025_01_19_000001_add_payment_method_to_bills_table.php
@@ -0,0 +1,28 @@
+string('payment_method', 20)->nullable()->after('category')->comment('支付方式:微信、支付宝、银行卡、现金、其他');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('account_bills', function (Blueprint $table) {
+ $table->dropColumn('payment_method');
+ });
+ }
+};
diff --git a/modules/Account/routes/api.php b/modules/Account/routes/api.php
index 975a0ab..dfbc77f 100644
--- a/modules/Account/routes/api.php
+++ b/modules/Account/routes/api.php
@@ -14,7 +14,7 @@ use Modules\Account\Controllers\Api\StatisticsController;
|
*/
-Route::middleware(['auth:api'])->group(function () {
+Route::name('account.')->prefix('account')->middleware(['auth.check:api'])->group(function () {
// 账单路由
Route::prefix('bill')->group(function () {
Route::get('list', [BillController::class, 'index']);
diff --git a/resources/mobile/components/pages/pages.vue b/resources/mobile/components/pages/pages.vue
index be58ff5..23b0fa2 100644
--- a/resources/mobile/components/pages/pages.vue
+++ b/resources/mobile/components/pages/pages.vue
@@ -9,9 +9,7 @@
-
-
-
+
@@ -160,9 +158,4 @@ export default {
width: 100%;
overflow-y: auto;
}
-
-.content-wrapper {
- width: 100%;
- min-height: 100%;
-}
diff --git a/resources/mobile/components/tab-bar/tab-bar.vue b/resources/mobile/components/tab-bar/tab-bar.vue
index 09e8c6d..5ca6274 100644
--- a/resources/mobile/components/tab-bar/tab-bar.vue
+++ b/resources/mobile/components/tab-bar/tab-bar.vue
@@ -211,11 +211,6 @@ export default {
diff --git a/resources/mobile/pages/account/bill/index.vue b/resources/mobile/pages/account/bill/index.vue
index 518ef3a..13757f8 100644
--- a/resources/mobile/pages/account/bill/index.vue
+++ b/resources/mobile/pages/account/bill/index.vue
@@ -62,7 +62,7 @@
group.income.toFixed(2) }}
-
+
{{ getCategoryIcon(bill.category_id) }}
@@ -96,28 +96,7 @@
-
-
-
-
-
-
-
- 编辑
-
-
-
- 删除
-
-
-
- 取消
-
-
-
+
@@ -176,12 +155,12 @@ export default {
return this.$store.getters.hasFamily
},
currentUserId() {
- return this.$store.state.user.userInfo?.id
+ return this.$store.state.user.userInfo?.uid
},
canDeleteBill() {
if (!this.currentBill || !this.currentUserId) return false
// 只能删除自己创建的账单
- return this.currentBill.user_id === this.currentUserId
+ return this.currentBill.user?.uid === this.currentUserId
},
groupedBills() {
const groups = {}
@@ -312,82 +291,11 @@ export default {
url: '/pages/account/bill/add'
})
},
- editBill(bill) {
- this.currentBill = bill
- // 如果是自己的账单,显示操作菜单
- if (bill.user_id === this.currentUserId) {
- this.$refs.actionPopup.open()
- } else {
- // 不是自己的账单,直接查看详情或提示
- uni.navigateTo({
- url: `/pages/account/bill/add?id=${bill.id}`
- })
- }
- },
- closeActionSheet() {
- this.$refs.actionPopup.close()
- this.currentBill = null
- },
- editCurrentBill() {
- if (!this.currentBill) return
- this.closeActionSheet()
+ viewBillDetail(bill) {
uni.navigateTo({
- url: `/pages/account/bill/add?id=${this.currentBill.id}`
+ url: `/pages/account/bill/detail?id=${bill.id}`
})
},
- deleteCurrentBill() {
- if (!this.currentBill) return
-
- uni.showModal({
- title: '删除确认',
- content: '确定要删除这条账单记录吗?删除后无法恢复。',
- confirmColor: '#FF6B6B',
- success: async (res) => {
- if (res.confirm) {
- await this.performDelete()
- }
- }
- })
- },
- async performDelete() {
- if (!this.currentBill) return
-
- this.loading = true
- try {
- const res = await this.$api.bill.delete.post({
- id: this.currentBill.id
- })
-
- if (res && res.code === 1) {
- uni.showToast({
- title: '删除成功',
- icon: 'success',
- duration: 1500
- })
-
- // 关闭弹窗
- this.closeActionSheet()
-
- // 刷新列表
- setTimeout(() => {
- this.loadBillList(true)
- }, 1500)
- } else {
- uni.showToast({
- title: res?.message || '删除失败',
- icon: 'none'
- })
- }
- } catch (error) {
- console.error('删除账单失败', error)
- uni.showToast({
- title: error?.message || '删除失败,请重试',
- icon: 'none'
- })
- } finally {
- this.loading = false
- }
- },
getCategoryName(categoryId) {
return this.categoryMap[categoryId]?.name || '未知'
},
@@ -415,15 +323,15 @@ export default {
diff --git a/resources/mobile/pages/account/statistics/index.vue b/resources/mobile/pages/account/statistics/index.vue
index 4154eca..9fca37d 100644
--- a/resources/mobile/pages/account/statistics/index.vue
+++ b/resources/mobile/pages/account/statistics/index.vue
@@ -338,7 +338,6 @@ export default {