初始上传
270
addon/bargain/api/controller/Bargain.php
Executable file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\api\controller;
|
||||
|
||||
use app\api\controller\BaseApi;
|
||||
use addon\bargain\model\Bargain as BargainModel;
|
||||
use app\model\order\OrderCommon;
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
*/
|
||||
class Bargain extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取我的砍价详情
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$condition = [
|
||||
[ 'launch_id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
$bargain = new BargainModel();
|
||||
$data = $bargain->getBargainLaunchDetail($condition, 'bargain_id,bargain_type,buy_type,curr_num,curr_price,floor_price,end_time,goods_id,headimg,launch_id,member_id,nickname,order_id,price,site_id,sku_id,sku_image,sku_name,start_time,status');
|
||||
if ($data[ 'code' ] == 0) {
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$bargain_goods_info = $bargain->getBargainGoodsDetail([ [ 'pbg.sku_id', '=', $data[ 'data' ][ 'sku_id' ] ], [ 'pb.status', '=', '1' ] ], 'pbg.bargain_stock,pb.status,g.goods_content')[ 'data' ];
|
||||
$data[ 'data' ][ 'bargain_stock' ] = $bargain_goods_info[ 'bargain_stock' ];
|
||||
$data[ 'data' ][ 'bargain_status' ] = $bargain_goods_info[ 'status' ];
|
||||
$data[ 'data' ][ 'goods_content' ] = $bargain_goods_info[ 'goods_content' ];
|
||||
if ($data[ 'data' ][ 'member_id' ] == $this->member_id) {
|
||||
$data[ 'data' ][ 'self' ] = 1;
|
||||
} else {
|
||||
$data[ 'data' ][ 'self' ] = 0;
|
||||
$record_info = $bargain->getBargainRecordInfo([ [ 'launch_id', '=', $id ], [ 'member_id', '=', $this->member_id ] ], 'id');
|
||||
$data[ 'data' ][ 'cut' ] = empty($record_info[ 'data' ]) ? 0 : 1;
|
||||
}
|
||||
} else {
|
||||
$data[ 'data' ][ 'self' ] = 0;
|
||||
$data[ 'data' ][ 'cut' ] = 0;
|
||||
}
|
||||
}
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的砍价分页列表
|
||||
*/
|
||||
public function launchPage()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
$status = $this->params[ 'status' ] ?? 'all';
|
||||
|
||||
$condition = [
|
||||
[ 'pbl.site_id', '=', $this->site_id ],
|
||||
[ 'pbl.member_id', '=', $this->member_id ]
|
||||
];
|
||||
if ($status != 'all') {
|
||||
$condition[] = [ 'pbl.status', '=', $status ];
|
||||
}
|
||||
$bargain = new BargainModel();
|
||||
$field = 'pbl.*, pb.status as bargain_status';
|
||||
$data = $bargain->getBargainLaunchPageList($condition, $field, 'pbl.launch_id desc', $page, $page_size, 'pbl', [
|
||||
[ 'promotion_bargain pb', 'pbl.bargain_id = pb.bargain_id', 'inner' ]
|
||||
]);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起砍价
|
||||
* @return false|string
|
||||
*/
|
||||
public function launch()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->launch($id, $this->member_id, $this->site_id, $this->store_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价
|
||||
*/
|
||||
public function bargain()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->bargain($id, $this->member_id, $this->site_id);
|
||||
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价记录
|
||||
* @return false|string
|
||||
*/
|
||||
public function record()
|
||||
{
|
||||
$id = $this->params[ 'id' ] ?? 0;
|
||||
if (empty($id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
|
||||
$condition = [
|
||||
[ 'launch_id', '=', $id ]
|
||||
];
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$data = $bargain->getBargainRecordPageList($condition, '*', 'id desc', $page, $page_size);
|
||||
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价详情
|
||||
* @return false|string|void
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
$launch_id = $this->params[ 'launch_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$token = $this->checkToken();
|
||||
$bargain = new BargainModel();
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pbg.site_id', '=', $this->site_id ],
|
||||
// [ 'pbg.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$goods_sku_detail = $bargain->getBargainGoodsDetail($condition, '')[ 'data' ];
|
||||
|
||||
$bargain->bargainBrowseInc([ [ 'bargain_id', '=', $bargain_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
|
||||
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
|
||||
if (empty($goods_sku_detail)) return $this->response($this->error($res));
|
||||
|
||||
if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
|
||||
//判断商品规格项
|
||||
$goods_spec_format = $bargain->getGoodsSpecFormat($bargain_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
|
||||
$res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
|
||||
$launch_info = [];
|
||||
if ($launch_id) {
|
||||
$condition = [
|
||||
[ 'launch_id', '=', $launch_id ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
$launch_info = $bargain->getBargainLaunchDetail($condition, 'bargain_id,bargain_type,buy_type,curr_num,curr_price,floor_price,end_time,goods_id,headimg,launch_id,member_id,nickname,order_id,price,site_id,sku_id,sku_image,sku_name,start_time,status')[ 'data' ] ?? [];
|
||||
} else {
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$launch_info = $bargain->getBargainLaunchDetail([
|
||||
[ 'bargain_id', '=', $goods_sku_detail[ 'bargain_id' ] ],
|
||||
[ 'sku_id', '=', $goods_sku_detail[ 'sku_id' ] ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
[ 'status', '=', 0 ]
|
||||
], 'bargain_id,bargain_type,buy_type,curr_num,curr_price,floor_price,end_time,goods_id,headimg,launch_id,member_id,nickname,order_id,price,site_id,sku_id,sku_image,sku_name,start_time,status')[ 'data' ] ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
if ($launch_info) {
|
||||
$launch_info[ 'pay_status' ] = 0;
|
||||
if ($launch_info[ 'order_id' ]) {
|
||||
$order = new OrderCommon();
|
||||
$order_info = $order->getOrderInfo([ [ 'order_id', '=', $launch_info[ 'order_id' ] ], [ 'site_id', '=', $this->site_id ] ], 'order_status, pay_status')[ 'data' ] ?? [];
|
||||
$launch_info[ 'pay_status' ] = $order_info[ 'pay_status' ] ?? 0;
|
||||
$launch_info[ 'order_status' ] = $order_info[ 'order_status' ];
|
||||
// if($launch_info['order_status'] == OrderCommon::ORDER_CLOSE) $launch_info['order_id'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($launch_info)) {
|
||||
if ($token[ 'code' ] == 0) {
|
||||
if ($launch_info[ 'member_id' ] == $this->member_id) {
|
||||
$launch_info[ 'self' ] = 1;
|
||||
$record_info = $bargain->getBargainRecordInfo([ [ 'launch_id', '=', $launch_info[ 'launch_id' ] ], [ 'member_id', '=', $this->member_id ] ], 'money');
|
||||
$launch_info[ 'my_bargain_money' ] = $record_info[ 'data' ][ 'money' ] ?? 0;
|
||||
} else {
|
||||
$launch_info[ 'self' ] = 0;
|
||||
$record_info = $bargain->getBargainRecordInfo([ [ 'launch_id', '=', $launch_info[ 'launch_id' ] ], [ 'member_id', '=', $this->member_id ] ], 'id');
|
||||
$launch_info[ 'cut' ] = empty($record_info[ 'data' ]) ? 0 : 1;
|
||||
}
|
||||
} else {
|
||||
$launch_info[ 'self' ] = 0;
|
||||
$launch_info[ 'cut' ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$res[ 'launch_info' ] = $launch_info;
|
||||
|
||||
//已砍成功的人
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'bargain_id', '=', $bargain_id ],
|
||||
[ 'status', '=', 1 ]
|
||||
];
|
||||
$launch_list = $bargain->getBargainLaunchList($condition, 'status,curr_price,nickname,headimg,end_time', 'launch_id desc', '', '', '', 20);
|
||||
$res[ 'launch_list' ] = $launch_list;
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
public function browse()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->bargainBrowseInc([ [ 'bargain_id', '=', $bargain_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
public function share()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
|
||||
$bargain = new BargainModel();
|
||||
$res = $bargain->bargainShareInc([ [ 'bargain_id', '=', $bargain_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
}
|
||||
226
addon/bargain/api/controller/Goods.php
Executable file
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\api\controller;
|
||||
|
||||
use addon\bargain\model\Bargain as BargainModel;
|
||||
use addon\bargain\model\Poster;
|
||||
use app\api\controller\BaseApi;
|
||||
use app\api\controller\Goodssku;
|
||||
|
||||
/**
|
||||
* 砍价商品
|
||||
*/
|
||||
class Goods extends BaseApi
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取砍价活动列表
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$page = $this->params[ 'page' ] ?? 1;
|
||||
$page_size = $this->params[ 'page_size' ] ?? PAGE_LIST_ROWS;
|
||||
$id_arr = $this->params[ 'id_arr' ] ?? '';
|
||||
$is_exclude_bargaining = $this->params[ 'is_exclude_bargaining' ] ?? 0; // 是否需排除砍价中
|
||||
|
||||
$bargain = new BargainModel();
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
if (!empty($id_arr)) {
|
||||
$condition[] = [ 'pb.goods_id', 'in', $id_arr ];
|
||||
}
|
||||
if ($is_exclude_bargaining) {
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$goods_id = $bargain->getBargainingGoodsId($this->member_id);
|
||||
if (!empty($goods_id)) $condition[] = [ 'g.goods_id', 'not in', $goods_id ];
|
||||
}
|
||||
}
|
||||
|
||||
$data = $bargain->getBargainPageList($condition, $page, $page_size, 'pb.bargain_id desc', '');
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价活动列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$num = $this->params[ 'num' ] ?? null;
|
||||
$id_arr = $this->params[ 'id_arr' ] ?? '';
|
||||
$is_exclude_bargaining = $this->params[ 'is_exclude_bargaining' ] ?? 0; // 是否需排除砍价中
|
||||
|
||||
$bargain = new BargainModel();
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
if (!empty($id_arr)) {
|
||||
$condition[] = [ 'pb.goods_id', 'in', $id_arr ];
|
||||
}
|
||||
if ($is_exclude_bargaining) {
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$goods_id = $bargain->getBargainingGoodsId($this->member_id);
|
||||
if (!empty($goods_id)) $condition[] = [ 'g.goods_id', 'not in', $goods_id ];
|
||||
}
|
||||
}
|
||||
|
||||
$data = $bargain->getBargainList($condition, '', 'pb.bargain_id desc', $num);
|
||||
return $this->response($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价中的商品列表
|
||||
* @return false|string
|
||||
*/
|
||||
public function bargainingList()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
$condition = [
|
||||
[ 'pbl.site_id', '=', $this->site_id ],
|
||||
[ 'pbl.member_id', '=', $this->member_id ],
|
||||
[ 'pbl.status', '=', 0 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
];
|
||||
|
||||
$join = [
|
||||
[ 'goods g', 'g.goods_id = pbl.goods_id', 'left' ],
|
||||
[ 'promotion_bargain pb', 'pb.goods_id = pbl.goods_id', 'left' ],
|
||||
];
|
||||
$field = 'pb.sale_num,pb.join_num,pbl.launch_id,pbl.bargain_id,pbl.sku_id,pbl.goods_id,pbl.site_id,pbl.start_time,pbl.end_time,pbl.member_id,pbl.curr_price,pbl.price,g.goods_name,g.goods_image,g.recommend_way,pbl.floor_price';
|
||||
$bargain = new BargainModel();
|
||||
$list = $bargain->getBargainLaunchList($condition, $field, 'pbl.start_time desc', 'pbl', $join);
|
||||
return $this->response($this->success($list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$bargain = new BargainModel();
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pbg.site_id', '=', $this->site_id ],
|
||||
[ 'pbg.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$goods_sku_detail = $bargain->getBargainGoodsDetail($condition)[ 'data' ];
|
||||
|
||||
if (empty($goods_sku_detail)) return $this->response($this->error());
|
||||
|
||||
$res[ 'goods_sku_detail' ] = $goods_sku_detail;
|
||||
|
||||
if (!empty($goods_sku_detail[ 'goods_spec_format' ])) {
|
||||
//判断商品规格项
|
||||
$goods_spec_format = $bargain->getGoodsSpecFormat($bargain_id, $this->site_id, $goods_sku_detail[ 'goods_spec_format' ]);
|
||||
$res[ 'goods_sku_detail' ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] == 0) {
|
||||
$launch_info = $bargain->getBargainLaunchDetail([
|
||||
[ 'bargain_id', '=', $goods_sku_detail[ 'bargain_id' ] ],
|
||||
[ 'sku_id', '=', $goods_sku_detail[ 'sku_id' ] ],
|
||||
[ 'member_id', '=', $this->member_id ],
|
||||
[ 'status', '=', 0 ]
|
||||
], 'launch_id');
|
||||
if (!empty($launch_info[ 'data' ])) $res[ 'goods_sku_detail' ][ 'launch_info' ] = $launch_info[ 'data' ];
|
||||
}
|
||||
|
||||
// 处理公共数据
|
||||
$goods_sku_api = new Goodssku();
|
||||
$goods_sku_api->handleGoodsDetailData($res[ 'goods_sku_detail' ]);
|
||||
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询商品SKU集合
|
||||
* @return false|string
|
||||
*/
|
||||
public function goodsSku()
|
||||
{
|
||||
$goods_id = $this->params[ 'goods_id' ] ?? 0;
|
||||
$bargain_id = $this->params[ 'bargain_id' ] ?? 0;
|
||||
if (empty($goods_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
if (empty($bargain_id)) {
|
||||
return $this->response($this->error('', 'REQUEST_ID'));
|
||||
}
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pbg.site_id', '=', $this->site_id ],
|
||||
// [ 'pbg.status', '=', 1 ],
|
||||
[ 'g.goods_id', '=', $goods_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
$goods = new BargainModel();
|
||||
$list = $goods->getBargainGoodsSkuList($condition);
|
||||
foreach ($list[ 'data' ] as $k => $v) {
|
||||
if (!empty($v[ 'goods_spec_format' ])) {
|
||||
$goods_spec_format = $goods->getGoodsSpecFormat($bargain_id, $this->site_id, $v[ 'goods_spec_format' ]);
|
||||
$list[ 'data' ][ $k ][ 'goods_spec_format' ] = json_encode($goods_spec_format);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品海报
|
||||
* @return false|string
|
||||
*/
|
||||
public function poster()
|
||||
{
|
||||
$this->checkToken();
|
||||
|
||||
$promotion_type = 'bargain';
|
||||
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
|
||||
$qrcode_param[ 'source_member' ] = $this->member_id;
|
||||
$poster = new Poster();
|
||||
$res = $poster->goods($this->params[ 'app_type' ], $this->params[ 'page' ], $qrcode_param, $promotion_type, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享图片
|
||||
* @return false|string
|
||||
*/
|
||||
public function shareImg()
|
||||
{
|
||||
$qrcode_param = json_decode($this->params[ 'qrcode_param' ], true);
|
||||
|
||||
$poster = new Poster();
|
||||
$res = $poster->shareImg($this->params[ 'page' ] ?? '', $qrcode_param, $this->site_id);
|
||||
return $this->response($res);
|
||||
}
|
||||
}
|
||||
74
addon/bargain/api/controller/Ordercreate.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Index.php
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2015-2025 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
* @author : niuteam
|
||||
* @date : 2022.8.8
|
||||
* @version : v5.0.0.1
|
||||
*/
|
||||
|
||||
namespace addon\bargain\api\controller;
|
||||
|
||||
use addon\bargain\model\BargainOrderCreate as OrderCreateModel;
|
||||
use app\api\controller\BaseOrderCreateApi;
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*/
|
||||
class Ordercreate extends BaseOrderCreateApi
|
||||
{
|
||||
/**
|
||||
* 创建订单
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params['order_key'] ?? '',
|
||||
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getInputParam(), $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->create();
|
||||
return $this->response($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算信息
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'order_key' => $this->params['order_key'] ?? '',//是否使用余额
|
||||
'is_balance' => $this->params['is_balance'] ?? 0,//是否使用余额
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam(), $this->getInvoiceParam()))->confirm();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* 待支付订单 数据初始化(确认订单)
|
||||
* @return string
|
||||
*/
|
||||
public function payment()
|
||||
{
|
||||
$token = $this->checkToken();
|
||||
if ($token['code'] < 0) return $this->response($token);
|
||||
$order_create = new OrderCreateModel();
|
||||
$data = [
|
||||
'id' => $this->params['launch_id'] ?? '',//砍价发起id
|
||||
'num' => 1,
|
||||
];
|
||||
$res = $order_create->setParam(array_merge($data, $this->getCommonParam(), $this->getDeliveryParam()))->orderPayment();
|
||||
return $this->response($this->success($res));
|
||||
}
|
||||
|
||||
}
|
||||
21
addon/bargain/component/controller/Bargain.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace addon\bargain\component\controller;
|
||||
|
||||
use app\component\controller\BaseDiyView;
|
||||
|
||||
/**
|
||||
* 砍价模块·组件
|
||||
*
|
||||
*/
|
||||
class Bargain extends BaseDiyView
|
||||
{
|
||||
|
||||
/**
|
||||
* 设计界面
|
||||
*/
|
||||
public function design()
|
||||
{
|
||||
return $this->fetch('bargain/design.html');
|
||||
}
|
||||
}
|
||||
68
addon/bargain/component/view/bargain/css/design.css
Executable file
@@ -0,0 +1,68 @@
|
||||
@CHARSET "UTF-8";
|
||||
.component-bargain .bargain-list{overflow: hidden;}
|
||||
/* 头部风格 */
|
||||
/* 样式一 */
|
||||
.component-bargain .bargain-list .style-1.bargain-head{display: flex;justify-content: space-between;align-items: center;height: 44px;box-sizing: border-box;margin: 0;padding: 0 10px;background-repeat: no-repeat;background-size: cover;margin-bottom: 10px;line-height: 1; border-radius: 9px 9px 0 0;}
|
||||
.component-bargain .bargain-list .style-1.bargain-head .left-img{max-width: 78px;max-height: 20px;}
|
||||
.component-bargain .bargain-list .style-1.bargain-head .head-content{position: relative;color: #fff;font-size: 12px;margin-right: auto;margin-left: 10px;line-height: 1;}
|
||||
.component-bargain .bargain-list .style-1.bargain-head .head-content::after{content:'';position: absolute;width: 1px;height: 12px;background-color: #fff;top: 50%; transform: translateY(-50%);left: -6px;}
|
||||
.component-bargain .bargain-list .style-1.bargain-head .head-right{display: flex;align-items: center;font-size: 12px; color: #fff;}
|
||||
/* 样式二 */
|
||||
.component-bargain .bargain-list .style-2.bargain-head{display: flex;justify-content: space-between;align-items: center;height: 44px;box-sizing: border-box;margin: 0;padding: 0 10px;background-repeat: no-repeat;background-size: cover;margin-bottom: 10px;line-height: 1; border-radius: 9px 9px 0 0;}
|
||||
.component-bargain .bargain-list .style-2.bargain-head .left-img{max-width: 78px;max-height: 20px;}
|
||||
.component-bargain .bargain-list .style-2.bargain-head .head-content{position: relative;color: #fff;font-size: 12px;margin-right: auto;margin-left: 10px;line-height: 1;}
|
||||
.component-bargain .bargain-list .style-2.bargain-head .head-content::after{content:'';position: absolute;width: 1px;height: 12px;background-color: #fff;top: 50%; transform: translateY(-50%);left: -6px;}
|
||||
.component-bargain .bargain-list .style-2.bargain-head .head-right{display: flex;align-items: center;justify-content: center;height: 18px;background: linear-gradient(270deg, #FFBD5B 0%, #FD882E 100%);border-radius: 12px;padding: 1px;}
|
||||
.component-bargain .bargain-list .style-2.bargain-head .head-right span:nth-child(1){position: relative;left: 3px;transform: scale(0.9);}
|
||||
.component-bargain .bargain-list .style-2.bargain-head .head-right span:nth-child(2){padding: 2px;background-color: #fff;color: #FFBD5B;border-radius: 50%;transform: scale(0.6);font-weight: bold;}
|
||||
|
||||
|
||||
/* 样式:单列 */
|
||||
.component-bargain .bargain-list .row1-of1{}
|
||||
.component-bargain .bargain-list .row1-of1 .item{display: flex;margin-bottom: 10px;padding: 8px;}
|
||||
.component-bargain .bargain-list .row1-of1 .item:last-child{margin-bottom: 0;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .img-wrap {width: 100px;height: 100px;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .img-wrap > img{width: 100%;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .img-wrap .bg{display: none;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content{flex:1;padding: 3px 0 3px 10px;display: flex;flex-direction: column;justify-content: space-between;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content .bottom-wrap{display: flex;justify-content: space-between;align-items: flex-end;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content .discount-price{font-weight: bold;display: flex;align-items: flex-end;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content .discount-price .unit{font-size: 12px;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content .discount-price .price{font-size: 16px;line-height: 1;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content .price-wrap{display: flex;align-items: flex-end;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content .price-wrap .original-price{margin-left: 5px;}
|
||||
.component-bargain .bargain-list .row1-of1 .item .content button{font-size: 12px;height: 26px;max-width: 70px;line-height: 20px;padding: 0 8px;}
|
||||
/* 风格二 */
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content{margin-top: 5px;}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .progress {display: flex;flex-direction: column;}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .progress .bg {width: auto;height: 10px;border-radius: 10px;background-color: #FFEADB;position: relative;}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .progress .bg::after{content: "";width: 13px;height: 13px;border-radius: 50%;background-color: #FA1A1A;position: absolute;top: 50%;transform: translateY(-50%);right: 0;}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .progress .bg .curr {width: 70px;height: 10px;border-radius: 10px;background-color: #FA1A1A;position: relative;}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .progress-bar{position: absolute;right: 0; width: 15px;height: 15px;top: 50%;transform: translateY(-50%);}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .num {font-size: 12px;margin-top: 6px;}
|
||||
.component-bargain .bargain-list .row1-of1.style-2.bargain-content .num span{color: #FA1A1A;}
|
||||
/* 风格三 */
|
||||
.component-bargain .bargain-list .row1-of1.style-3.bargain-content .progress{display: flex; color: #999999;font-size: 13px;}
|
||||
.component-bargain .bargain-list .row1-of1.style-3 .item .content{justify-content: space-around;}
|
||||
|
||||
/* 样式:横向滑动 */
|
||||
.component-bargain .bargain-list .horizontal-slide{display: flex;margin: 10px;overflow: hidden;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item {width: 97px;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .img-wrap {width: 97px;height: 97px;overflow: hidden;position: relative;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .img-wrap > img{width: calc(100% + 1px);}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .img-wrap .bg {position: absolute;width: 100%;height: 30px;bottom: 0;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .img-wrap .bg img {width: 100%;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .img-wrap .num {width: 90px;position: absolute;bottom: 5px;padding-left: 10px;font-size: 12px;line-height: 1;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .content {padding: 5px 10px;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .content .discount-price{margin-top: 5px;font-weight: bold;display: flex;align-items: baseline;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .content .discount-price .unit{font-size: 12px; height: 16px;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .content .discount-price .price{font-size: 16px;}
|
||||
.component-bargain .bargain-list .horizontal-slide .item .content .original-price {font-size: 12px;line-height: 1;margin-top: 5px;text-decoration: line-through;}
|
||||
|
||||
/* 秒杀头部弹窗样式 */
|
||||
.component-bargain .bargain-style-list-box{display: none;}
|
||||
.bargain-style-list-con{display: flex;flex-wrap: wrap;}
|
||||
.bargain-style-list-con .bargain-style-li{overflow: hidden;display: flex;align-items: center;justify-content: center;width: 280px;height: 100px;margin-right: 12px;margin-top: 15px;cursor: pointer;border: 1px solid #ededed;background: #f7f8fa;}
|
||||
.bargain-style-list-con .bargain-style-li img{max-width: 280px;max-height: 220px;}
|
||||
.bargain-style-list-con .bargain-style-li:nth-child(1), .bargain-style-list-con .bargain-style-li:nth-child(2), .bargain-style-list-con .bargain-style-li:nth-child(3){margin-top: 0;}
|
||||
.bargain-style-list-con .bargain-style-li:nth-child(3n){margin-right: 0;}
|
||||
418
addon/bargain/component/view/bargain/design.html
Executable file
@@ -0,0 +1,418 @@
|
||||
<nc-component :data="data[index]" class="component-bargain">
|
||||
|
||||
<!-- 预览 -->
|
||||
<template slot="preview">
|
||||
<div class="bargain-list" :style="{ background: nc.componentBgColor,
|
||||
borderTopLeftRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.componentAngle == 'round' ? nc.topAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.componentAngle == 'round' ? nc.bottomAroundRadius + 'px' : 0)
|
||||
}">
|
||||
<div v-if="nc.titleStyle.isShow" :class="[nc.titleStyle.style,'bargain-head']" :style="{'backgroundImage':'url('+ changeImgUrl(nc.titleStyle.backgroundImage) + '), linear-gradient(to right,'+nc.titleStyle.bgColorStart+','+ nc.titleStyle.bgColorEnd+')'}">
|
||||
<h3 v-if="nc.titleStyle.leftStyle == 'text'" class="left-text" :style="{fontSize: nc.titleStyle.fontSize + 'px',color: nc.titleStyle.textColor,fontWeight: nc.titleStyle.fontWeight ? 'bold' : ''}">{{nc.titleStyle.leftText}}</h3>
|
||||
<img v-else class="left-img" :src="changeImgUrl(nc.titleStyle.leftImg)" />
|
||||
<div v-if="nc.titleStyle.style == 'style-1'" class="head-content" :style="{color: nc.titleStyle.textColor}">低至0元免费拿</div>
|
||||
<div class="head-right" :style="{fontSize: nc.titleStyle.moreFontSize + 'px',color: nc.titleStyle.moreColor}">
|
||||
<span>{{nc.titleStyle.more}}</span>
|
||||
<span class="iconyoujiantou iconfont"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div :class="[nc.template,nc.style,'bargain-content']">
|
||||
<template v-if="nc.tempData.previewList && Object.keys(nc.tempData.previewList).length">
|
||||
<div class="item" v-for="(item, previewIndex) in nc.tempData.previewList" :key="previewIndex"
|
||||
:style="{
|
||||
borderTopLeftRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderTopRightRadius: (nc.elementAngle == 'round' ? nc.topElementAroundRadius + 'px' : 0),
|
||||
borderBottomLeftRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
borderBottomRightRadius: (nc.elementAngle == 'round' ? nc.bottomElementAroundRadius + 'px' : 0),
|
||||
backgroundColor: nc.elementBgColor,
|
||||
marginLeft: nc.template=='horizontal-slide' && (nc.slideMode == 'scroll' && nc.goodsMarginType=='diy' && (nc.goodsMarginNum+'px') || ((60 - nc.margin.both*2) /6 + 'px')) || '',
|
||||
marginRight: nc.template=='horizontal-slide' && (nc.slideMode == 'scroll' && nc.goodsMarginType=='diy' && (nc.goodsMarginNum+'px') || ((60 - nc.margin.both*2) /6 + 'px')) || '',
|
||||
boxShadow: nc.ornament.type == 'shadow' ? ('0 0 5px ' + nc.ornament.color) : '',
|
||||
border: nc.ornament.type == 'stroke' ? '1px solid ' + nc.ornament.color : ''}">
|
||||
<div class="img-wrap" :style="{ borderRadius: nc.imgAroundRadius + 'px' }">
|
||||
<img :style="{ borderRadius: nc.imgAroundRadius + 'px' }" :src="changeImgUrl('public/static/img/default_img/square.png')" />
|
||||
<div class="bg" v-if="nc.saleStyle.control"><img src="{$resource_path}/img/bg.png" /></div>
|
||||
<div class="num" v-if="nc.saleStyle.control" :style="{ color : nc.saleStyle.color }">已砍299件</div>
|
||||
</div>
|
||||
|
||||
<div class="content" v-if="nc.goodsNameStyle.control || nc.priceStyle.mainControl || nc.priceStyle.lineControl || nc.btnStyle.control">
|
||||
<div class="goods-name" v-if="nc.goodsNameStyle.control" :style="{ color : nc.goodsNameStyle.color,fontWeight : nc.goodsNameStyle.fontWeight ? 'bold' : '' }" :class="[{'using-hidden' : nc.nameLineMode == 'single'},{'multi-hidden' : nc.nameLineMode == 'multiple'}]">{{ item.goods_name }}</div>
|
||||
<div class="progress" v-if="nc.template == 'row1-of1'&&nc.style=='style-2'">
|
||||
<div class="bg">
|
||||
<div class="curr" >
|
||||
<img class="progress-bar" src="{$resource_path}/img/progress_bar_01.png" alt="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="num" >最低可砍至 <span>¥9</span></div>
|
||||
</div>
|
||||
<div class="progress" v-if="nc.template == 'row1-of1'&&nc.style=='style-3'"> 最低可砍至 <span class="num" :style="{ color : nc.priceStyle.mainColor }">¥9</span></div>
|
||||
<div class="bottom-wrap">
|
||||
<div class="price-wrap">
|
||||
<div class="discount-price" v-if="nc.priceStyle.mainControl">
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">¥</span>
|
||||
<span class="price" :style="{ color : nc.priceStyle.mainColor }">{{item.discount_price.split(".")[0]}}</span>
|
||||
<span class="unit" :style="{ color : nc.priceStyle.mainColor }">{{"."+item.discount_price.split(".")[1]}}</span>
|
||||
</div>
|
||||
<div class="original-price" v-if="nc.priceStyle.lineControl" :style="{ color : nc.priceStyle.lineColor }">¥{{item.line_price}}</div>
|
||||
</div>
|
||||
<div class="bottom-btn" v-if="nc.template == 'horizontal-slide'&&nc.style=='style-2'">0元免费拿</div>
|
||||
<button v-if="nc.btnStyle.control" class="layui-btn" :style="{ background : 'linear-gradient(to right,' + nc.btnStyle.bgColorStart + ',' + nc.btnStyle.bgColorEnd + ')', color : nc.btnStyle.textColor,borderRadius : nc.btnStyle.aroundRadius + 'px' }">{{ nc.btnStyle.text }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 内容编辑 -->
|
||||
<template slot="edit-content">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<bargain-list-sources></bargain-list-sources>
|
||||
<div class="template-edit-title">
|
||||
<h3>头部风格</h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">头部状态</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.titleStyle.isShow = !nc.titleStyle.isShow" :class="{ 'layui-form-checked' : nc.titleStyle.isShow }">
|
||||
<span>{{ nc.titleStyle.isShow ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="nc.titleStyle.isShow">
|
||||
<div class="layui-form-item" v-if="nc.tempData.methods">
|
||||
<label class="layui-form-label sm">选择风格</label>
|
||||
<div class="layui-input-block">
|
||||
<div v-if="nc.titleStyle.styleName" class="text-color selected-style" @click="nc.tempData.methods.selectTopStyle">
|
||||
<span>{{nc.titleStyle.styleName}}</span>
|
||||
<i class="layui-icon layui-icon-right"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">主标题类型</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.titleStyle.leftStyle='text'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.titleStyle.leftStyle=='text') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.titleStyle.leftStyle=='text' ? "" : "" }}</i>
|
||||
<div>文字</div>
|
||||
</div>
|
||||
<div @click="nc.titleStyle.leftStyle='img'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.titleStyle.leftStyle=='img') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.titleStyle.leftStyle=='img' ? "" : "" }}</i>
|
||||
<div>图片</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.titleStyle.leftStyle=='text'">
|
||||
<label class="layui-form-label sm">标题文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.titleStyle.leftText" maxlength="4" placeholder="限时秒杀" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" v-if="nc.titleStyle.leftStyle=='img'">
|
||||
<label class="layui-form-label sm">标题图片</label>
|
||||
<div class="layui-input-block">
|
||||
<img-upload :data="{ data: nc.titleStyle,field:'leftImg'}" data-disabled="1"></img-upload>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">右侧文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.titleStyle.more" maxlength="6" placeholder="更多" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品风格</h3>
|
||||
<div class="layui-form-item list-style" v-if="nc.tempData.templateList">
|
||||
<label class="layui-form-label sm">风格</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source">{{ nc.tempData.templateList[nc.template].text }}</div>
|
||||
<div class="template-selected">
|
||||
<div v-for="(item,templateKey) in nc.tempData.templateList" :key="templateKey" class="source-item" :title="item.text"
|
||||
@click="nc.tempData.methods.selectTemplate(templateKey)"
|
||||
:class="[(nc.template == templateKey) ? 'text-color border-color' : '' ]">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 暂时只有一种样式,先隐藏 -->
|
||||
<div class="style-selected">
|
||||
<div v-for="(item,styleIndex) in nc.tempData.templateList[nc.template].styleList" :key="styleIndex" @click="nc.tempData.methods.selectTemplate('',item)" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.style==item.value) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.style == item.value ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>商品数据</h3>
|
||||
<div class="layui-form-item" v-if="nc.tempData.goodsSources">
|
||||
<label class="layui-form-label sm">数据来源</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="source-selected">
|
||||
<div class="source">{{ nc.tempData.goodsSources[nc.sources].text }}</div>
|
||||
<div v-for="(item,sourcesKey) in nc.tempData.goodsSources" :key="sourcesKey" class="source-item" :title="item.text" @click="nc.sources=sourcesKey" :class="{ 'text-color border-color' : (nc.sources == sourcesKey) }">
|
||||
<i class='iconfont' :class='item.icon'></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.sources == 'diy'">
|
||||
<label class="layui-form-label sm">手动选择</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="selected-style" @click="nc.tempData.methods.addGoods()">
|
||||
<span v-if="nc.goodsId.length == 0">请选择</span>
|
||||
<span v-if="nc.goodsId.length > 0" class="text-color">已选{{ nc.goodsId.length }}个</span>
|
||||
<i class="iconfont iconyoujiantou"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<slide :data="{ field : 'count', label: '商品数量', min:1, max: 30}" v-if="nc.sources != 'diy'"></slide>
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">是否显示</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.btnStyle.control = !nc.btnStyle.control" :class="{ 'layui-form-checked' : nc.btnStyle.control }">
|
||||
<span>{{ nc.btnStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.btnStyle.control">
|
||||
<label class="layui-form-label sm">文字</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" v-model="nc.btnStyle.text" maxlength="6" placeholder="请输入按钮文字" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title">
|
||||
<h3>显示内容</h3>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.control = !nc.goodsNameStyle.control" :class="{ 'layui-form-checked' : nc.goodsNameStyle.control }">
|
||||
<span>{{ nc.goodsNameStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">销售价</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.mainControl = !nc.priceStyle.mainControl" :class="{ 'layui-form-checked' : nc.priceStyle.mainControl }">
|
||||
<span>{{ nc.priceStyle.mainControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.priceStyle.lineSupport">
|
||||
<label class="layui-form-label sm">划线价</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.priceStyle.lineControl = !nc.priceStyle.lineControl" :class="{ 'layui-form-checked' : nc.priceStyle.lineControl }">
|
||||
<span>{{ nc.priceStyle.lineControl ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.saleStyle.support">
|
||||
<label class="layui-form-label sm">商品销量</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.saleStyle.control = !nc.saleStyle.control" :class="{ 'layui-form-checked' : nc.saleStyle.control }">
|
||||
<span>{{ nc.saleStyle.control ? '显示' : '隐藏' }}</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- 弹框 -->
|
||||
<article class="bargain-style-list-box">
|
||||
<div class="bargain-style-list layui-form">
|
||||
<div class="bargain-style-list-con">
|
||||
<div class="bargain-style-li" v-for="(value,name,previewIndex) in nc.tempData.styleList" :key="name" :class="{'selected border-color': nc.titleStyle.style == name}" :data_key="name">
|
||||
<span class="layui-hide">风格{{previewIndex + 1}}</span>
|
||||
<img :src="'{$resource_path}/img/style_title_' + (previewIndex+1) + '.png'" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="style">
|
||||
<input type="hidden" name="style_name" />
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</template>
|
||||
|
||||
<!-- 样式编辑 -->
|
||||
<template slot="edit-style">
|
||||
<template v-if="nc.lazyLoad">
|
||||
<template v-if="nc.titleStyle.isShow">
|
||||
<div class="template-edit-title">
|
||||
<h3>头部样式</h3>
|
||||
<template v-if="nc.titleStyle.leftStyle == 'text'">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">标题加粗</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.titleStyle.fontWeight = !nc.titleStyle.fontWeight" :class="{ 'layui-form-checked' : nc.titleStyle.fontWeight }">
|
||||
<span>加粗</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<color :data="{ field : 'textColor', 'label' : '标题颜色', parent : 'titleStyle', defaultColor : '#303133' }"></color>
|
||||
<slide :data="{ field : 'fontSize',parent : 'titleStyle', label : '标题大小', min: 12, max : 16 }"></slide>
|
||||
</template>
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '背景颜色', parent : 'titleStyle', defaultColor : '#FF209D,#B620E0' }"></color>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">背景图片</label>
|
||||
<div class="layui-input-block">
|
||||
<img-upload :data="{ data: nc.titleStyle,field:'backgroundImage'}" data-disabled="1"></img-upload>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="template-edit-title">
|
||||
<h3>“更多”样式</h3>
|
||||
<color :data="{ field : 'moreColor', 'label' : '文字颜色', parent : 'titleStyle', defaultColor : '#999999' }"></color>
|
||||
<slide :data="{ field : 'moreFontSize',parent : 'titleStyle', label : '文字大小', min: 12, max : 14 }"></slide>
|
||||
</div>
|
||||
</template>
|
||||
<div class="template-edit-title">
|
||||
<h3>商品样式</h3>
|
||||
|
||||
<div class="layui-form-item tag-wrap">
|
||||
<label class="layui-form-label sm">边框</label>
|
||||
<div class="layui-input-block">
|
||||
<div v-for="(item,ornamentIndex) in nc.tempData.ornamentList" :key="ornamentIndex" @click="nc.ornament.type=item.type" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.ornament.type==item.type) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.ornament.type == item.type ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color v-if="nc.ornament.type != 'default'" :data="{ field : 'color', 'label' : '边框颜色', parent : 'ornament', defaultColor : '#EDEDED' }"></color>
|
||||
|
||||
<slide :data="{ field : 'imgAroundRadius', label: '图片圆角', min:0, max: 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item" v-if="nc.template == 'horizontal-slide'">
|
||||
<label class="layui-form-label sm">滚动方式</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.slideMode = 'scroll' " :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.slideMode == 'scroll') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.slideMode == 'scroll' ? "" : "" }}</i>
|
||||
<div>平移</div>
|
||||
</div>
|
||||
<div @click="nc.slideMode = 'slide' " :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.slideMode == 'slide') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.slideMode == 'slide' ? "" : "" }}</i>
|
||||
<div>切屏</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" v-show="nc.goodsNameStyle.control">
|
||||
<label class="layui-form-label sm">商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" @click="nc.goodsNameStyle.fontWeight = !nc.goodsNameStyle.fontWeight" :class="{ 'layui-form-checked' : nc.goodsNameStyle.fontWeight }">
|
||||
<span>加粗</span>
|
||||
<i class="layui-icon layui-icon-ok"></i>
|
||||
</div>
|
||||
<div v-for="(item,nameLineIndex) in nc.tempData.nameLineModeList" :key="nameLineIndex" @click="nc.nameLineMode=item.value" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.nameLineMode==item.value) }">
|
||||
<i class="layui-anim layui-icon">{{ nc.nameLineMode == item.value ? "" : "" }}</i>
|
||||
<div>{{item.text}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<color :data="{ field : 'elementBgColor', 'label' : '商品背景' }"></color>
|
||||
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'topElementAroundRadius', label : '上圆角', max : 50 }"></slide>
|
||||
<slide v-show="nc.elementAngle == 'round'" :data="{ field : 'bottomElementAroundRadius', label : '下圆角', max : 50 }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="nc.theme == 'diy'">
|
||||
<color :data="{ field : 'color', 'label' : '商品名称', parent : 'goodsNameStyle', defaultColor : '#303133' }"></color>
|
||||
<color :data="{ field : 'mainColor', 'label' : '销售价', parent : 'priceStyle', defaultColor : '#FF6A00' }"></color>
|
||||
<div v-show="nc.priceStyle.lineSupport">
|
||||
<color :data="{ field : 'lineColor', 'label' : '划线价', parent : 'priceStyle', defaultColor : '#999CA7' }"></color>
|
||||
</div>
|
||||
<div v-show="nc.saleStyle.support">
|
||||
<color :data="{ field : 'color', 'label' : '商品销量', parent : 'saleStyle', defaultColor : '#999CA7' }"></color>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="template-edit-title" v-show="nc.btnStyle.support && nc.btnStyle.control">
|
||||
<h3>购买按钮</h3>
|
||||
|
||||
<slide :data="{ field : 'aroundRadius', label: '圆角', min:0, max: 50, parent: 'btnStyle' }"></slide>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label sm">色调</label>
|
||||
<div class="layui-input-block">
|
||||
<div @click="nc.btnStyle.theme='default'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'default') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'default' ? "" : "" }}</i>
|
||||
<div>跟随主题风格</div>
|
||||
</div>
|
||||
<div @click="nc.btnStyle.theme='diy'" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : (nc.btnStyle.theme == 'diy') }">
|
||||
<i class="layui-anim layui-icon">{{ nc.btnStyle.theme == 'diy' ? "" : "" }}</i>
|
||||
<div>自定义</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="nc.btnStyle.theme == 'diy'">
|
||||
<color :data="{ field : 'bgColorStart,bgColorEnd', 'label' : '背景颜色', parent : 'btnStyle', defaultColor : '#FF7B1D,#FF1544' }"></color>
|
||||
<color :data="{ field : 'textColor', 'label' : '文字颜色', parent : 'btnStyle', defaultColor : '#FFFFFF' }"></color>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- 资源 -->
|
||||
<template slot="resource">
|
||||
<js>
|
||||
var bargainResourcePath = "{$resource_path}"; // http路径
|
||||
var bargainRelativePath = "{$relative_path}"; // 相对路径
|
||||
</js>
|
||||
<css src="{$resource_path}/css/design.css"></css>
|
||||
<js src="{$resource_path}/js/design.js"></js>
|
||||
</template>
|
||||
|
||||
</nc-component>
|
||||
BIN
addon/bargain/component/view/bargain/img/bg.png
Executable file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
addon/bargain/component/view/bargain/img/progress_bar_01.png
Executable file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
addon/bargain/component/view/bargain/img/row1_of1_style_2_bg.png
Executable file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
addon/bargain/component/view/bargain/img/row1_of1_style_2_name.png
Executable file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
addon/bargain/component/view/bargain/img/row1_of1_style_3_name.png
Executable file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
addon/bargain/component/view/bargain/img/style_title_1.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
BIN
addon/bargain/component/view/bargain/img/style_title_2.png
Executable file
|
After Width: | Height: | Size: 13 KiB |
217
addon/bargain/component/view/bargain/js/design.js
Executable file
@@ -0,0 +1,217 @@
|
||||
var bargainListHtml = '<div style="display:none;"></div>';
|
||||
|
||||
Vue.component("bargain-list-sources", {
|
||||
template: bargainListHtml,
|
||||
data: function () {
|
||||
return {
|
||||
data: this.$parent.data,
|
||||
goodsSources: {
|
||||
initial: {
|
||||
text: "默认",
|
||||
icon: "iconmofang"
|
||||
},
|
||||
diy: {
|
||||
text: "手动选择",
|
||||
icon: "iconshoudongxuanze"
|
||||
},
|
||||
},
|
||||
templateList: {
|
||||
"row1-of1": {
|
||||
text: "单列",
|
||||
icon: "iconiPhone86",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
saleSupport: false, // 是否支持商品销量
|
||||
lineSupport: false, // 是否支持划线价
|
||||
},
|
||||
{
|
||||
text: "样式2",
|
||||
value: "style-2",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
saleSupport: false, // 是否支持商品销量
|
||||
lineSupport: false, // 是否支持划线价
|
||||
},
|
||||
{
|
||||
text: "样式3",
|
||||
value: "style-3",
|
||||
cartSupport: true, // 是否支持按钮
|
||||
saleSupport: false, // 是否支持商品销量
|
||||
lineSupport: false, // 是否支持划线价
|
||||
}
|
||||
],
|
||||
},
|
||||
"horizontal-slide": {
|
||||
text: "横向滑动",
|
||||
icon: "iconshangpinliebiaohengxianghuadong",
|
||||
styleList: [
|
||||
{
|
||||
text: "样式1",
|
||||
value: "style-1",
|
||||
cartSupport: false, // 是否支持按钮
|
||||
saleSupport: true, // 是否支持商品销量
|
||||
lineSupport: true, // 是否支持划线价
|
||||
}
|
||||
],
|
||||
},
|
||||
},
|
||||
ornamentList: [
|
||||
{
|
||||
type: 'default',
|
||||
text: '默认',
|
||||
},
|
||||
{
|
||||
type: 'shadow',
|
||||
text: '投影',
|
||||
},
|
||||
{
|
||||
type: 'stroke',
|
||||
text: '描边',
|
||||
},
|
||||
],
|
||||
nameLineModeList: [
|
||||
{
|
||||
text: "单行",
|
||||
value: "single"
|
||||
},
|
||||
{
|
||||
text: "多行",
|
||||
value: "multiple"
|
||||
}
|
||||
],
|
||||
styleList: {
|
||||
"style-1": {
|
||||
leftStyle: "img",
|
||||
leftImg: bargainRelativePath + '/img/row1_of1_style_2_name.png',
|
||||
leftText: "疯狂砍价",
|
||||
backgroundImage: bargainRelativePath + '/img/row1_of1_style_2_bg.png',
|
||||
bgColorStart: "#FF209D",
|
||||
bgColorEnd: "#B620E0",
|
||||
textColor: "#FFFFFF",
|
||||
moreColor: "#FFFFFF",
|
||||
more: "更多"
|
||||
},
|
||||
"style-2": {
|
||||
leftStyle: "img",
|
||||
leftImg: bargainRelativePath + '/img/row1_of1_style_3_name.png',
|
||||
leftText: "疯狂砍价",
|
||||
backgroundImage: '',
|
||||
bgColorStart: "#FFFFFF",
|
||||
bgColorEnd: "#FFFFFF",
|
||||
textColor: "#FFFFFF",
|
||||
moreColor: "#FFFFFF",
|
||||
more: "更多"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
if (!this.$parent.data.verify) this.$parent.data.verify = [];
|
||||
this.$parent.data.verify.push(this.verify);//加载验证方法
|
||||
|
||||
this.$parent.data.ignore = ['textColor']; //加载忽略内容 -- 其他设置中的属性设置
|
||||
this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
|
||||
|
||||
Object.assign(this.data.titleStyle, this.styleList[this.data.titleStyle.style]);
|
||||
|
||||
var previewList = {};
|
||||
for (var i = 1; i < 4; i++) {
|
||||
previewList["goods_id_" + ns.gen_non_duplicate(i)] = {
|
||||
goods_name: "砍价商品",
|
||||
discount_price: (Math.random() * 100 * i + 10).toFixed(2), // 随机价格
|
||||
line_price: (Math.random() * 100 * i + 100 + 10).toFixed(2), // 随机价格
|
||||
sale_num: Math.floor((Math.random() * 100 * i + 10 + 10))
|
||||
};
|
||||
}
|
||||
|
||||
// 组件所需的临时数据
|
||||
this.$parent.data.tempData = {
|
||||
goodsSources: this.goodsSources,
|
||||
templateList: this.templateList,
|
||||
ornamentList: this.ornamentList,
|
||||
nameLineModeList: this.nameLineModeList,
|
||||
previewList: previewList,
|
||||
styleList: this.styleList,
|
||||
methods: {
|
||||
addGoods: this.addGoods,
|
||||
selectTemplate: this.selectTemplate,
|
||||
selectTopStyle: this.selectTopStyle
|
||||
}
|
||||
};
|
||||
|
||||
loadImgMagnify();
|
||||
},
|
||||
methods: {
|
||||
verify: function (index) {
|
||||
var res = {code: true, message: ""};
|
||||
if (vue.data[index].sources === 'diy' && vue.data[index].goodsId.length === 0) {
|
||||
res.code = false;
|
||||
res.message = "请选择商品";
|
||||
}
|
||||
return res;
|
||||
},
|
||||
addGoods: function () {
|
||||
var self = this;
|
||||
goodsSelect(function (res) {
|
||||
self.$parent.data.goodsId = res;
|
||||
}, self.$parent.data.goodsId, {mode: "spu", promotion: "bargain", disabled: 0, post: ns.appModule});
|
||||
},
|
||||
selectTemplate(template, item) {
|
||||
if (template) {
|
||||
this.$parent.data.template = template;
|
||||
item = this.templateList[template].styleList[0];
|
||||
}
|
||||
|
||||
// 修改按钮样式
|
||||
if(item.value == "style-3"){
|
||||
this.$parent.data.btnStyle.bgColorStart = "#3EDB73";
|
||||
this.$parent.data.btnStyle.bgColorEnd = "#1DB576";
|
||||
this.$parent.data.btnStyle.textColor = "#FFFFFF";
|
||||
this.$parent.data.btnStyle.aroundRadius = "4";
|
||||
this.$parent.data.btnStyle.text = "去砍价";
|
||||
}else{
|
||||
this.$parent.data.btnStyle.bgColorStart = "rgb(255, 123, 29)";
|
||||
this.$parent.data.btnStyle.bgColorEnd = "rgb(255, 21, 68)";
|
||||
this.$parent.data.btnStyle.textColor = "#FFFFFF";
|
||||
this.$parent.data.btnStyle.aroundRadius = "25";
|
||||
this.$parent.data.btnStyle.text = "立即抢购";
|
||||
}
|
||||
|
||||
this.$parent.data.style = item.value;
|
||||
this.$parent.data.btnStyle.support = item.cartSupport;
|
||||
this.$parent.data.btnStyle.control = item.cartSupport;
|
||||
this.$parent.data.saleStyle.support = item.saleSupport;
|
||||
this.$parent.data.saleStyle.control = item.saleSupport;
|
||||
this.$parent.data.priceStyle.lineSupport = item.lineSupport;
|
||||
this.$parent.data.priceStyle.lineControl = item.lineSupport;
|
||||
},
|
||||
selectTopStyle: function () {
|
||||
var self = this;
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '风格选择',
|
||||
area: ['910px', '350px'],
|
||||
btn: ['确定', '返回'],
|
||||
content: $(".draggable-element[data-index='" + self.data.index + "'] .edit-attribute .bargain-style-list-box").html(),
|
||||
success: function (layero, index) {
|
||||
$(".layui-layer-content input[name='style']").val(self.data.titleStyle.style);
|
||||
$(".layui-layer-content input[name='style_name']").val(self.data.titleStyle.styleName);
|
||||
$("body").off("click", ".layui-layer-content .bargain-style-list-con .bargain-style-li").on("click", ".layui-layer-content .bargain-style-list-con .bargain-style-li", function () {
|
||||
$(this).addClass("selected border-color").siblings().removeClass("selected border-color bg-color-after");
|
||||
$(".layui-layer-content input[name='style']").val($(this).attr("data_key"));
|
||||
$(".layui-layer-content input[name='style_name']").val($(this).find("span").text());
|
||||
});
|
||||
},
|
||||
yes: function (index, layero) {
|
||||
self.data.titleStyle.style = $(".layui-layer-content input[name='style']").val();
|
||||
Object.assign(self.data.titleStyle, self.styleList[self.data.titleStyle.style]);
|
||||
self.data.titleStyle.styleName = $(".layui-layer-content input[name='style_name']").val();
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
83
addon/bargain/config/diy_view.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
|
||||
// 自定义模板页面类型,格式:[ 'title' => '页面类型名称', 'name' => '页面标识', 'path' => '页面路径', 'value' => '页面数据,json格式' ]
|
||||
'template' => [],
|
||||
|
||||
// 后台自定义组件——装修
|
||||
'util' => [
|
||||
[
|
||||
'name' => 'Bargain',
|
||||
'title' => '砍价',
|
||||
'type' => 'PROMOTION',
|
||||
'value' => '{"style":"style-1","sources":"initial","count":6,"goodsId":[],"ornament":{"type":"default","color":"#EDEDED"},"nameLineMode":"single","template":"horizontal-slide","btnStyle":{"text":"立即抢购","textColor":"#FFFFFF","theme":"default","aroundRadius":25,"control":false,"support":false,"bgColorStart":"#FF7B1D","bgColorEnd":"#FF1544"},"imgAroundRadius":5,"saleStyle":{"color":"#FFFFFF","control":true,"support":true},"slideMode":"scroll","theme":"default","goodsNameStyle":{"color":"#303133","control":true,"fontWeight":false},"priceStyle":{"mainColor":"#FF1745","mainControl":true,"lineColor":"#999CA7","lineControl":true,"lineSupport":true},"titleStyle":{"bgColorStart":"#FF209D","bgColorEnd":"#B620E0","isShow":true,"leftStyle":"img","leftImg":"","style":"style-1","styleName":"风格1","leftText":"疯狂砍价","fontSize":16,"fontWeight":true,"textColor":"#FFFFFF","more":"更多","moreColor":"#FFFFFF","moreFontSize":12,"backgroundImage":""},"goodsMarginType":"default","goodsMarginNum":10}',
|
||||
'sort' => '30004',
|
||||
'support_diy_view' => '',
|
||||
'max_count' => 1,
|
||||
'icon' => 'iconfont iconkanjia',
|
||||
]
|
||||
],
|
||||
|
||||
// 自定义页面路径
|
||||
'link' => [
|
||||
[
|
||||
'name' => 'BARGAIN',
|
||||
'title' => '砍价',
|
||||
'parent' => 'MARKETING_LINK',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'sort' => 0,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'BARGAIN_PREFECTURE',
|
||||
'title' => '砍价专区',
|
||||
'wap_url' => '/pages_promotion/bargain/list',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
[
|
||||
'name' => 'MY_BARGAIN',
|
||||
'title' => '我的砍价',
|
||||
'wap_url' => '/pages_promotion/bargain/my_bargain',
|
||||
'web_url' => '',
|
||||
'sort' => 0
|
||||
],
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'BARGAIN_GOODS',
|
||||
'title' => '砍价商品',
|
||||
'parent' => 'COMMODITY',
|
||||
'wap_url' => '',
|
||||
'web_url' => '',
|
||||
'child_list' => []
|
||||
]
|
||||
],
|
||||
|
||||
// 自定义图标库
|
||||
'icon_library' => [],
|
||||
|
||||
// uni-app 组件,格式:[ 'name' => '组件名称/文件夹名称', 'path' => '文件路径/目录路径' ],多个逗号隔开,自定义组件名称前缀必须是diy-,也可以引用第三方组件
|
||||
'component' => [],
|
||||
|
||||
// uni-app 页面,多个逗号隔开
|
||||
'pages' => [],
|
||||
|
||||
// 模板信息,格式:'title' => '模板名称', 'name' => '模板标识', 'cover' => '模板封面图', 'preview' => '模板预览图', 'desc' => '模板描述'
|
||||
'info' => [],
|
||||
|
||||
// 主题风格配色,格式可以自由定义扩展,【在uni-app中通过:this.themeStyle... 获取定义的颜色字段,例如:this.themeStyle.main_color】
|
||||
'theme' => [],
|
||||
|
||||
// 自定义页面数据,格式:[ 'title' => '页面名称', 'name' => "页面标识", 'value' => [页面数据,json格式] ]
|
||||
'data' => []
|
||||
];
|
||||
76
addon/bargain/config/event.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// 事件定义文件
|
||||
return [
|
||||
'bind' => [
|
||||
|
||||
],
|
||||
|
||||
'listen' => [
|
||||
//展示活动
|
||||
'ShowPromotion' => [
|
||||
'addon\bargain\event\ShowPromotion',
|
||||
],
|
||||
|
||||
'PromotionType' => [
|
||||
'addon\bargain\event\PromotionType',
|
||||
],
|
||||
|
||||
//关闭砍价
|
||||
'CloseBargain' => [
|
||||
'addon\bargain\event\CloseBargain',
|
||||
],
|
||||
|
||||
//开启砍价
|
||||
'OpenBargain' => [
|
||||
'addon\bargain\event\OpenBargain',
|
||||
],
|
||||
// 关闭发起的砍价
|
||||
'BargainLaunchClose' => [
|
||||
'addon\bargain\event\BargainLaunchClose',
|
||||
],
|
||||
|
||||
// 商品营销活动类型
|
||||
'GoodsPromotionType' => [
|
||||
'addon\bargain\event\GoodsPromotionType',
|
||||
],
|
||||
|
||||
// 商品营销活动信息
|
||||
'GoodsPromotion' => [
|
||||
'addon\bargain\event\GoodsPromotion',
|
||||
],
|
||||
|
||||
// 商品列表
|
||||
'GoodsListPromotion' => [
|
||||
'addon\bargain\event\GoodsListPromotion',
|
||||
],
|
||||
// 商品分类
|
||||
'GoodsListCategoryIds' => [
|
||||
'addon\bargain\event\GoodsListCategoryIds',
|
||||
],
|
||||
|
||||
// 订单营销活动类型
|
||||
'OrderPromotionType' => [
|
||||
'addon\bargain\event\OrderPromotionType',
|
||||
],
|
||||
// 订单支付
|
||||
'OrderPayAfter' => [
|
||||
'addon\bargain\event\OrderPayAfter',
|
||||
],
|
||||
/**
|
||||
* 消息发送
|
||||
*/
|
||||
//消息模板
|
||||
'SendMessageTemplate' => [
|
||||
// 砍价成功
|
||||
'addon\bargain\event\MessageBargainComplete',
|
||||
],
|
||||
|
||||
// 活动专区——砍价页面配置
|
||||
'PromotionZoneConfig' => [
|
||||
'addon\bargain\event\BargainZoneConfig',
|
||||
]
|
||||
],
|
||||
|
||||
'subscribe' => [
|
||||
],
|
||||
];
|
||||
20
addon/bargain/config/info.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
return [
|
||||
'name' => 'bargain',
|
||||
'title' => '砍价',
|
||||
'description' => '砍价管理活动',
|
||||
'type' => 'promotion', //插件类型 system :系统插件(自动安装), promotion:扩展营销插件 tool:工具插件
|
||||
'status' => 1,
|
||||
'author' => '',
|
||||
'version' => '5.5.3',
|
||||
'version_no' => '553250709001',
|
||||
'content' => '',
|
||||
];
|
||||
85
addon/bargain/config/menu_shop.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | 店铺端菜单设置
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN',
|
||||
'title' => '砍价',
|
||||
'url' => 'bargain://shop/bargain/lists',
|
||||
'parent' => 'PROMOTION_CENTER',
|
||||
'is_show' => 1,
|
||||
'sort' => 100,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_LIST',
|
||||
'title' => '砍价商品',
|
||||
'url' => 'bargain://shop/bargain/lists',
|
||||
'parent' => 'PROMOTION_BARGAIN',
|
||||
'is_show' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_ADD',
|
||||
'title' => '添加活动',
|
||||
'url' => 'bargain://shop/bargain/add',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_EDIT',
|
||||
'title' => '编辑活动',
|
||||
'url' => 'bargain://shop/bargain/edit',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_DETAIL',
|
||||
'title' => '活动详情',
|
||||
'url' => 'bargain://shop/bargain/detail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_DELETE',
|
||||
'title' => '删除活动',
|
||||
'url' => 'bargain://shop/bargain/delete',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_FINISH',
|
||||
'title' => '结束活动',
|
||||
'url' => 'bargain://shop/bargain/finish',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_LAUNCH',
|
||||
'title' => '砍价列表',
|
||||
'url' => 'bargain://shop/bargain/launchlist',
|
||||
'parent' => 'PROMOTION_BARGAIN',
|
||||
'is_show' => 1,
|
||||
'child_list' => [
|
||||
[
|
||||
'name' => 'PROMOTION_BARGAIN_LAUNCH_DETAIL',
|
||||
'title' => '砍价详情',
|
||||
'url' => 'bargain://shop/bargain/launchdetail',
|
||||
'sort' => 1,
|
||||
'is_show' => 0,
|
||||
'type' => 'button',
|
||||
]
|
||||
|
||||
]
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
1
addon/bargain/data/install.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
1
addon/bargain/data/uninstall.sql
Executable file
@@ -0,0 +1 @@
|
||||
SET NAMES 'utf8';
|
||||
23
addon/bargain/event/BargainLaunchClose.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
class BargainLaunchClose
|
||||
{
|
||||
public function handle($params)
|
||||
{
|
||||
$bargain = new Bargain();
|
||||
$res = $bargain->cronCloseBargainLaunch($params[ 'relate_id' ]);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
36
addon/bargain/event/BargainZoneConfig.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
|
||||
/**
|
||||
* 活动专区——砍价页面配置
|
||||
*/
|
||||
class BargainZoneConfig
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
if (empty($params) || $params[ 'name' ] == 'bargain') {
|
||||
$data = [
|
||||
'name' => 'bargain', // 标识
|
||||
'title' => '砍价', // 名称
|
||||
'url' => 'shop/adv/lists?keyword=NS_BARGAIN', // 自定义跳转链接
|
||||
'preview' => 'addon/bargain/shop/view/public/img/zone_preview.png', // 预览图
|
||||
// 页面配置
|
||||
'value' => [
|
||||
'bg_color' => '#F0353E'
|
||||
],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
addon/bargain/event/CloseBargain.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
/**
|
||||
* 关闭活动
|
||||
*/
|
||||
class CloseBargain
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$bargain = new Bargain();
|
||||
$res = $bargain->cronCloseBargain($params['relate_id']);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
36
addon/bargain/event/GoodsListCategoryIds.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
/**
|
||||
* 商品分类
|
||||
*/
|
||||
class GoodsListCategoryIds
|
||||
{
|
||||
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'bargain') return [];
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
$model = new Bargain();
|
||||
$res = $model->getGoodsCategoryIds($condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
57
addon/bargain/event/GoodsListPromotion.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsListPromotion
|
||||
{
|
||||
|
||||
public function handle($param)
|
||||
{
|
||||
if (empty($param[ 'promotion' ]) || $param[ 'promotion' ] != 'bargain') return [];
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $param[ 'site_id' ] ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
if (!empty($param[ 'goods_name' ])) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $param[ 'goods_name' ] . '%' ];
|
||||
}
|
||||
|
||||
if (!empty($param[ 'select_type' ]) && $param[ 'select_type' ] == 'selected' && isset($param[ 'goods_ids' ])) {
|
||||
$condition[] = [ 'g.goods_id', 'in', $param[ 'goods_ids' ] ];
|
||||
}
|
||||
if (!empty($param[ 'category_id' ])) {
|
||||
$condition[] = [ 'g.category_id', 'like', '%,' . $param[ 'category_id' ] . ',%' ];
|
||||
}
|
||||
if (!empty($param[ 'label_id' ])) {
|
||||
$condition[] = [ 'g.label_id', '=', $param[ 'label_id' ] ];
|
||||
}
|
||||
if (!empty($param[ 'goods_class' ])) {
|
||||
$condition[] = [ 'g.goods_class', '=', $param[ 'goods_class' ] ];
|
||||
}
|
||||
|
||||
$field = 'pb.*,g.goods_name,g.goods_image,g.price,g.recommend_way,sku.sku_id,sku.price,sku.sku_name,sku.sku_image,sku.stock as goods_stock,g.label_name,g.goods_class_name';
|
||||
|
||||
$model = new Bargain();
|
||||
|
||||
$list = $model->getBargainPageList($condition, $param[ 'page' ], $param[ 'page_size' ], 'g.create_time desc', $field);
|
||||
|
||||
return $list;
|
||||
}
|
||||
}
|
||||
69
addon/bargain/event/GoodsPromotion.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
use app\model\goods\Goods as GoodsModel;
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
*/
|
||||
class GoodsPromotion
|
||||
{
|
||||
|
||||
/**
|
||||
* 商品营销活动信息
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if (isset($param[ 'goods_sku_detail' ])) {
|
||||
$goods_info = $param[ 'goods_sku_detail' ];
|
||||
if (!empty($goods_info[ 'promotion_addon' ])) {
|
||||
$promotion_addon = json_decode($goods_info[ 'promotion_addon' ], true);
|
||||
if (!empty($promotion_addon[ 'bargin' ])) {
|
||||
return [
|
||||
'promotion_type' => 'bargin',
|
||||
'promotion_name' => '砍价',
|
||||
'bargain_id' => $promotion_addon[ 'bargain' ]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (empty($param[ 'goods_id' ])) return [];
|
||||
$goods_model = new GoodsModel();
|
||||
$goods_info = $goods_model->getGoodsInfo([ [ 'goods_id', '=', $param[ 'goods_id' ] ] ], 'promotion_addon')[ 'data' ];
|
||||
if (!empty($goods_info[ 'promotion_addon' ])) {
|
||||
$promotion_addon = json_decode($goods_info[ 'promotion_addon' ], true);
|
||||
if (!empty($promotion_addon[ 'bargain' ])) {
|
||||
$bargain_model = new Bargain();
|
||||
$condition = [
|
||||
[ 'pbg.bargain_id', '=', $promotion_addon[ 'bargain' ] ],
|
||||
[ 'pb.status', '=', 1 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$field = 'pbg.id,pbg.bargain_id,pbg.goods_id,pbg.sku_id,pbg.floor_price,pb.bargain_name';
|
||||
$goods_detail = $bargain_model->getBargainGoodsDetail($condition, $field)[ 'data' ];
|
||||
if (!empty($goods_detail)) {
|
||||
$goods_detail[ 'promotion_type' ] = 'bargain';
|
||||
$goods_detail[ 'promotion_name' ] = '砍价';
|
||||
return $goods_detail;
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
27
addon/bargain/event/GoodsPromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class GoodsPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ 'name' => '砍价', 'short' => '砍', 'type' => 'bargain', 'color' => '#F58760', 'url' => 'bargain://shop/bargain/lists' ];
|
||||
}
|
||||
}
|
||||
25
addon/bargain/event/Install.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
/**
|
||||
* 应用安装
|
||||
*/
|
||||
class Install
|
||||
{
|
||||
/**
|
||||
* 执行安装
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
26
addon/bargain/event/MessageBargainComplete.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
class MessageBargainComplete
|
||||
{
|
||||
public function handle($param)
|
||||
{
|
||||
//发送消息
|
||||
if ($param[ "keywords" ] == "BARGAIN_COMPLETE") {
|
||||
$model = new Bargain();
|
||||
$result = $model->bargainCompleteMessage($param);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/bargain/event/OpenBargain.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
/**
|
||||
* 启动活动
|
||||
*/
|
||||
class OpenBargain
|
||||
{
|
||||
|
||||
public function handle($params)
|
||||
{
|
||||
$bargain = new Bargain();
|
||||
$res = $bargain->cronOpenBargain($params[ 'relate_id' ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
35
addon/bargain/event/OrderPayAfter.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use addon\bargain\model\Bargain;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class OrderPayAfter
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function handle($param)
|
||||
{
|
||||
if ($param['promotion_type'] == 'bargain') {
|
||||
$bargain_order = new Bargain();
|
||||
$res = $bargain_order->orderPay($param);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
27
addon/bargain/event/OrderPromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
/**
|
||||
* 订单营销活动类型
|
||||
*/
|
||||
class OrderPromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "砍价", "type" => "bargain" ];
|
||||
}
|
||||
}
|
||||
46
addon/bargain/event/PromotionSummary.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class PromotionSummary
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'bargain',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '砍价',
|
||||
//展示介绍
|
||||
'description' => '邀请好友砍价后低价购买',
|
||||
//展示图标
|
||||
'icon' => 'addon/bargain/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'bargain://shop/bargain/lists',
|
||||
]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
27
addon/bargain/event/PromotionType.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
*/
|
||||
class PromotionType
|
||||
{
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* @return array
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return [ "name" => "砍价", "type" => "bargain" ];
|
||||
}
|
||||
}
|
||||
96
addon/bargain/event/ShowPromotion.php
Executable file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
*/
|
||||
class ShowPromotion
|
||||
{
|
||||
public $promotion_type = 'time_limit';
|
||||
|
||||
/**
|
||||
* 活动展示
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
public function handle($params)
|
||||
{
|
||||
$data = [
|
||||
'shop' => [
|
||||
[
|
||||
//插件名称
|
||||
'name' => 'bargain',
|
||||
//店铺端展示分类 shop:营销活动 member:互动营销
|
||||
'show_type' => 'shop',
|
||||
//展示主题
|
||||
'title' => '砍价',
|
||||
//展示介绍
|
||||
'description' => '邀请好友砍价后低价购买',
|
||||
//展示图标
|
||||
'icon' => 'addon/bargain/icon.png',
|
||||
//跳转链接
|
||||
'url' => 'bargain://shop/bargain/lists',
|
||||
'summary' => $this->summary($params),
|
||||
]
|
||||
]
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 营销活动概况
|
||||
* @param $params
|
||||
* @return array
|
||||
*/
|
||||
private function summary($params)
|
||||
{
|
||||
if (empty($params)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(isset($params['promotion_type']) && $params['promotion_type'] != $this->promotion_type){
|
||||
return [];
|
||||
}
|
||||
|
||||
//获取活动数量
|
||||
if (isset($params[ 'count' ])) {
|
||||
$count = model("promotion_bargain")->getCount([ 'site_id' => $params[ 'site_id' ] ]);
|
||||
return [
|
||||
'count' => $count
|
||||
];
|
||||
}
|
||||
//获取活动概况,需要获取开始时间与结束时间
|
||||
if (isset($params[ 'summary' ])) {
|
||||
$join = [
|
||||
[ 'goods g', 'p.goods_id = g.goods_id', 'inner' ]
|
||||
];
|
||||
$list = model("promotion_bargain")->getList([
|
||||
[ '', 'exp', Db::raw('not ( (`start_time` >= ' . $params[ 'end_time' ] . ') or (`end_time` <= ' . $params[ 'start_time' ] . '))') ],
|
||||
[ 'p.site_id', '=', $params[ 'site_id' ] ],
|
||||
[ 'p.status', '<>', 2 ],
|
||||
[ 'p.status', '<>', 3 ],
|
||||
[ 'p.status', '<>', 4 ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
], 'p.bargain_name as promotion_name,p.bargain_id as promotion_id,p.start_time,p.end_time', '', 'p', $join, 'p.create_time');
|
||||
return !empty($list) ? [
|
||||
'time_limit' => [
|
||||
'count' => count($list),
|
||||
'detail' => $list,
|
||||
'color' => '#6699FF'
|
||||
]
|
||||
] : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
25
addon/bargain/event/UnInstall.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\event;
|
||||
|
||||
/**
|
||||
* 应用卸载
|
||||
*/
|
||||
class UnInstall
|
||||
{
|
||||
/**
|
||||
* 执行卸载
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return success();
|
||||
}
|
||||
}
|
||||
BIN
addon/bargain/icon.png
Executable file
|
After Width: | Height: | Size: 1.5 KiB |
1352
addon/bargain/model/Bargain.php
Executable file
265
addon/bargain/model/BargainOrderCreate.php
Executable file
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\model;
|
||||
|
||||
use app\model\BaseModel;
|
||||
use app\model\order\OrderCommon;
|
||||
use app\model\order\OrderCreateTool;
|
||||
use app\model\system\Pay;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 订单创建(砍价)
|
||||
*/
|
||||
class BargainOrderCreate extends BaseModel
|
||||
{
|
||||
|
||||
use OrderCreateTool;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->promotion_type = 'bargain';
|
||||
$this->promotion_type_name = '砍价';
|
||||
}
|
||||
|
||||
public $bargain_info = [];
|
||||
|
||||
/**
|
||||
* 订单创建
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this->confirm();
|
||||
//校验错误
|
||||
$error_result = $this->checkError();
|
||||
if ($error_result !== true) {
|
||||
return $error_result;
|
||||
}
|
||||
$bargain_model = new Bargain();
|
||||
$pay = new Pay();
|
||||
$is_fenxiao = $this->bargain_info[ 'is_fenxiao' ];
|
||||
model('order')->startTrans();
|
||||
|
||||
//循环生成多个订单
|
||||
try {
|
||||
//订单创建数据
|
||||
$order_insert_data = $this->getOrderInsertData([ 'discount' ], 'invert');
|
||||
$order_insert_data[ 'store_id' ] = $this->store_id;
|
||||
$order_insert_data[ 'create_time' ] = time();
|
||||
$order_insert_data[ 'is_enable_refund' ] = 0;
|
||||
//订单类型以及状态
|
||||
$this->orderType();
|
||||
$order_insert_data[ 'order_type' ] = $this->order_type[ 'order_type_id' ];
|
||||
$order_insert_data[ 'order_type_name' ] = $this->order_type[ 'order_type_name' ];
|
||||
$order_insert_data[ 'order_status_name' ] = $this->order_type[ 'order_status' ][ 'name' ];
|
||||
$order_insert_data[ 'order_status_action' ] = json_encode($this->order_type[ 'order_status' ], JSON_UNESCAPED_UNICODE);
|
||||
$order_insert_data[ 'is_fenxiao' ] = $is_fenxiao;
|
||||
|
||||
$this->order_id = model('order')->add($order_insert_data);
|
||||
//订单项目表
|
||||
$order_goods_insert_data = [];
|
||||
foreach ($this->goods_list as $order_goods_v) {
|
||||
$order_goods_v[ 'is_fenxiao' ] = $is_fenxiao;
|
||||
$order_goods_insert_data[] = $this->getOrderGoodsInsertData($order_goods_v);
|
||||
}
|
||||
model('order_goods')->addList($order_goods_insert_data);
|
||||
|
||||
//扣除余额(统一扣除)
|
||||
$this->useBalance();
|
||||
|
||||
// 砍价绑定订单id
|
||||
$bargain_data = [ 'order_id' => $this->order_id ];
|
||||
$bargain_data[ 'status' ] = 2;
|
||||
//未砍到低价都为砍价失败
|
||||
if ($this->bargain_info[ 'curr_price' ] == $this->bargain_info[ 'floor_price' ]) {
|
||||
$bargain_data[ 'status' ] = 1;
|
||||
}
|
||||
model('promotion_bargain_launch')->update($bargain_data, [ [ 'launch_id', '=', $this->bargain_info[ 'launch_id' ] ] ]);
|
||||
|
||||
//批量库存处理(卡密商品支付后在扣出库存)
|
||||
$this->batchDecOrderGoodsStock();
|
||||
|
||||
//扣除商品库存
|
||||
foreach ($this->goods_list as $v) {
|
||||
//活动库存
|
||||
$bargain_stock_result = $bargain_model->decStock([ 'bargain_id' => $this->bargain_info[ 'bargain_id' ], 'sku_id' => $v[ 'sku_id' ], 'num' => $v[ 'num' ] ]);
|
||||
if ($bargain_stock_result[ 'code' ] < 0) {
|
||||
model('order')->rollback();
|
||||
return $bargain_stock_result;
|
||||
}
|
||||
}
|
||||
model('order')->commit();
|
||||
//订单创建后事件
|
||||
$this->orderCreateAfter();
|
||||
//生成整体支付单据
|
||||
$pay->addPay($this->site_id, $this->out_trade_no, $this->pay_type, $this->order_name, $this->order_name, $this->pay_money, '', 'OrderPayNotify', '', $this->order_id, $this->member_id);
|
||||
return $this->success($this->out_trade_no);
|
||||
|
||||
} catch (Exception $e) {
|
||||
model('order')->rollback();
|
||||
return $this->error('', $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单计算
|
||||
*/
|
||||
public function calculate()
|
||||
{
|
||||
$this->initMemberAddress(); //初始化地址
|
||||
$this->initMemberAccount(); //初始化会员账户
|
||||
//商品列表信息
|
||||
$this->getOrderGoodsCalculate();
|
||||
//优惠以及附属计算
|
||||
$this->shopOrderCalculate();
|
||||
//获取发票相关
|
||||
$this->getInovice();
|
||||
//定义缓存,并返回key值
|
||||
$this->order_key = create_no();
|
||||
$this->setOrderCache(get_object_vars($this), $this->order_key);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品的计算信息
|
||||
* @return true
|
||||
*/
|
||||
public function getOrderGoodsCalculate()
|
||||
{
|
||||
//查询砍价信息
|
||||
$bargain_model = new Bargain();
|
||||
$launch_id = $this->param[ 'id' ];
|
||||
$this->bargain_info = $bargain_model->getBargainLaunchDetail([ [ 'launch_id', '=', $launch_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ] ?? [];
|
||||
if (empty($this->bargain_info)) throw new Exception('找不到您的砍价记录');
|
||||
//判断砍价是否成功
|
||||
if ($this->bargain_info[ 'buy_type' ] == 1 && $this->bargain_info[ 'status' ] != 1) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '该商品您尚未砍价成功!';
|
||||
}
|
||||
//判断砍价是否已经下单了
|
||||
$bargain_order_id = $this->bargain_info[ 'order_id' ] ?? 0;
|
||||
if (!$bargain_order_id) {
|
||||
$bargain_order_info = model('order')->getInfo([ [ 'order_id', '=', $bargain_order_id ] ], 'order_status');
|
||||
if ($bargain_order_info && $bargain_order_info[ 'order_status' ] != OrderCommon::ORDER_CLOSE) {
|
||||
$this->error = 1;
|
||||
$this->error_msg = '本次砍价您已下单过了!';
|
||||
}
|
||||
}
|
||||
|
||||
$this->getBargainGoodsInfo();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取砍价商品列表信息
|
||||
* @return true
|
||||
*/
|
||||
public function getBargainGoodsInfo()
|
||||
{
|
||||
//组装商品列表
|
||||
$field = 'sku_id,sku_name, sku_no,
|
||||
price, discount_price, cost_price, stock, weight, volume, sku_image,
|
||||
ngs.site_id, goods_state, is_virtual, support_trade_type,ngs.supplier_id,ngs.form_id,
|
||||
is_free_shipping, shipping_template, goods_class, goods_class_name,goods_id, ns.site_name,ngs.sku_spec_format,ngs.goods_name';
|
||||
$join = [
|
||||
[
|
||||
'site ns',
|
||||
'ngs.site_id = ns.site_id',
|
||||
'inner'
|
||||
]
|
||||
];
|
||||
$info = model('goods_sku')->getInfo([ [ 'ngs.sku_id', '=', $this->bargain_info[ 'sku_id' ] ], [ 'ngs.site_id', '=', $this->site_id ] ], $field, 'ngs', $join);
|
||||
if (!empty($info)) {
|
||||
$num = $this->param[ 'num' ];
|
||||
//判断是否是虚拟订单
|
||||
if ($info[ 'is_virtual' ]) {
|
||||
$this->is_virtual = 1;
|
||||
} else {
|
||||
$this->is_virtual = 0;
|
||||
}
|
||||
$info[ 'num' ] = $num;
|
||||
$price = $this->bargain_info[ 'curr_price' ];
|
||||
$goods_money = $price * $num;
|
||||
$info[ 'price' ] = $price;
|
||||
$info[ 'goods_money' ] = $goods_money;
|
||||
$info[ 'real_goods_money' ] = $goods_money;//真实商品金额
|
||||
$info[ 'coupon_money' ] = 0;//优惠券金额
|
||||
$info[ 'promotion_money' ] = 0;//优惠金额
|
||||
|
||||
$this->site_name = $info[ 'site_name' ];
|
||||
$this->goods_money = $goods_money;
|
||||
$this->goods_list_str = $info[ 'sku_id' ] . ':' . $info[ 'num' ];
|
||||
$this->order_name = string_split('', ',', $info[ 'sku_name' ]);
|
||||
$this->goods_num = $info[ 'num' ];
|
||||
$this->goods_list[] = $info;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺订单计算
|
||||
*/
|
||||
public function shopOrderCalculate()
|
||||
{
|
||||
//重新计算订单总额
|
||||
$this->getOrderMoney();
|
||||
//理论上是多余的操作
|
||||
if ($this->order_money < 0) {
|
||||
$this->order_money = 0;
|
||||
}
|
||||
//总结计算
|
||||
$this->pay_money = $this->order_money;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 待付款订单
|
||||
*/
|
||||
public function orderPayment()
|
||||
{
|
||||
//计算
|
||||
$this->calculate();
|
||||
//配送信息数据
|
||||
$this->getDeliveryData();
|
||||
//订单初始项
|
||||
event('OrderPayment', [ 'order_object' => $this ]);
|
||||
|
||||
return get_object_vars($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 抵扣优惠项计算
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
$order_key = $this->param[ 'order_key' ];
|
||||
$this->getOrderCache($order_key);
|
||||
//初始化地址
|
||||
$this->initMemberAddress();
|
||||
//初始化门店信息
|
||||
$this->initStore();
|
||||
//配送计算
|
||||
$this->calculateDelivery();
|
||||
//批量校验配送方式
|
||||
$this->batchCheckDeliveryType();
|
||||
//计算发票相关
|
||||
$this->calculateInvoice();
|
||||
//计算余额
|
||||
$this->calculateBalcnce();
|
||||
$this->pay_money = $this->order_money - $this->balance_money;
|
||||
//设置过的商品项信息
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
603
addon/bargain/model/Poster.php
Executable file
@@ -0,0 +1,603 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\model;
|
||||
|
||||
use addon\postertemplate\model\PosterTemplate as PosterTemplateModel;
|
||||
use app\model\BaseModel;
|
||||
use app\model\system\Site;
|
||||
use app\model\upload\Upload;
|
||||
use app\model\web\Config;
|
||||
use extend\Poster as PosterExtend;
|
||||
|
||||
/**
|
||||
* 海报生成类
|
||||
*/
|
||||
class Poster extends BaseModel
|
||||
{
|
||||
/**
|
||||
* 商品海报
|
||||
*/
|
||||
public function goods($app_type, $page, $qrcode_param, $promotion_type, $site_id)
|
||||
{
|
||||
try {
|
||||
if ($page == '/pages_promotion/bargain/detail') {
|
||||
$goods_info = $this->getGoodsInfo($qrcode_param[ 'bargain_id' ]);
|
||||
unset($qrcode_param[ 'bargain_id' ]);
|
||||
} else {
|
||||
$goods_info = $this->getGoodsInfo($qrcode_param[ 'id' ]);
|
||||
}
|
||||
if (empty($goods_info)) return $this->error('未获取到商品信息');
|
||||
|
||||
$qrcode_info = $this->getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id);
|
||||
if ($qrcode_info[ 'code' ] < 0) return $qrcode_info;
|
||||
|
||||
//判断海报是否存在或停用
|
||||
$template_info = $this->getTemplateInfo($goods_info[ 'template_id' ]);
|
||||
|
||||
$site_model = new Site();
|
||||
$condition = array (
|
||||
["site_id", "=", $site_id]
|
||||
);
|
||||
$site_info = $site_model->getSiteInfo($condition);
|
||||
|
||||
$member_info = [];
|
||||
if (!empty($qrcode_param[ 'source_member' ])) {
|
||||
$member_info = $this->getMemberInfo($qrcode_param[ 'source_member' ]);
|
||||
}
|
||||
|
||||
$upload_config_model = new Config();
|
||||
$upload_config_result = $upload_config_model->getDefaultImg($site_id);
|
||||
|
||||
if (empty($goods_info[ 'template_id' ]) || empty($template_info) || $template_info[ 'template_status' ] == 0) {
|
||||
$poster_width = 720;
|
||||
$poster_height = 1280;
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 背景图
|
||||
'data' => [
|
||||
img('upload/poster/bg/promotion_bargain.png'),
|
||||
0,
|
||||
0,
|
||||
720,
|
||||
1280,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 商品图
|
||||
'data' => [
|
||||
$goods_info[ 'sku_image' ],
|
||||
86,
|
||||
174,
|
||||
548,
|
||||
548,
|
||||
'square',
|
||||
5,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 二维码
|
||||
'data' => [
|
||||
$qrcode_info[ 'data' ][ 'path' ],
|
||||
273,
|
||||
916,
|
||||
175,
|
||||
175,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'原价 ¥ ' . $goods_info[ 'price' ] . ' 最低可砍至 ¥ ' . $goods_info[ 'floor_price' ],
|
||||
18,
|
||||
[51, 51, 51],
|
||||
86,
|
||||
828,
|
||||
548,
|
||||
1,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info[ 'sku_name' ],
|
||||
25,
|
||||
[34, 34, 34],
|
||||
86,
|
||||
780,
|
||||
548,
|
||||
1,
|
||||
true,
|
||||
1
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
if (!empty($member_info)) {
|
||||
$member_option = [
|
||||
[
|
||||
'action' => 'imageCircularCopy', // 写入用户头像
|
||||
'data' => [
|
||||
!empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
|
||||
86,
|
||||
40,
|
||||
101,
|
||||
101
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
$member_info[ 'nickname' ],
|
||||
24,
|
||||
[51, 51, 51],
|
||||
210,
|
||||
85,
|
||||
420,
|
||||
1,
|
||||
0,
|
||||
1
|
||||
]
|
||||
]
|
||||
];
|
||||
$option = array_merge($option, $member_option);
|
||||
}
|
||||
} else {
|
||||
$condition = [
|
||||
['template_id', '=', $goods_info[ 'template_id' ]],
|
||||
['site_id', '=', $site_id]
|
||||
];
|
||||
$poster_template_model = new PosterTemplateModel();
|
||||
$poster_data = $poster_template_model->getPosterTemplateInfo($condition);
|
||||
$poster_data[ 'data' ][ 'template_json' ] = json_decode($poster_data[ 'data' ][ 'template_json' ], true);
|
||||
$poster_width = 720;
|
||||
$poster_height = 1280;
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$fontRate = 0.725; // 20px 等于 14.5磅,换算比率 1px = 0.725磅
|
||||
if (!empty($poster_data[ 'data' ][ 'background' ])) {
|
||||
list($width, $height, $type, $attr) = getimagesize(img($poster_data[ 'data' ][ 'background' ]));
|
||||
$back_ground = [
|
||||
'action' => 'imageCopy', // 写入背景图
|
||||
'data' => [
|
||||
img($poster_data[ 'data' ][ 'background' ]),
|
||||
0,
|
||||
0,
|
||||
$poster_width,
|
||||
$poster_height,
|
||||
'square',
|
||||
true,
|
||||
1
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$back_ground = [
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [255, 255, 255]
|
||||
];
|
||||
}
|
||||
$ground = [
|
||||
[
|
||||
'action' => 'setBackground',
|
||||
'data' => [255, 255, 255]
|
||||
]
|
||||
];
|
||||
$option = [
|
||||
$back_ground,
|
||||
[
|
||||
'action' => 'imageText', // 写入店铺名称
|
||||
'data' => [
|
||||
$site_info[ 'data' ][ 'site_name' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'store_name_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_left' ] * 2,
|
||||
($poster_data[ 'data' ][ 'template_json' ][ 'store_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'store_name_font_size' ]) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_name_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 店铺logo
|
||||
'data' => [
|
||||
!empty($site_info[ 'data' ][ 'logo_square' ]) ? $site_info[ 'data' ][ 'logo_square' ] : getUrl() . '/app/shop/view/public/img/shop_logo.png',
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_height' ] * 2,
|
||||
'square',
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'store_logo_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品图
|
||||
'data' => [
|
||||
img($goods_info[ 'sku_image' ], 'mid'),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'goods_img_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_img_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info[ 'sku_name' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_name_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_left' ] * 2,
|
||||
($poster_data[ 'data' ][ 'template_json' ][ 'goods_name_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_name_font_size' ]) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_width' ] * 2,
|
||||
1,//文本行数 $poster_data['data']['template_json']['goods_name_height']*2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_name_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 写入商品二维码
|
||||
'data' => [
|
||||
$qrcode_info[ 'data' ][ 'path' ],
|
||||
$poster_data[ 'data' ][ 'qrcode_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'qrcode_height' ] * 2,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'¥' . $goods_info[ 'floor_price' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_price_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_left' ] * 2,
|
||||
($poster_data[ 'data' ][ 'template_json' ][ 'goods_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_price_font_size' ]) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_price_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
if ($goods_info[ 'price' ] == 0) {
|
||||
$line = '一一一';
|
||||
} else {
|
||||
$line = '一一一一';
|
||||
}
|
||||
$market_price = [
|
||||
[
|
||||
'action' => 'imageText', // 写入商品划线价格
|
||||
'data' => [
|
||||
'¥' . $goods_info[ 'price' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2,
|
||||
($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ]) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ] ?? 0
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入线
|
||||
'data' => [
|
||||
$line,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_left' ] * 2 - 5,
|
||||
($poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_font_size' ]) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_height' ] * 2,
|
||||
true,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'goods_market_price_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
$option = array_merge($option, $market_price);
|
||||
|
||||
if (!empty($member_info)) {
|
||||
$member_option = [
|
||||
[
|
||||
'action' => 'imageCopy', // 写入用户头像
|
||||
'data' => [
|
||||
!empty($member_info[ 'headimg' ]) ? $member_info[ 'headimg' ] : $upload_config_result[ 'data' ][ 'value' ][ 'head' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_left' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_top' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_height' ] * 2,
|
||||
!empty($poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ]) ? $poster_data[ 'data' ][ 'template_json' ][ 'headimg_shape' ] : 'square',
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'headimg_is_show' ]
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入分享人昵称
|
||||
'data' => [
|
||||
$member_info[ 'nickname' ],
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ] * $fontRate * 2,
|
||||
hex2rgb($poster_data[ 'data' ][ 'template_json' ][ 'nickname_color' ]),
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_left' ] * 2,
|
||||
($poster_data[ 'data' ][ 'template_json' ][ 'nickname_top' ] + $poster_data[ 'data' ][ 'template_json' ][ 'nickname_font_size' ]) * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_width' ] * 2,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_height' ] * 2,
|
||||
0,
|
||||
$poster_data[ 'data' ][ 'template_json' ][ 'nickname_is_show' ]
|
||||
]
|
||||
],
|
||||
];
|
||||
$option = array_merge($ground, $option, $member_option);
|
||||
}
|
||||
}
|
||||
|
||||
$option_res = $poster->create($option);
|
||||
if (is_array($option_res)) return $option_res;
|
||||
|
||||
$res = $option_res->jpeg('upload/poster/goods', 'goods_' . $promotion_type . '_' . $goods_info[ 'bargain_id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . time() . '_' . $app_type);
|
||||
if ($res[ 'code' ] == 0) {
|
||||
$upload = new Upload($site_id);
|
||||
$cloud_res = $upload->fileCloud($res[ 'data' ][ 'path' ]);
|
||||
if ($cloud_res[ 'code' ] >= 0) {
|
||||
return $this->success(["path" => $cloud_res[ 'data' ]]);
|
||||
} else {
|
||||
return $this->error();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param unknown $member_id
|
||||
*/
|
||||
private function getMemberInfo($member_id)
|
||||
{
|
||||
return model('member')->getInfo(['member_id' => $member_id], 'nickname,headimg');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品信息
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
private function getGoodsInfo($id)
|
||||
{
|
||||
$join = [
|
||||
['goods_sku sku', 'pbg.sku_id = sku.sku_id', 'inner'],
|
||||
];
|
||||
$field = 'pbg.bargain_id,pbg.floor_price,sku.sku_name,sku.sku_id,sku.sku_image,sku.template_id,sku.price';
|
||||
return model('promotion_bargain_goods')->getInfo(['pbg.bargain_id' => $id], $field, 'pbg', $join);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品二维码
|
||||
* @param unknown $app_type 请求类型
|
||||
* @param unknown $page uniapp页面路径
|
||||
* @param unknown $qrcode_param 二维码携带参数
|
||||
* @param string $promotion_type 活动类型 null为无活动
|
||||
*/
|
||||
private function getGoodsQrcode($app_type, $page, $qrcode_param, $promotion_type, $site_id)
|
||||
{
|
||||
return event('Qrcode', [
|
||||
'site_id' => $site_id,
|
||||
'app_type' => $app_type,
|
||||
'type' => 'create',
|
||||
'data' => $qrcode_param,
|
||||
'page' => $page,
|
||||
'qrcode_path' => 'upload/qrcode/goods',
|
||||
'qrcode_name' => 'goods_' . $promotion_type . '_' . $qrcode_param[ 'l_id' ] . '_' . $qrcode_param[ 'source_member' ] . '_' . $site_id,
|
||||
], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海报信息
|
||||
* @param unknown $template_id
|
||||
*/
|
||||
private function getTemplateInfo($template_id)
|
||||
{
|
||||
return model('poster_template')->getInfo(['template_id' => $template_id], 'template_id,template_status');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分享图片
|
||||
* @param $page
|
||||
* @param $qrcode_param
|
||||
* @param $site_id
|
||||
* @return array|\extend\multitype|PosterExtend|string|string[]
|
||||
*/
|
||||
public function shareImg($page, $qrcode_param, $site_id)
|
||||
{
|
||||
try {
|
||||
if ($page == '/pages_promotion/bargain/launch') {
|
||||
$goods_info = $this->getGoodsInfo($qrcode_param[ 'bargain_id' ]);
|
||||
unset($qrcode_param[ 'bargain_id' ]);
|
||||
} else {
|
||||
$goods_info = $this->getGoodsInfo($qrcode_param[ 'id' ]);
|
||||
}
|
||||
if (empty($goods_info)) {
|
||||
return $this->error('未获取到商品信息');
|
||||
}
|
||||
|
||||
$file_path = 'upload/share_img/bargain_' . $goods_info[ 'bargain_id' ] . '/sku_' . $goods_info[ 'sku_id' ] . '.jpg';
|
||||
if (file_exists($file_path)) return $this->success(['path' => $file_path]);
|
||||
|
||||
$poster_width = 600;
|
||||
$poster_height = 480;
|
||||
|
||||
$poster = new PosterExtend($poster_width, $poster_height);
|
||||
$option = [
|
||||
[
|
||||
'action' => 'setBackground', // 设背景色
|
||||
'data' => [255, 255, 255]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 商品图
|
||||
'data' => [
|
||||
img($goods_info[ 'sku_image' ], 'mid'),
|
||||
30,
|
||||
130,
|
||||
200,
|
||||
200,
|
||||
'square',
|
||||
50,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品名称
|
||||
'data' => [
|
||||
$goods_info[ 'sku_name' ],
|
||||
22,
|
||||
[51, 51, 51],
|
||||
250,
|
||||
170,
|
||||
330,
|
||||
2,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
'砍成价:¥',
|
||||
15,
|
||||
[255, 0, 0],
|
||||
250,
|
||||
295,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品价格
|
||||
'data' => [
|
||||
$goods_info[ 'floor_price' ],
|
||||
32,
|
||||
[255, 0, 0],
|
||||
345,
|
||||
295,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1,
|
||||
PUBLIC_PATH . 'static/font/custom.ttf'
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品原价
|
||||
'data' => [
|
||||
'原 价:¥',
|
||||
15,
|
||||
[153, 153, 153],
|
||||
250,
|
||||
330,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageText', // 写入商品原价
|
||||
'data' => [
|
||||
$goods_info[ 'price' ],
|
||||
16,
|
||||
[153, 153, 153],
|
||||
345,
|
||||
328,
|
||||
300,
|
||||
2,
|
||||
false,
|
||||
1,
|
||||
PUBLIC_PATH . 'static/font/custom.ttf',
|
||||
]
|
||||
],
|
||||
// 划线(两条线)
|
||||
[
|
||||
'action' => 'imageline',
|
||||
'data' => [
|
||||
325,
|
||||
320,
|
||||
325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
|
||||
320,
|
||||
[153, 153, 153],
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageline',
|
||||
'data' => [
|
||||
325,
|
||||
321,
|
||||
325 + imagettfbbox(16, 0, PUBLIC_PATH . 'static/font/custom.ttf', '¥ ' . $goods_info[ 'price' ])[ 2 ],
|
||||
321,
|
||||
[153, 153, 153],
|
||||
]
|
||||
],
|
||||
[
|
||||
'action' => 'imageCopy', // 背景图
|
||||
'data' => [
|
||||
img('upload/share_img/bg/bargain_1.png'),
|
||||
0,
|
||||
0,
|
||||
600,
|
||||
480,
|
||||
'square',
|
||||
0,
|
||||
1
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
$option_res = $poster->create($option);
|
||||
if (is_array($option_res)) {
|
||||
return $option_res;
|
||||
}
|
||||
|
||||
return $option_res->jpeg('upload/share_img/bargain_' . $goods_info[ 'bargain_id' ],
|
||||
'sku_' . $goods_info[ 'sku_id' ]);
|
||||
} catch (\Exception $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分享图片
|
||||
* @param int $bargain_id
|
||||
*/
|
||||
public function clearShareImg(int $bargain_id)
|
||||
{
|
||||
$dir = 'upload/share_img/bargain_' . $bargain_id;
|
||||
@deleteDir($dir);
|
||||
}
|
||||
|
||||
}
|
||||
135
addon/bargain/model/share/WchatShare.php
Executable file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\model\share;
|
||||
|
||||
use addon\bargain\model\Bargain as BargainModel;
|
||||
use app\model\share\WchatShareBase as BaseModel;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WchatShare extends BaseModel
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '砍价分享',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_BARGAIN_PROMOTE',
|
||||
'path' => [ '/pages_promotion/bargain/detail' ],
|
||||
'method_prefix' => 'goodsDetail',
|
||||
],
|
||||
[
|
||||
'title' => '砍价列表',
|
||||
'config_key' => 'WCHAT_SHARE_CONFIG_BARGAIN_LIST_PROMOTE',
|
||||
'path' => [ '/pages_promotion/bargain/list' ],
|
||||
'method_prefix' => 'goodsList',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* 砍价分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsListShareData($param)
|
||||
{
|
||||
//跳转路径
|
||||
$link = $this->getShareLink($param);
|
||||
$config_method = $this->goodsListShareConfig(__FUNCTION__);
|
||||
$config_data = $this->$config_method($param)[ 'value' ];
|
||||
|
||||
$data = [
|
||||
'link' => $link,
|
||||
'desc' => $config_data[ 'desc' ],
|
||||
'imgUrl' => $config_data[ 'imgUrl' ],
|
||||
'title' => $config_data[ 'title' ]
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价列表分享配置
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
public function goodsListShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([ [ 'site_id', '=', $site_id ], [ 'app_module', '=', 'shop' ], [ 'config_key', '=', $config[ 'config_key' ] ] ])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => "砍价列表",
|
||||
'desc' => "我在参加\n砍价活动",
|
||||
'imgUrl' => ''
|
||||
];
|
||||
}
|
||||
if (empty($data[ 'value' ][ 'imgUrl' ])) {
|
||||
$data[ 'value' ][ 'imgUrl' ] = img('addon/bargain/icon.png');
|
||||
}
|
||||
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function goodsDetailShareData($param)
|
||||
{
|
||||
$url = $param[ 'url' ];
|
||||
|
||||
//跳转路径
|
||||
$parse_res = parse_url($url);
|
||||
parse_str($parse_res[ 'query' ] ?? '', $query);
|
||||
|
||||
if (isset($query[ 'id' ]) || isset($query[ 'bargain_id' ])) {
|
||||
$bargain_id = $query[ 'id' ] ?? $query[ 'bargain_id' ];
|
||||
$goods = new BargainModel();
|
||||
$sku_info = $goods->getBargainGoodsDetail([ [ 'pb.bargain_id', '=', $bargain_id ] ])[ 'data' ];
|
||||
if (!empty($sku_info)) {
|
||||
$config_model = new \app\model\share\WchatShare();
|
||||
$config_data = $config_model->goodsDetailShareConfig($param);
|
||||
|
||||
$title = str_replace('{goods_name}', $sku_info[ 'sku_name' ], $config_data[ 'value' ][ 'title' ]);
|
||||
$desc = str_replace('{price}', $sku_info[ 'floor_price' ], $config_data[ 'value' ][ 'desc' ]);
|
||||
$link = $this->getShareLink($param);
|
||||
$image_url = $sku_info[ 'sku_image' ];
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'desc' => $desc,
|
||||
'link' => $link,
|
||||
'imgUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'hideOptionMenu' => false,
|
||||
'hideMenuItems' => [],
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
89
addon/bargain/model/share/WeappShare.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\model\share;
|
||||
|
||||
use app\model\share\WeappShareBase;
|
||||
use app\model\system\Config as ConfigModel;
|
||||
|
||||
/**
|
||||
* 分享
|
||||
*/
|
||||
class WeappShare extends WeappShareBase
|
||||
{
|
||||
protected $config = [
|
||||
[
|
||||
'title' => '砍价列表',
|
||||
'config_key' => 'WEAPP_SHARE_CONFIG_BARGAIN_LIST',
|
||||
'path' => [ '/pages_promotion/bargain/list' ],
|
||||
'method_prefix' => 'bargainList',
|
||||
],
|
||||
];
|
||||
|
||||
protected $sort = 2;
|
||||
|
||||
/**
|
||||
* 首页分享数据
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function bargainListShareData($param)
|
||||
{
|
||||
//获取和替换配置数据
|
||||
$config_data = $this->bargainListShareConfig($param);
|
||||
$title = $config_data[ 'value' ][ 'title' ];
|
||||
$image_url = $config_data[ 'value' ][ 'imageUrl' ] ? img($config_data[ 'value' ][ 'imageUrl' ]) : '';
|
||||
$path = $this->getSharePath($param);
|
||||
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'path' => $path,
|
||||
'imageUrl' => $image_url,
|
||||
];
|
||||
return [
|
||||
'permission' => [
|
||||
'onShareAppMessage' => true,
|
||||
'onShareTimeline' => true,
|
||||
],
|
||||
'data' => $data,//分享内容
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页分享配置
|
||||
* @param $param
|
||||
* @return array
|
||||
*/
|
||||
protected function bargainListShareConfig($param)
|
||||
{
|
||||
$site_id = $param[ 'site_id' ];
|
||||
$config = $param[ 'config' ];
|
||||
|
||||
$config_model = new ConfigModel();
|
||||
$data = $config_model->getConfig([
|
||||
[ 'site_id', '=', $site_id ],
|
||||
[ 'app_module', '=', 'shop' ],
|
||||
[ 'config_key', '=', $config[ 'config_key' ] ],
|
||||
])[ 'data' ];
|
||||
if (empty($data[ 'value' ])) {
|
||||
$data[ 'value' ] = [
|
||||
'title' => '跟我一起来砍价吧!',
|
||||
'imageUrl' => '',
|
||||
];
|
||||
}
|
||||
$variable = [];
|
||||
|
||||
return [
|
||||
'value' => $data[ 'value' ],
|
||||
'variable' => $variable,
|
||||
];
|
||||
}
|
||||
}
|
||||
353
addon/bargain/shop/controller/Bargain.php
Executable file
@@ -0,0 +1,353 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\shop\controller;
|
||||
|
||||
use addon\bargain\model\Bargain as BargainModel;
|
||||
|
||||
class Bargain extends BaseController
|
||||
{
|
||||
|
||||
/*
|
||||
* 砍价商品列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
|
||||
$model = new BargainModel();
|
||||
|
||||
$condition = [
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
|
||||
//获取续签信息
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$status = input('status', '');//砍价状态
|
||||
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'pb.status', '=', $status ];
|
||||
}
|
||||
//商品名称
|
||||
$goods_name = input('goods_name', '');
|
||||
if ($goods_name) {
|
||||
$condition[] = [ 'g.goods_name', 'like', '%' . $goods_name . '%' ];
|
||||
}
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'pb.end_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'pb.start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$start_timestamp = date_to_time($start_time);
|
||||
$end_timestamp = date_to_time($end_time);
|
||||
$sql = "pb.start_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or pb.end_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or (pb.start_time <= {$start_timestamp} and pb.end_time >= {$end_timestamp})";
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
|
||||
}
|
||||
|
||||
//排序
|
||||
$order = input('order', 'create_time');
|
||||
$sort = input('sort', 'desc');
|
||||
if (!empty($sort)) {
|
||||
$order_by = 'pb.' . $order . ' ' . $sort;
|
||||
} else {
|
||||
$order_by = 'pb.create_time desc';
|
||||
}
|
||||
$list = $model->getBargainPageList($condition, $page, $page_size, $order_by);
|
||||
return $list;
|
||||
} else {
|
||||
$bargain_status = $model->getBargainStatus();
|
||||
$this->assign('bargain_status', $bargain_status[ 'data' ]);
|
||||
|
||||
return $this->fetch('bargain/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$common_data = [
|
||||
'site_id' => $this->site_id,
|
||||
'bargain_name' => input('bargain_name', ''),
|
||||
'is_fenxiao' => input('is_fenxiao', ''),
|
||||
'buy_type' => input('buy_type', ''),
|
||||
'bargain_type' => input('bargain_type', ''),
|
||||
'bargain_num' => input('bargain_num', ''),
|
||||
'bargain_time' => input('bargain_time', ''),
|
||||
'remark' => input('remark', ''),
|
||||
'is_own' => input('is_own', ''),
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
'is_differ_new_user' => input('is_differ_new_user', 0),
|
||||
'distinguish' => input('distinguish', 1),
|
||||
'new_low' => input('new_low', ''),
|
||||
'aged_tall' => input('aged_tall'),
|
||||
'aged_fixation' => input('aged_fixation'),
|
||||
'bargain_max_num' => input('bargain_max_num', 0),
|
||||
'help_bargain_num' => input('help_bargain_num', 0),
|
||||
];
|
||||
|
||||
$goods = [
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
];
|
||||
$sku_list = input('sku_list', '');
|
||||
$bargain_model = new BargainModel();
|
||||
return $bargain_model->addBargain($common_data, $goods, $sku_list);
|
||||
} else {
|
||||
$bargain_name = '砍价 ' . date('Y-m-d');
|
||||
$this->assign('bargain_name', $bargain_name);
|
||||
return $this->fetch('bargain/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$bargain_model = new BargainModel();
|
||||
|
||||
$bargain_id = input('bargain_id', '');
|
||||
if (request()->isJson()) {
|
||||
|
||||
$common_data = [
|
||||
'bargain_id' => $bargain_id,
|
||||
'site_id' => $this->site_id,
|
||||
'bargain_name' => input('bargain_name', ''),
|
||||
'is_fenxiao' => input('is_fenxiao', ''),
|
||||
'buy_type' => input('buy_type', ''),
|
||||
'bargain_type' => input('bargain_type', ''),
|
||||
'bargain_num' => input('bargain_num', ''),
|
||||
'bargain_time' => input('bargain_time', ''),
|
||||
'remark' => input('remark', ''),
|
||||
'is_own' => input('is_own', ''),
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
'is_differ_new_user' => input('is_differ_new_user', 0),
|
||||
'distinguish' => input('distinguish', 1),
|
||||
'new_low' => input('new_low', ''),
|
||||
'aged_tall' => input('aged_tall'),
|
||||
'aged_fixation' => input('aged_fixation'),
|
||||
'bargain_max_num' => input('bargain_max_num', 0),
|
||||
'help_bargain_num' => input('help_bargain_num', 0),
|
||||
];
|
||||
$sku_list = input('sku_list', '');
|
||||
$goods = [
|
||||
'goods_id' => input('goods_id', ''),
|
||||
'sku_ids' => input('sku_ids', ''),
|
||||
];
|
||||
return $bargain_model->editBargain($common_data, $goods, $sku_list);
|
||||
} else {
|
||||
|
||||
//获取砍价信息
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$bargain_info = $bargain_model->getBargainInfo($condition);
|
||||
if (empty($bargain_info[ 'data' ])) $this->error('未获取到活动数据', href_url('bargain://shop/bargain/lists'));
|
||||
$this->assign('bargain_info', $bargain_info[ 'data' ]);
|
||||
return $this->fetch('bargain/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 砍价详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$bargain_model = new BargainModel();
|
||||
|
||||
$bargain_id = input('bargain_id', '');
|
||||
//获取砍价信息
|
||||
$condition = [
|
||||
[ 'pb.bargain_id', '=', $bargain_id ],
|
||||
[ 'pb.site_id', '=', $this->site_id ],
|
||||
[ 'g.goods_state', '=', 1 ],
|
||||
[ 'g.is_delete', '=', 0 ]
|
||||
];
|
||||
$bargain_info = $bargain_model->getBargainJoinGoodsList($condition);
|
||||
|
||||
if (empty($bargain_info[ 'data' ])) $this->error('未获取到活动数据', href_url('bargain://shop/bargain/lists'));
|
||||
|
||||
$this->assign('bargain_info', $bargain_info[ 'data' ]);
|
||||
return $this->fetch('bargain/detail');
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除砍价活动
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$bargain_id = input('bargain_id', '');
|
||||
$bargain_model = new BargainModel();
|
||||
return $bargain_model->deleteBargain($bargain_id, $this->site_id);
|
||||
}
|
||||
|
||||
/*
|
||||
* 结束砍价活动
|
||||
*/
|
||||
public function finish()
|
||||
{
|
||||
$bargain_id = input('bargain_id', '');
|
||||
$bargain_model = new BargainModel();
|
||||
return $bargain_model->finishBargain($bargain_id, $this->site_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取商品列表
|
||||
* @return array
|
||||
*/
|
||||
public function getSkuList()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$bargain_model = new BargainModel();
|
||||
$bargain_id = input('bargain_id', '');
|
||||
$bargain_info = $bargain_model->getBargainGoodsList($bargain_id, $this->site_id);
|
||||
return $bargain_info;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价列表
|
||||
*/
|
||||
public function launchList()
|
||||
{
|
||||
$bargain_id = input('bargain_id', '');
|
||||
if (request()->isJson()) {
|
||||
$goods_name = input('goods_name', '');
|
||||
$nickname = input('nickname', '');
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
$status = input('status', '');//砍价状态
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$bargain_model = new BargainModel();
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if ($bargain_id) {
|
||||
$condition[] = [ 'bargain_id', '=', $bargain_id ];
|
||||
}
|
||||
if ($status !== '') {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
if ($goods_name) {
|
||||
$condition[] = [ 'sku_name', 'like', '%' . $goods_name . '%' ];
|
||||
}
|
||||
if ($nickname) {
|
||||
$condition[] = [ 'nickname', 'like', '%' . $nickname . '%' ];
|
||||
}
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'start_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$condition[] = [ 'start_time', 'between', [ date_to_time($start_time), date_to_time($end_time) ] ];
|
||||
}
|
||||
|
||||
$list = $bargain_model->getBargainLaunchPageListInAdmin($condition, '', 'launch_id desc', $page, $page_size);
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
$this->assign('bargain_id', $bargain_id);
|
||||
|
||||
return $this->fetch('bargain/launch_list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 帮砍记录
|
||||
* @return mixed
|
||||
*/
|
||||
public function launchDetail()
|
||||
{
|
||||
$launch_id = input('launch_id', '');
|
||||
$bargain_model = new BargainModel();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
|
||||
$condition = [ [ 'launch_id', '=', $launch_id ] ];
|
||||
$list = $bargain_model->getBargainRecordPageList($condition, '', 'id desc', $page, $page_size);
|
||||
return $list;
|
||||
} else {
|
||||
|
||||
$this->assign('launch_id', $launch_id);
|
||||
//获取发起人信息
|
||||
$info = $bargain_model->getBargainLaunchDetail([ [ 'launch_id', '=', $launch_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
|
||||
if (empty($info[ 'data' ])) $this->error('未获取到活动数据', href_url('bargain://shop/bargain/launchlist'));
|
||||
|
||||
$this->assign('info', $info[ 'data' ]);
|
||||
|
||||
return $this->fetch('bargain/launch_detail');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 砍价推广
|
||||
*/
|
||||
public function bargainUrl()
|
||||
{
|
||||
$bargain_id = input('bargain_id', '');
|
||||
$app_type = input('app_type', 'all');
|
||||
$bargain_model = new BargainModel();
|
||||
$res = $bargain_model->urlQrcode('/pages_promotion/bargain/detail', [ 'b_id' => $bargain_id ], 'bargain', $app_type, $this->site_id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @return array
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$bargain_id = input('bargain_id', '');
|
||||
$bargain_model = new BargainModel();
|
||||
foreach ($bargain_id as $k => $v){
|
||||
$res = $bargain_model->deleteBargain($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量关闭
|
||||
* @return array
|
||||
*/
|
||||
public function finishAll()
|
||||
{
|
||||
$bargain_id = input('bargain_id', '');
|
||||
$bargain_model = new BargainModel();
|
||||
foreach ($bargain_id as $k => $v){
|
||||
$res = $bargain_model->finishBargain($v, $this->site_id);
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
30
addon/bargain/shop/controller/BaseController.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\bargain\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\App;
|
||||
|
||||
class BaseController extends BaseShop
|
||||
{
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'SHOP_ADDON_CSS' => __ROOT__ . '/addon/bargain/shop/view/public/css',
|
||||
'SHOP_ADDON_IMG' => __ROOT__ . '/addon/bargain/shop/view/public/img',
|
||||
'SHOP_ADDON_JS' => __ROOT__ . '/addon/bargain/shop/view/public/js',
|
||||
];
|
||||
|
||||
//执行父类构造函数
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
}
|
||||
729
addon/bargain/shop/view/bargain/add.html
Executable file
@@ -0,0 +1,729 @@
|
||||
<style>
|
||||
.len-input {width: 100%;max-width: 120px;}
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.desc{margin-bottom: 15px;border:1px dashed #ff8143;padding: 5px 10px;background: #fff0e9;color: #ff8143;width: 65%;}
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.layui-carousel { position: absolute; top: 90px; left: 1350px; background: #fff;}
|
||||
.goods_num {padding-left: 20px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="desc">
|
||||
请自觉遵守微信关于规范外部链接内容管理的规范,防止由于微信封号导致不必要的损失。<a href="http://weixin.qq.com/cgi-bin/readtemplate?t=weixin_external_links_content_management_specification" target="_blank">点击查看详情</a>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_name" value="{$bargain_name}" lay-verify="required" autocomplete="off" class="layui-input len-long" maxlength="40">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="start_time" name="start_time" lay-verify="required" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="end_time" name="end_time" lay-verify="required|time" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>砍价有效期:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="bargain_time" value="" lay-verify="required|int" data-min="4" data-max="48" data-unit="小时" placeholder="4-48小时" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">小时</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>自用户发起砍价到砍价截止的时间</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否参与分销:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_fenxiao" value="0" title="不参与" checked>
|
||||
<input type="radio" name="is_fenxiao" value="1" title="参与">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">购买方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="buy_type" value="0" title="任意金额可购买" checked>
|
||||
<input type="radio" name="buy_type" value="1" title="砍到指定价格才可购买">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">帮砍金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="bargain_type" lay-filter='bargain_type' value="1" title="随机金额" checked >
|
||||
<input type="radio" name="bargain_type" lay-filter='bargain_type' value="0" title="固定金额" >
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>设置每位帮砍用户的砍价金额规则</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否允许自己砍价:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_own" lay-filter="" value="1" lay-skin="switch" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item bargain_num">
|
||||
<label class="layui-form-label"><span class="required">*</span>最少帮砍人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="bargain_num" value="" lay-verify="required|int" data-min="2" data-max="100" data-unit="人" placeholder="2-100人" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>最少帮砍人数为该砍价订单最少人数</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item bargain_max_num">
|
||||
<label class="layui-form-label"><span class="required">*</span>砍成人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="bargain_max_num" value="0" lay-verify="bargain_max_num" data-min="2" data-max="100" data-unit="人" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>由于帮砍金额为随机金额,实际砍成人数可能小于设置的砍成人数,但是达到砍成人数时砍价必然成功</p>
|
||||
<p>若砍成人数设置为0,表示不限制砍成人数,累计帮砍金额达到最低砍价金额时砍价成功</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>最大帮砍次数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="help_bargain_num" value="0" lay-verify="help_bargain_num" data-unit="人" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>每个会员针对当前活动商品最多帮砍次数,0为不限制</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" style="display: none">
|
||||
<label class="layui-form-label">是否区分新老用户:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" lay-filter="is_differ_new_user" name="is_differ_new_user" value="1" title="是" >
|
||||
<input type="radio" lay-filter="is_differ_new_user" name="is_differ_new_user" value="0" title="否" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div name="distinguish" style="display: none">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>新用户区分标准:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="distinguish" value="1" lay-verify="required|int" data-min="1" data-max="100" data-unit="人" placeholder="1-100天" autocomplete="off" class="layui-input len-short" min="1">
|
||||
<span class="layui-form-label label-time">天内新注册且未砍过价的</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div name='random' style="display: none">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新用户最低随机金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="new_low" lay-verify="flo" autocomplete="off" class="layui-input combined-price len-short" value="0.00" step="1" min="0.00">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">老用户最高随机金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="aged_tall" autocomplete="off" class="layui-input combined-price len-short" value="0.00" step="1" min="0.00">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div name='fixed' class="layui-form-item layui-hide" style="display: none">
|
||||
<label class="layui-form-label">老用户固定砍价:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="aged_fixation" autocomplete="off" class="layui-input combined-price len-short" value="0.00" step="1" min="0.00">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label">活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button> <span class="goods_num">已选商品(<span id="goods_num" class="text-color">0</span>)</span>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="sku_ids">
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">活动规则说明:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="300"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-carousel" >
|
||||
<img src="__STATIC__/img/bargain.png" >
|
||||
</div>-->
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backBargainList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="money">首刀金额</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="bargain-stock">砍价库存</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="floor-price">底价</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="bargainFirst">
|
||||
<input type="number" class="layui-input len-input bargain-first" value="{{d.first_bargain_price ? d.first_bargain_price : ''}}" lay-verify="bargain_first" min="0.00" oninput="bargainFirst({{ d.sku_id }},event)" onporpertychange="bargainFirst({{ d.sku_id }},event)" />
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="bargainStock">
|
||||
<input type="number" class="layui-input len-input bargain-stock" value="{{d.bargain_stock ? d.bargain_stock : d.stock }}" lay-verify="bargain_stock" min="0" oninput="bargainStock({{ d.sku_id }},event)" onporpertychange="bargainStock({{ d.sku_id }},event)"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="minPrice">
|
||||
<input type="number" class="layui-input len-input min-price" lay-verify="min_price" min="0.00" value="{{d.floor_price ? d.floor_price : 0.00}}" oninput="bargainMinPrice({{ d.sku_id }},event)" onporpertychange="bargainMinPrice({{ d.sku_id }},event)"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delRow(this,{{d.sku_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var goodsId = {}, selectedGoodsId = [], sku_list = [],
|
||||
form,laydate,repeat_flag,currentDate,minDate,
|
||||
is_differ_new_user = 1,bargain_type = 1;
|
||||
layui.use(['form', 'laydate'], function() {
|
||||
form = layui.form;
|
||||
laydate = layui.laydate;
|
||||
repeat_flag = false;
|
||||
currentDate = new Date();
|
||||
minDate = "";
|
||||
currentDate.setDate(currentDate.getDate() + 30);
|
||||
form.render();
|
||||
|
||||
/**
|
||||
* 新老客户单选框选择
|
||||
*/
|
||||
|
||||
form.on("radio(is_differ_new_user)", function(data){
|
||||
is_differ_new_user = data.value;
|
||||
if(data.value == '1'){
|
||||
$("div[name='distinguish']").removeClass('layui-hide')
|
||||
}else{
|
||||
$("div[name='distinguish']").addClass('layui-hide')
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 帮砍金额单选框选择
|
||||
*/
|
||||
form.on("radio(bargain_type)",function(data){
|
||||
bargain_type = data.value;
|
||||
if(data.value == '1'){
|
||||
$("div[name='random']").removeClass('layui-hide');
|
||||
$("div[name='fixed']").addClass('layui-hide');
|
||||
$(".bargain_max_num").removeClass('layui-hide');
|
||||
$('.bargain_num .layui-form-label').html('<span class="required">*</span>最少帮砍人数:');
|
||||
$('.bargain_num .word-aux').html('<p>最少帮砍人数为该砍价订单最少人数</p>');
|
||||
}else{
|
||||
$("div[name='random']").addClass('layui-hide');
|
||||
$("div[name='fixed']").removeClass('layui-hide');
|
||||
$(".bargain_max_num").addClass('layui-hide');
|
||||
$('.bargain_num .layui-form-label').html('<span class="required">*</span>砍成人数:');
|
||||
$('.bargain_num .word-aux').html('');
|
||||
}
|
||||
});
|
||||
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
for (var i = 0; i <= 30; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
if (i == 1) {
|
||||
var html = '<option value="' + i + '" selected>0' + i + '</option>';
|
||||
}
|
||||
$(".bargain-day").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 23; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
$(".bargain-hour").append(html);
|
||||
}
|
||||
for (var i = 0; i <= 59; i++) {
|
||||
if (i < 10) {
|
||||
var html = '<option value="' + i + '">0' + i + '</option>';
|
||||
} else {
|
||||
var html = '<option value="' + i + '">' + i + '</option>';
|
||||
}
|
||||
$(".bargain-minute").append(html);
|
||||
}
|
||||
form.render('select');
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(currentDate)
|
||||
});
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender() {
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class = "layui-input len-mid" autocomplete="off"> ');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
int: function(value, item) {
|
||||
var str = $(item).parents(".layui-form-item").find("label").text().split("*").join("");
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
var min = $(item).attr("data-min");
|
||||
var max = $(item).attr("data-max");
|
||||
var unit = $(item).attr("data-unit");
|
||||
|
||||
if (value < Number(min)) {
|
||||
return str + '不能小于' + min + unit;
|
||||
}
|
||||
if (value > Number(max)) {
|
||||
return str + '不能大于' + max + unit;
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return str + '必须为整数';
|
||||
}
|
||||
},
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (value < 1 || value % 1 != 0) {
|
||||
return '请输入大于0的正整数!';
|
||||
}
|
||||
},
|
||||
sum: function(value) {
|
||||
if (value < 2 || value % 1 != 0) {
|
||||
return '参团人数不能小于2,且必须是整数!';
|
||||
}
|
||||
},
|
||||
bargain_first: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".bargain-price").text();
|
||||
var min_price = $(item).parents("tr").find("input[lay-verify='min_price']").val();
|
||||
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (value < 0) {
|
||||
return '首刀金额不能小于0';
|
||||
}
|
||||
if (Number(value) >= Number(price)) {
|
||||
return '首刀金额必须小于商品价格';
|
||||
}
|
||||
if ((Number(value) + Number(min_price)) >= Number(price)) {
|
||||
return '首刀金额与底价之和必须小于商品价格';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '首刀金额最多保留两位小数';
|
||||
}
|
||||
},
|
||||
bargain_stock: function(value, item) {
|
||||
var stock = $(item).parents("tr").find(".stock").text();
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '砍价库存不能小于0';
|
||||
}
|
||||
if (Number(value) > Number(stock)) {
|
||||
return '砍价库存不能大于商品总库存';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '砍价库存必须为整数';
|
||||
}
|
||||
},
|
||||
min_price: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".bargain-price").text();
|
||||
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '商品底价不能小于0';
|
||||
}
|
||||
if (Number(value) > Number(price)) {
|
||||
return '商品底价不能大于商品价格';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '商品底价最多保留两位小数';
|
||||
}
|
||||
},
|
||||
bargain_max_num: function(value, item) {
|
||||
var bargain_type = $('input[name="bargain_type"]:checked').val();
|
||||
if(bargain_type == 1) {
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '砍成人数不能小于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '砍成人数必须为整数';
|
||||
}
|
||||
var bargain_num = $('input[name="bargain_num"]').val();
|
||||
|
||||
if (Number(value) <= Number(bargain_num)) {
|
||||
return '砍成人数不能小于最少帮砍人数';
|
||||
}
|
||||
}
|
||||
},
|
||||
help_bargain_num: function (value, item){
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '最大帮砍次数不能小于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '最大帮砍次数必须为整数';
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
|
||||
if (!Object.keys(goodsId).length) {
|
||||
layer.msg("请选择活动商品!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.goods_ids = selectedGoodsId.split(',');
|
||||
|
||||
var skuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
Object.values(item.sku_id).forEach(function (skuItem,skuIndex) {
|
||||
skuId.push(skuItem.sku);
|
||||
});
|
||||
});
|
||||
data.field.sku_ids = skuId;
|
||||
|
||||
var skuLisArr = [];
|
||||
sku_list.forEach(function(item,index) {
|
||||
var sku_detail = {};
|
||||
sku_detail.sku_id = item.sku_id;
|
||||
sku_detail.goods_id = item.goods_id;
|
||||
sku_detail.first_bargain_price = item.first_bargain_price || 0.00;
|
||||
sku_detail.bargain_stock = item.bargain_stock || item.stock;
|
||||
sku_detail.floor_price = item.floor_price || 0.00;
|
||||
skuLisArr.push(sku_detail);
|
||||
});
|
||||
data.field.sku_list = skuLisArr;
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("bargain://shop/bargain/add"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
location.hash = ns.hash("bargain://shop/bargain/lists");
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},{
|
||||
title: '商品名称',
|
||||
width: '23%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span class="bargain-price">' + data.price +'</span></p>';
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '<p class="stock">' + data.stock +'</p>';
|
||||
}
|
||||
}, {
|
||||
title: '<span title="首刀金额自定义">首刀金额自定义</span>',
|
||||
unresize: 'false',
|
||||
width: '16%',
|
||||
templet: '#bargainFirst'
|
||||
}, {
|
||||
title: '砍价库存',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#bargainStock'
|
||||
}, {
|
||||
title: '底价',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#minPrice'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false'
|
||||
}]
|
||||
],
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*/
|
||||
table.toolbar(function(obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "money":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "bargain-stock":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
case "floor-price":
|
||||
editInput(2,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '首刀金额',
|
||||
value: 'first_bargain_price'
|
||||
}, {
|
||||
name: '砍价库存',
|
||||
value: 'bargain_stock'
|
||||
}, {
|
||||
name: '底价',
|
||||
value: 'floor_price'
|
||||
}];
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: "修改" + text[textIndex].name,
|
||||
area: ['600px'],
|
||||
btn: ["保存", "返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_edit_input" lay-verify="required" autocomplete="off" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function (index, layero) {
|
||||
var val = $("input[name='bargain_edit_input']").val();
|
||||
if (!val) {
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item, index) {
|
||||
sku_list.forEach(function (skuItem, skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id) {
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
*/
|
||||
function addGoods() {
|
||||
goodsSelect(function (data) {
|
||||
|
||||
sku_list = [];
|
||||
goodsId = [];
|
||||
|
||||
for (var key in data) {
|
||||
|
||||
goodsId['goods_' + data[key].goods_id] = {};
|
||||
goodsId['goods_' + data[key].goods_id].sku_id = {};
|
||||
goodsId['goods_' + data[key].goods_id].spu_id = data[key].goods_id;
|
||||
|
||||
for (var sku in data[key].sku_list) {
|
||||
var item = data[key].sku_list[sku];
|
||||
goodsId['goods_' + data[key].goods_id].sku_id['sku_' + item.sku_id] = {};
|
||||
goodsId['goods_' + data[key].goods_id].sku_id['sku_' + item.sku_id].sku = item.sku_id;
|
||||
sku_list.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
renderTable(sku_list);
|
||||
$("input[name='sku_ids']").val(JSON.stringify(goodsId));
|
||||
|
||||
var spuId = [];
|
||||
Object.values(goodsId).forEach(function (item, index) {
|
||||
spuId.push(item.spu_id);
|
||||
});
|
||||
selectedGoodsId = spuId.toString();
|
||||
$("#goods_num").html(sku_list.length)
|
||||
}, selectedGoodsId);
|
||||
}
|
||||
|
||||
function delRow(obj,id) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == parseInt(id)){
|
||||
sku_list.splice(i,1);
|
||||
}
|
||||
}
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
delete item.sku_id['sku_'+id];
|
||||
if (!Object.keys(item.sku_id).length){
|
||||
delete goodsId['goods_'+item.spu_id];
|
||||
}
|
||||
});
|
||||
|
||||
var spuId = [];
|
||||
Object.values(goodsId).forEach(function (item,index) {
|
||||
spuId.push(item.spu_id);
|
||||
});
|
||||
selectedGoodsId = spuId.toString();
|
||||
$(obj).parents("tr").remove();
|
||||
$("#goods_num").html(sku_list.length)
|
||||
}
|
||||
|
||||
function bargainFirst(index,event) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index) sku_list[i].first_bargain_price = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
|
||||
function bargainStock(index,event) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index) sku_list[i].bargain_stock = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
|
||||
function bargainMinPrice(index,event) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == index) sku_list[i].floor_price = event.srcElement.value;
|
||||
}
|
||||
}
|
||||
|
||||
function backBargainList() {
|
||||
location.hash = ns.hash("bargain://shop/bargain/lists");
|
||||
}
|
||||
|
||||
</script>
|
||||
117
addon/bargain/shop/view/bargain/detail.html
Executable file
@@ -0,0 +1,117 @@
|
||||
<link rel="stylesheet" href="STATIC_CSS/promotion_detail.css">
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item">
|
||||
<label>活动名称:</label>
|
||||
<span>{$bargain_info.bargain_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$bargain_info.start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$bargain_info.end_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>购买方式:</label>
|
||||
<span>{if $bargain_info.buy_type == 1} 砍到指定价格 {else/} 任意金额可购买 {/if}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>帮砍金额:</label>
|
||||
<span>{if $bargain_info.bargain_type == 1} 随机金额 {else/} 固定金额 {/if}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>帮砍人数:</label>
|
||||
<span>{$bargain_info.bargain_time} 小时</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否允许自己砍价:</label>
|
||||
<span>{if $bargain_info.is_own == 1} 是 {else/} 否 {/if}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>是否参与分销:</label>
|
||||
<span>{if $bargain_info.is_fenxiao == 1} 参与 {else/} 不参与 {/if}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item-line">
|
||||
<label>活动规则:</label>
|
||||
<span>{$bargain_info.remark}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">活动商品</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class='promotion-view-list'>
|
||||
<table id="promotion_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type='text/html' id="promotion_list_item_box_html">
|
||||
<div class="promotion-list-item-title">
|
||||
<div class="promotion-list-item-title-icon">
|
||||
<img src="{{ ns.img(d.sku_image) }}" alt="">
|
||||
</div>
|
||||
<p class="promotion-list-item-title-name multi-line-hiding">{{ d.sku_name }}</p>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var list = {:json_encode($bargain_info.goods_list, JSON_UNESCAPED_UNICODE)};
|
||||
layui.use('table', function() {
|
||||
new Table({
|
||||
elem: '#promotion_list',
|
||||
cols: [
|
||||
[{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '26%',
|
||||
unresize: 'false',
|
||||
templet: "#promotion_list_item_box_html"
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return data.stock;
|
||||
}
|
||||
}, {
|
||||
field: 'first_bargain_price',
|
||||
title: '首刀金额',
|
||||
unresize: 'false'
|
||||
}, {
|
||||
field: 'bargain_stock',
|
||||
title: '砍价库存',
|
||||
unresize: 'false'
|
||||
}, {
|
||||
field: 'floor_price',
|
||||
title: '底价',
|
||||
unresize: 'false'
|
||||
}]
|
||||
],
|
||||
data: list
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
709
addon/bargain/shop/view/bargain/edit.html
Executable file
@@ -0,0 +1,709 @@
|
||||
<style>
|
||||
.len-input{width: 100%;max-width: 120px;}
|
||||
.layui-table-view{margin-top: 0;}
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.desc{margin-bottom: 15px;border:1px dashed #ff8143;padding: 5px 10px;background: #fff0e9;color: #ff8143;width: 65%;}
|
||||
.forbidden{cursor:not-allowed;background-color: #eee;}
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.layui-carousel { position: absolute; top: 90px; left: 1350px; background: #fff;}
|
||||
#bargain_num{width: 60px !important;}
|
||||
.layui-form-item .layui-input-block .label-time{width: auto;margin-left: 10px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="desc">
|
||||
请自觉遵守微信关于规范外部链接内容管理的规范,防止由于微信封号导致不必要的损失。<a href="http://weixin.qq.com/cgi-bin/readtemplate?t=weixin_external_links_content_management_specification" target="_blank">点击查看详情</a>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_name" lay-verify="required" value="{$bargain_info.bargain_name}" autocomplete="off" class="layui-input len-long" maxlength="40">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>活动名称将显示在活动列表中,方便商家管理</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" id="start_time" name="start_time" value="{:date('Y-m-d H:i:s', $bargain_info.start_time)}" lay-verify="required" class="layui-input" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" id="end_time" name="end_time" value="{:date('Y-m-d H:i:s', $bargain_info.end_time)}" lay-verify="required|time" class="layui-input" autocomplete="off" readonly>
|
||||
<input type="hidden" value="{$bargain_info.end_time}" id="old_end_time">
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>砍价有效期:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="bargain_time" value="{$bargain_info.bargain_time}" lay-verify="required|int" data-min="4" data-max="48" data-unit="小时" placeholder="4-48小时" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">小时</div>
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>自用户发起砍价到砍价截止的时间</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否参与分销:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_fenxiao" value="0" title="不参与" {if condition="$bargain_info.is_fenxiao == 0"}checked{/if} >
|
||||
<input type="radio" name="is_fenxiao" value="1" title="参与" {if condition="$bargain_info.is_fenxiao == 1"}checked{/if} >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">购买方式:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="buy_type" value="0" title="任意金额可购买" {if condition="$bargain_info.buy_type == 0"}checked{/if} >
|
||||
<input type="radio" name="buy_type" value="1" title="砍到指定价格才可购买" {if condition="$bargain_info.buy_type == 1"}checked{/if} >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">帮砍金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="bargain_type" value="1" lay-filter='bargain_type' title="随机金额" {if condition="$bargain_info.bargain_type == 1"}checked{/if} >
|
||||
<input type="radio" name="bargain_type" value="0" lay-filter='bargain_type' title="固定金额" {if condition="$bargain_info.bargain_type == 0"}checked{/if} >
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>设置每位帮砍用户的砍价金额规则</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否允许自己砍价:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_own" lay-filter="" {if condition="$bargain_info.is_own == 1"}checked{/if} value="1" lay-skin="switch" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item bargain_num">
|
||||
<label class="layui-form-label"><span class="required">*</span>最少帮砍人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="bargain_num" value="{$bargain_info.bargain_num}" lay-verify="required|int" data-min="2" data-max="100" data-unit="人" placeholder="2-100人" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>最少帮砍人数为该砍价订单最少人数</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item bargain_max_num">
|
||||
<label class="layui-form-label"><span class="required">*</span>砍成人数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="bargain_max_num" value="{$bargain_info.bargain_max_num}" lay-verify="bargain_max_num" data-min="2" data-max="100" data-unit="人" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>由于帮砍金额为随机金额,实际砍成人数可能小于设置的砍成人数,但是达到砍成人数时砍价必然成功</p>
|
||||
<p>若砍成人数设置为0,表示不限制砍成人数,累计帮砍金额达到最低砍价金额时砍价成功</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>最大帮砍次数:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="help_bargain_num" value="{$bargain_info.help_bargain_num}" lay-verify="help_bargain_num" data-unit="人" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>每个会员针对当前活动商品最多帮砍次数,0为不限制</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item" style="display: none">
|
||||
<label class="layui-form-label">是否区分新老用户:</label>
|
||||
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_differ_new_user" value="1" lay-filter='is_differ_new_user' title="是" {if condition="$bargain_info.is_differ_new_user == 1"}checked{/if} >
|
||||
<input type="radio" name="is_differ_new_user" value="0" lay-filter='is_differ_new_user' title="否" {if condition="$bargain_info.is_differ_new_user == 0"}checked{/if} >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div name="distinguish" style="display: none">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>新用户区分标准:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="distinguish" id="bargain_num" value="{$bargain_info.distinguish}" lay-verify="required|int" data-min="1" data-max="100" data-unit="人" placeholder="1-100天" autocomplete="off" class="layui-input len-short" min="1">
|
||||
<span class="layui-form-label label-time">天内新注册且未砍过价的</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div name='random' style="display: none">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新用户最低随机金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="new_low" value="{$bargain_info.new_low}" autocomplete="off" class="layui-input combined-price len-short" step="1" min="0.00">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">老用户最高随机金额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="aged_tall" value="{$bargain_info.aged_tall}" autocomplete="off" class="layui-input combined-price len-short" step="1" min="0.00">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div name='fixed' class="layui-form-item layui-hide" style="display: none">
|
||||
<label class="layui-form-label">老用户固定砍价:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="aged_fixation" value="{$bargain_info.aged_fixation}" autocomplete="off" class="layui-input combined-price len-short" step="1" min="0.00">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label">活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">活动规则说明:</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="300">{$bargain_info.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-carousel" style="display: none" >
|
||||
<img src="__STATIC__/img/bargain.png" >
|
||||
</div>-->
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backBargainList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="bargain_id" value="{$bargain_info.bargain_id}" />
|
||||
</div>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="money">首刀金额</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="bargain-stock">砍价库存</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="floor-price">底价</button>
|
||||
</script>
|
||||
<script>
|
||||
var sku_list = [],is_differ_new_user = 1,bargain_type = 1;
|
||||
sku_list = {:json_encode($bargain_info.goods_list, JSON_UNESCAPED_UNICODE)};
|
||||
sku_list.forEach(function (item,index) {
|
||||
item.is_delete = item.bargain_stock ? 1 : 2;
|
||||
});
|
||||
layui.use(['form', 'laydate'], function() {
|
||||
var form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false,
|
||||
startDate = '{$bargain_info.start_time}',
|
||||
endDate = '{$bargain_info.end_time}',
|
||||
minDate = "";
|
||||
form.render();
|
||||
|
||||
/**
|
||||
* 新老客户单选框选择
|
||||
*/
|
||||
form.on("radio(is_differ_new_user)", function(data){
|
||||
is_differ_new_user = data.value;
|
||||
if(data.value == '1'){
|
||||
$("div[name='distinguish']").removeClass('layui-hide')
|
||||
}else{
|
||||
$("div[name='distinguish']").addClass('layui-hide')
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 帮砍金额单选框选择
|
||||
*/
|
||||
form.on("radio(bargain_type)",function(data){
|
||||
bargain_type = data.value;
|
||||
if(data.value == '1'){
|
||||
$("div[name='random']").removeClass('layui-hide');
|
||||
$("div[name='fixed']").addClass('layui-hide');
|
||||
$(".bargain_max_num").removeClass('layui-hide');
|
||||
$('.bargain_num .layui-form-label').html('<span class="required">*</span>最少帮砍人数:');
|
||||
$('.bargain_num .word-aux').html('<p>最少帮砍人数为该砍价订单最少人数</p>');
|
||||
}else{
|
||||
$("div[name='random']").addClass('layui-hide');
|
||||
$("div[name='fixed']").removeClass('layui-hide');
|
||||
$(".bargain_max_num").addClass('layui-hide');
|
||||
$('.bargain_num .layui-form-label').html('<span class="required">*</span>砍成人数:');
|
||||
$('.bargain_num .word-aux').html('');
|
||||
}
|
||||
});
|
||||
|
||||
var bargain_type = $('input[name="bargain_type"]:checked').val();
|
||||
|
||||
if(bargain_type == 1){
|
||||
$("div[name='random']").removeClass('layui-hide');
|
||||
$("div[name='fixed']").addClass('layui-hide');
|
||||
$(".bargain_max_num").removeClass('layui-hide');
|
||||
$('.bargain_num .layui-form-label').html('<span class="required">*</span>最少帮砍人数:');
|
||||
$('.bargain_num .word-aux').html('<p>最少帮砍人数为该砍价订单最少人数</p>');
|
||||
}else{
|
||||
$("div[name='random']").addClass('layui-hide');
|
||||
$("div[name='fixed']").removeClass('layui-hide');
|
||||
$(".bargain_max_num").addClass('layui-hide');
|
||||
$('.bargain_num .layui-form-label').html('<span class="required">*</span>砍成人数:');
|
||||
$('.bargain_num .word-aux').html('');
|
||||
}
|
||||
|
||||
renderTable(sku_list); // 初始化表格
|
||||
|
||||
var now_time = ((new Date()).getTime())/1000;
|
||||
var start_time = ((new Date($("#start_time").val())).getTime())/1000;
|
||||
var old_end_time = ((new Date($("#end_time").val())).getTime())/1000;
|
||||
if(now_time <= start_time){
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime',
|
||||
done: function(value) {
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
}
|
||||
if(now_time <= old_end_time){
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender() {
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class = "layui-input len-mid" autocomplete="off"> ');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
int: function(value, item) {
|
||||
var str = $(item).parents(".layui-form-item").find("label").text().split("*").join("");
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
var min = $(item).attr("data-min");
|
||||
var max = $(item).attr("data-max");
|
||||
var unit = $(item).attr("data-unit");
|
||||
|
||||
if (value < Number(min)) {
|
||||
return str + '不能小于' + min + unit;
|
||||
}
|
||||
if (value > Number(max)) {
|
||||
return str + '不能大于' + max + unit;
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return str + '必须为整数';
|
||||
}
|
||||
},
|
||||
time: function(value) {
|
||||
var now_time = ((new Date()).getTime())/1000;
|
||||
var start_time = ((new Date($("#start_time").val())).getTime())/1000;
|
||||
var end_time = ((new Date(value)).getTime())/1000;
|
||||
var old_end_time = $('#old_end_time').val();
|
||||
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (end_time < old_end_time) {
|
||||
return '结束时间不能小于之前设置的结束时间!';
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (value < 1 || value % 1 != 0) {
|
||||
return '请输入大于0的正整数!';
|
||||
}
|
||||
},
|
||||
sum: function(value) {
|
||||
if (value < 2 || value % 1 != 0) {
|
||||
return '参团人数不能小于2,且必须是整数!';
|
||||
}
|
||||
},
|
||||
bargain_first: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".bargain-price").text();
|
||||
var min_price = $(item).parents("tr").find("input[lay-verify='min_price']").val();
|
||||
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (value < 0) {
|
||||
return '首刀金额不能小于0';
|
||||
}
|
||||
if (Number(value) >= Number(price)) {
|
||||
return '首刀金额必须小于商品价格';
|
||||
}
|
||||
if ((Number(value) + Number(min_price)) >= Number(price)) {
|
||||
return '首刀金额与底价之和必须小于商品价格';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '首刀金额最多保留两位小数';
|
||||
}
|
||||
},
|
||||
bargain_stock: function(value, item) {
|
||||
var stock = $(item).parents("tr").find(".stock").text();
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '砍价库存不能小于0';
|
||||
}
|
||||
if (Number(value) > Number(stock)) {
|
||||
return '砍价库存不能大于商品总库存';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '砍价库存必须为整数';
|
||||
}
|
||||
},
|
||||
min_price: function(value, item) {
|
||||
var price = $(item).parents("tr").find(".bargain-price").text();
|
||||
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '商品底价不能小于0';
|
||||
}
|
||||
if (Number(value) > Number(price)) {
|
||||
return '商品底价不能大于商品价格';
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '商品底价最多保留两位小数';
|
||||
}
|
||||
},
|
||||
bargain_max_num: function(value, item) {
|
||||
var bargain_type = $('input[name="bargain_type"]:checked').val();
|
||||
if(bargain_type == 1) {
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '砍成人数不能小于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '砍成人数必须为整数';
|
||||
}
|
||||
var bargain_num = $('input[name="bargain_num"]').val();
|
||||
|
||||
if (Number(value) <= Number(bargain_num)) {
|
||||
return '砍成人数不能小于最少帮砍人数';
|
||||
}
|
||||
}
|
||||
},
|
||||
help_bargain_num: function (value, item){
|
||||
if (value == "" || value == 0) {
|
||||
return;
|
||||
}
|
||||
if (Number(value) < 0) {
|
||||
return '最大帮砍次数不能小于0';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '最大帮砍次数必须为整数';
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data){
|
||||
|
||||
data.field.sku_ids = [];
|
||||
data.field.goods_id = sku_list[0].goods_id;
|
||||
sku_list.forEach(function (item,index) {
|
||||
if (item.is_delete == 2) return false;
|
||||
data.field.sku_ids.push(item.sku_id);
|
||||
});
|
||||
|
||||
if (data.field.sku_ids.length == 0) {
|
||||
layer.msg("请选择参与活动商品!", {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
var skuLisArr = [];
|
||||
sku_list.forEach(function(item,index) {
|
||||
var sku_detail = {};
|
||||
sku_detail.sku_id = item.sku_id;
|
||||
sku_detail.goods_id = item.goods_id;
|
||||
sku_detail.first_bargain_price = item.first_bargain_price || 0.00;
|
||||
sku_detail.bargain_stock = item.bargain_stock || item.stock;
|
||||
sku_detail.floor_price = item.floor_price || 0.00;
|
||||
sku_detail.is_delete = item.is_delete || 1;
|
||||
skuLisArr.push(sku_detail);
|
||||
});
|
||||
data.field.sku_list = skuLisArr;
|
||||
|
||||
if(repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("bargain://shop/bargain/edit"),
|
||||
data: data.field,
|
||||
async: false,
|
||||
success: function(res){
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("bargain://shop/bargain/lists");
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},{
|
||||
title: '商品名称',
|
||||
width: '23%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span class="bargain-price">' + data.price +'</span></p>';
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '<p class="stock">' + data.stock +'</p>';
|
||||
}
|
||||
}, {
|
||||
title: '<span title="首刀金额自定义">首刀金额自定义</span>',
|
||||
unresize: 'false',
|
||||
width: '16%',
|
||||
templet: '#bargainFirst'
|
||||
}, {
|
||||
title: '砍价库存',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#bargainStock'
|
||||
}, {
|
||||
title: '底价',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#minPrice'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
|
||||
/**
|
||||
* 批量操作
|
||||
*/
|
||||
table.toolbar(function(obj) {
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "money":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "bargain-stock":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
case "floor-price":
|
||||
editInput(2,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '首刀金额',
|
||||
value: 'first_bargain_price'
|
||||
},{
|
||||
name: '砍价库存',
|
||||
value: 'bargain_stock'
|
||||
},{
|
||||
name: '底价',
|
||||
value: 'floor_price'
|
||||
}];
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_edit_input" lay-verify="required" autocomplete="off" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='bargain_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bargainFirst(index,event) {
|
||||
sku_list[index-1].first_bargain_price = event.srcElement.value;
|
||||
}
|
||||
|
||||
function bargainStock(index,event) {
|
||||
sku_list[index-1].bargain_stock = event.srcElement.value;
|
||||
}
|
||||
|
||||
function bargainMinPrice(index,event) {
|
||||
sku_list[index-1].floor_price = event.srcElement.value;
|
||||
}
|
||||
function backBargainList() {
|
||||
location.hash = ns.hash("bargain://shop/bargain/lists");
|
||||
}
|
||||
$("body").off("click",".no-participation").on("click",".no-participation",function(){
|
||||
$(this).text("参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",true);
|
||||
$(item).attr("disabled",true);
|
||||
$(item).addClass("forbidden");
|
||||
});
|
||||
$(this).addClass("participation").removeClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_delete = 2;
|
||||
});
|
||||
|
||||
$("body").off("click",".participation").on("click",".participation",function(){
|
||||
$(this).text("不参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",false);
|
||||
$(item).attr("disabled",false);
|
||||
$(item).removeClass("forbidden");
|
||||
});
|
||||
$(this).removeClass("participation").addClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_delete = 1;
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="bargainFirst">
|
||||
{{# if(!d.bargain_stock){ }}
|
||||
<input type="number" class="layui-input len-input bargain-first forbidden" value="{{d.first_bargain_price}}" lay-verify="bargain_first" min="0.00" oninput="bargainFirst({{ d.LAY_INDEX }},event)" onporpertychange="bargainFirst({{ d.LAY_INDEX }},event)" readonly disabled/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input bargain-first" value="{{d.first_bargain_price}}" lay-verify="bargain_first" min="0.00" oninput="bargainFirst({{ d.LAY_INDEX }},event)" onporpertychange="bargainFirst({{ d.LAY_INDEX }},event)"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="bargainStock">
|
||||
{{# if(!d.bargain_stock){ }}
|
||||
<input type="number" class="layui-input len-input bargain-stock forbidden" value="{{d.bargain_stock}}" lay-verify="bargain_stock" min="0" oninput="bargainStock({{ d.LAY_INDEX }},event)" onporpertychange="bargainStock({{ d.LAY_INDEX }},event)" readonly disabled/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input bargain-stock" value="{{d.bargain_stock}}" lay-verify="bargain_stock" min="0" oninput="bargainStock({{ d.LAY_INDEX }},event)" onporpertychange="bargainStock({{ d.LAY_INDEX }},event)"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="minPrice">
|
||||
{{# if(!d.bargain_stock){ }}
|
||||
<input type="number" class="layui-input len-input min-price forbidden" value="{{d.floor_price}}" lay-verify="min_price" min="0.00" oninput="bargainMinPrice({{ d.LAY_INDEX }},event)" onporpertychange="bargainMinPrice({{ d.LAY_INDEX }},event)" readonly disabled/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input min-price" value="{{d.floor_price}}" lay-verify="min_price" min="0.00" oninput="bargainMinPrice({{ d.LAY_INDEX }},event)" onporpertychange="bargainMinPrice({{ d.LAY_INDEX }},event)"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
{{# if(!d.bargain_stock){ }}
|
||||
<a class="layui-btn participation">参与</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn no-participation">不参与</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
133
addon/bargain/shop/view/bargain/launch_detail.html
Executable file
@@ -0,0 +1,133 @@
|
||||
<style>
|
||||
.layui-table[lay-skin=line] {margin-top: 15px; border-width: 0;}
|
||||
.title-pic{flex-shrink: 0;display: inline-block;width: 50px;height: 50px;text-align: center;line-height: 50px;margin-left: 5px;}
|
||||
.layui-layout-admin .layui-table-header{background-color: transparent;}
|
||||
.layui-layout-admin .layui-table-view .layui-table-body .layui-table[lay-skin=line]{margin-top: 0;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form tips-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">发起人信息:</label>
|
||||
<div class="table-title layui-input-inline">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{:img($info['headimg'])}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' "/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{$info['nickname']}">{$info['nickname']}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品信息:</label>
|
||||
<div class="table-title layui-input-inline">
|
||||
<div class="title-pic">
|
||||
<img layer-src src="{:img($info['sku_image'])}"/>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{$info['sku_name']}">{$info['sku_name']}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">发起砍价时间:</label>
|
||||
<div class="layui-input-inline">{:time_to_date($info.start_time)}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">最少砍价数/已砍人数:</label>
|
||||
<div class="layui-input-inline">{$info.need_num} / {$info.curr_num}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">底价:</label>
|
||||
<div class="layui-input-inline">¥{$info.floor_price}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">结束时间:</label>
|
||||
<div class="layui-input-inline">{:time_to_date($info.end_time)}</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">砍价状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
{if $info.status == 2}
|
||||
砍价失败
|
||||
{elseif $info.status == 0}
|
||||
砍价中
|
||||
{else/}
|
||||
砍价成功
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 列表 -->
|
||||
<table id="order_list" lay-filter="order_list"></table>
|
||||
|
||||
<!-- 参与人 -->
|
||||
<script type="text/html" id="member_info">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.headimg){ }}
|
||||
<img layer-src src="{{ns.img(d.headimg)}}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' "/>
|
||||
{{# } else{ }}
|
||||
<img layer-src src="{:img('public/static/img/default_img/head.png')}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color" title="{{d.nickname}}">{{d.nickname}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var launch_id = "{$launch_id}";
|
||||
|
||||
layui.use(['form'], function() {
|
||||
var table,form = layui.form;
|
||||
form.render();
|
||||
|
||||
table = new Table({
|
||||
elem: '#order_list',
|
||||
url: ns.url("bargain://shop/bargain/launchdetail"),
|
||||
where: {
|
||||
"launch_id": launch_id
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
title: '帮砍人信息',
|
||||
unresize: 'false',
|
||||
templet:'#member_info'
|
||||
}, {
|
||||
title: '帮砍金额',
|
||||
unresize: 'false',
|
||||
templet:function(data){
|
||||
return '¥' + data.money;
|
||||
}
|
||||
}, {
|
||||
title: '帮砍时间',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.bargain_time);
|
||||
}
|
||||
}]
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'check': //查看
|
||||
window.open(ns.href("shop/order/detail", {"order_id": data.order_id}));
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
263
addon/bargain/shop/view/bargain/launch_list.html
Executable file
@@ -0,0 +1,263 @@
|
||||
<style>
|
||||
.layui-layout-admin .screen{margin-bottom: 15px;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
</style>
|
||||
|
||||
{if condition="$bargain_id"}
|
||||
<input type="hidden" class="bargain-id" value="{$bargain_id}" />
|
||||
{else/}
|
||||
<input type="hidden" class="bargain-id" value="" />
|
||||
{/if}
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-form layui-colla-content layui-form layui-show" lay-filter="order_list">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="goods_name">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">会员昵称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="nickname">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">砍价状态</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="status" lay-filter="status">
|
||||
<option value="">全部</option>
|
||||
<option value="1">砍价成功</option>
|
||||
<option value="0">砍价中</option>
|
||||
<option value="2">砍价失败</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">发起时间</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(7, this);return false;">近7天</button>
|
||||
<button class="layui-btn layui-btn-primary date-picker-btn" onclick="datePick(30, this);return false;">近30天</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table id="team_list" lay-filter="team_list"></table>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.sku_image){ }}
|
||||
<img layer-src="{{ns.img(d.sku_image.split(',')[0],'big')}}" src="{{ns.img(d.sku_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.sku_name}}">{{d.sku_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 会员 -->
|
||||
<script type="text/html" id="member_info">
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{# if(d.headimg){ }}
|
||||
<img layer-src src="{{ns.img(d.headimg)}}"/>
|
||||
{{# }else if(d.headimg == ''){ }}
|
||||
<img layer-src src="{:img('public/static/img/default_img/head.png')}">
|
||||
{{# } }}
|
||||
</div>
|
||||
<!-- <div class='title-pic'>
|
||||
<img layer-src src="{{ns.img(d.sku_image.split(',')[0],'small')}}" onerror="this.src = '{:img('public/static/img/default_img/head.png')}' ">
|
||||
</div> -->
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.nickname}}">{{d.nickname}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{{# if(d.status == 0){ }}
|
||||
砍价中
|
||||
{{# }else if(d.status == 1){ }}
|
||||
砍价成功
|
||||
{{# }else if(d.status == 2){ }}
|
||||
砍价失败
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="record">帮砍记录</a>
|
||||
{{# if(d.status == 1 && d.order_id > 0){ }}
|
||||
<a class="layui-btn" lay-event="order">查看订单</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'element', 'laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
laydate = layui.laydate;
|
||||
|
||||
form.render();
|
||||
|
||||
//渲染时间
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#team_list',
|
||||
url: ns.url("bargain://shop/bargain/launchlist"),
|
||||
where: {
|
||||
"bargain_id": $(".bargain-id").val()
|
||||
},
|
||||
cols: [
|
||||
[ {
|
||||
title: '会员信息',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: '#member_info'
|
||||
},{
|
||||
title: '砍价商品',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#goods'
|
||||
}, {
|
||||
title: '发起砍价时间',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet:function(data){
|
||||
return ns.time_to_date(data.start_time);
|
||||
}
|
||||
}, {
|
||||
title: '最少砍价数/已砍人数',
|
||||
unresize: 'false',
|
||||
align:'center',
|
||||
width: '12%',
|
||||
templet: function(data) {
|
||||
return data.need_num + ' / ' + data.curr_num;
|
||||
}
|
||||
}, {
|
||||
title: '底价',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.floor_price;
|
||||
}
|
||||
}, {
|
||||
title: '结束时间',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.end_time);
|
||||
}
|
||||
}, {
|
||||
title: '砍价状态',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
templet: '#status'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align : 'right'
|
||||
}]
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
//监听筛选事件
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'record': //帮砍记录
|
||||
location.hash = ns.hash("bargain://shop/bargain/launchdetail?launch_id="+ data.launch_id);
|
||||
break;
|
||||
case 'order': //订单
|
||||
window.open(ns.href("shop/order/detail", {"order_id": data.order_id}));
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function datePick(date_num,event_obj){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
$(event_obj).addClass('selected');
|
||||
|
||||
Date.prototype.Format = function (fmt,date_num) { //author: meizz
|
||||
this.setDate(this.getDate()-date_num);
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"H+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
||||
var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
|
||||
var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
|
||||
$("input[name=start_time]").val(before_time,0);
|
||||
$("input[name=end_time]").val(now_time,date_num-1);
|
||||
}
|
||||
</script>
|
||||
136
addon/bargain/shop/view/bargain/lists.html
Executable file
@@ -0,0 +1,136 @@
|
||||
<link rel="stylesheet" type="text/css" href="SHOP_ADDON_CSS/list.css" />
|
||||
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加砍价</button>
|
||||
</div>
|
||||
<!-- 搜索框 -->
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="goods_name" placeholder="请输入商品名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">活动时间</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button type="button" class="layui-btn" lay-filter="search" lay-submit>筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="bargain_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" data-status="">全部</li>
|
||||
{foreach $bargain_status as $k=>$v}
|
||||
<li data-status="{$k}">{$v}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="bargain_list" lay-filter="bargain_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品 -->
|
||||
<script type="text/html" id="goods_info">
|
||||
<div class="table-title">
|
||||
|
||||
<div class="contraction" data-id="{{d.bargain_id}}" data-open="0">
|
||||
<span>+</span>
|
||||
</div>
|
||||
|
||||
<div class="title-pic">
|
||||
{{# if(d.goods_image){ }}
|
||||
<img layer-src="{{ns.img(d.goods_image.split(',')[0],'big')}}" src="{{ns.img(d.goods_image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content">
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.goods_name}}">{{d.goods_name}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 时间 -->
|
||||
<script id="time" type="text/html">
|
||||
<div class="layui-elip">开始:{{ns.time_to_date(d.start_time)}}</div>
|
||||
<div class="layui-elip">结束:{{ns.time_to_date(d.end_time)}}</div>
|
||||
</script>
|
||||
|
||||
<!-- 推广 -->
|
||||
{include file="app/shop/view/component/promote_show.html"}
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="operation-wrap" data-bargain-id="{{d.bargain_id}}">
|
||||
<div class="popup-qrcode-wrap" style="display: none">
|
||||
<img class="popup-qrcode-loadimg" src="__STATIC__/loading/loading.gif"/>
|
||||
</div>
|
||||
<div class="table-btn">
|
||||
{{# if(d.status == 1){ }}
|
||||
<a class="layui-btn text-color" lay-event="select">推广</a>
|
||||
{{# } }}
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
{{# if(d.status == 0){ }}
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# }else if(d.status == 1){ }}
|
||||
<a class="layui-btn" lay-event="launch">砍价列表</a>
|
||||
<a class="layui-btn" lay-event="close">结束</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn" lay-event="launch">砍价列表</a>
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="toolbarAction">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="invalid">批量关闭</button>
|
||||
</script>
|
||||
|
||||
<!-- 商品sku -->
|
||||
<script type="text/html" id="skuList">
|
||||
<tr class="js-list-{{d.index}}" id="sku_img_{{d.index}}">
|
||||
<td colspan="10">
|
||||
<ul class="sku-list">
|
||||
{{# for(var i=0; i<d.list.length; i++){ }}
|
||||
<li>
|
||||
<div class="img-wrap">
|
||||
<img layer-src src="{{ns.img(d.list[i].sku_image)}}">
|
||||
</div>
|
||||
<div class="info-wrap">
|
||||
<span class="sku-name" title="{{d.list[i].sku_name}}">{{d.list[i].sku_name}}</span>
|
||||
<span class="price">商品价格:¥{{d.list[i].price}}</span>
|
||||
<span class="price">底价:¥{{d.list[i].floor_price}}</span>
|
||||
<span class="price">库存:¥{{d.list[i].bargain_stock}}</span>
|
||||
<span class="sale_num">销量:{{d.list[i].sale_num}}</span>
|
||||
<span class="sale_num">参与人数:{{d.list[i].join_num}}</span>
|
||||
</div>
|
||||
</li>
|
||||
{{# } }}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="SHOP_ADDON_JS/list.js?time=20240603" ></script>
|
||||
4
addon/bargain/shop/view/public/css/list.css
Executable file
@@ -0,0 +1,4 @@
|
||||
.screen{margin-bottom: 15px;}
|
||||
.contraction span{cursor: pointer;display: inline-block;width: 17px;height: 17px;text-align: center;line-height: 14px;user-select: none;}
|
||||
.screen .layui-colla-content .goods-category-container .layui-input{width: 240px !important;}
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
BIN
addon/bargain/shop/view/public/img/zone_preview.png
Executable file
|
After Width: | Height: | Size: 120 KiB |
355
addon/bargain/shop/view/public/js/list.js
Executable file
@@ -0,0 +1,355 @@
|
||||
var laytpl;
|
||||
$(function () {
|
||||
$("body").off("click", ".contraction").on("click", ".contraction", function () {
|
||||
var bargain_id = $(this).attr("data-id");
|
||||
var open = $(this).attr("data-open");
|
||||
var tr = $(this).parent().parent().parent().parent();
|
||||
var index = tr.attr("data-index");
|
||||
if (open == 1) {
|
||||
$(this).children("span").text("+");
|
||||
$(".js-list-" + index).remove();
|
||||
} else {
|
||||
$(this).children("span").text("-");
|
||||
$.ajax({
|
||||
url: ns.url("bargain://shop/bargain/getSkuList"),
|
||||
data: {bargain_id: bargain_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
var sku_list = $("#skuList").html();
|
||||
var data = {
|
||||
list: res.data,
|
||||
index: index
|
||||
};
|
||||
laytpl(sku_list).render(data, function (html) {
|
||||
tr.after(html);
|
||||
});
|
||||
layer.photos({
|
||||
photos: '.img-wrap',
|
||||
anim: 5
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(this).attr("data-open", (open == 0 ? 1 : 0));
|
||||
});
|
||||
|
||||
layui.use(['form', 'element', 'laytpl', 'laydate'], function () {
|
||||
laytpl = layui.laytpl;
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
element.on('tab(bargain_tab)', function () {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#bargain_list',
|
||||
url: ns.url("bargain://shop/bargain/lists"),
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox',
|
||||
width: '3%',
|
||||
},{
|
||||
title: '商品信息',
|
||||
unresize: 'false',
|
||||
width: '25%',
|
||||
templet: '#goods_info'
|
||||
}, {
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
templet: function (data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'floor_price',
|
||||
title: '底价',
|
||||
unresize: 'false',
|
||||
width: '7%',
|
||||
sort : true,
|
||||
templet: function (data) {
|
||||
return '¥' + data.floor_price;
|
||||
}
|
||||
}, {
|
||||
field: 'join_num',
|
||||
title: '参与人数',
|
||||
unresize: 'false',
|
||||
width: '7%',
|
||||
sort : true
|
||||
}, {
|
||||
field: 'sale_num',
|
||||
title: '砍价成功人数',
|
||||
unresize: 'false',
|
||||
width: '8%',
|
||||
sort : true
|
||||
}, {
|
||||
field: 'bargain_stock',
|
||||
title: '砍价总库存',
|
||||
unresize: 'false',
|
||||
width: '7%'
|
||||
// }, {
|
||||
// title: '库存剩余',
|
||||
// unresize: 'false',
|
||||
// width: '8%',
|
||||
// templet: function (data) {
|
||||
// return data.bargain_stock - data.sale_num;
|
||||
// }
|
||||
}, {
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
field: 'status_name',
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '8%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right',
|
||||
}]
|
||||
],
|
||||
toolbar: '#toolbarAction'
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function (data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
table.on("sort",function (obj) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
order:obj.field,
|
||||
sort:obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function (data) {
|
||||
var status = $(this).attr("data-status");
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 监听工具栏操作
|
||||
table.toolbar(function (obj) {
|
||||
var data = obj.data;
|
||||
if(data.length <= 0) return;
|
||||
var bargainIdAll = [];
|
||||
for (var i in data){
|
||||
bargainIdAll.push(data[i].bargain_id);
|
||||
}
|
||||
|
||||
switch (obj.event) {
|
||||
case 'delete':
|
||||
deleteBargainAll(bargainIdAll)
|
||||
break;
|
||||
case 'invalid':
|
||||
closeBargainAll(bargainIdAll)
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
//批量删除
|
||||
function deleteBargainAll(data){
|
||||
layer.confirm('确定要删除砍价活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("bargain://shop/bargain/deleteAll"),
|
||||
data: {
|
||||
bargain_id: data
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
//批量关闭
|
||||
function closeBargainAll(data){
|
||||
layer.confirm('确定要结束砍价活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("bargain://shop/bargain/finishAll"),
|
||||
data: {
|
||||
bargain_id: data
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload();
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function (obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("bargain://shop/bargain/detail", {"bargain_id": data.bargain_id});
|
||||
break;
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("bargain://shop/bargain/edit", {"bargain_id": data.bargain_id});
|
||||
break;
|
||||
case 'del': //删除
|
||||
deleteGroupbuy(data.bargain_id);
|
||||
break;
|
||||
case 'select': //推广
|
||||
bargainUrl(data);
|
||||
break;
|
||||
case 'close': // 结束
|
||||
closeGroupbuy(data.bargain_id);
|
||||
break;
|
||||
case 'launch': //砍价列表
|
||||
location.hash = ns.hash("bargain://shop/bargain/launchlist", {"bargain_id": data.bargain_id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteGroupbuy(bargain_id) {
|
||||
layer.confirm('确定要删除该砍价活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("bargain://shop/bargain/delete"),
|
||||
data: {
|
||||
bargain_id: bargain_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
// 结束
|
||||
function closeGroupbuy(bargain_id) {
|
||||
|
||||
layer.confirm('确定要结束该砍价活动吗?', function (index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("bargain://shop/bargain/finish"),
|
||||
data: {
|
||||
bargain_id: bargain_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function (res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
function bargainUrl(data){
|
||||
new PromoteShow({
|
||||
url:ns.url("bargain://shop/bargain/bargainurl"),
|
||||
param:{bargain_id:data.bargain_id},
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("bargain://shop/bargain/add");
|
||||
}
|
||||