| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\admin\controller\user;
- use app\common\controller\Backend;
- use app\common\model\ProductLists;
- use think\exception\DbException;
- use think\response\Json;
- /**
- * 用户存储列表 TeamRewards
- *
- * @icon fa fa-circle-o
- */
- class Userpledge extends Backend
- {
- /**
- * TeamRewards模型对象
- * @var \app\admin\model\TeamRewards
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\common\model\UserPledge;
- }
- /**
- * 查看
- *
- * @return string|Json
- * @throws \think\Exception
- * @throws DbException
- */
- public function index()
- {
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if (false === $this->request->isAjax()) {
- return $this->view->fetch();
- }
- //如果发送的来源是 Selectpage,则转发到 Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- [$where, $sort, $order, $offset, $limit] = $this->buildparams();
- $list = $this->model->with('users,pledges')
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
-
- $result = ['total' => $list->total(), 'rows' => $list->items()];
- return json($result);
- }
- /**
- * 详情
- */
- public function detail($ids)
- {
- $row = $this->model->get(['id' => $ids]);
- if (!$row) {
- $this->error(__('No Results were found'));
- }
- if ($this->request->isAjax()) {
- $this->success("Ajax请求成功", null, ['id' => $ids]);
- }
- $product = new ProductLists();
- $details = json_decode($row->details, true);
- foreach ($details as &$detail) {
- $detail['name'] = $product::where('id', $detail['id'])->value('zh_name');
- }
- $this->view->assign("row", $details);
- return $this->view->fetch();
- }
- }
|