<?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 $iXUoW) { goto ZghcR; hLxsG: if (Request::isPost()) { return $W3CVY->request(); } goto C4S92; Tlpq4: $W3CVY->useSimple(function (AbstractField $jJyrp, $YaV4m, $DbHm9) { return AutoRenderedFieldValue::makeView('module::Member.View.pc.memberAddress.item', array('item' => $YaV4m)); }); goto wgevf; DHO0p: return $iXUoW->view($kF488)->pageTitle('我的地址')->body($W3CVY); goto hHpZ8; mo7Rf: $W3CVY->disableCUD()->disableItemOperate()->canAdd(true)->urlAdd(action('\\' . __CLASS__ . '@add'))->addDialogSize(array('60%', '80%')); goto Tlpq4; wgevf: $W3CVY->title('地址'); goto hLxsG; uIfPh: $W3CVY->repositoryFilter(function (RepositoryFilter $mHisM) { $mHisM->where(array('memberUserId' => MemberUser::id())); }); goto mo7Rf; ZghcR: $W3CVY = Grid::make('member_address'); goto uIfPh; C4S92: list($kF488, $NMB1l) = $this->viewPaths('memberAddress.index'); goto DHO0p; hHpZ8: } private function doAddEdit() { goto NUTpr; MIKTE: $lLaeU = null; goto mR31A; PwPG9: $P2vse->pageTitle(($gZ39D ? '修改' : '增加') . '地址'); goto uYY_4; NUTpr: $gZ39D = CRUDUtil::id(); goto MIKTE; uYY_4: $P2vse->text('name', '姓名')->required(); goto L4VzV; rXxF7: $P2vse->text('post', '邮政编码'); goto PJCyM; eFjst: $P2vse->textarea('detail', '详细地址')->required(); goto rXxF7; mR31A: if ($gZ39D) { $lLaeU = ModelUtil::get('member_address', array('id' => $gZ39D, 'memberUserId' => MemberUser::id())); BizException::throwsIfEmpty('地址不存在', $lLaeU); } goto z_1e1; L4VzV: $P2vse->text('phone', '手机号')->required(); goto tMBh1; mKETN: $P2vse->useDialog(); goto PwPG9; z_1e1: $P2vse = app(WebConfigBuilder::class); goto mKETN; tMBh1: if (modstart_module_enabled('Area')) { $P2vse->areaChina('area', '省市地区')->required(); } else { $bW35T = '<div class=\'tw-bg-gray-200 tw-rounded tw-px-2\'>省市地区需要依赖 <a href=\'https://modstart.com/m/Area\' target=\'_blank\'>Area</a> 模块</div>'; $P2vse->html('area', '省市地区')->html($bW35T)->addable(true)->required(); } goto eFjst; PJCyM: return $P2vse->perform(ArrayUtil::keepKeys($lLaeU, array('name', 'phone', 'area', 'detail', 'post')), function (Form $NX6uw) use($gZ39D) { $avcnU = $NX6uw->dataForming(); if ($gZ39D) { ModelUtil::update('member_address', $gZ39D, $avcnU); } else { $avcnU['memberUserId'] = MemberUser::id(); ModelUtil::insert('member_address', $avcnU); } return Response::redirect(CRUDUtil::jsDialogCloseAndParentGridRefresh()); }); goto Pgz2W; Pgz2W: } public function add() { return $this->doAddEdit(); } public function edit() { return $this->doAddEdit(); } public function delete() { goto oBAUj; oBAUj: $gZ39D = CRUDUtil::id(); goto JwKEA; JwKEA: $lLaeU = ModelUtil::get('member_address', array('id' => $gZ39D, 'memberUserId' => MemberUser::id())); goto QBdJB; gjj7D: return Response::redirect(CRUDUtil::jsGridRefresh()); goto EJz33; QBdJB: BizException::throwsIfEmpty('地址不存在', $lLaeU); goto Us9xQ; Us9xQ: ModelUtil::delete('member_address', $gZ39D); goto gjj7D; EJz33: } }