diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index fe26fd22a..9daa350e3 100755 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -125,6 +125,7 @@ class Goods extends Common 'common_app_is_online_service' => (int) MyC('common_app_is_online_service'), 'common_app_is_limitedtimediscount' => (int) MyC('common_app_is_limitedtimediscount'), 'common_app_is_good_thing' => (int) MyC('common_app_is_good_thing'), + 'common_app_is_poster_share' => (int) MyC('common_app_is_poster_share'), ]; // 秒杀 @@ -279,5 +280,22 @@ class Goods extends Common ]; return DataReturn('success', 0, $result); } + + /** + * 商品海报 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-08-17T21:10:41+0800 + */ + public function Poster() + { + // 是否开启海报功能 + if(MyC('common_app_is_poster_share') == 1) + { + return CallPluginsServiceMethod('distribution', 'PosterGoodsService', 'GoodsCreateMiniWechat', $this->data_post); + } + return DataReturn('海报功能未启用', -100); + } } ?> \ No newline at end of file diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 495bb27d3..495f12de5 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -208,7 +208,7 @@ class User extends Common $result['avatar'] = isset($result['avatarUrl']) ? $result['avatarUrl'] : ''; $result['gender'] = empty($result['gender']) ? 0 : ($result['gender'] == 2) ? 1 : 2; $result['openid'] = $result['openId']; - $result['referrer']= isset($this->data_post['referrer']) ? intval($this->data_post['referrer']) : 0; + $result['referrer']= isset($this->data_post['referrer']) ? $this->data_post['referrer'] : 0; return UserService::AuthUserProgram($result, 'weixin_openid'); } } else { diff --git a/application/tags.php b/application/tags.php index 84ec11fcb..5d2257883 100755 --- a/application/tags.php +++ b/application/tags.php @@ -32,73 +32,21 @@ return array ( 'log_write' => array ( ), - 'plugins_css' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - 1 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_js' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - 1 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_service_navigation_header_handle' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - 1 => 'app\\plugins\\answers\\Hook', - 2 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_service_goods_handle_end' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - ), - 'plugins_service_goods_spec_base' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - ), - 'plugins_view_goods_detail_base_top' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - ), - 'plugins_view_home_floor_top' => - array ( - 0 => 'app\\plugins\\limitedtimediscount\\Hook', - ), 'plugins_service_users_center_left_menu_handle' => array ( - 0 => 'app\\plugins\\coupon\\Hook', + 0 => 'app\\plugins\\distribution\\Hook', ), 'plugins_service_header_navigation_top_right_handle' => array ( - 0 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_view_goods_detail_panel_bottom' => - array ( - 0 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_view_buy_goods_bottom' => - array ( - 0 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_service_buy_handle' => - array ( - 0 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_view_buy_form_inside' => - array ( - 0 => 'app\\plugins\\coupon\\Hook', - ), - 'plugins_service_buy_order_insert_success' => - array ( - 0 => 'app\\plugins\\coupon\\Hook', + 0 => 'app\\plugins\\distribution\\Hook', ), 'plugins_service_order_status_change_history_success_handle' => array ( - 0 => 'app\\plugins\\coupon\\Hook', + 0 => 'app\\plugins\\distribution\\Hook', ), - 'plugins_service_user_register_end' => + 'plugins_service_order_aftersale_audit_handle_end' => array ( - 0 => 'app\\plugins\\coupon\\Hook', + 0 => 'app\\plugins\\distribution\\Hook', ), ); ?> \ No newline at end of file diff --git a/extend/base/Wechat.php b/extend/base/Wechat.php index 1101533cd..67f9a34d9 100755 --- a/extend/base/Wechat.php +++ b/extend/base/Wechat.php @@ -125,27 +125,53 @@ class Wechat */ public function MiniQrCodeCreate($params) { - // 参数校验 - if(empty($params['path'])) + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'page', + 'error_msg' => 'page地址不能为空', + ], + [ + 'checked_type' => 'length', + 'checked_data' => '1,32', + 'key_name' => 'scene', + 'error_msg' => 'scene参数 1~32 个字符之间', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) { - return '页面地址不能为空'; + return DataReturn($ret, -1); } - $params['width'] = empty($params['width']) ? 1000 : intval($params['width']); // 获取access_token $access_token = $this->GetMiniAccessToken(); if($access_token === false) { - return ''; + return DataReturn('access_token获取失败', -1); } - // 网络请求 - $url = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token='.$access_token; + // 获取二维码 + $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='.$access_token; $data = [ - 'path' => $params['path'], - 'width' => $params['width'], + 'page' => $params['page'], + 'scene' => $params['scene'], + 'width' => empty($params['width']) ? 1000 : intval($params['width']), ]; - return $this->HttpRequestPost($url, json_encode($data), false); + $res = $this->HttpRequestPost($url, json_encode($data), false); + if(!empty($res)) + { + if(stripos($res, 'errcode') === false) + { + return DataReturn('获取成功', 0, $res); + } + $res = json_decode($res, true); + $msg = isset($res['errmsg']) ? $res['errmsg'] : '获取二维码失败'; + } else { + $msg = '获取二维码失败'; + } + return DataReturn($msg, -1); } /** diff --git a/public/appmini/old/weixin/app.js b/public/appmini/old/weixin/app.js index 88aac5954..8171c0fd4 100755 --- a/public/appmini/old/weixin/app.js +++ b/public/appmini/old/weixin/app.js @@ -15,7 +15,7 @@ App({ // 用户地址选择缓存key cache_buy_user_address_select_key: "cache_buy_user_address_select_key", - // 用户传入信息缓存key + // 启动参数缓存key cache_launch_info_key: "cache_shop_launch_info_key", // 默认用户头像 @@ -61,7 +61,7 @@ App({ // 请求地址 request_url: "{{request_url}}", - // request_url: 'http://tp5-dev.com/', + request_url: 'http://tp5-dev.com/', // request_url: 'https://test.shopxo.net/', // 基础信息 @@ -73,60 +73,31 @@ App({ * 小程序初始化 */ onLaunch(options) { + // 启动参数处理 + options = this.launch_params_handle(options); + // 设置设备信息 this.set_system_info(); - // 启动query参数处理 - this.startup_query(options); + // 缓存启动参数 + wx.setStorage({ + key: this.data.cache_launch_info_key, + data: options + }); }, /** - * 启动query参数处理 + * 启动参数处理 */ - startup_query(params) { - // 没有启动参数则返回 - if ((params || null) == null) { - return false; + launch_params_handle(params) { + // 启动参数处理 + if ((params.query || null) != null) { + params = params.query; } - - // 启动处理类型 - var type = params.type || null; - switch (type) { - // type=page - case "page": - // 页面 - var page = params.page || null; - - // 参数名 - var params_field = params.params_field || null; - - // 参数值 - var params_value = params.params_value || null; - - // 页面跳转 - if (page != null) { - wx.navigateTo({ - url: "/pages/" + page + "/" + page + "?" + params_field + "=" + params_value - }); - } - break; - - // type=view - case "view": - var url = params.url || null; - - // 页面跳转 - if (url != null) { - wx.navigateTo({ - url: '/pages/web-view/web-view?url=' + url - }); - } - break; - - // 默认 - default: - break; + if ((params.scene || null) != null) { + params = this.url_params_to_json(decodeURIComponent(params.scene)); } + return params; }, /** @@ -266,8 +237,8 @@ App({ get_user_login_info(object, method, openid, auth_data) { // 邀请人参数 var params = wx.getStorageSync(this.data.cache_launch_info_key) || null; - var referrer = (params == null) ? 0 : (params.data.referrer || 0); - + var referrer = (params == null) ? 0 : (params.referrer || 0); + console.log(params) // 远程解密数据 var $this = this; wx.request({ @@ -518,6 +489,22 @@ App({ } return false; + }, + + /** + * url参数转json对象 + */ + url_params_to_json(url_params) { + var json = new Object(); + if ((url_params || null) != null) + { + var arr = url_params.split('&'); + for(var i = 0; i - + {{item.content}} {{item.add_time}} 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 18b62475a..d737411d1 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.js +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.js @@ -63,6 +63,10 @@ Page({ }, onLoad(params) { + // 启动参数处理 + params = app.launch_params_handle(params); + + // 参数赋值,初始化 //params['goods_id']=2; this.setData({params: params}); this.init(); @@ -730,6 +734,42 @@ Page({ } }, + // 商品海报分享 + poster_event() { + var user = app.get_user_cache_info(this, 'poster_event'); + // 用户未绑定用户则转到登录页面 + if (app.user_is_need_login(user)) { + wx.navigateTo({ + url: "/pages/login/login?event_callback=init" + }); + return false; + } else { + wx.showLoading({ title: '生成中...' }); + wx.request({ + url: app.get_request_url('poster', 'goods'), + method: 'POST', + data: { "goods_id": this.data.goods.id }, + dataType: 'json', + success: (res) => { + wx.hideLoading(); + if (res.data.code == 0) { + console.log(res.data); + wx.previewImage({ + current: res.data.data, + urls: [res.data.data] + }); + } else { + app.showToast(res.data.msg); + } + }, + fail: () => { + wx.hideLoading(); + app.showToast("服务器请求出错"); + } + }); + } + }, + // 自定义分享 onShareAppMessage() { return { 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 67801e87d..3d3b9cf85 100755 --- a/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml +++ b/public/appmini/old/weixin/pages/goods-detail/goods-detail.wxml @@ -187,7 +187,7 @@ 一键分享给好友、群聊 - + diff --git a/public/appmini/old/weixin/pages/user/user.wxml b/public/appmini/old/weixin/pages/user/user.wxml index 5f1402ab3..3cd93d9a2 100755 --- a/public/appmini/old/weixin/pages/user/user.wxml +++ b/public/appmini/old/weixin/pages/user/user.wxml @@ -1,7 +1,7 @@ - + {{nickname}}