1. 程式人生 > >人人商城[二開]修改分享頁面到朋友圈可以獎勵積分

人人商城[二開]修改分享頁面到朋友圈可以獎勵積分

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
版權宣告:本文為博主原創文章,轉載請附上博文連結!