From fec3daea9a3f1cb7134af27c3dd878b59e3b0ac0 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Thu, 17 Oct 2019 14:06:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=8A=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Goods.php | 5 ++- application/common.php | 13 ++++++ application/service/PluginsService.php | 21 +++++++-- .../appmini/old/weixin/pages/coupon/coupon.js | 2 +- .../old/weixin/pages/coupon/coupon.wxml | 4 +- .../weixin/pages/goods-detail/goods-detail.js | 44 +++++++++++++++++++ .../pages/goods-detail/goods-detail.wxml | 6 +-- .../pages/goods-detail/goods-detail.wxss | 18 ++++++++ .../weixin/pages/user-coupon/user-coupon.wxml | 2 +- 9 files changed, 104 insertions(+), 11 deletions(-) diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index 050f4c784..58ee9f6b3 100755 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -169,7 +169,10 @@ class Goods extends Common $ret = CallPluginsServiceMethod('coupon', 'CouponService', 'CouponList', $coupon_params); // 排除商品不支持的活动 - $ret['data'] = CallPluginsServiceMethod('coupon', 'BaseService', 'CouponListGoodsExclude', ['data'=>$ret['data'], 'goods_id'=>$goods_id]); + if(!empty($ret['data'])) + { + $ret['data'] = CallPluginsServiceMethod('coupon', 'BaseService', 'CouponListGoodsExclude', ['data'=>$ret['data'], 'goods_id'=>$goods_id]); + } // 返回数据 return [ diff --git a/application/common.php b/application/common.php index ab65d2367..b6cddb3c2 100755 --- a/application/common.php +++ b/application/common.php @@ -88,6 +88,12 @@ function PathToParams($key = null, $default = null, $path = '') */ function CallPluginsData($plugins, $attachment_field = [], $service_name = '', $attachment_property = 'base_config_attachment_field') { + // 插件是否启用 + if(app\service\PluginsService::PluginsStatus($plugins) != 1) + { + return DataReturn('插件状态异常['.$plugins.']', -1); + } + // 未指定附件字段则自动去获取 $attachment = []; if(empty($attachment_field) && !empty($attachment_property)) @@ -128,6 +134,13 @@ function CallPluginsServiceMethod($plugins, $service, $method, $params = null) { if(method_exists($plugins_class, $method)) { + // 插件是否启用 + if(app\service\PluginsService::PluginsStatus($plugins) != 1) + { + return DataReturn('插件状态异常['.$plugins.']', -1); + } + + // 调用方法返回数据 return $plugins_class::$method($params); } else { return DataReturn('类方法未定义['.$plugins.'-'.$service.'-'.$method.']', -1); diff --git a/application/service/PluginsService.php b/application/service/PluginsService.php index 924dc3f2b..3a83967f5 100755 --- a/application/service/PluginsService.php +++ b/application/service/PluginsService.php @@ -46,10 +46,10 @@ class PluginsService if(empty($data)) { // 获取数据 - $data = Db::name('Plugins')->where(['plugins'=>$plugins])->value('data'); - if(!empty($data)) + $ret = self::PluginsField($plugins, 'data'); + if(!empty($ret['data'])) { - $data = json_decode($data, true); + $data = json_decode($ret['data'], true); // 是否有自定义附件需要处理 if(!empty($attachment_field) && is_array($attachment_field)) @@ -166,5 +166,20 @@ class PluginsService $data = Db::name('Plugins')->where(['plugins'=>$plugins])->value($field); return DataReturn('操作成功', 0, $data); } + + /** + * 应用状态 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-10-17 + * @desc description + * @param [string] $plugins [应用标记] + */ + public static function PluginsStatus($plugins) + { + $ret = self::PluginsField($plugins, 'is_enable'); + return $ret['data']; + } } ?> \ No newline at end of file diff --git a/public/appmini/old/weixin/pages/coupon/coupon.js b/public/appmini/old/weixin/pages/coupon/coupon.js index b5f1ccb53..8c52f184f 100644 --- a/public/appmini/old/weixin/pages/coupon/coupon.js +++ b/public/appmini/old/weixin/pages/coupon/coupon.js @@ -75,7 +75,7 @@ Page({ }); }, - // 领取事件 + // 优惠劵领取事件 receive_event(e) { var user = app.get_user_cache_info(this, "receive_event"); // 用户未绑定用户则转到登录页面 diff --git a/public/appmini/old/weixin/pages/coupon/coupon.wxml b/public/appmini/old/weixin/pages/coupon/coupon.wxml index d4867ac6a..feac3c959 100644 --- a/public/appmini/old/weixin/pages/coupon/coupon.wxml +++ b/public/appmini/old/weixin/pages/coupon/coupon.wxml @@ -8,12 +8,12 @@ {{item.discount_value}} - {{item.type == 0 ? '元' : '折'}} + {{item.type_unit}} {{item.desc}} {{item.use_limit_type_name}} - + {{item.is_operable_name}} diff --git a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js index 858836214..76595254d 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js @@ -787,6 +787,50 @@ Page({ } }, + // 优惠劵领取事件 + coupon_receive_event(e) { + var user = app.get_user_cache_info(this, "receive_event"); + // 用户未绑定用户则转到登录页面 + if (app.user_is_need_login(user)) { + wx.redirectTo({ + url: "/pages/login/login?event_callback=receive_event" + }); + return false; + } else { + var self = this; + var index = e.currentTarget.dataset.index; + var value = e.currentTarget.dataset.value; + var temp_list = this.data.plugins_coupon_data.data; + if (temp_list[index]['is_operable'] != 0) { + wx.showLoading({ title: "处理中..." }); + wx.request({ + url: app.get_request_url("receive", "coupon"), + method: "POST", + data: { "coupon_id": value }, + dataType: "json", + header: { 'content-type': 'application/x-www-form-urlencoded' }, + success: res => { + wx.hideLoading(); + if (res.data.code == 0) { + app.showToast(res.data.msg, "success"); + if (self.data.plugins_coupon_data.base != null && self.data.plugins_coupon_data.base.is_repeat_receive != 1) { + temp_list[index]['is_operable'] = 0; + temp_list[index]['is_operable_name'] = '已领取'; + self.setData({ 'plugins_coupon_data.data': temp_list }); + } + } else { + app.showToast(res.data.msg); + } + }, + fail: () => { + wx.hideLoading(); + app.showToast("服务器请求出错"); + } + }); + } + } + }, + // 自定义分享 onShareAppMessage() { var user = app.get_user_cache_info(this, 'goods_favor_event') || null; diff --git a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml index d2a7ca63f..9461a13a1 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml @@ -73,12 +73,12 @@ {{item.discount_value}} - {{item.type == 0 ? '元' : '折'}} - {{item.desc}} + {{item.type_unit}} {{item.use_limit_type_name}} + {{item.desc}} - + {{item.is_operable_name}} diff --git a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxss b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxss index ca57173cc..381a66842 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxss +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxss @@ -293,15 +293,33 @@ } +/* + * 优惠劵 - 插件 + */ .coupon-container { white-space: nowrap; box-sizing: border-box; padding: 20rpx 10rpx; } +.coupon-container scroll-view { + height: 174rpx; +} .coupon-container .item { display: inline-block; + width: 60vw; +} +.coupon-container .v-left { + padding: 20rpx 0 20rpx 20rpx; } .coupon-container .item:not(:last-child) { margin-right: 20rpx; +} +.coupon-container .item, +.coupon-container .v-right, +.coupon-container .v-right .circle { + height: 170rpx; +} +.coupon-container .v-left .base .price { + font-size: 46rpx; } \ No newline at end of file diff --git a/public/appmini/old/weixin/pages/user-coupon/user-coupon.wxml b/public/appmini/old/weixin/pages/user-coupon/user-coupon.wxml index 1b4aa6202..53ccd76bf 100644 --- a/public/appmini/old/weixin/pages/user-coupon/user-coupon.wxml +++ b/public/appmini/old/weixin/pages/user-coupon/user-coupon.wxml @@ -16,7 +16,7 @@ {{item.coupon.discount_value}} - {{item.coupon.type == 0 ? '元' : '折'}} + {{item.coupon.type_unit}} {{item.coupon.desc}} {{item.coupon.use_limit_type_name}}