<?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 $WLCMC) { goto XGGm9; ZdeJ5: list($faKDa, $FtPNG) = $this->viewPaths('memberAddress.index'); goto sDMjg; sDMjg: return $WLCMC->view($faKDa)->pageTitle('我的地址')->body($ExhHT); goto G60zD; ReF99: if (Request::isPost()) { return $ExhHT->request(); } goto ZdeJ5; gkDgP: $ExhHT->disableCUD()->disableItemOperate()->canAdd(true)->urlAdd(action('\\' . __CLASS__ . '@add'))->addDialogSize(array('60%', '80%')); goto y3WCr; XGGm9: $ExhHT = Grid::make('member_address'); goto Li3UU; y3WCr: $ExhHT->useSimple(function (AbstractField $Wvq57, $FSL7c, $xZl3o) { return AutoRenderedFieldValue::makeView('module::Member.View.pc.memberAddress.item', array('item' => $FSL7c)); }); goto nzadh; nzadh: $ExhHT->title('地址'); goto ReF99; Li3UU: $ExhHT->repositoryFilter(function (RepositoryFilter $zBPGV) { $zBPGV->where(array('memberUserId' => MemberUser::id())); }); goto gkDgP; G60zD: } private function doAddEdit() { goto GtrhB; n0Sb9: $enw1u = app(WebConfigBuilder::class); goto XOVcL; kdE4n: $rpy90 = null; goto Wdhxc; k5xyl: $enw1u->pageTitle(($StE5h ? '修改' : '增加') . '地址'); goto JVr9h; BshB3: $enw1u->textarea('detail', '详细地址')->required(); goto Rng4W; Rng4W: $enw1u->text('post', '邮政编码'); goto TZCi6; XOVcL: $enw1u->useDialog(); goto k5xyl; FsNNR: $enw1u->text('phone', '手机号')->required(); goto GC2E_; JVr9h: $enw1u->text('name', '姓名')->required(); goto FsNNR; GC2E_: if (modstart_module_enabled('Area')) { $enw1u->areaChina('area', '省市地区')->required(); } else { $S_vgw = '<div class=\'tw-bg-gray-200 tw-rounded tw-px-2\'>省市地区需要依赖 <a href=\'https://modstart.com/m/Area\' target=\'_blank\'>Area</a> 模块</div>'; $enw1u->html('area', '省市地区')->html($S_vgw)->addable(true)->required(); } goto BshB3; TZCi6: return $enw1u->perform(ArrayUtil::keepKeys($rpy90, array('name', 'phone', 'area', 'detail', 'post')), function (Form $hUMbi) use($StE5h) { $cwaKT = $hUMbi->dataForming(); if ($StE5h) { ModelUtil::update('member_address', $StE5h, $cwaKT); } else { $cwaKT['memberUserId'] = MemberUser::id(); ModelUtil::insert('member_address', $cwaKT); } return Response::redirect(CRUDUtil::jsDialogCloseAndParentGridRefresh()); }); goto vNqoy; Wdhxc: if ($StE5h) { $rpy90 = ModelUtil::get('member_address', array('id' => $StE5h, 'memberUserId' => MemberUser::id())); BizException::throwsIfEmpty('地址不存在', $rpy90); } goto n0Sb9; GtrhB: $StE5h = CRUDUtil::id(); goto kdE4n; vNqoy: } public function add() { return $this->doAddEdit(); } public function edit() { return $this->doAddEdit(); } public function delete() { goto RBc0h; ihWKR: $rpy90 = ModelUtil::get('member_address', array('id' => $StE5h, 'memberUserId' => MemberUser::id())); goto mACbD; mACbD: BizException::throwsIfEmpty('地址不存在', $rpy90); goto duvLm; duvLm: ModelUtil::delete('member_address', $StE5h); goto Nq5dy; Nq5dy: return Response::redirect(CRUDUtil::jsGridRefresh()); goto H8UHT; RBc0h: $StE5h = CRUDUtil::id(); goto ihWKR; H8UHT: } }