From 7a18b4473ed193e2d65b2d423810f657728dcf3f Mon Sep 17 00:00:00 2001 From: Devil Date: Tue, 1 Dec 2020 10:52:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=81=E5=BE=AE=E4=BF=A1=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E6=9C=8B=E5=8F=8B=E5=9C=88=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=9B=BE=E7=89=87+=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sourcecode/alipay/default/app.js | 18 ++++++++++--- .../pages/goods-category/goods-category.js | 3 +-- .../pages/goods-detail/goods-detail.js | 3 +-- .../pages/goods-search/goods-search.js | 3 +-- .../alipay/default/pages/index/index.js | 3 +-- sourcecode/baidu/default/app.js | 19 ++++++++++---- .../pages/goods-detail/goods-detail.js | 3 +-- .../pages/goods-search/goods-search.js | 3 +-- sourcecode/baidu/default/pages/index/index.js | 3 +-- sourcecode/qq/default/app.js | 19 ++++++++++---- .../pages/goods-category/goods-category.js | 3 +-- .../pages/goods-detail/goods-detail.js | 3 +-- .../pages/goods-search/goods-search.js | 3 +-- sourcecode/qq/default/pages/index/index.js | 3 +-- sourcecode/toutiao/default/app.js | 19 ++++++++++---- .../pages/goods-detail/goods-detail.js | 3 +-- .../pages/goods-search/goods-search.js | 3 +-- .../toutiao/default/pages/index/index.js | 3 +-- sourcecode/weixin/default/app.js | 19 ++++++++++---- .../pages/goods-category/goods-category.js | 12 +++++++-- .../pages/goods-detail/goods-detail.js | 13 ++++++++-- .../pages/goods-search/goods-search.js | 14 +++++++++-- .../weixin/default/pages/index/index.js | 11 ++++++-- .../pages/plugins/coupon/index/index.js | 20 +++++++++++++++ .../plugins/membershiplevelvip/index/index.js | 20 +++++++++++++++ .../plugins/weixinliveplayer/detail/detail.js | 25 +++++++++++-------- .../plugins/weixinliveplayer/index/index.js | 13 ++++++++-- .../plugins/weixinliveplayer/search/search.js | 18 ++++++++++--- 28 files changed, 207 insertions(+), 75 deletions(-) diff --git a/sourcecode/alipay/default/app.js b/sourcecode/alipay/default/app.js index abf95d528..ae4d1405a 100644 --- a/sourcecode/alipay/default/app.js +++ b/sourcecode/alipay/default/app.js @@ -204,14 +204,24 @@ App({ }, /** - * 从缓存获取用户信息 + * 从缓存获取用户信息、可指定key和默认值 + * key 数据key + * default_value 默认值 */ - get_user_cache_info() { + get_user_cache_info(key, default_value) { var user = my.getStorageSync({ key: this.data.cache_user_info_key }); if ((user.data || null) == null) { - return false; + // 是否存在默认值 + return (default_value == undefined) ? false : default_value; } + + // 是否读取key + if((key || null) != null) { + return (user[key] == undefined) ? (default_value == undefined ? null : default_value) : user[key]; + } + return user.data; + }, /** @@ -780,7 +790,7 @@ App({ }, /** - * 获取配置信息、可指定默认值 + * 获取配置信息、可指定key和默认值 * key 数据key(支持多级读取、以 . 分割key名称) * default_value 默认值 */ diff --git a/sourcecode/alipay/default/pages/goods-category/goods-category.js b/sourcecode/alipay/default/pages/goods-category/goods-category.js index 453a30fcd..4538decff 100755 --- a/sourcecode/alipay/default/pages/goods-category/goods-category.js +++ b/sourcecode/alipay/default/pages/goods-category/goods-category.js @@ -108,8 +108,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/alipay/default/pages/goods-detail/goods-detail.js b/sourcecode/alipay/default/pages/goods-detail/goods-detail.js index 004778162..e68847033 100644 --- a/sourcecode/alipay/default/pages/goods-detail/goods-detail.js +++ b/sourcecode/alipay/default/pages/goods-detail/goods-detail.js @@ -824,8 +824,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: this.data.goods.title+'-'+app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/alipay/default/pages/goods-search/goods-search.js b/sourcecode/alipay/default/pages/goods-search/goods-search.js index f8423e145..f9f0908c5 100755 --- a/sourcecode/alipay/default/pages/goods-search/goods-search.js +++ b/sourcecode/alipay/default/pages/goods-search/goods-search.js @@ -221,8 +221,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; var category_id = this.data.params['category_id'] || 0; var keywords = this.data.params['keywords'] || ''; return { diff --git a/sourcecode/alipay/default/pages/index/index.js b/sourcecode/alipay/default/pages/index/index.js index 8b47593de..709bd4915 100644 --- a/sourcecode/alipay/default/pages/index/index.js +++ b/sourcecode/alipay/default/pages/index/index.js @@ -214,8 +214,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/baidu/default/app.js b/sourcecode/baidu/default/app.js index 5dfa8be9b..b5fe6e2fe 100755 --- a/sourcecode/baidu/default/app.js +++ b/sourcecode/baidu/default/app.js @@ -202,13 +202,22 @@ App({ }, /** - * 从缓存获取用户信息 + * 从缓存获取用户信息、可指定key和默认值 + * key 数据key + * default_value 默认值 */ - get_user_cache_info() { - let user = swan.getStorageSync(this.data.cache_user_info_key) || null; + get_user_cache_info(key, default_value) { + var user = swan.getStorageSync(this.data.cache_user_info_key) || null; if (user == null) { - return false; + // 是否存在默认值 + return (default_value == undefined) ? false : default_value; } + + // 是否读取key + if((key || null) != null) { + return (user[key] == undefined) ? (default_value == undefined ? null : default_value) : user[key]; + } + return user; }, @@ -694,7 +703,7 @@ App({ }, /** - * 获取配置信息、可指定默认值 + * 获取配置信息、可指定key和默认值 * key 数据key(支持多级读取、以 . 分割key名称) * default_value 默认值 */ diff --git a/sourcecode/baidu/default/pages/goods-detail/goods-detail.js b/sourcecode/baidu/default/pages/goods-detail/goods-detail.js index 623dd6d9a..740667c66 100755 --- a/sourcecode/baidu/default/pages/goods-detail/goods-detail.js +++ b/sourcecode/baidu/default/pages/goods-detail/goods-detail.js @@ -755,8 +755,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: this.data.goods.title+'-'+app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/baidu/default/pages/goods-search/goods-search.js b/sourcecode/baidu/default/pages/goods-search/goods-search.js index f488123fb..269d54c68 100755 --- a/sourcecode/baidu/default/pages/goods-search/goods-search.js +++ b/sourcecode/baidu/default/pages/goods-search/goods-search.js @@ -236,8 +236,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; var category_id = this.data.params['category_id'] || 0; var keywords = this.data.params['keywords'] || ''; return { diff --git a/sourcecode/baidu/default/pages/index/index.js b/sourcecode/baidu/default/pages/index/index.js index 23d2ca124..1dbc8c52b 100755 --- a/sourcecode/baidu/default/pages/index/index.js +++ b/sourcecode/baidu/default/pages/index/index.js @@ -203,8 +203,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/qq/default/app.js b/sourcecode/qq/default/app.js index b85a76b87..6ce766077 100755 --- a/sourcecode/qq/default/app.js +++ b/sourcecode/qq/default/app.js @@ -201,13 +201,22 @@ App({ }, /** - * 从缓存获取用户信息 + * 从缓存获取用户信息、可指定key和默认值 + * key 数据key + * default_value 默认值 */ - get_user_cache_info() { - let user = qq.getStorageSync(this.data.cache_user_info_key) || null; + get_user_cache_info(key, default_value) { + var user = qq.getStorageSync(this.data.cache_user_info_key) || null; if (user == null) { - return false; + // 是否存在默认值 + return (default_value == undefined) ? false : default_value; } + + // 是否读取key + if((key || null) != null) { + return (user[key] == undefined) ? (default_value == undefined ? null : default_value) : user[key]; + } + return user; }, @@ -699,7 +708,7 @@ App({ }, /** - * 获取配置信息、可指定默认值 + * 获取配置信息、可指定key和默认值 * key 数据key(支持多级读取、以 . 分割key名称) * default_value 默认值 */ diff --git a/sourcecode/qq/default/pages/goods-category/goods-category.js b/sourcecode/qq/default/pages/goods-category/goods-category.js index 41874e108..df98ef9a7 100755 --- a/sourcecode/qq/default/pages/goods-category/goods-category.js +++ b/sourcecode/qq/default/pages/goods-category/goods-category.js @@ -108,8 +108,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/qq/default/pages/goods-detail/goods-detail.js b/sourcecode/qq/default/pages/goods-detail/goods-detail.js index 2a6d6e3be..92c39c411 100755 --- a/sourcecode/qq/default/pages/goods-detail/goods-detail.js +++ b/sourcecode/qq/default/pages/goods-detail/goods-detail.js @@ -843,8 +843,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: this.data.goods.title+'-'+app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/qq/default/pages/goods-search/goods-search.js b/sourcecode/qq/default/pages/goods-search/goods-search.js index 6c332a0fc..fd9bab442 100755 --- a/sourcecode/qq/default/pages/goods-search/goods-search.js +++ b/sourcecode/qq/default/pages/goods-search/goods-search.js @@ -222,8 +222,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; var category_id = this.data.params['category_id'] || 0; var keywords = this.data.params['keywords'] || ''; return { diff --git a/sourcecode/qq/default/pages/index/index.js b/sourcecode/qq/default/pages/index/index.js index 886963d82..26d5f7780 100755 --- a/sourcecode/qq/default/pages/index/index.js +++ b/sourcecode/qq/default/pages/index/index.js @@ -201,8 +201,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/toutiao/default/app.js b/sourcecode/toutiao/default/app.js index 6ef315b23..d903fb737 100755 --- a/sourcecode/toutiao/default/app.js +++ b/sourcecode/toutiao/default/app.js @@ -202,13 +202,22 @@ App({ }, /** - * 从缓存获取用户信息 + * 从缓存获取用户信息、可指定key和默认值 + * key 数据key + * default_value 默认值 */ - get_user_cache_info() { - let user = tt.getStorageSync(this.data.cache_user_info_key) || null; + get_user_cache_info(key, default_value) { + var user = tt.getStorageSync(this.data.cache_user_info_key) || null; if (user == null) { - return false; + // 是否存在默认值 + return (default_value == undefined) ? false : default_value; } + + // 是否读取key + if((key || null) != null) { + return (user[key] == undefined) ? (default_value == undefined ? null : default_value) : user[key]; + } + return user; }, @@ -817,7 +826,7 @@ App({ }, /** - * 获取配置信息、可指定默认值 + * 获取配置信息、可指定key和默认值 * key 数据key(支持多级读取、以 . 分割key名称) * default_value 默认值 */ diff --git a/sourcecode/toutiao/default/pages/goods-detail/goods-detail.js b/sourcecode/toutiao/default/pages/goods-detail/goods-detail.js index 5b061165a..219954429 100755 --- a/sourcecode/toutiao/default/pages/goods-detail/goods-detail.js +++ b/sourcecode/toutiao/default/pages/goods-detail/goods-detail.js @@ -846,8 +846,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: this.data.goods.title+'-'+app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/toutiao/default/pages/goods-search/goods-search.js b/sourcecode/toutiao/default/pages/goods-search/goods-search.js index 266975be1..2f6357f7a 100755 --- a/sourcecode/toutiao/default/pages/goods-search/goods-search.js +++ b/sourcecode/toutiao/default/pages/goods-search/goods-search.js @@ -222,8 +222,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; var category_id = this.data.params['category_id'] || 0; var keywords = this.data.params['keywords'] || ''; return { diff --git a/sourcecode/toutiao/default/pages/index/index.js b/sourcecode/toutiao/default/pages/index/index.js index 83ad60497..1bfa02a1c 100755 --- a/sourcecode/toutiao/default/pages/index/index.js +++ b/sourcecode/toutiao/default/pages/index/index.js @@ -201,8 +201,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, diff --git a/sourcecode/weixin/default/app.js b/sourcecode/weixin/default/app.js index c6ce0a03e..966efaeb9 100755 --- a/sourcecode/weixin/default/app.js +++ b/sourcecode/weixin/default/app.js @@ -202,13 +202,22 @@ App({ }, /** - * 从缓存获取用户信息 + * 从缓存获取用户信息、可指定key和默认值 + * key 数据key + * default_value 默认值 */ - get_user_cache_info() { - let user = wx.getStorageSync(this.data.cache_user_info_key) || null; + get_user_cache_info(key, default_value) { + var user = wx.getStorageSync(this.data.cache_user_info_key) || null; if (user == null) { - return false; + // 是否存在默认值 + return (default_value == undefined) ? false : default_value; } + + // 是否读取key + if((key || null) != null) { + return (user[key] == undefined) ? (default_value == undefined ? null : default_value) : user[key]; + } + return user; }, @@ -711,7 +720,7 @@ App({ }, /** - * 获取配置信息、可指定默认值 + * 获取配置信息、可指定key和默认值 * key 数据key(支持多级读取、以 . 分割key名称) * default_value 默认值 */ diff --git a/sourcecode/weixin/default/pages/goods-category/goods-category.js b/sourcecode/weixin/default/pages/goods-category/goods-category.js index 9e279fc89..8a4f1eb5a 100755 --- a/sourcecode/weixin/default/pages/goods-category/goods-category.js +++ b/sourcecode/weixin/default/pages/goods-category/goods-category.js @@ -111,12 +111,20 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, path: '/pages/goods-category/goods-category?referrer=' + user_id }; }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + return { + title: app.data.application_title, + query: 'referrer=' + user_id + }; + }, }); \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/goods-detail/goods-detail.js b/sourcecode/weixin/default/pages/goods-detail/goods-detail.js index 8bc5e8bcd..f4276d9c7 100755 --- a/sourcecode/weixin/default/pages/goods-detail/goods-detail.js +++ b/sourcecode/weixin/default/pages/goods-detail/goods-detail.js @@ -872,8 +872,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: this.data.goods.title+'-'+app.data.application_title, desc: app.data.application_describe, @@ -881,4 +880,14 @@ Page({ imageUrl: this.data.goods.images }; }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + return { + title: this.data.goods.title+'-'+app.data.application_title, + query: 'goods_id=' + this.data.goods.id +'&referrer='+user_id, + imageUrl: this.data.goods.images + }; + }, }); diff --git a/sourcecode/weixin/default/pages/goods-search/goods-search.js b/sourcecode/weixin/default/pages/goods-search/goods-search.js index 144885a9f..022e9e855 100755 --- a/sourcecode/weixin/default/pages/goods-search/goods-search.js +++ b/sourcecode/weixin/default/pages/goods-search/goods-search.js @@ -225,8 +225,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; var category_id = this.data.params['category_id'] || 0; var keywords = this.data.params['keywords'] || ''; return { @@ -235,4 +234,15 @@ Page({ path: '/pages/goods-search/goods-search?referrer=' + user_id+'&category_id='+category_id+'&keywords='+keywords }; }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var category_id = this.data.params['category_id'] || 0; + var keywords = this.data.params['keywords'] || ''; + return { + title: app.data.application_title, + query: 'referrer=' + user_id+'&category_id='+category_id+'&keywords='+keywords + }; + }, }); diff --git a/sourcecode/weixin/default/pages/index/index.js b/sourcecode/weixin/default/pages/index/index.js index 269c278db..c731eeeb9 100755 --- a/sourcecode/weixin/default/pages/index/index.js +++ b/sourcecode/weixin/default/pages/index/index.js @@ -204,8 +204,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; return { title: app.data.application_title, desc: app.data.application_describe, @@ -213,4 +212,12 @@ Page({ }; }, + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + return { + title: app.data.application_title, + query: 'referrer=' + user_id + }; + }, }); diff --git a/sourcecode/weixin/default/pages/plugins/coupon/index/index.js b/sourcecode/weixin/default/pages/plugins/coupon/index/index.js index ae870af9f..1714eaf7e 100644 --- a/sourcecode/weixin/default/pages/plugins/coupon/index/index.js +++ b/sourcecode/weixin/default/pages/plugins/coupon/index/index.js @@ -165,4 +165,24 @@ Page({ this.get_data_list(); }, + // 自定义分享 + onShareAppMessage() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; + return { + title: name, + desc: app.data.application_describe, + path: '/pages/index/index?referrer=' + user_id + }; + }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; + return { + title: name, + query: 'referrer=' + user_id + }; + }, }); diff --git a/sourcecode/weixin/default/pages/plugins/membershiplevelvip/index/index.js b/sourcecode/weixin/default/pages/plugins/membershiplevelvip/index/index.js index fd5f8c364..a4958b874 100644 --- a/sourcecode/weixin/default/pages/plugins/membershiplevelvip/index/index.js +++ b/sourcecode/weixin/default/pages/plugins/membershiplevelvip/index/index.js @@ -83,4 +83,24 @@ Page({ this.get_data_list(); }, + // 自定义分享 + onShareAppMessage() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; + return { + title: name, + desc: app.data.application_describe, + path: '/pages/index/index?referrer=' + user_id + }; + }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; + return { + title: name, + query: 'referrer=' + user_id + }; + }, }); \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/plugins/weixinliveplayer/detail/detail.js b/sourcecode/weixin/default/pages/plugins/weixinliveplayer/detail/detail.js index 04a3b0680..aa73594af 100644 --- a/sourcecode/weixin/default/pages/plugins/weixinliveplayer/detail/detail.js +++ b/sourcecode/weixin/default/pages/plugins/weixinliveplayer/detail/detail.js @@ -125,16 +125,9 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; - if ((this.data.detail || null) != null) - { - var did = this.data.detail.id; - var name = this.data.detail.name; - } else { - var did = 0; - var name = app.data.application_title; - } + var user_id = app.get_user_cache_info('id', 0) || 0; + var did = ((this.data.detail || null) != null) ? this.data.detail.id : 0; + var name = ((this.data.detail || null) != null) ? this.data.detail.name : app.data.application_title; return { title: name, desc: app.data.application_describe, @@ -142,4 +135,16 @@ Page({ imageUrl: this.data.detail.share_img || '' }; }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var did = ((this.data.detail || null) != null) ? this.data.detail.id : 0; + var name = ((this.data.detail || null) != null) ? this.data.detail.name : app.data.application_title; + return { + title: name, + query: 'id=' + did + '&referrer=' + user_id, + imageUrl: this.data.detail.share_img || '' + }; + }, }); \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/plugins/weixinliveplayer/index/index.js b/sourcecode/weixin/default/pages/plugins/weixinliveplayer/index/index.js index c0306e1f0..57100fc9e 100644 --- a/sourcecode/weixin/default/pages/plugins/weixinliveplayer/index/index.js +++ b/sourcecode/weixin/default/pages/plugins/weixinliveplayer/index/index.js @@ -85,8 +85,7 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; return { title: name, @@ -94,4 +93,14 @@ Page({ path: '/pages/plugins/weixinliveplayer/index/index?referrer=' + user_id }; }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; + return { + title: name, + query: 'referrer=' + user_id + }; + }, }); \ No newline at end of file diff --git a/sourcecode/weixin/default/pages/plugins/weixinliveplayer/search/search.js b/sourcecode/weixin/default/pages/plugins/weixinliveplayer/search/search.js index 8124f323d..06b776846 100644 --- a/sourcecode/weixin/default/pages/plugins/weixinliveplayer/search/search.js +++ b/sourcecode/weixin/default/pages/plugins/weixinliveplayer/search/search.js @@ -2,6 +2,7 @@ const app = getApp(); Page({ data: { data_list: [], + data_base: null, data_page_total: 0, data_page: 1, data_list_loding_status: 1, @@ -97,6 +98,7 @@ Page({ data_page_total: res.data.data.page_total, data_list_loding_status: 3, data_page: this.data.data_page + 1, + data_base: data.base || null, }); // 是否还有数据 @@ -155,12 +157,22 @@ Page({ // 自定义分享 onShareAppMessage() { - var user = app.get_user_cache_info() || null; - var user_id = (user != null && (user.id || null) != null) ? user.id : 0; + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; return { - title: app.data.application_title, + title: name, desc: app.data.application_describe, path: '/pages/plugins/weixinliveplayer/search/search?referrer=' + user_id }; }, + + // 分享朋友圈 + onShareTimeline() { + var user_id = app.get_user_cache_info('id', 0) || 0; + var name = ((this.data.data_base || null) != null && (this.data.data_base.application_name || null) != null) ? this.data.data_base.application_name : app.data.application_title; + return { + title: name, + query: 'referrer=' + user_id + }; + }, }); \ No newline at end of file