"openid": "" openid没有传入
wx.addCard 卡券添加显示签名错误wx.addCard能够正常显示卡卷,但是领取按钮显示 “签名错误” 签名算法如下:[代码]public[代码] [代码]function[代码] [代码]getCard([代码][代码]$card_id[代码][代码],[代码][代码]$sessionId[代码][代码]){[代码][代码] [代码][代码]//获取openid[代码][代码] [代码][代码]$openid[代码] [代码]= [代码][代码]$this[代码][代码]->openId([代码][代码]$sessionId[代码][代码]);[代码][代码] [代码][代码]//获取ticket[代码][代码] [代码][代码]$res[代码] [代码]= [代码][代码]$this[代码][代码]->getApiTicket();[代码] [代码] [代码][代码]//生成签名[代码][代码] [代码][代码]$now[代码] [代码]=time();[代码][代码] [代码][代码]$timestamp[代码] [代码]= [代码][代码]$now[代码][代码];[代码][代码] [代码][代码]$nonceStr[代码] [代码]= [代码][代码]$this[代码][代码]->createNonceStr(8);[代码][代码] [代码][代码]$arr[代码] [代码]= [代码][代码]array[代码][代码]([代码][代码]$card_id[代码][代码],[代码][代码]$res[代码][代码][[代码][代码]'ticket'[代码][代码]],[代码][代码]$nonceStr[代码][代码],[代码][代码]$openid[代码][代码],[代码][代码]$timestamp[代码][代码]);[代码][代码]//组装参数[代码][代码] [代码][代码]asort([代码][代码]$arr[代码][代码], SORT_STRING);[代码][代码] [代码][代码]$sortString[代码] [代码]= [代码][代码]""[代码][代码];[代码][代码] [代码][代码]foreach[代码][代码]([代码][代码]$arr[代码] [代码]as[代码] [代码]$temp[代码][代码]){[代码][代码] [代码][代码]$sortString[代码] [代码]= [代码][代码]$sortString[代码][代码].[代码][代码]$temp[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]$signature[代码] [代码]= sha1([代码][代码]$sortString[代码][代码]);[代码] [代码] [代码][代码]$card[代码] [代码]= [代码][代码]array[代码][代码]([代码][代码] [代码][代码]'timestamp'[代码] [代码]=> [代码][代码]$timestamp[代码][代码],[代码][代码] [代码][代码]'signature'[代码] [代码]=> [代码][代码]$signature[代码][代码],[代码][代码] [代码][代码]'cardId'[代码] [代码]=> [代码][代码]$card_id[代码][代码],[代码][代码] [代码][代码]'ticket'[代码] [代码]=> [代码][代码]$res[代码][代码][[代码][代码]'ticket'[代码][代码]],[代码][代码] [代码][代码]'nonce_str'[代码] [代码]=> [代码][代码]$nonceStr[代码][代码] [代码][代码]);[代码][代码] [代码][代码]return[代码] [代码]$card[代码][代码];[代码][代码] [代码][代码]}[代码] 小程序js [代码]wx.request({[代码][代码] [代码][代码]url: url + [代码][代码]'/api/app/getAppCard'[代码][代码],[代码][代码] [代码][代码]data:{[代码][代码] [代码][代码]session_id : sessionId,[代码][代码] [代码][代码]card_id: [代码][代码]'pwJno0xiCS3HfuSpQoJtTCtEXODU'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]var[代码] [代码]card_info = res.data.cardArray[代码][代码] [代码][代码]console.log(res.data.cardArray)[代码][代码] [代码][代码]wx.addCard({[代码][代码] [代码][代码]cardList: [[代码][代码] [代码][代码]{[代码][代码] [代码][代码]cardId: card_info.cardId,[代码][代码] [代码][代码]cardExt: [代码][代码]'{"code": "", "openid": "", "timestamp": "'[代码][代码]+card_info.timestamp+[代码][代码]'", "signature":"'[代码][代码]+card_info.signature+[代码][代码]'"}'[代码][代码] [代码][代码]}[代码][代码] [代码][代码]],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res) [代码][代码]// 卡券添加结果[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete: [代码][代码]function[代码][代码](res)[代码][代码] [代码][代码]{[代码][代码] [代码][代码]console.log(res)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码]
2018-06-01