作者 王晓刚
1 个管道 的构建 通过 耗费 22 秒

合并分支 'wxg' 到 'master'

前台购买咨询功能、前台店铺详情页面



查看合并请求 !60
<?php
namespace app\admin\controller;
use app\common\controller\Backend;
/**
* 购买咨询
*
* @icon fa fa-circle-o
*/
class Consult extends Backend
{
/**
* Consult模型对象
* @var \app\admin\model\Consult
*/
protected $model = null;
protected $searchFields = 'goods.goodsname,user.username,user.mobile';
public function _initialize()
{
parent::_initialize();
$this->model = new \app\admin\model\Consult;
$this->view->assign("statusList", $this->model->getStatusList());
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = true;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['goods','user'])
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->with(['goods','user'])
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->getRelation('goods')->visible(['goodsname']);
$row->getRelation('user')->visible(['username','mobile']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}
... ...
<?php
return [
'User_id' => '用户id',
'Goods_id' => '商品id',
'Createtime' => '创建时间',
'Status' => '状态',
'Status 1' => '待处理',
'Status 2' => '已处理',
'Goods.goodsname' => '商品型号',
'User.username' => '用户名'
];
... ...
<?php
namespace app\admin\model;
use think\Model;
class Consult extends Model
{
// 表名
protected $name = 'consult';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'status_text'
];
public function getStatusList()
{
return ['1' => __('Status 1'), '2' => __('Status 2')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function goods()
{
return $this->belongsTo('Goods', 'goods_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function user()
{
return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}
... ...
<?php
namespace app\admin\validate;
use think\Validate;
class Consult extends Validate
{
/**
* 验证规则
*/
protected $rule = [
];
/**
* 提示消息
*/
protected $message = [
];
/**
* 验证场景
*/
protected $scene = [
'add' => [],
'edit' => [],
];
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_id" data-rule="required" data-source="goods/index" class="form-control selectpage" name="row[goods_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_id" data-rule="required" data-source="goods/index" class="form-control selectpage" name="row[goods_id]" type="text" value="{$row.goods_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="radio">
{foreach name="statusList" item="vo"}
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
{/foreach}
</div>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
<button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
</div>
</div>
</form>
... ...
<div class="panel panel-default panel-intro">
<div class="panel-heading">
{:build_heading(null,FALSE)}
<ul class="nav nav-tabs" data-field="status">
<li class="active"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
{foreach name="statusList" item="vo"}
<li><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
{/foreach}
</ul>
</div>
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<!--<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('consult/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
<!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('consult/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('consult/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
<!--<a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('consult/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
<!--<div class="dropdown btn-group {:$auth->check('consult/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
</ul>
</div>-->
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('consult/edit')}"
data-operate-del="{:$auth->check('consult/del')}"
width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -22,7 +22,13 @@ class Order extends Frontend
{
protected $noNeedLogin = [''];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->view->assign('is_search', 0);
$this->view->assign('is_active', 0);
$this->view->assign('title', '');
}
/**
* 确认订单
* @return mixed
... ...
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/5/20
* Time: 19:57
*/
namespace app\index\controller;
use app\common\controller\Frontend;
use app\index\model\Store;
use think\Db;
class Shop extends Frontend
{
protected $noNeedLogin = ['detail'];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->view->assign('is_search', 0);
$this->view->assign('is_active', 0);
$this->view->assign('title', '店铺详情');
}
public function detail(){
$user_id = $this->auth->id;
$store_id = $this->request->param('store_id',0,'intval');
if(empty($store_id)){
$this->error('缺少必要参数');
}
$storeModel = new Store();
$data = $storeModel->findData(['id'=>$store_id]);
$is_collect = "2";
if(!empty($user_id)){
$storecollect = Db::name('storecollect')->where(['user_id'=>$user_id,'stores_id'=>$data['id']])->find();
if(!empty($storecollect)){
$is_collect = "1";
}
}
$data['is_collect'] = $is_collect;
$this->assign('data',$data);
// dump($data);
return $this->fetch();
}
public function collect(){
$user_id = $this->auth->id;
$store_id = $this->request->param('store_id',0,'intval');
if(empty($store_id)){
$this->error('缺少必要参数');
}
$data = Db::name('storecollect')->where(['user_id'=>$user_id,'stores_id'=>$store_id])->find();
$arr['user_id'] = $user_id;
$arr['stores_id'] = $store_id;
$arr['updatetime'] = time();
if(empty($data)){
$arr['createtime'] = time();
$result = Db::name('storecollect')->insert($arr);
}else{
$result = Db::name('storecollect')->where(['id'=>$data['id']])->update($arr);
}
if(empty($result)){
$this->error('sql执行失败');
}
$this->success('SUCCESS');
}
}
\ No newline at end of file
... ...
... ... @@ -565,7 +565,7 @@
<div class="infoBox">
<p class="commodityTitle">{$data.goodsname}</p>
<div class="shopInfo">
<a href="">{$data.store_name}</a>
<a href="{:url('index/shop/detail',array('store_id'=>$data.store_id))}">{$data.store_name}</a>
{foreach name="$data.property" item="p"}
<span>{$p}</span>
{/foreach}
... ... @@ -867,6 +867,8 @@
{include file="public/js"/}
<script>
var goods_id = "{$data.id}";
var is_impose = "{$data.is_impose}";//是否限购
var imposenum = "{$data.imposenum}";//限购数量
var html1 = "<button class=\"btn buy\" onclick=\"buy("+goods_id+")\">\n" +
" 立即购买\n" +
" </button>\n" +
... ... @@ -1014,6 +1016,13 @@
// Netscape/Firefox/Opera
keyCode = e.which
}
if(is_impose == 1){
console.log(imposenum);
console.log($('.spinner input').val());
if(parseInt($('.spinner input').val()) >= parseInt(imposenum)){
return false;
};
}
$('.spinner input').val(isNaN(parseFloat($('.spinner input').val()))?1:parseFloat($('.spinner input').val()));
$('#totalPrice').html('¥0.00');
if (keyCode>=48&&keyCode<=57 || keyCode>=96&&keyCode<=105 || keyCode==8){
... ...
... ... @@ -737,24 +737,24 @@
type:"POST",
data:{"province_id":province_id,"page":page,"pageNum":pageNum,'paginate':1,'sort':sort,'keyword':keyword,'lng':lng,'lat':lat},
success:function(res){
console.log(res);
var goods_html = "";
$(res.data.data).each(function (key1, vo) {
var property = "";
$(vo.property).each(function (key2, p) {
property += "<span class=\"myLable\">"+p+"</span>";
});
var str = "<tr>\n" +
var str = "<tr onclick=\"window.location.href='{:url('index/goods/detail',array('goods_id'=>'GOODS_ID'))}'\">\n" +
" <td>"+vo.id+"</td>\n" +
" <td><img src=\""+vo.thumbnail+"\" alt=\"\" style='width: 100px;height:50px'></td>\n" +
" <td>"+vo.goodsname+"</td>\n" +
" <td>"+vo.inventory+"</td>\n" +
" <td>"+vo.store_name+property+"\n" +
" <td onclick=\"window.event.stopPropagation();window.location.href='{:url('index/shop/detail',array('store_id'=>'STORE_ID'))}'\">"+vo.store_name+property+"\n" +
" <td>"+vo.brand+"</td>\n" +
" <td>单价:¥"+vo.price+"</td>\n" +
" <td>"+vo.store_address+"("+vo.distance+"km)</td>\n" +
" </tr>";
goods_html += str.replace("GOODS_ID",vo.id);
goods_html += str.replace("GOODS_ID",vo.id).replace("STORE_ID",vo.store_id);
console.log(goods_html);
});
$('.goods_dom').html(goods_html);
$('#resultsNum').html(res.data.total+"件");
... ...
<!DOCTYPE html>
<html lang="zh">
{include file="public/head"/}
<!--swiper引入-->
<link rel="stylesheet" href="__CDN__/assets/store/js/Swiper-3.4.2/css/swiper.min.css">
<script type="text/javascript" src="__CDN__/assets/store/js/Swiper-3.4.2/js/swiper.min.js"></script>
<!--分页插件引入-->
<script type="text/javascript" src="__CDN__/assets/store/js/pagination/js/pagination.min.js"></script>
<link rel="stylesheet" href="__CDN__/assets/store/js/pagination/css/pagination.css">
<style>
.content{
width: 100%;
font-size: 0;
background: rgba(249,249,249,1);
}
/*店铺信息部分样式*/
.content .shopInfoBox{
width: 100%;
height: 322px;
margin-bottom: 12px;
background: rgba(255,255,255,1);
}
.content .shopInfoBox .shopInfoMain{
width: 1200px;
height: 100%;
margin: 0 auto;
padding: 30px;
}
.content .shopInfoBox .shopInfoMain .imgBox{
display: inline-block;
width: 262px;
height: 262px;
}
.content .shopInfoBox .shopInfoMain .imgBox img{
width: 100%;
height: 100%;
}
.content .shopInfoBox .shopInfoMain .infoBox{
width: 878px;
height: 100%;
float: right;
padding-left: 20px;
}
.content .shopInfoBox .shopInfoMain .infoBox .shopTitle{
width: 100%;
height: 28px;
font-size: 20px;
font-family: PingFang SC;
font-weight: 500;
line-height: 28px;
color: rgba(6,18,30,1);
margin-bottom: 10px;
}
.content .shopInfoBox .shopInfoMain .infoBox .contactNumber{
width: 100%;
height: 22px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
line-height: 20px;
color: rgba(61,68,77,1);
margin-bottom: 6px;
}
.content .shopInfoBox .shopInfoMain .infoBox .shopAddress{
width: 100%;
height: 22px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
line-height: 20px;
color: rgba(61,68,77,1);
margin-bottom: 10px;
}
.content .shopInfoBox .shopInfoMain .infoBox .shopIntroduceBox{
width: 100%;
height: 108px;
margin-bottom: 6px;
}
.content .shopInfoBox .shopInfoMain .infoBox .shopIntroduceBox .title{
width: 100%;
height: 22px;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
line-height: 22px;
color: rgba(61,68,77,1);
margin: 0 0 6px 0;
}
.content .shopInfoBox .shopInfoMain .infoBox .shopIntroduceBox .contentText{
width: 100%;
height: 80px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 400;
line-height: 16px;
color: rgba(61,68,77,1);
}
.content .shopInfoBox .shopInfoMain .infoBox .buttonBox{
width: 100%;
height: 51px;
}
.content .shopInfoBox .shopInfoMain .infoBox .buttonBox button{
width: 215px;
height: 51px;
background:rgba(244,244,244,1);
border-radius: 2px;
margin-right: 23px;
border: 0;
font-size: 18px;
font-family: PingFang SC;
font-weight: 500;
line-height: 25px;
color: rgba(91,94,99,1);
}
.content .shopInfoBox .shopInfoMain .infoBox .buttonBox .collected{
color: rgba(255,148,23,1);
}
/*店铺商城部分样式*/
.content .bestSellersBox{
width: 100%;
/*height: 1063px;*/
background: rgba(255,255,255,1);
}
.content .bestSellersBox .bestSellersMain{
width: 1200px;
margin: 0 auto;
}
.content .bestSellersBox .bestSellersMain .titleBox{
width: 1200px;
height: 62px;
line-height: 62px;
}
.content .bestSellersBox .bestSellersMain .titleBox span:first-child{
display: inline-block;
float: left;
width: 6px;
height: 20px;
margin-top: 21px;
background: rgba(0,159,142,1);
border-radius: 2px;
}
.content .bestSellersBox .bestSellersMain .titleBox span:nth-child(2){
height: 22px;
line-height: 22px;
float: left;
margin-top: 20px;
padding-left: 12px;
font-size: 16px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(0,159,142,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList{
width: 100%;
padding: 0 19px 0 29px;
margin-bottom: 20px;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox{
position: relative;
display: inline-block;
width: 182px;
height: 301px;
margin-right: 10px;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox a .insurance_icon{
position: absolute;
top: 0;
right: 0;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .imgBox{
position: relative;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .imgBox img{
width: 182px;
height: 182px;
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .imgBox span{
display: block;
position: absolute;
top: 152px;
width: 100%;
height: 30px;
padding: 0 12px;
background: rgba(0,0,0,0.5);
border-radius: 0 0 4px 4px;
font-size: 14px;
font-family: PingFang SC;
font-weight: 500;
line-height: 30px;
color: rgba(0,159,142,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .commodityPrice{
width: 100%;
height: 33px;
line-height: 40px;
margin: 0;
font-size: 14px;
font-family: PingFang SC;
font-weight: 600;
color: rgba(255,49,0,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .commodityName{
width: 100%;
height: 42px;
line-height: 21px;
margin: 0 0 4px 0;
text-align: left;
font-size: 14px;
font-family: PingFang SC;
font-weight: 500;
color: rgba(6,18,30,1);
}
.content .bestSellersBox .bestSellersMain .bestSellersList .commodityBox .labelBox span{
display: inline-block;
width: 70px;
height: 21px;
margin-right: 6px;
background: rgba(244,244,244,1);
border-radius: 2px;
font-size: 12px;
font-family: PingFang SC;
font-weight: 400;
line-height: 21px;
text-align: center;
color: rgba(0,0,0,1);
opacity: 0.85;
}
.content .bestSellersBox .bestSellersMain .pagingBox{
width: 100%;
height: 35px;
text-align: center;
font-size: 14px;
font-family: PingFangSC-Regular;
line-height: 22px;
color: rgba(0,0,0,1);
}
</style>
<style>
/*分页样式重写*/
.paginationMyOrder{
margin: 40px 120px;
}
#paginationGoodsCollect,#paginationStoreCollect{
padding: 20px 0 40px 240px;
}
.whj_jqueryPaginationCss-1 .whj_border{
font-size:14px;
font-family:PingFangSC-Regular;
color:rgba(0,0,0,0.65);
/*opacity:0.65;*/
border:1px solid rgba(0,0,0,0.15);
}
.whj_jqueryPaginationCss-1 .whj_padding{
margin: 0 4px;
width:32px;
height:32px;
line-height: 32px;
text-align: center;
border-radius:4px;
padding: 0;
}
.whj_jqueryPaginationCss-1 .whj_checked{
color: #fff;
border: 0;
background:rgba(0,159,142,1);
box-shadow:0px 6px 12px rgba(0,0,0,0.04);
}
.whj_jqueryPaginationCss-1 .whj_padding:hover{
color: #fff;
border: 0;
background:rgba(0,159,142,1);
box-shadow:0px 6px 12px rgba(0,0,0,0.04);
}
.whj_jqueryPaginationCss-1 select:hover{
color: #fff;
}
.whj_jqueryPaginationCss-1 select{
height:32px;
line-height: 32px;
text-align: center;
border-radius:4px;
margin: 0 4px 0 12px;
width:88px;
color:rgba(0,0,0,0.65)!important;
padding: 0 10px;
/*background: url("../images/selectIcon.png") no-repeat no-repeat 60px 8px !important;*/
}
.whj_jqueryPaginationCss-1 .whj_color{
background: transparent!important;
font-size:14px;
font-family:PingFangSC-Regular;
color:rgba(0,0,0,0.65)!important;
}
.whj_jqueryPaginationCss-1 input{
margin: 0 4px;
width:48px;
height:32px;
border:1px solid rgba(0,0,0,0.15)!important;
border-radius:4px!important;
}
</style>
<body>
{include file="public/header"/}
<!--主要内容-->
<div class="content">
{include file="public/nav"}
<!--店铺信息部分-->
<div class="shopInfoBox">
<div class="shopInfoMain">
<div class="imgBox">
<img src="{$data.thumbnail}" alt="img">
</div>
<div class="infoBox">
<p class="shopTitle">{$data.name}</p>
<p class="contactNumber">联系电话:{$data.phone}</p>
<p class="shopAddress">店铺地址:{$data.address}</p>
<div class="shopIntroduceBox">
<p class="title">店铺简介:</p>
<p class="contentText"> {$data.content}</p>
</div>
<div class="buttonBox">
<button id="collectionBtn" class="btn collection {if condition='$data.is_collect eq 1'}collected{/if}" onclick="collection({$data.id})">
{if condition="$data['is_collect'] eq 2"}
<img src="__CDN__/assets/store/images/collection_dark.png" alt="user">
<span style="font-family: 黑体;vertical-align: middle;color: rgba(91,94,99,1);">收藏</span>
{else /}
<img src="__CDN__/assets/store/images/collection_light.png" alt="user">
<span style="font-family: 黑体;vertical-align: middle;color: #FF9417;">收藏</span>
{/if}
</button>
</div>
</div>
</div>
</div>
<!--店铺商城部分-->
<div class="bestSellersBox">
<div class="bestSellersMain">
<div class="titleBox">
<span></span>
<span>店铺商城</span>
</div>
<div class="bestSellersList goods_dom">
</div>
<div class="pagingBox">
<div class="paginationMyOrder" id="paginationAllOrder">
<div class="whj_jqueryPaginationCss-1"></div>
</div>
</div>
</div>
</div>
</div>
{include file="public/footer"/}
{include file="public/js"/}
<script>
$(function () {
initLocation();
});
//定位当前位置
function initLocation(){
// 百度地图API功能
var map = new BMap.Map("allmap");
var point = new BMap.Point(116.331398,39.897445);
map.centerAndZoom(point,12);
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
if(this.getStatus() == BMAP_STATUS_SUCCESS){
var mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
//省份名称转换为id
$.ajax({
url:"{:url('index/sundry/get_province_id')}",
type:"POST",
data:{"province_name":r.address.province},
async:false,
success:function(res){
if(res.code == 1){
province_id = res.data.province_id;
lng = r.point.lng;
lat = r.point.lat;
//初始化产品热卖
initGoodsList();
}else{
toast(res.msg);
}
},
error:function(res){
toast('与服务器断开连接');
}
});
} else {
toast('failed'+this.getStatus());
}
},{enableHighAccuracy: true})
}
//初始化商品列表
function initGoodsList(page = 1, pageNum = 25){
$.ajax({
url:"{:url('index/goods/get_all')}",
type:"POST",
data:{"province_id":province_id,"page":page,"pageNum":pageNum,'paginate':1},
success:function(res){
console.log(res);
var goods_html = "";
$(res.data.data).each(function (key1, vo) {
var property = "";
$(vo.property).each(function (key2, p) {
property += "<span>"+p+"</span>";
});
var insurance = "";
if(vo.insurance == '1'){
insurance = "<img class=\"insurance_icon\" src=\"__CDN__/assets/store/images/insurance_icon.png\" alt=\"img\">";
}
var str = "<div class=\"commodityBox\">\n" +
" <a href=\"{:url('index/goods/detail',array('goods_id'=>'GOODS_ID'))}\">\n" +
" <div class=\"imgBox\">\n" +
" <img src=\""+vo.thumbnail+"\" alt=\"img\">\n" +
" <span>"+vo.store_name+"</span>\n" +
" </div>\n" +
" <p class=\"commodityPrice\">¥"+vo.price+"</p>\n" +
" <p class=\"commodityName\">"+vo.goodsname+"</p>\n" +
" <div class=\"labelBox\">\n" +
" "+property+"\n" +
" </div>\n" +
" "+insurance+"\n" +
" </a>\n" +
" </div>";
goods_html += str.replace("GOODS_ID",vo.id);
});
$('.goods_dom').html(goods_html);
//初始化分页
var totalPage = Math.ceil(res.data.total/pageNum);
initPaging(res.data.total,res.data.current_page,totalPage,pageNum);
},
error:function(res){
toast('与服务器断开连接');
}
});
}
//初始化分页
function initPaging(totalSize = 0, current_page = 1, totalPage = 0, pageNum, showPageNum = 5) {
$("#paginationAllOrder").whjPaging({
//每页显示数据条数
pageNum: pageNum,
//当前页
current_page: current_page,
//可选,总条数
totalSize: totalSize,
//可选,总页数
totalPage: totalPage,
//可选,展示页码数量,默认5个页码数量
showPageNum: showPageNum,
//可选,css设置,可设置值:css-1,css-2,css-3,css-4,css-5,默认css-1,可自定义样式
css: 'css-1',
//可选,上一页按钮展示文本,默认显示文本为上一页
previousPage: "<span class=\"glyphicon glyphicon-menu-left\" aria-hidden=\"true\" style='opacity:0.65;font-size:12px;'></span>",
//可选,下一页按钮展示文本,默认显示文本为下一页
nextPage: "<span class=\"glyphicon glyphicon-menu-right\" aria-hidden=\"true\" style='opacity:0.65;font-size:12px;'></span>",
//可选,是否展示刷新,默认true
isShowRefresh: false,
//可选,是否展示首页与尾页,默认true
isShowFL: false,
//可选,是否展示共{}页,默认true
isShowTotalPage: false,
//可选,是否展示共{}条记录,默认true
isShowTotalSize: false,
//可选,是否需要重新设置当前页码、总页数及总条数,默认false,如果设为true,那么在请求服务器返回数据时,需要调用setPage方法
isResetPage: false,
//可选,跳至展示文本,默认显示文本为跳至
skip: "跳至",
//可选,确认按钮展示文本,默认显示文本为确认
confirm: "确认",
//必选,回掉函数,返回参数:第一个参数为页码,第二个参数为每页显示N条
callBack: function (currPage, pageSize) {
console.log('currPage:' + currPage + ' pageSize:' + pageSize);
initGoodsList(currPage, pageSize)
}
});
}
/*//收藏、取消收藏
function collection() {
var userName = getCookie('user_name');
if(userName == null || userName == ''){
window.location.href = 'login.html?page=shopDetail';
}else{
if($('#collectionBtn').hasClass('collected')){
$('#collectionBtn img').attr('src','images/collection_dark.png');
$('#collectionBtn').removeClass('collected');
}else{
$('#collectionBtn img').attr('src','images/collection_light.png');
$('#collectionBtn').addClass('collected');
}
}
}*/
//收藏、取消收藏
function collection(store_id) {
$.ajax({
url:"{:url('index/shop/collect')}",
type:"POST",
data:{"store_id":store_id},
success:function(res){
if(res.code == 1){
if($('#collectionBtn').hasClass('collected')){
$('#collectionBtn img').attr('src','__CDN__/assets/store/images/collection_dark.png');
$('#collectionBtn span').css('color','rgba(91,94,99,1)');
$('#collectionBtn').removeClass('collected');
}else{
$('#collectionBtn img').attr('src','__CDN__/assets/store/images/collection_light.png');
$('#collectionBtn span').css('color','#FF9417');
$('#collectionBtn').addClass('collected');
}
toast('操作成功');
}else{
toast(res.msg);
}
},
error:function(res){
toast("与服务器断开连接");
}
})
}
</script>
</body>
</html>
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'consult/index' + location.search,
// add_url: 'consult/add',
// edit_url: 'consult/edit',
del_url: 'consult/del',
multi_url: 'consult/multi',
table: 'consult',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'user_id', title: __('User_id'),visible:false},
{field: 'user.username', title: __('User.username')},
{field: 'user.mobile', title: __('手机号')},
{field: 'goods_id', title: __('Goods_id'),visible:false},
{field: 'goods.goodsname', title: __('Goods.goodsname')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});
\ No newline at end of file
... ...