<?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 $j13Tr) { goto eDwAR; SSda1: $ktizU->useSimple(function (AbstractField $UdGHQ, $Z32UA, $OPJGK) { return AutoRenderedFieldValue::makeView('module::Member.View.pc.memberAddress.item', array('item' => $Z32UA)); }); goto f0RC1; E0GaC: $ktizU->disableCUD()->disableItemOperate()->canAdd(true)->urlAdd(action('\\' . __CLASS__ . '@add'))->addDialogSize(array('60%', '80%')); goto SSda1; f0RC1: $ktizU->title('地址'); goto PAFCu; eDwAR: $ktizU = Grid::make('member_address'); goto G_mWS; G_mWS: $ktizU->repositoryFilter(function (RepositoryFilter $wPpmz) { $wPpmz->where(array('memberUserId' => MemberUser::id())); }); goto E0GaC; E0vtv: return $j13Tr->view($RzPgc)->pageTitle('我的地址')->body($ktizU); goto hGvW3; PAFCu: if (Request::isPost()) { return $ktizU->request(); } goto p3hwP; p3hwP: list($RzPgc, $FViDa) = $this->viewPaths('memberAddress.index'); goto E0vtv; hGvW3: } private function doAddEdit() { goto Y60Sl; nVZG_: if ($M3rBS) { $HKoLA = ModelUtil::get('member_address', array('id' => $M3rBS, 'memberUserId' => MemberUser::id())); BizException::throwsIfEmpty('地址不存在', $HKoLA); } goto laQ0Z; fHH2I: $IuwRA->text('name', '姓名')->required(); goto ltHfc; tDze1: if (modstart_module_enabled('Area')) { $IuwRA->areaChina('area', '省市地区')->required(); } else { $ZhTLO = '<div class=\'tw-bg-gray-200 tw-rounded tw-px-2\'>省市地区需要依赖 <a href=\'https://modstart.com/m/Area\' target=\'_blank\'>Area</a> 模块</div>'; $IuwRA->html('area', '省市地区')->html($ZhTLO)->addable(true)->required(); } goto IfLrK; Emmx1: $IuwRA->useDialog(); goto NJZVi; Y60Sl: $M3rBS = CRUDUtil::id(); goto BDBxK; LPJs3: $IuwRA->text('post', '邮政编码'); goto YIY7C; laQ0Z: $IuwRA = app(WebConfigBuilder::class); goto Emmx1; IfLrK: $IuwRA->textarea('detail', '详细地址')->required(); goto LPJs3; YIY7C: return $IuwRA->perform(ArrayUtil::keepKeys($HKoLA, array('name', 'phone', 'area', 'detail', 'post')), function (Form $s4jIj) use($M3rBS) { $Pg57y = $s4jIj->dataForming(); if ($M3rBS) { ModelUtil::update('member_address', $M3rBS, $Pg57y); } else { $Pg57y['memberUserId'] = MemberUser::id(); ModelUtil::insert('member_address', $Pg57y); } return Response::redirect(CRUDUtil::jsDialogCloseAndParentGridRefresh()); }); goto aDvsY; BDBxK: $HKoLA = null; goto nVZG_; ltHfc: $IuwRA->text('phone', '手机号')->required(); goto tDze1; NJZVi: $IuwRA->pageTitle(($M3rBS ? '修改' : '增加') . '地址'); goto fHH2I; aDvsY: } public function add() { return $this->doAddEdit(); } public function edit() { return $this->doAddEdit(); } public function delete() { goto jR9P6; fZmMV: ModelUtil::delete('member_address', $M3rBS); goto sdH7H; sdH7H: return Response::redirect(CRUDUtil::jsGridRefresh()); goto mc3jZ; jR9P6: $M3rBS = CRUDUtil::id(); goto zNt4K; zNt4K: $HKoLA = ModelUtil::get('member_address', array('id' => $M3rBS, 'memberUserId' => MemberUser::id())); goto Sm_gd; Sm_gd: BizException::throwsIfEmpty('地址不存在', $HKoLA); goto fZmMV; mc3jZ: } }