This commit is contained in:
pushuo 2022-06-30 20:10:00 +08:00
parent a29bdd09ae
commit 1bad99dd0e
5 changed files with 94 additions and 31 deletions

View File

@ -53,7 +53,8 @@ class CustomerController extends Controller
$data = [ $data = [
'customer' => $customer, 'customer' => $customer,
'customer_groups' => CustomerGroupRepo::list(), 'customer_groups' => CustomerGroupRepo::list(),
'country' => CountryRepo::all(), 'countries' => CountryRepo::all(),
'country_id' => setting('country_id'),
'_redirect' => $this->getRedirect(), '_redirect' => $this->getRedirect(),
]; ];

View File

@ -18,8 +18,8 @@ class Header extends Component
$this->addLink('管理首页', admin_route('home.index'), true); $this->addLink('管理首页', admin_route('home.index'), true);
$this->addLink('订单管理', admin_route('home.index')); $this->addLink('订单管理', admin_route('home.index'));
$this->addLink('商品管理', admin_route('products.index')); $this->addLink('商品管理', admin_route('products.index'));
$this->addLink('会员管理', admin_route('home.index')); $this->addLink('会员管理', admin_route('customers.index'));
$this->addLink('营销管理', admin_route('home.index')); $this->addLink('插件管理', admin_route('plugins.index'));
$this->addLink('系统设置', admin_route('home.index')); $this->addLink('系统设置', admin_route('home.index'));
} }

View File

