123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- <?php
- namespace app\index\controller;
- use app\index\model\OrderAddress;
- use app\index\model\user\PointsLog as PointsLogModel;
- use app\index\model\Goods as GoodsModel;
- use app\index\model\Order as OrderModel;
- use think\facade\Session;
- /**
- * 默认控制器
- * Class User
- * @package app\api\controller
- */
- class User extends Controller
- {
- /**
- * 个人中心
- * @return \think\response\View
- */
- public function personal()
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- $goodsModel = new GoodsModel();
- //$goods['content'] = html_entity_decode($goods['content']);
- return view('order', ['goods' => []]);
- }
- /**
- * 我的订单页面
- * @return \think\response\View
- */
- public function order(string $orderType = 'received')
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- return view('order');
- }
- /**
- * 订单详情
- * @param $orderId
- * @return \think\response\View
- * @throws \cores\exception\BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function orderDetails($orderId)
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- $model = OrderModel::getUserOrderDetail($orderId);
- $orderAddress = OrderAddress::get(['order_id' => $orderId]);
- return view('orderDetails', ['order' => $model, 'orderAddress' => $orderAddress]);
- }
- /**
- * 我的积分页面
- * @return \think\response\View
- */
- public function myScores()
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return view('passport/logIn');
- }
- $model = new PointsLogModel;
- $list = $model->getList();
- $user = \app\index\service\User::getCurrentLoginUser();
- return view('integral', ['user' => $user]);
- }
- /**
- * 我的积分列表
- * @return \think\response\Json
- * @throws \app\common\exception\BaseException
- * @throws \think\db\exception\DbException
- */
- public function pointsLogs()
- {
- $model = new PointsLogModel;
- $list = $model->getList();
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 分享商品
- * @return \think\response\Json
- */
- public function shareUser()
- {
- $userId = Session::get('user_id');
- if (empty($userId)) {
- return $this->renderJson(config('status.not_logged'), 'Log in please!');
- }
- $goodsId = $this->request->param('goodsId');
- if (empty($goodsId)) {
- return $this->renderError('Invalid goods');
- }
- $mailbox = $this->request->param('mailbox');
- if (empty($mailbox)) {
- return $this->renderError('Invalid mailbox');
- }
- //$encryptUserId = encrypt($userId);
- $encryptUserId = '';
- //dd($encryptUserId);
- $url = url('/index/index/productDetail?goodsId=' . $goodsId . '&key=' . $encryptUserId);
- //todo 发邮件
- return $this->renderSuccess([]);
- }
- }
|