<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Member\Web\Controller; use Illuminate\Support\Facades\View; use ModStart\App\Web\Layout\WebConfigBuilder; use ModStart\App\Web\Layout\WebPage; use ModStart\Core\Dao\ModelUtil; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\Request; use ModStart\Core\Input\Response; use ModStart\Core\Util\ArrayUtil; use ModStart\Core\Util\CRUDUtil; use ModStart\Field\AbstractField; use ModStart\Field\AutoRenderedFieldValue; use ModStart\Form\Form; use ModStart\Grid\Grid; use ModStart\Grid\GridFilter; use ModStart\Module\ModuleManager; use ModStart\Repository\Filter\RepositoryFilter; use Module\Member\Auth\MemberUser; use Module\Member\Support\MemberLoginCheck; class MemberAddressController extends MemberFrameController implements MemberLoginCheck { private $api; public function __construct() { parent::__construct(); $this->api = app(\Module\Member\Api\Controller\MemberAddressController::class); } public function index(WebPage $JcqUq) { goto Edk2i; qtAOb: $gwmIt->useSimple(function (AbstractField $pZ_lR, $jIWZA, $aaYHa) { return AutoRenderedFieldValue::makeView('module::Member.View.pc.memberAddress.item', array('item' => $jIWZA)); }); goto LnvM9; qUDF3: $gwmIt->repositoryFilter(function (RepositoryFilter $bu01d) { $bu01d->where(array('memberUserId' => MemberUser::id())); }); goto VX6gE; LnvM9: $gwmIt->title('地址'); goto xLPad; VX6gE: $gwmIt->disableCUD()->disableItemOperate()->canAdd(true)->urlAdd(action('\\' . __CLASS__ . '@add'))->addDialogSize(array('60%', '80%')); goto qtAOb; xLPad: if (Request::isPost()) { return $gwmIt->request(); } goto GLYle; NdPU7: return $JcqUq->view($qVdRh)->pageTitle('我的地址')->body($gwmIt); goto sA9MR; GLYle: list($qVdRh, $plloB) = $this->viewPaths('memberAddress.index'); goto NdPU7; Edk2i: $gwmIt = Grid::make('member_address'); goto qUDF3; sA9MR: } private function doAddEdit() { goto zQfdm; xk613: if (modstart_module_enabled('Area')) { $lZifj->areaChina('area', '省市地区')->required(); } else { $AZvp2 = '<div class=\'tw-bg-gray-200 tw-rounded tw-px-2\'>省市地区需要依赖 <a href=\'https://modstart.com/m/Area\' target=\'_blank\'>Area</a> 模块</div>'; $lZifj->html('area', '省市地区')->html($AZvp2)->addable(true)->required(); } goto JyNQw; kNE1F: $lZifj->text('name', '姓名')->required(); goto fG8TQ; fG8TQ: $lZifj->text('phone', '手机号')->required(); goto xk613; aPdqG: $lZifj = app(WebConfigBuilder::class); goto AdBp7; Z6QPa: $lpVAI = null; goto GuJn8; UVnLL: $lZifj->pageTitle(($ULYbu ? '修改' : '增加') . '地址'); goto kNE1F; JyNQw: $lZifj->textarea('detail', '详细地址')->required(); goto UrANN; AdBp7: $lZifj->useDialog(); goto UVnLL; UrANN: $lZifj->text('post', '邮政编码'); goto Galyu; Galyu: return $lZifj->perform(ArrayUtil::keepKeys($lpVAI, array('name', 'phone', 'area', 'detail', 'post')), function (Form $yZTO2) use($ULYbu) { $U8wjN = $yZTO2->dataForming(); if ($ULYbu) { ModelUtil::update('member_address', $ULYbu, $U8wjN); } else { $U8wjN['memberUserId'] = MemberUser::id(); ModelUtil::insert('member_address', $U8wjN); } return Response::redirect(CRUDUtil::jsDialogCloseAndParentGridRefresh()); }); goto HLNHQ; zQfdm: $ULYbu = CRUDUtil::id(); goto Z6QPa; GuJn8: if ($ULYbu) { $lpVAI = ModelUtil::get('member_address', array('id' => $ULYbu, 'memberUserId' => MemberUser::id())); BizException::throwsIfEmpty('地址不存在', $lpVAI); } goto aPdqG; HLNHQ: } public function add() { return $this->doAddEdit(); } public function edit() { return $this->doAddEdit(); } public function delete() { goto g1UMW; h7NXb: return Response::redirect(CRUDUtil::jsGridRefresh()); goto Dl_rS; HUhzg: ModelUtil::delete('member_address', $ULYbu); goto h7NXb; kf8XZ: $lpVAI = ModelUtil::get('member_address', array('id' => $ULYbu, 'memberUserId' => MemberUser::id())); goto i3ZTc; g1UMW: $ULYbu = CRUDUtil::id(); goto kf8XZ; i3ZTc: BizException::throwsIfEmpty('地址不存在', $lpVAI); goto HUhzg; Dl_rS: } }