From b968596fc50833f415e4e6f158b9d93b6be1e45b Mon Sep 17 00:00:00 2001 From: pushuo <229102104@qq.com> Date: Thu, 30 Jun 2022 20:53:35 +0800 Subject: [PATCH] wip --- .../views/pages/customers/form.blade.php | 58 +++++++----- .../admin/views/pages/plugins/index.blade.php | 2 +- .../shop/default/css/bootstrap/bootstrap.scss | 4 + themes/default/checkout.blade.php | 91 ++++++++++++++++++- 4 files changed, 128 insertions(+), 27 deletions(-) diff --git a/resources/beike/admin/views/pages/customers/form.blade.php b/resources/beike/admin/views/pages/customers/form.blade.php index dd06a9b4..8cdc7537 100644 --- a/resources/beike/admin/views/pages/customers/form.blade.php +++ b/resources/beike/admin/views/pages/customers/form.blade.php @@ -46,8 +46,8 @@ 操作 - - + + @{{ index }} @{{ address.name }} @{{ address.phone }} @@ -55,7 +55,7 @@ 222 - + {{-- --}} @@ -139,14 +139,16 @@ password: '', customer_group_id: 1, status: @json($customer['status']) * 1, - address: [] }, + addresses: @json($customer['addresses'] ?? []), + source: { customer_group: @json($customer_groups ?? []), countries: @json($countries ?? []), zones: [] }, + dialogAddress: { show: false, index: null, @@ -161,9 +163,11 @@ address_2: '', } }, + rules: { name: [{required: true, message: '请输入用户名', trigger: 'blur'}, ], }, + addressRules: { name: [{required: true, message: '请输入姓名', trigger: 'blur'}, ], phone: [{required: true, message: '请输入联系电话', trigger: 'blur'}, ], @@ -202,44 +206,52 @@ editAddress(index) { if (typeof index == 'number') { this.dialogAddress.index = index; - - this.$nextTick(() => { - this.dialogAddress.form = JSON.parse(JSON.stringify(this.form.address[index])) - }) + this.dialogAddress.form = JSON.parse(JSON.stringify(this.addresses[index])) } this.dialogAddress.show = true }, - deleteAddress(index) { - this.form.address.splice(index, 1) + deleteAddress(id, index) { + const self = this; + + $.ajax({ + url: `/admin/customers/{{ $customer['id'] }}/addresses/${id}`, + type: 'delete', + success: function(res) { + self.$message.success(res.message); + self.addresses.splice(index, 1) + } + }) }, addressFormSubmit(form) { + const self = this; + this.$refs[form].validate((valid) => { if (!valid) { this.$message.error('请检查表单是否填写正确'); return; } - if (this.dialogAddress.index === null) { - this.form.address.push(JSON.parse(JSON.stringify(this.dialogAddress.form))); - } else { - this.form.address[this.dialogAddress.index] = JSON.parse(JSON.stringify(this.dialogAddress.form)); - } + const type = this.dialogAddress.form.id ? 'put' : 'post'; $.ajax({ - url: `/admin/countries/{{ $customer['id'] }}/addresses`, - data: this.dialogAddress.form, - type: 'post', + url: `/admin/customers/{{ $customer['id'] }}/addresses${type == 'put' ? '/' + this.dialogAddress.form.id : ''}`, + data: self.dialogAddress.form, + type: type, success: function(res) { - console.log(res) + if (type == 'post') { + self.addresses.push(res.data) + } else { + self.addresses[self.dialogAddress.index] = res.data + } + self.$message.success(res.message); + self.$refs[form].resetFields(); + self.dialogAddress.show = false + self.dialogAddress.index = null; } }) - - this.$refs[form].resetFields(); - this.dialogAddress.show = false - this.dialogAddress.index = null; }); }, diff --git a/resources/beike/admin/views/pages/plugins/index.blade.php b/resources/beike/admin/views/pages/plugins/index.blade.php index 66374cda..624012ef 100644 --- a/resources/beike/admin/views/pages/plugins/index.blade.php +++ b/resources/beike/admin/views/pages/plugins/index.blade.php @@ -35,7 +35,7 @@
enabled ? 'checked' : '' }} data-code="{{ $plugin->code }}"> + {{ $plugin->getEnabled() ? 'checked' : '' }} data-code="{{ $plugin->code }}">
diff --git a/resources/beike/shop/default/css/bootstrap/bootstrap.scss b/resources/beike/shop/default/css/bootstrap/bootstrap.scss index 0dff6df5..2b8d5d2e 100644 --- a/resources/beike/shop/default/css/bootstrap/bootstrap.scss +++ b/resources/beike/shop/default/css/bootstrap/bootstrap.scss @@ -68,4 +68,8 @@ $dropdown-item-padding-y: .4rem; margin-right: 1rem; opacity: .1; } +} + +.table > :not(:first-child) { + border-top: none; } \ No newline at end of file diff --git a/themes/default/checkout.blade.php b/themes/default/checkout.blade.php index 75901e58..cecbe32f 100644 --- a/themes/default/checkout.blade.php +++ b/themes/default/checkout.blade.php @@ -2,8 +2,14 @@ @section('body-class', 'page-checkout') +@push('header') + + + +@endpush + @section('content') -
+