@ -16,13 +16,14 @@ class ShopServiceProvider extends ServiceProvider
{ {
$uri = request()->getRequestUri(); $uri = request()->getRequestUri();
$this->loadSettings();
if (Str::startsWith($uri, '/admin')) { if (Str::startsWith($uri, '/admin')) {
return; return;
} }
$this->loadRoutesFrom(__DIR__ . '/../Routes/shop.php'); $this->loadRoutesFrom(__DIR__ . '/../Routes/shop.php');
$this->mergeConfigFrom(__DIR__ . '/../../Config/beike.php', 'beike'); $this->mergeConfigFrom(__DIR__ . '/../../Config/beike.php', 'beike');
$this->loadSettings();
$this->registerGuard(); $this->registerGuard();
$this->app->booted(function () { $this->app->booted(function () {

View File

@ -26,14 +26,14 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-switch v-model="form.status"></el-switch> <el-switch v-model="form.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="submitForm('form')">提交</el-button> <el-button type="primary" @click="submitForm('form')">提交</el-button>
</el-form-item> </el-form-item>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="地址管理" name="address"> <el-tab-pane label="地址管理" name="address" v-if="form.id">
<button class="btn btn-primary mb-3" type="button" @click="editAddress">添加地址</button> <button class="btn btn-primary mb-3" type="button" @click="editAddress">添加地址</button>
<table class="table"> <table class="table">
<thead> <thead>
@ -55,6 +55,7 @@
<td>222</td> <td>222</td>
<td> <td>
<button class="btn btn-outline-secondary btn-sm" type="button" @click="editAddress(index)">编辑</button> <button class="btn btn-outline-secondary btn-sm" type="button" @click="editAddress(index)">编辑</button>
<button class="btn btn-outline-danger btn-sm ml-1" type="button" @click="deleteAddress(index)">删除</button>
</td>{{-- </td>{{--
</tr> --}} </tr> --}}
</tbody> </tbody>
@ -71,7 +72,7 @@
</el-form> </el-form>
</div> </div>
<el-dialog title="编辑地址" :visible.sync="dialogAddress.show" width="580px"> <el-dialog title="编辑地址" :visible.sync="dialogAddress.show" width="600px">
<el-form ref="addressForm" :rules="addressRules" :model="dialogAddress.form" label-width="100px"> <el-form ref="addressForm" :rules="addressRules" :model="dialogAddress.form" label-width="100px">
<el-form-item label="姓名" prop="name"> <el-form-item label="姓名" prop="name">
<el-input v-model="dialogAddress.form.name"></el-input> <el-input v-model="dialogAddress.form.name"></el-input>
@ -79,16 +80,35 @@
<el-form-item label="联系电话" prop="phone"> <el-form-item label="联系电话" prop="phone">
<el-input maxlength="11" v-model="dialogAddress.form.phone"></el-input> <el-input maxlength="11" v-model="dialogAddress.form.phone"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="地址"> <el-form-item label="地址" required>
<el-row> <div class="row">
<el-col :span="8"> <div class="col-4">
<el-select v-model="dialogAddress.form.country_id" placeholder="请选择"> <el-form-item>
<el-option v-for="item in source.countrys" :key="item.country_id" :label="item.name" <el-select v-model="dialogAddress.form.country_id" filterable placeholder="选择国家" @change="countryChange">
:value="item.country_id"> <el-option v-for="item in source.countries" :key="item.id" :label="item.name"
</el-option> :value="item.id">
</el-select> </el-option>
</el-col> </el-select>
</el-row> </el-form-item>
</div>
<div class="col-4">
<el-form-item prop="zone_id">
<el-select v-model="dialogAddress.form.zone_id" filterable placeholder="选择省份">
<el-option v-for="item in source.zones" :key="item.id" :label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</div>
<div class="col-4">
<el-form-item prop="city_id">
<el-input v-model="dialogAddress.form.city_id" placeholder="输入 city"></el-input>
</el-form-item>
</div>
</div>
</el-form-item>
<el-form-item label="邮编" prop="zipcode">
<el-input v-model="dialogAddress.form.zipcode"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="详细地址 1" prop="address_1"> <el-form-item label="详细地址 1" prop="address_1">
<el-input v-model="dialogAddress.form.address_1"></el-input> <el-input v-model="dialogAddress.form.address_1"></el-input>
@ -113,23 +133,19 @@
data: { data: {
customerTab: 'customer', customerTab: 'customer',
form: { form: {
id: '', id: @json($customer['id'] ?? null),
name: '', name: @json($customer['name']),
email: '', email: @json($customer['email']),
password: '', password: '',
customer_group_id: 1, customer_group_id: 1,
status: false, status: @json($customer['status']) * 1,
address: [] address: []
}, },
source: { source: {
customer_group: @json($customer_groups), customer_group: @json($customer_groups ?? []),
countrys: [ countries: @json($countries ?? []),
{country_id: 44, name: "中国"}, zones: []
{country_id: 22, name: "美国"},
{country_id: 122, name: "俄罗斯"},
{country_id: 123, name: "英国"},
{country_id: 113, name: "法国"},
]
}, },
dialogAddress: { dialogAddress: {
show: false, show: false,
@ -137,9 +153,10 @@
form: { form: {
name: '', name: '',
phone: '', phone: '',
country_id: 44, country_id: @json(setting('country_id')) * 1,
city_id: '', zipcode: '',
zone_id: '', zone_id: '',
city_id: '',
address_1: '', address_1: '',
address_2: '', address_2: '',
} }
@ -151,16 +168,34 @@
name: [{required: true, message: '请输入姓名', trigger: 'blur'}, ], name: [{required: true, message: '请输入姓名', trigger: 'blur'}, ],
phone: [{required: true, message: '请输入联系电话', trigger: 'blur'}, ], phone: [{required: true, message: '请输入联系电话', trigger: 'blur'}, ],
address_1: [{required: true, message: '请输入详细地址 1', trigger: 'blur'}, ], address_1: [{required: true, message: '请输入详细地址 1', trigger: 'blur'}, ],
zone_id: [{required: true, message: '请选择省份', trigger: 'blur'}, ],
city_id: [{required: true, message: '请填写 city', trigger: 'blur'}, ],
} }
}, },
// 在挂载开始之前被调用:相关的 render 函数首次被调用
beforeMount () {
this.countryChange(this.dialogAddress.form.country_id);
},
methods: { methods: {
submitForm(form) { submitForm(form) {
const self = this;
this.$refs[form].validate((valid) => { this.$refs[form].validate((valid) => {
if (!valid) { if (!valid) {
this.$message.error('请检查表单是否填写正确'); this.$message.error('请检查表单是否填写正确');
return; return;
} }
$.ajax({
url: `/admin/countries/${e}/zones`,
type: 'get',
success: function(res) {
this.$message.success('提交成功');
}
})
}); });
}, },
@ -176,6 +211,10 @@
this.dialogAddress.show = true this.dialogAddress.show = true
}, },
deleteAddress(index) {
this.form.address.splice(index, 1)
},
addressFormSubmit(form) { addressFormSubmit(form) {
this.$refs[form].validate((valid) => { this.$refs[form].validate((valid) => {
if (!valid) { if (!valid) {
@ -189,6 +228,15 @@
this.form.address[this.dialogAddress.index] = JSON.parse(JSON.stringify(this.dialogAddress.form)); this.form.address[this.dialogAddress.index] = JSON.parse(JSON.stringify(this.dialogAddress.form));
} }
$.ajax({
url: `/admin/countries/{{ $customer['id'] }}/addresses`,
data: this.dialogAddress.form,
type: 'post',
success: function(res) {
console.log(res)
}
})
this.$refs[form].resetFields(); this.$refs[form].resetFields();
this.dialogAddress.show = false this.dialogAddress.show = false
this.dialogAddress.index = null; this.dialogAddress.index = null;
@ -200,6 +248,18 @@
this.dialogAddress.show = false this.dialogAddress.show = false
this.dialogAddress.index = null; this.dialogAddress.index = null;
}, },
countryChange(e) {
const self = this;
$.ajax({
url: `/admin/countries/${e}/zones`,
type: 'get',
success: function(res) {
self.source.zones = res.data.zones;
}
})
}
} }
}); });
</script> </script>

View File

@ -3,6 +3,7 @@
@section('title', '插件列表') @section('title', '插件列表')
@section('content') @section('content')
<div id="category-app" class="card"> <div id="category-app" class="card">
<div class="card-body"> <div class="card-body">
<a href="{{ admin_route('categories.create') }}" class="btn btn-primary">创建插件</a> <a href="{{ admin_route('categories.create') }}" class="btn btn-primary">创建插件</a>