后台顾客管理
This commit is contained in:
parent
d64b9bad82
commit
e8d46d7278
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* AddressController.php
|
||||
*
|
||||
* @copyright 2022 opencart.cn - All Rights Reserved
|
||||
* @link http://www.guangdawangluo.com
|
||||
* @author TL <mengwb@opencart.cn>
|
||||
* @created 2022-06-28 20:17:04
|
||||
* @modified 2022-06-28 20:17:04
|
||||
*/
|
||||
|
||||
namespace Beike\Shop\Http\Controllers\Account;
|
||||
|
||||
use Beike\Shop\Http\Resources\CustomerResource;
|
||||
use Beike\Repositories\AddressRepo;
|
||||
use Beike\Repositories\CustomerRepo;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AddressController extends Controller
|
||||
{
|
||||
protected string $defaultRoute = 'addresses.index';
|
||||
public function index(Request $request, int $customerId)
|
||||
{
|
||||
$addresses = AddressRepo::listByCustomer($customerId);
|
||||
$data = [
|
||||
'addresses' => CustomerResource::collection($addresses),
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function store(Request $request, int $customerId)
|
||||
{
|
||||
$data = $request->only(['name', 'phone', 'country_id', 'state_id', 'state', 'city_id', 'city', 'zipcode', 'address_1', 'address_2']);
|
||||
$data['customer_id'] = $customerId;
|
||||
return AddressRepo::create($data);
|
||||
}
|
||||
|
||||
public function update(Request $request, int $customerId, int $addressId)
|
||||
{
|
||||
return AddressRepo::update($addressId, $request->only(['name', 'phone', 'country_id', 'state_id', 'state', 'city_id', 'city', 'zipcode', 'address_1', 'address_2']));
|
||||
}
|
||||
|
||||
public function destroy(Request $request, int $customerId)
|
||||
{
|
||||
CustomerRepo::delete($customerId);
|
||||
|
||||
return ['success' => true];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
@extends('admin::admin.layouts.master')
|
||||
|
||||
@section('title', '分类管理')
|
||||
|
||||
@push('header')
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div id="app">
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>编辑分类</span>
|
||||
</div>
|
||||
|
||||
<el-form label-width="200px" size="small1">
|
||||
|
||||
<el-form-item label="分类名称">
|
||||
<div style="max-width: 400px">
|
||||
@foreach (locales() as $locale)
|
||||
<el-input class="mb-1">
|
||||
<template slot="append">{{ $locale['name'] }}</template>
|
||||
</el-input>
|
||||
@endforeach
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="分类描述">
|
||||
<div style="max-width: 400px">
|
||||
@foreach (locales() as $locale)
|
||||
<el-input v-model="form.descriptions['{{ $locale['code'] }}'].content" class="mb-1">
|
||||
<template slot="append">{{ $locale['name'] }}</template>
|
||||
</el-input>
|
||||
@endforeach
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="上级分类">
|
||||
<el-select v-model="form.parent_id" placeholder="请选择上级分类">
|
||||
@foreach ($categories as $_category)
|
||||
<el-option label="{{ $_category->name }}" value="{{ $_category->id }}"></el-option>
|
||||
@endforeach
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.active">
|
||||
<el-radio :label="1">启用</el-radio>
|
||||
<el-radio :label="0">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">立即创建</el-button>
|
||||
<el-button>取消</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('footer')
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
parent_id: 0,
|
||||
active: 1,
|
||||
descriptions: {
|
||||
zh_cn: {
|
||||
name: '',
|
||||
content: '',
|
||||
},
|
||||
en: {
|
||||
name: '',
|
||||
content: '',
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
save() {
|
||||
axios.post(@json(admin_route('categories.store')), this.form).then(response => {
|
||||
this.loading = false;
|
||||
}).catch(error => {
|
||||
// this.$message.error(error.response.data.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
@extends('admin::layouts.master')
|
||||
|
||||
@section('title', '顾客管理')
|
||||
|
||||
@section('content')
|
||||
<div id="customer-app" class="card">
|
||||
<div class="card-header">
|
||||
编辑顾客
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ admin_route($customer->id ? 'customers.update' : 'customers.store', $customer) }}"
|
||||
method="POST">
|
||||
@csrf
|
||||
@method($customer->id ? 'PUT' : 'POST')
|
||||
<input type="hidden" name="_redirect" value="{{ $_redirect }}">
|
||||
|
||||
|
||||
<x-admin-form-switch title="状态" name="active" :value="old('active', $customer->active ?? 1)"/>
|
||||
|
||||
<x-admin::form.row>
|
||||
<button type="submit" class="btn btn-primary">保存</button>
|
||||
<a href="{{ $_redirect }}" class="btn btn-outline-secondary">返回</a>
|
||||
</x-admin::form.row>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('footer')
|
||||
@endpush
|
||||
Loading…
Reference in New Issue