使用eacyWechat进行卡券开发

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_32028711/article/details/79299247

插件 :easyWechat

版本:3.x

php代码:

$option = \EasyCacheDriver::getOption('wj',true);
$app  = new Application($option);
$card = $app->card;

$js = $app->js;

$cardPackage = $card->jsConfigForAssign( $cardList);
$param = $js->config(['addCard','openCard','onMenuShareAppMessage','onMenuShareTimeline','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone','getLocation'],false);
$cardPackage = json_decode($cardPackage,1);  //因为最后返回的是json 所以在这要先解码
return json(['code'=>0,

    'cardPackage'=>$cardPackage,
    'js'=>$param,  //wx.config  需要的参数
   ]);
前端代码:
wx.config({$js})
var js;
var card_package;
function getBtn(){
    getFromAjax("/rzvote/public/index.php/index/member/send",function(res){
        if(res.code == 0){
            showTips(1,'领取成功','');

            js = res.js
            card_package = res.cardPackage  //返回的卡券包
            console.log(card_package)
            wx.ready(function(){
                wx.addCard({
                    cardList: card_package, // 需要添加的卡券列表
                    success: function (res) {
                        var cardList = res.cardList; // 添加的卡券列表信息
                        console.log(res)
                    },
                    error:function(res){
                        alert(res)
                        console.log(res);
                    },
                    fail:function(res){
                        alert(res)
                    }
                });
            });

        }else {
            showTips(0,'领取失败',res.msg);
        }
    });
}

展开阅读全文

微信卡券接口问题

07-29

string buff = "\"card\": \"card_type\": \"CASH\",\"groupon\": \"base_info\": \"logo_url \": \"https://mmbiz.qlogo.cn/mmbiz/pEjibTibnM4kjzGwdia33qWmBZKTsncHxm1kpQ1UqeXSOyIlLq8KLPDb9VB6XbHN425ibicXHAfYNDLj2lF0Z5MVia6g/0\",\"brand_name\": \"456\",\"code_type\": \"CODE_TYPE_TEXT\",\"title\": \"654\",\"sub_title\": \"周末狂欢必备\",\"color\": \"Color010\",\"notice\": \"使用时向服务员出示此券\",\"service_phone\": \"020-88888888\",\"description\": \"不可与其他优惠同享\",\"date_info\": \"type\": \"DATE_TYPE_FIX_TIME_RANGE\",\"end_timestamp\": \"1422724261\",\"sku\": \"quantity\": 0,\"get_limit\": 2,\"use_custom_code\": false,\"bind_openid\": false,\"can_share\": true,\"can_give_friend\": true,\"custom_url_name\": \"立即使用\",\"custom_url\": \"http://www.qq.com\",\"custom_url_sub_title\": \"6个汉字tips\",\"promotion_url_name\": \"更多优惠\",\"promotion_url\": \"http://www.qq.com\",\"source\": \"大众点评\",\"least_cost\": 100,\"reduce_cost\": 20000";rn一直返回47001不知道哪出问题了,解析没问题的rnrn "card": rn "card_type": "CASH", rn "groupon": rn "base_info": rn "logo_url ": "https://mmbiz.qlogo.cn/mmbiz/pEjibTibnM4kjzGwdia33qWmBZKTsncHxm1kpQ1UqeXSOyIlLq8KLPDb9VB6XbHN425ibicXHAfYNDLj2lF0Z5MVia6g/0", rn "brand_name": "456", rn "code_type": "CODE_TYPE_TEXT", rn "title": "654", rn "sub_title": "周末狂欢必备", rn "color": "Color010", rn "notice": "使用时向服务员出示此券", rn "service_phone": "020-88888888", rn "description": "不可与其他优惠同享", rn "date_info": rn "type": "DATE_TYPE_FIX_TIME_RANGE", rn "end_timestamp": "1422724261"rn , rn "sku": rn "quantity": 0rn , rn "get_limit": 2, rn "use_custom_code": false, rn "bind_openid": false, rn "can_share": true, rn "can_give_friend": true, rn "custom_url_name": "立即使用", rn "custom_url": "http://www.qq.com", rn "custom_url_sub_title": "6个汉字tips", rn "promotion_url_name": "更多优惠", rn "promotion_url": "http://www.qq.com", rn "source": "大众点评"rn , rn "least_cost": 100, rn "reduce_cost": 20000rn rn rnrn帮我看一下谢谢。刚刚接触.net 论坛

没有更多推荐了,返回首页