作者 guosheng
1 个管道 的构建 通过 耗费 9 秒

用户登录判断调试

... ... @@ -114,6 +114,7 @@ class Frontend extends Controller
// 加载当前控制器语言包
$this->loadlang($controllername);
$this->assign('site', $site);
$this->assign('token', $token);
$this->assign('config', $config);
}
... ...
... ... @@ -9,12 +9,15 @@
namespace app\index\controller;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
class Address extends HomeBase
class Address extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
public function add(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$param = $this->request->param();
$validate = new \think\Validate([
'name' => 'require',
... ... @@ -39,7 +42,7 @@ class Address extends HomeBase
$this->success('SUCCESS','',['address_id'=>$result]);
}
public function edit(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$param = $this->request->param();
$validate = new \think\Validate([
'address_id' => 'require',
... ... @@ -62,7 +65,7 @@ class Address extends HomeBase
$this->success('SUCCESS','',['address_id'=>$param['address_id']]);
}
public function update(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$param = $this->request->param();
$validate = new \think\Validate([
'name' => 'require',
... ... @@ -100,7 +103,7 @@ class Address extends HomeBase
if(empty($id)){
$this->error('缺少必要参数');
}
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$addressModel = new \app\index\model\Address();
$result = $addressModel->where(['user_id'=>$user_id,'id'=>$id])->delete();
if(empty($result)){
... ...
... ... @@ -9,17 +9,21 @@
namespace app\index\controller;
use app\common\controller\Frontend;
use app\common\controller\HomeBase;
use app\index\model\Store;
class Car extends HomeBase
class Car extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* 购物车页面
* @return mixed
*/
public function index(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$carModel = new \app\index\model\Car();
$car1 = $carModel->where(['user_id'=>$user_id])->group('store_id')->select();
$store_ids = [];
... ... @@ -47,7 +51,7 @@ class Car extends HomeBase
* 更新购物车
*/
public function add(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$goods_id = $this->request->param('goods_id',0,'intval');
$number = $this->request->param('number',1,'intval');
$type = $this->request->param('type',0,'intval');//1增,2减
... ...
... ... @@ -9,13 +9,16 @@
namespace app\index\controller;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
use app\index\model\Goodscollect;
class Collect extends HomeBase
class Collect extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
public function index(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$goods_id = $this->request->param('goods_id',0,'intval');
if(empty($goods_id)){
$this->error('缺少必要参数');
... ...
... ... @@ -9,12 +9,15 @@
namespace app\index\controller;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
use app\index\model\Firmstores;
use app\index\model\Minestore;
class Enter extends HomeBase
class Enter extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* 申请入驻页面
* @return mixed
... ... @@ -23,7 +26,7 @@ class Enter extends HomeBase
* @throws \think\exception\DbException
*/
public function index(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
... ... @@ -44,7 +47,7 @@ class Enter extends HomeBase
* @throws \think\exception\DbException
*/
public function apply_personage(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
... ... @@ -65,7 +68,7 @@ class Enter extends HomeBase
* @throws \think\exception\DbException
*/
public function apply_company(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
... ... @@ -79,7 +82,7 @@ class Enter extends HomeBase
}
public function submit_personage(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
... ... @@ -119,7 +122,7 @@ class Enter extends HomeBase
}
public function submit_company(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$userModel = new \app\index\model\User();
$user = $userModel->findData(['id'=>$user_id]);
if(empty($user)){
... ...
... ... @@ -9,7 +9,7 @@
namespace app\index\controller;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
use app\index\model\Evaluate;
use app\index\model\Goodscollect;
use app\index\model\Goodstype;
... ... @@ -17,8 +17,11 @@ use app\index\model\Pic;
use app\index\model\Province;
use app\index\model\Store;
class Goods extends HomeBase
class Goods extends Frontend
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 采购中心页面
* @return mixed
... ... @@ -47,7 +50,10 @@ class Goods extends HomeBase
* @return mixed
*/
public function detail(){
$user_id = $this->userId;
$user_id = 0;
if($this->auth->isLogin()) {
$user_id = $this->auth->id;
}
$goods_id = $this->request->param('goods_id',0,'intval');
if(empty($goods_id)){
$this->error('缺少必要参数');
... ...
... ... @@ -2,11 +2,14 @@
namespace app\index\controller;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
use app\index\model\Hot;
class Index extends HomeBase
class Index extends Frontend
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
public function index(){
//热门搜索
$hotModel = new Hot();
... ...
... ... @@ -96,9 +96,19 @@ class Member extends Frontend
->order('createtime','DESC')
->paginate($param['pageNum'],false,['page'=>$param['page']]);
$list = $order->items();
$status = [
'1' => '待支付',
'2' => '待发货',
'3' => '待收货',
'4' => '待评价',
'5' => '售后',
'6' => '已完成',
];
foreach ($list as $k=>$v) {
$order[$k]['store_name'] = $store_model->where('id',$v['store_id'])->value('name');
$order[$k]['goods'] = $order_info_model->where('order_id',$v['id'])->select();
$order[$k]['operate'] = $this->get_operate($v['status']);
$order[$k]['status'] = $status[$v['status']];
}
$return = [
'list' => $list,
... ... @@ -111,6 +121,45 @@ class Member extends Frontend
}
}
private function get_operate($status) {
$operate = '';
switch ($status) {
case '1':
$operate = '<button type="button" class="btn operateBtn operateBtnGreen topay">付款</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey cancel" >取消订单</button>';
break;
case '2':
$operate = '<button type="button" class="btn operateBtn operateBtnGreen refund">退款</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
case '3':
$operate = '<button type="button" class="btn operateBtn operateBtnGreen topay">付款</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey cancel" >取消订单</button>';
break;
case '4':
$operate = '<button type="button" class="btn operateBtn operateBtnGreen confirm">确认收货</button>' .
' <button type="button" class="btn operateBtn operateBtnGreen refund">退款</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey detail" >查看订单</button>';
break;
case '5':
$operate = '<button type="button" class="btn operateBtn operateBtnGreen comment">去评价</button>' .
' <button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
case '6':
$operate = '<button type="button" class="btn operateBtn operateBtnGrey delete">删除</button>';
break;
case '7':
$operate = '<button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
case '8':
$operate = '<button type="button" class="btn operateBtn operateBtnGrey detail">查看订单</button>';
break;
}
return $operate;
}
// 我的会员
public function member()
{
... ...
... ... @@ -9,13 +9,16 @@
namespace app\api\controller;
use app\common\controller\Api;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
use app\index\model\OrderDetail;
use app\index\model\Viporder;
use think\Db;
class Notify extends HomeBase
class Notify extends Frontend
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 购买会员
* @return bool
... ...
... ... @@ -9,6 +9,7 @@
namespace app\index\controller;
use app\common\controller\Frontend;
use app\common\controller\HomeBase;
use app\index\model\Address;
use app\index\model\Area;
... ... @@ -17,8 +18,11 @@ use app\index\model\OrderInfo;
use app\index\model\Store;
use think\Db;
class Order extends HomeBase
class Order extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* 确认订单
* @return mixed
... ... @@ -27,7 +31,7 @@ class Order extends HomeBase
* @throws \think\exception\DbException
*/
public function confirm(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
// $car_ids = $this->request->param('car_ids');
$data = $this->request->param('data');
$province_id = $this->request->param('province_id',0,'intval');
... ... @@ -132,7 +136,7 @@ class Order extends HomeBase
* @throws \think\exception\DbException
*/
public function confirm_ajax(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
// $car_ids = $this->request->param('car_ids');
$data = $this->request->param('data');
$province_id = $this->request->param('province_id',0,'intval');
... ... @@ -218,7 +222,7 @@ class Order extends HomeBase
* @throws \think\exception\DbException
*/
public function create_order(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$data = $this->request->param('data');
$express = $this->request->param('express',0,'intval');
$address_id = $this->request->param('address_id',0,'intval');
... ... @@ -380,7 +384,7 @@ class Order extends HomeBase
* @throws \think\exception\DbException
*/
public function pay(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$order_id = $this->request->param('order_id',0,'intval');
$order_detail_id = $this->request->param('order_detail_id',0,'intval');
if(empty($order_id) && empty($order_detail_id)){
... ... @@ -436,7 +440,7 @@ class Order extends HomeBase
* @throws \think\exception\DbException
*/
public function order_pay(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$order_id = $this->request->param('order_id',0,'intval');
$order_detail_id = $this->request->param('order_detail_id',0,'intval');
if(empty($order_id) && empty($order_detail_id)){
... ...
... ... @@ -9,7 +9,7 @@
namespace app\index\controller;
use app\common\controller\HomeBase;
use app\common\controller\Frontend;
use app\index\model\Area;
use app\index\model\Province;
use fast\Http;
... ... @@ -19,8 +19,11 @@ use fast\Http;
* Class Sundry
* @package app\index\controller
*/
class Sundry extends HomeBase
class Sundry extends Frontend
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 关键字输入提示
*/
... ...
... ... @@ -10,7 +10,6 @@ namespace app\index\controller;
use app\common\controller\Frontend;
use app\common\controller\HomeBase;
use app\index\model\Code;
use fast\Random;
use think\captcha\Captcha;
... ... @@ -20,14 +19,13 @@ use think\Db;
class User extends Frontend
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = [];
protected $noNeedRight = ['*'];
/**
* 登录页
* @return mixed
*/
public function login_view(){
print_r(Cookie::get('token'));
$this->assign('title',"登录");
return $this->fetch();
}
... ...
... ... @@ -9,16 +9,19 @@
namespace app\index\controller;
use app\common\controller\Frontend;
use app\index\controller\WechatPay;
use app\common\controller\HomeBase;
use app\index\model\Firmstores;
use app\index\model\Minestore;
use app\index\model\Price;
use app\index\model\Province;
use app\index\model\Viporder;
class Vip extends HomeBase
class Vip extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
/**
* vip购买页面
* @return mixed
... ... @@ -27,7 +30,7 @@ class Vip extends HomeBase
* @throws \think\exception\DbException
*/
public function index(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
//个人店铺
$minestoreModel = new Minestore();
$minestore = $minestoreModel->findData(['user_id'=>$user_id]);
... ... @@ -57,7 +60,7 @@ class Vip extends HomeBase
* @throws \think\exception\DbException
*/
public function create_order(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$param = $this->request->param();
$validate = new \think\Validate([
'pay_type' => 'require',
... ... @@ -150,7 +153,7 @@ class Vip extends HomeBase
* @throws \think\exception\DbException
*/
public function order_pay(){
$user_id = $this->getUserId();
$user_id = $this->auth->id;
$order_id = $this->request->param('order_id',0,'intval');
if(empty($order_id)){
$this->error('缺少必要参数');
... ...
... ... @@ -13,6 +13,11 @@ use think\Model;
class OrderDetail extends Model
{
public function getCreatetimeAttr($data) {
return date('Y-m-d H:i',$data);
}
public function insertData($data){
$result = $this->insertGetId($data);
return $result;
... ...
... ... @@ -596,14 +596,16 @@
display: inline-block;
}
.storeName {
width: 180px;
padding: 0 30px;
font-weight: 500;
color: rgba(61, 68, 77, 1);
font-size: 14px;
font-family: PingFang SC;
overflow: hidden;
}
.orderNum {
width: 173px;
width: 220px;
}
.orderTime {
width: 164px;
... ... @@ -615,7 +617,7 @@
color: rgba(61, 68, 77, 1);
padding-right: 26px;
height: 20px;
overflow: hidden; /*超出部分隐藏*/
/*overflow: hidden; !*超出部分隐藏*!*/
text-overflow: ellipsis; /* 超出部分显示省略号 */
white-space: nowrap; /*规定段落中的文本不进行换行 */
}
... ... @@ -779,7 +781,7 @@
<div class="allOrderContent">
<ul>
<li class="goodsDesc">
<img class="goodsPic" src="images/shoppingImg.png" alt="">
<img class="goodsPic" src="__CDN__/assets/store/images/shoppingImg.png" alt="">
<span class="goodsName">商品名称商品名称商品名称商品名称商品名称商品名称</span>
</li>
<li class="goodsDetail goodsDetailShow">
... ... @@ -1545,16 +1547,10 @@
' ¥'+vg.goods_price+'\n' +
' </li>\n' +
' <li class="goodsDetail goodsDetailState goodsDetailShow">\n' +
' 待支付\n' +
' '+v.status+'\n' +
' </li>\n' +
' <li class="goodsDetail operate">\n' +
' <button type="button" class="btn operateBtn operateBtnGreen onclick="payment()">付款</button>\n' +
' <button type="button" class="btn operateBtn operateBtnGrey" onclick="seeOrder()">查看订单</button>\n' +
' <button type="button" class="btn operateBtn operateBtnGrey" onclick="cancelOrder">取消订单</button>\n' +
' <!-- <button type="button" class="btn operateBtn operateBtnGreen">退款</button>\n' +
' <button type="button" class="btn operateBtn operateBtnGreen">确认收货</button>\n' +
' <button type="button" class="btn operateBtn operateBtnGreen">去评价</button>\n' +
' <button type="button" class="btn operateBtn operateBtnGrey">删除</button>-->\n' +
' <li class="goodsDetail operate" data-order_id="'+v.id+'" data-num="'+v.num+'">\n' +
' '+ v.operate +
' </li>\n' +
' <div class="clear"></div>\n' +
' </ul>';
... ... @@ -1578,12 +1574,16 @@
function initOrderList(obj,totalSize = 0, current_page = 1, totalPage = 0, pageNum = 1, showPageNum = 5) {
//全部订单分页
$("#paginationAllOrder").whjPaging({
//每页显示数据条数
pageNum: pageNum,
//当前页
current_page: current_page,
//可选,总条数
totalSize: 90,
totalSize: totalSize,
//可选,总页数
totalPage: 18,
totalPage: totalPage,
//可选,展示页码数量,默认5个页码数量
showPageNum: 5,
showPageNum: showPageNum,
//可选,css设置,可设置值:css-1,css-2,css-3,css-4,css-5,默认css-1,可自定义样式
css: 'css-1',
//可选,上一页按钮展示文本,默认显示文本为上一页
... ... @@ -1632,25 +1632,6 @@
type: 'success'
});
}
//设置cookie
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
//获取cookie
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
</script>
</body>
</html>
\ No newline at end of file
... ...