小程序
小游戏
企业微信
微信支付
扫描小程序码分享
现象:测试环境真机测试没有任何问题, 获取code后换取openid。
生产环境获取code后,后台请求code2Session接口(且后台只收到一次前台的请求),发现code与前端vconsole日志显示的code不一致,导致code2Session接口返回 40029
排查两天没发现问题所在,求助各位大佬。
代码:
4 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
wx.login({ success: function(res) { //加签 var addsignData_100001 = { txn_type: '100001', js_code: res.code, user_channel:'000' } var outDate_100001 = addSign.jiaqian(addsignData_100001); wx.showLoading({ title: '', mask: true }) wx.request({ url: app.globalData.service_url, data: outDate_100001, method: 'POST', success: function(res) { //验签 var verifySignData = res.data; var inData = verifySign.yanqian(verifySignData); wx.setStorageSync('openid', inData.openid) if (inData.unionid) { wx.setStorageSync('unionid', inData.unionid) } else { wx.setStorageSync('unionid', '') } wx.setStorageSync('userid', inData.userid) wx.setStorageSync('id_no', inData.id_no) wx.setStorageSync('phone', inData.phone) console.log(res) that.setData({ register: inData.is_register }) if (inData.is_register == '0' && inData.phone==''){ return }else{ app.globalData.register1 == '02' that.setData({ register1: '02' }) } //加签 var addsignData_100006 = { txn_type: '100006', openid: res.data.openid, user_channel: '000', unionid: res.data.unionid, // cpStatus: '02', userid: res.data.userid, id_no: res.data.id_no, phone: res.data.phone } var outDate_100006 = addSign.jiaqian(addsignData_100006); wx.request({ url: app.globalData.service_url, method: 'POST', data: outDate_100006, success: function(res) { wx.hideLoading() console.log(res) //验签 var verifySignData = res.data; var inData = verifySign.yanqian(verifySignData); let list = inData.coupon if (inData == "") { list = [] } for (let i = 0; i < list.length; i++) { list[i].checked = false list[i].cpStartDate = format.formatTime(list[i].cpStartDate) list[i].cpEndDate = format.formatTime(list[i].cpEndDate) list[i].showstatus = '01' list[i].txtStyle = '' } that.setData({ list: list, deleteList: list }) } }) }, fail: function() { wx.hideLoading() }, complete: function() { wx.hideLoading() } }) } }) },
代码片段,图片运行不了
let list = inData.coupon
if (inData == "") {
list = []
}
for (let i = 0; i < list.length; i++) {
list[i].checked = false
list[i].cpStartDate = format.formatTime(list[i].cpStartDate)
list[i].cpEndDate = format.formatTime(list[i].cpEndDate)
list[i].showstatus = '01'
list[i].txtStyle = ''
that.setData({
list: list,
deleteList: list
})
},
fail: function() {
wx.hideLoading()
complete: function() {
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
wx.login({ success: function(res) { //加签 var addsignData_100001 = { txn_type: '100001', js_code: res.code, user_channel:'000' } var outDate_100001 = addSign.jiaqian(addsignData_100001); wx.showLoading({ title: '', mask: true }) wx.request({ url: app.globalData.service_url, data: outDate_100001, method: 'POST', success: function(res) { //验签 var verifySignData = res.data; var inData = verifySign.yanqian(verifySignData); wx.setStorageSync('openid', inData.openid) if (inData.unionid) { wx.setStorageSync('unionid', inData.unionid) } else { wx.setStorageSync('unionid', '') } wx.setStorageSync('userid', inData.userid) wx.setStorageSync('id_no', inData.id_no) wx.setStorageSync('phone', inData.phone) console.log(res) that.setData({ register: inData.is_register }) if (inData.is_register == '0' && inData.phone==''){ return }else{ app.globalData.register1 == '02' that.setData({ register1: '02' }) } //加签 var addsignData_100006 = { txn_type: '100006', openid: res.data.openid, user_channel: '000', unionid: res.data.unionid, // cpStatus: '02', userid: res.data.userid, id_no: res.data.id_no, phone: res.data.phone } var outDate_100006 = addSign.jiaqian(addsignData_100006); wx.request({ url: app.globalData.service_url, method: 'POST', data: outDate_100006, success: function(res) { wx.hideLoading() console.log(res) //验签 var verifySignData = res.data; var inData = verifySign.yanqian(verifySignData); let list = inData.coupon if (inData == "") { list = [] } for (let i = 0; i < list.length; i++) { list[i].checked = false list[i].cpStartDate = format.formatTime(list[i].cpStartDate) list[i].cpEndDate = format.formatTime(list[i].cpEndDate) list[i].showstatus = '01' list[i].txtStyle = '' } that.setData({ list: list, deleteList: list }) } }) }, fail: function() { wx.hideLoading() }, complete: function() { wx.hideLoading() } }) } }) },
代码片段,图片运行不了
let list = inData.coupon
if (inData == "") {
list = []
}
for (let i = 0; i < list.length; i++) {
list[i].checked = false
list[i].cpStartDate = format.formatTime(list[i].cpStartDate)
list[i].cpEndDate = format.formatTime(list[i].cpEndDate)
list[i].showstatus = '01'
list[i].txtStyle = ''
}
that.setData({
list: list,
deleteList: list
})
}
})
},
fail: function() {
wx.hideLoading()
},
complete: function() {
wx.hideLoading()
}
})
}
})
},