提交 3aaa31cc 编写于 作者: D devil_gong

search

上级 b0429f28
{
"pages": [
"pages": ["pages/goods-search/goods-search",
"pages/index/index",
"pages/goods-category/goods-category",
"pages/cart/cart",
......@@ -8,7 +8,7 @@
"pages/login/login",
"pages/paytips/paytips",
"pages/goods-search/goods-search",
"pages/goods-detail/goods-detail",
"pages/goods-attribute/goods-attribute",
"pages/buy/buy",
......
......@@ -105,15 +105,15 @@ Page({
// 数量输入事件
goods_buy_number_blur(e) {
var index = e.currentTarget.dataset.index || 0;
var index = e.target.dataset.index || 0;
var buy_number = parseInt(e.detail.value) || 1;
this.goods_buy_number_func(index, buy_number);
},
// 数量操作事件
goods_buy_number_event(e) {
var index = e.currentTarget.dataset.index || 0;
var type = parseInt(e.currentTarget.dataset.type) || 0;
var index = e.target.dataset.index || 0;
var type = parseInt(e.target.dataset.type) || 0;
var temp_buy_number = parseInt(this.data.data_list[index]['stock']);
if (type == 0) {
var buy_number = temp_buy_number - 1;
......@@ -280,7 +280,7 @@ Page({
// 选中处理
selectedt_event(e) {
var type = e.currentTarget.dataset.type || null;
var type = e.target.dataset.type || null;
if (type != null)
{
var temp_data_list = this.data.data_list;
......@@ -296,7 +296,7 @@ Page({
// 节点操作
case 'node' :
var index = e.currentTarget.dataset.index || 0;
var index = e.target.dataset.index || 0;
temp_data_list[index]['selected'] = (temp_data_list[index]['selected'] == true) ? false : true;
break;
}
......
/* 商品列表 */
/**
* 商品列表
*/
.data-list {
overflow: hidden;
}
......@@ -25,4 +27,64 @@
.data-list .items .base,
.data-list .items .base .price {
margin-top: 15rpx;
}
/**
* 条件
*/
.popup-form {
height: calc(100vh - 20rpx);
padding: 20rpx 20rpx 0 20rpx;
}
.popup-form input {
font-size: 24rpx;
height: 50rpx;
line-height: 50rpx;
background: #efefef;
}
.screening-price input {
width: 220rpx;
}
.screening-price .separator {
margin-top: 20rpx;
width: 30rpx;
}
.popup-form .keywords input {
width: 490rpx;
}
.popup-form .item:not(:last-child) {
margin-bottom: 50rpx;
}
.popup-form .item .title {
margin-bottom: 10rpx;
font-size: 28rpx;
}
.popup-form .form-submit {
height: 80rpx;
line-height: 80rpx;
position: absolute;
left: 0;
bottom: 0;
border-radius: 0;
}
/**
* 排序导航
*/
.nav-sort-content .item {
height: 60rpx;
line-height: 60rpx;
width: 160rpx;
}
.nav-sort-content .item .icon {
width: 30rpx;
height: 30rpx;
vertical-align: middle;
}
.screening-submit {
width: 45rpx;
height: 45rpx;
position: absolute;
top: 10rpx;
right: 20rpx;
}
\ No newline at end of file
<!-- 排序 -->
<view class="nav-sort oh br-b">
<view class="nav-sort-content">
<block a:for="{{search_nav_sort_list}}">
<view class="item tc fl" data-index="{{index}}" onTap="nav_sort_event">
<text class="cr-666">{{item.name}}</text>
<image a:if="{{(item.icon || null) != null}}" class="icon" src="/images/search-{{item.icon}}-icon.png" mode="aspectFill" />
</view>
</block>
</view>
<image class="screening-submit" src="/images/search-submit-icon.png" mode="aspectFill" onTap="popup_form_event_show" />
</view>
<!-- 筛选条件 popup -->
<popup show="{{is_show_popup_form}}" position="right" onClose="popup_form_event_close">
<form onSubmit="form_submit_event" class="popup-form oh bg-white">
<view class="item oh screening-price">
<view class="title cr-666">价格区间(元)</view>
<input type="digit" placeholder="最低价" name="min_price" class="br fl" />
<view class="cr-888 fl tc separator">~</view>
<input type="digit" placeholder="最高价" name="max_price" class="br fl" />
</view>
<view class="item keywords">
<view class="title cr-666">关键字</view>
<input type="text" placeholder="关键字" name="keywords" value="{{(params.keywords || '')}}" class="br" />
</view>
<button formType="submit" class="bg-main form-submit wh-auto" disabled="{{popup_form_loading_status}}" hover-class="none">确认</button>
</form>
</popup>
<!-- 列表 -->
<scroll-view scroll-y="{{true}}" class="scroll-box" onScrollToLower="scroll_lower" lower-threshold="30">
<view class="data-list">
<view class="items bg-white" a:for="{{data_list}}">
......
......@@ -7,10 +7,18 @@ Page({
data_page_total: 0,
data_page: 1,
params: null,
post_data: {},
is_show_popup_form: false,
popup_form_loading_status: false,
search_nav_sort_list: [
{ name: "综合", field: "default", sort: "asc", "icon": null },
{ name: "销量", field: "sales_count", sort: "asc", "icon": "default" },
{ name: "价格", field: "price", sort: "asc", "icon": "default" },
],
},
onLoad(params) {
this.setData({params: params});
this.setData({params: params, post_data: params});
this.init();
},
......@@ -128,4 +136,52 @@ Page({
scroll_lower(e) {
this.get_data_list();
},
// 搜索条件
form_submit_event(e) {
this.setData({ post_data: e.detail.value, data_page: 1});
this.popup_form_event_close();
this.get_data_list(1);
},
// 筛选条件关闭
popup_form_event_close(e) {
this.setData({ is_show_popup_form: false});
},
// 筛选条件开启
popup_form_event_show(e) {
this.setData({ is_show_popup_form: true });
},
// 筛选
nav_sort_event(e) {
var index = e.target.dataset.index || 0;
var temp_post_data = this.data.post_data;
var temp_search_nav_sort = this.data.search_nav_sort_list;
var temp_sort = (temp_search_nav_sort[index]['sort'] == 'desc') ? 'asc' : 'desc';
for (var i in temp_search_nav_sort) {
if(i != index) {
if (temp_search_nav_sort[i]['icon'] != null) {
temp_search_nav_sort[i]['icon'] = 'default';
}
temp_search_nav_sort[i]['sort'] = 'desc';
}
}
temp_search_nav_sort[index]['sort'] = temp_sort;
if (temp_search_nav_sort[index]['icon'] != null) {
temp_search_nav_sort[index]['icon'] = temp_sort;
}
temp_post_data['order_by_field'] = temp_search_nav_sort[index]['field'];
temp_post_data['order_by_type'] = temp_sort;
this.setData({
post_data: temp_post_data,
search_nav_sort_list: temp_search_nav_sort,
data_page: 1,
});
this.get_data_list(1);
},
});
{
"pullRefresh": true
"pullRefresh": true,
"usingComponents": {
"popup": "mini-antui/es/popup/index"
}
}
\ No newline at end of file
/**
* 搜索
*/
.search {
left: 0;
top: 20rpx;
box-sizing: border-box;
padding: 15rpx 20rpx;
background: #d2364c;
}
.search-content {
border-radius: 6rpx;
position: relative;
}
.search icon {
position: absolute;
left: 10rpx;
top: 10rpx;
}
.search input {
font-size: 28rpx;
padding-left: 50rpx;
box-sizing: border-box;
height: 60rpx;
line-height: 60rpx;
}
/**
* 楼层数据
*/
.floor-list, .floor-left {
overflow: hidden;
position: relative;
......
<!-- 搜索 -->
<view class="search wh-auto">
<view class="search-content bg-white oh">
<icon type="search" size="16" />
<input type="text" confirm-type="search" placeholder="其实搜索很简单^_^!" class="wh-auto" onConfirm="search_input_event" />
</view>
</view>
<!-- 轮播 -->
<component-home-banner />
......
......@@ -72,6 +72,20 @@ Page({
});
},
// 搜索事件
search_input_event(e) {
var keywords = e.detail.value || null;
if (keywords == null) {
my.showToast({content: '请输入搜索关键字'});
return false;
}
// 进入搜索页面
my.navigateTo({
url: '/pages/goods-search/goods-search?keywords='+keywords
});
},
// 下拉刷新
onPullDownRefresh() {
this.init();
......
......@@ -293,7 +293,7 @@ Page({
if (res.data.code == 0) {
var temp_data_list = this.data.data_list;
temp_data_list[index]['status'] = 5;
temp_data_list[index]['status_text'] = '已取消';
temp_data_list[index]['status_name'] = '已取消';
this.setData({data_list: temp_data_list});
my.showToast({
......@@ -346,7 +346,7 @@ Page({
if (res.data.code == 0) {
var temp_data_list = this.data.data_list;
temp_data_list[index]['status'] = 4;
temp_data_list[index]['status_text'] = '已完成';
temp_data_list[index]['status_name'] = '已完成';
this.setData({data_list: temp_data_list});
my.showToast({
......
......@@ -48,7 +48,7 @@ class BuyController extends CommonController
public function Index()
{
// 获取商品列表
$params = $_POST;
$params = $this->data_post;
$params['user'] = $this->user;
$ret = BuyService::BuyTypeGoodsList($params);
......@@ -94,7 +94,7 @@ class BuyController extends CommonController
*/
public function Add()
{
$params = $_POST;
$params = $this->data_post;
$params['user'] = $this->user;
$ret = BuyService::OrderAdd($params);
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
......
......@@ -46,9 +46,9 @@ class CommonController extends Controller
$this->CommonInit();
// 输入参数
$this->data_post = I('post.');
$this->data_get = I('get.');
$this->data_request = I('request.');
$this->data_post = $_POST;
$this->data_get = $_GET;
$this->data_request = $_REQUEST;
}
/**
......
......@@ -130,34 +130,16 @@ class OrderController extends CommonController
*/
public function Cancel()
{
if(empty($this->data_post['id']))
{
$this->ajaxReturn('请选择订单');
}
$m = M('Order');
$where = ['id'=>intval($this->data_post['id']), 'user_id' => $this->user['id']];
$data = $m->where($where)->field('id,status')->find();
if(empty($data))
{
$this->ajaxReturn(L('common_data_no_exist_error'));
}
if(!in_array($data['status'], [0,1]))
{
$status_text = L('common_order_user_status')[$data['status']]['name'];
$this->ajaxReturn('状态不可操作['.$status_text.']');
}
$save_data = ['status' => 5, 'cancel_time' => time(), 'upd_time' => time()];
if($m->where($where)->save($save_data))
{
$this->ajaxReturn(L('common_cancel_success'), 0);
}
$this->ajaxReturn(L('common_cancel_error'));
$params = $this->data_post;
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
$ret = OrderService::OrderCancel($params);
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
}
/**
* [Collect 订单完成]
* [Collect 订单收货]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
......@@ -165,127 +147,31 @@ class OrderController extends CommonController
*/
public function Collect()
{
if(empty($this->data_post['id']))
{
$this->ajaxReturn('请选择订单');
}
$m = M('Order');
$where = ['id'=>intval($this->data_post['id']), 'user_id' => $this->user['id']];
$data = $m->where($where)->field('id,status')->find();
if(empty($data))
{
$this->ajaxReturn(L('common_data_no_exist_error'));
}
if(!in_array($data['status'], [3]))
{
$status_text = L('common_order_user_status')[$data['status']]['name'];
$this->ajaxReturn('状态不可操作['.$status_text.']');
}
$save_data = ['status' => 4, 'success_time' => time(), 'upd_time' => time()];
if($m->where($where)->save($save_data))
{
$this->ajaxReturn(L('common_confirm_success'), 0);
}
$this->ajaxReturn(L('common_confirm_error'));
$params = $this->data_post;
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
$ret = OrderService::OrderCollect($params);
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
}
// /**
// * [Pay 订单支付]
// * @author Devil
// * @blog http://gong.gg/
// * @version 1.0.0
// * @datetime 2018-07-22T22:10:46+0800
// */
// public function Pay()
// {
// if(empty($this->data_post['id']))
// {
// $this->ajaxReturn('请选择订单');
// }
// $m = M('Order');
// $where = ['id'=>intval($this->data_post['id']), 'user_id' => $this->user['id']];
// $data = $m->where($where)->field('id,status,total_price')->find();
// if(empty($data))
// {
// $this->ajaxReturn(L('common_data_no_exist_error'));
// }
// if($data['total_price'] <= 0.00)
// {
// $this->ajaxReturn('金额不能为0');
// }
// if($data['status'] != 1)
// {
// $status_text = L('common_order_user_status')[$data['status']]['name'];
// $this->ajaxReturn('状态不可操作['.$status_text.']');
// }
// // 发起支付
// $notify_url = __MY_URL__.'Notify/order.php';
// $pay_data = array(
// 'out_user' => md5($this->user['id']),
// 'order_sn' => $data['id'].GetNumberCode(6),
// 'name' => '订单支付',
// 'total_price' => $data['total_price'],
// 'notify_url' => $notify_url,
// );
// $pay = (new \Library\Alipay())->SoonPay($pay_data, C("alipay_key_secret"));
// if(empty($pay))
// {
// $this->ajaxReturn('支付接口异常');
// }
// $this->ajaxReturn(L('common_operation_success'), 0, $pay);
// }
/**
* 确认
* 订单删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-06-18T00:10:32+0800
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-30
* @desc description
*/
public function Confirm()
public function Delete()
{
die('error');
// 参数
$params = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '请选择订单',
]
];
$ret = params_checked($this->data_post, $params);
if($ret !== true)
{
$this->ajaxReturn($ret);
}
// 订单处理
$m = M('Order');
$where = ['id'=>intval($this->data_post['id']), 'user_id' => $this->user['id']];
$data = $m->where($where)->field('id,status')->find();
if(empty($data))
{
$this->ajaxReturn(L('common_data_no_exist_error'));
}
// 状态
if($temp['status'] != 0)
{
$status_text = L('common_order_user_status')[$data['status']]['name'];
$this->ajaxReturn('状态不可操作['.$status_text.']');
}
// 开始处理
$save_data = ['status' => 1, 'confirm_time' => time(), 'upd_time' => time()];
if($m->where($where)->save($data))
{
$this->ajaxReturn(L('common_confirm_success'), 0);
}
$this->ajaxReturn(L('common_confirm_error'));
$params = $this->data_post;
$params['user_id'] = $this->user['id'];
$params['creator'] = $this->user['id'];
$params['creator_name'] = $this->user['user_name_view'];
$params['user_type'] = 'user';
$ret = OrderService::OrderDelete($params);
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
}
}
......
......@@ -87,18 +87,20 @@ class SearchService
if(!empty($params['screening_price_id']))
{
$price = M('ScreeningPrice')->field('min_price,max_price')->where(['is_enable'=>1, 'id'=>intval($params['screening_price_id'])])->find();
if(!empty($price['min_price']) && !empty($price['max_price']))
$params['min_price'] = $price['min_price'];
$params['max_price'] = $price['max_price'];
if(!empty($params['min_price']) && !empty($params['max_price']))
{
$where['g.price'] = [
['EGT', $price['min_price']],
['LT', $price['max_price']],
['EGT', $params['min_price']],
['LT', $params['max_price']],
];
} else if(!empty($price['min_price']))
} else if(!empty($params['min_price']))
{
$where['g.price'] = ['EGT', $price['min_price']];
} else if(!empty($price['max_price']))
$where['g.price'] = ['EGT', $params['min_price']];
} else if(!empty($params['max_price']))
{
$where['g.price'] = ['LT', $price['max_price']];
$where['g.price'] = ['LT', $params['max_price']];
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册