提交 cbf1e1ed 编写于 作者: G gongfuxiang

推荐用户优化和商品新增海报

上级 152fe30a
...@@ -125,6 +125,7 @@ class Goods extends Common ...@@ -125,6 +125,7 @@ class Goods extends Common
'common_app_is_online_service' => (int) MyC('common_app_is_online_service'), '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_limitedtimediscount' => (int) MyC('common_app_is_limitedtimediscount'),
'common_app_is_good_thing' => (int) MyC('common_app_is_good_thing'), '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 ...@@ -279,5 +280,22 @@ class Goods extends Common
]; ];
return DataReturn('success', 0, $result); 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
...@@ -208,7 +208,7 @@ class User extends Common ...@@ -208,7 +208,7 @@ class User extends Common
$result['avatar'] = isset($result['avatarUrl']) ? $result['avatarUrl'] : ''; $result['avatar'] = isset($result['avatarUrl']) ? $result['avatarUrl'] : '';
$result['gender'] = empty($result['gender']) ? 0 : ($result['gender'] == 2) ? 1 : 2; $result['gender'] = empty($result['gender']) ? 0 : ($result['gender'] == 2) ? 1 : 2;
$result['openid'] = $result['openId']; $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'); return UserService::AuthUserProgram($result, 'weixin_openid');
} }
} else { } else {
......
...@@ -32,73 +32,21 @@ return array ( ...@@ -32,73 +32,21 @@ return array (
'log_write' => 'log_write' =>
array ( 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' => 'plugins_service_users_center_left_menu_handle' =>
array ( array (
0 => 'app\\plugins\\coupon\\Hook', 0 => 'app\\plugins\\distribution\\Hook',
), ),
'plugins_service_header_navigation_top_right_handle' => 'plugins_service_header_navigation_top_right_handle' =>
array ( array (
0 => 'app\\plugins\\coupon\\Hook', 0 => 'app\\plugins\\distribution\\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',
), ),
'plugins_service_order_status_change_history_success_handle' => 'plugins_service_order_status_change_history_success_handle' =>
array ( array (
0 => 'app\\plugins\\coupon\\Hook', 0 => 'app\\plugins\\distribution\\Hook',
), ),
'plugins_service_user_register_end' => 'plugins_service_order_aftersale_audit_handle_end' =>
array ( array (
0 => 'app\\plugins\\coupon\\Hook', 0 => 'app\\plugins\\distribution\\Hook',
), ),
); );
?> ?>
\ No newline at end of file
...@@ -125,27 +125,53 @@ class Wechat ...@@ -125,27 +125,53 @@ class Wechat
*/ */
public function MiniQrCodeCreate($params) 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
$access_token = $this->GetMiniAccessToken(); $access_token = $this->GetMiniAccessToken();
if($access_token === false) 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 = [ $data = [
'path' => $params['path'], 'page' => $params['page'],
'width' => $params['width'], '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);
} }
/** /**
......
...@@ -15,7 +15,7 @@ App({ ...@@ -15,7 +15,7 @@ App({
// 用户地址选择缓存key // 用户地址选择缓存key
cache_buy_user_address_select_key: "cache_buy_user_address_select_key", cache_buy_user_address_select_key: "cache_buy_user_address_select_key",
// 用户传入信息缓存key // 启动参数缓存key
cache_launch_info_key: "cache_shop_launch_info_key", cache_launch_info_key: "cache_shop_launch_info_key",
// 默认用户头像 // 默认用户头像
...@@ -61,7 +61,7 @@ App({ ...@@ -61,7 +61,7 @@ App({
// 请求地址 // 请求地址
request_url: "{{request_url}}", request_url: "{{request_url}}",
// request_url: 'http://tp5-dev.com/', request_url: 'http://tp5-dev.com/',
// request_url: 'https://test.shopxo.net/', // request_url: 'https://test.shopxo.net/',
// 基础信息 // 基础信息
...@@ -73,60 +73,31 @@ App({ ...@@ -73,60 +73,31 @@ App({
* 小程序初始化 * 小程序初始化
*/ */
onLaunch(options) { onLaunch(options) {
// 启动参数处理
options = this.launch_params_handle(options);
// 设置设备信息 // 设置设备信息
this.set_system_info(); this.set_system_info();
// 启动query参数处理 // 缓存启动参数
this.startup_query(options); wx.setStorage({
key: this.data.cache_launch_info_key,
data: options
});
}, },
/** /**
* 启动query参数处理 * 启动参数处理
*/ */
startup_query(params) { launch_params_handle(params) {
// 没有启动参数则返回 // 启动参数处理
if ((params || null) == null) { if ((params.query || null) != null) {
return false; params = params.query;
} }
if ((params.scene || null) != null) {
// 启动处理类型 params = this.url_params_to_json(decodeURIComponent(params.scene));
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;
} }
return params;
}, },
/** /**
...@@ -266,8 +237,8 @@ App({ ...@@ -266,8 +237,8 @@ App({
get_user_login_info(object, method, openid, auth_data) { get_user_login_info(object, method, openid, auth_data) {
// 邀请人参数 // 邀请人参数
var params = wx.getStorageSync(this.data.cache_launch_info_key) || null; 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; var $this = this;
wx.request({ wx.request({
...@@ -518,6 +489,22 @@ App({ ...@@ -518,6 +489,22 @@ App({
} }
return false; 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<arr.length; i++) {
var temp = arr[i].split('=');
json[temp[0]] = temp[1]
}
}
return json;
} }
}); });
\ No newline at end of file
{ {
"pages": [ "pages": ["pages/goods-detail/goods-detail",
"pages/index/index", "pages/index/index",
"pages/goods-category/goods-category", "pages/goods-category/goods-category",
"pages/cart/cart", "pages/cart/cart",
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"pages/login/login", "pages/login/login",
"pages/paytips/paytips", "pages/paytips/paytips",
"pages/goods-search/goods-search", "pages/goods-search/goods-search",
"pages/goods-detail/goods-detail",
"pages/goods-comment/goods-comment", "pages/goods-comment/goods-comment",
"pages/goods-attribute/goods-attribute", "pages/goods-attribute/goods-attribute",
"pages/buy/buy", "pages/buy/buy",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="item bg-white spacing-mb" wx:if="{{data_list.length > 0}}" wx:for="{{data_list}}"> <view class="item bg-white spacing-mb" wx:if="{{data_list.length > 0}}" wx:for="{{data_list}}">
<view class="base"> <view class="base">
<view class="oh"> <view class="oh">
<image class="avatar fl" src="{{item.avatar}}" mode="widthFix" data-index="{{index}}" onError="user_avatar_error" /> <image class="avatar fl" src="{{item.avatar}}" mode="widthFix" data-index="{{index}}" binderror="user_avatar_error" />
<view class="desc fr tl">{{item.content}}</view> <view class="desc fr tl">{{item.content}}</view>
</view> </view>
<view class="cr-888 tr">{{item.add_time}}</view> <view class="cr-888 tr">{{item.add_time}}</view>
......
...@@ -63,6 +63,10 @@ Page({ ...@@ -63,6 +63,10 @@ Page({
}, },
onLoad(params) { onLoad(params) {
// 启动参数处理
params = app.launch_params_handle(params);
// 参数赋值,初始化
//params['goods_id']=2; //params['goods_id']=2;
this.setData({params: params}); this.setData({params: params});
this.init(); this.init();
...@@ -730,6 +734,42 @@ Page({ ...@@ -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() { onShareAppMessage() {
return { return {
......
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
<text class="cr-888 single-text">一键分享给好友、群聊</text> <text class="cr-888 single-text">一键分享给好友、群聊</text>
</button> </button>
</view> </view>
<view wx:if="{{common_app_is_poster_share == 1}}" class="share-items oh"> <view wx:if="{{common_app_is_poster_share == 1}}" class="share-items oh" bindtap="poster_event">
<image src="/images/share-friend-icon.png" mode="scaleToFill" /> <image src="/images/share-friend-icon.png" mode="scaleToFill" />
<text class="cr-888 single-text">生成海报,分享到朋友圈、好友及群聊</text> <text class="cr-888 single-text">生成海报,分享到朋友圈、好友及群聊</text>
</view> </view>
......
<!-- 头部 --> <!-- 头部 -->
<view class="head-box bg-main"> <view class="head-box bg-main">
<view class="head-item oh tc"> <view class="head-item oh tc">
<image bindtap="preview_event" onError="user_avatar_error" class="avatar" src="{{avatar}}" mode="widthFix" /> <image bindtap="preview_event" binderror="user_avatar_error" class="avatar" src="{{avatar}}" mode="widthFix" />
<text class="item-name dis-block cr-fff">{{nickname}}</text> <text class="item-name dis-block cr-fff">{{nickname}}</text>
</view> </view>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册