小程序分享优化、微信分享朋友圈支持自定义图片+参数

feat/task1-c-wallet
Devil 2020-12-01 10:52:18 +08:00
parent d1e10cb5db
commit 7a18b4473e
28 changed files with 207 additions and 75 deletions

View File

@ -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 默认值
*/

View File

@ -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,

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 默认值
*/

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 默认值
*/

View File

@ -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,

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 默认值
*/

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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 默认值
*/

View File

@ -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
};
},
});

View File

@ -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
};
},
});

View File

@ -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
};
},
});

View File

@ -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
};
},
});

View File

@ -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
};
},
});

View File

@ -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
};
},
});

View File

@ -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 || ''
};
},
});

View File

@ -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
};
},
});

View File

@ -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
};
},
});