人人商城[二开]修改分享页面到朋友圈可以奖励积分

https://blog.csdn.net/qq19124152/article/details/81012150

模版修改位置:

addons/ewei_shopv2/template/mobile/default/_share.html

代码:

wx.onMenuShareTimeline({
{php echo tttaddshare(json_encode($_W['shopshare']))}, // 分享内容
success: function () {
// 用户确认分享后执行的回调函数
var url = "{php echo mobileUrl('member/addshare', array('ctype'=>fenxiangok))}";
$.post(url, function(dat){
//alert(2);
});
},
cancel: function () {
// 用户取消分享后执行的回调函数
}

});
添加一个函数用于去掉分享代码的大括号,

位置:addons\ewei_shopv2\core\inc\functions.php

function tttaddshare($str)
{
$str=trim($str,'{');
$str=trim($str,'}');

return $str;

}
然后在 addons\ewei_shopv2\core\mobile\member\addshare.php 这个文件是新建的

$openid = $_W['openid'];
$uniacid = $_W['uniacid'];
$member = m('member')->getMember($openid);

if ($_GPC['ctype']=='fenxiangok') { //这个判断没乱用只是为了不让人随便访问到而已。
if (empty($member)) {
exit();
}
$time=date('Y-m-d',time());
$logrow = pdo_fetch('select * from ' . tablename('ewei_shop_addshare_log') . ' where openid=:openid and uniacid=:uniacid limit 1', array(':openid' => $openid,':uniacid' => $_W['uniacid']));
//上面这个表是新建的,为了统计分享数量,并且限制每个人每天只能获得一次分享得到积分的机会
if(strtotime($time)>$logrow['createtime']){
$log = array('uniacid' => $_W['uniacid'],'openid' => $openid, 'createtime' => strtotime($time));
pdo_insert('ewei_shop_addshare_log', $log);
m('member')->setCredit($openid, 'credit2', 1, array(0, '分享赠送积分+1'));
exit();
}
}
数据表:

DROP TABLE IF EXISTS `ims_ewei_shop_addshare_log`;
CREATE TABLE `ims_ewei_shop_addshare_log` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`uniacid` int(10) NOT NULL,
`createtime` int(11) DEFAULT NULL,
`openid` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
因为自己在项目中用到了这块,所以特意记录了下来,希望看到的人能够帮助你。

如果有更多问题可以联系的QQ。就是我用户名,
---------------------
作者:qq19124152
来源:CSDN
原文:https://blog.csdn.net/qq19124152/article/details/81012150
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自www.cnblogs.com/westsoft/p/9945597.html
今日推荐