- 小程序 C#后台获取手机号码获取不到?
wx.login({ success: (res) => { console.log("res.code:"+res.code); wx.request({ url: '/api/OnLogin/get', data: { code: res.code, smallprogram:"010" }, success: (open) => { console.log('222222222'); console.log(open.data); wx.setStorageSync("session_key", open.data.session_key); wx.setStorageSync("openid", open.data.openid); } }) } wx.getUserProfile({ desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 success: (file) => { console.log(file); console.log('00000000000000'); this.setData({ encryptedData: file.encryptedData, iv: file.iv }) wx.setStorageSync("nickName", file.userInfo.nickName,); wx.setStorageSync("HeadUrl", file.userInfo.avatarUrl); this.setData({ userNicheng: wx.getStorageSync("nickName"), }) } getPhoneNumber: function(e) { var that = this,qy=wx.getStorageSync("qy")||"055100038",fid=wx.getStorageSync("fid")||"0"; var session_key = wx.getStorageSync("session_key"); console.log("getPhoneNumberok" + e.detail.errMsg); var name=wx.getStorageSync("nickName")==null?"":wx.getStorageSync("nickName"); var photo=wx.getStorageSync("HeadUrl")==null?"":wx.getStorageSync("HeadUrl"); var openid=wx.getStorageSync("openid")==null?"":wx.getStorageSync("openid"); var cgl='/api/OnLogin/get?encryptedData='+this.data.encryptedData+'&iv='+this.data.iv+'&session_key='+session_key +'&qy='+qy+'&name='+name+'&photo='+photo+'&openid='+openid+'&fid='+fid; console.log(cgl); if (e.detail.errMsg == "getPhoneNumber:ok") { wx.request({ url: '/api/OnLogin/get', data: { encryptedData: this.data.encryptedData, iv: this.data.iv, session_key: session_key, qy:qy, name:wx.getStorageSync("nickName")==null?"":wx.getStorageSync("nickName"), photo:wx.getStorageSync("HeadUrl")==null?"":wx.getStorageSync("HeadUrl"), openid:wx.getStorageSync("openid")==null?"":wx.getStorageSync("openid"), fid:fid }, method: "get", success: function(res) { wx.setStorageSync("mobile", res.data); that.setData({ phone:res.data, }); } }) 后台 encryptedData = encryptedData.Replace(" ", "+"); int mod4 = encryptedData.Length % 4; if (mod4 > 0) { encryptedData += new string('=', 4 - mod4); } byte[] encryData = Convert.FromBase64String(encryptedData); RijndaelManaged rijndaelCipher = new RijndaelManaged(); Session_key = Session_key.Replace(" ", "+"); mod4 = Session_key.Length % 4; if (mod4 > 0) {Session_key += new string('=', 4 - mod4); } rijndaelCipher.Key = Convert.FromBase64String(Session_key); IV = IV.Replace(" ", "+"); mod4 = IV.Length % 4; if (mod4 > 0) { IV += new string('=', 4 - mod4); } rijndaelCipher.IV = Convert.FromBase64String(IV); rijndaelCipher.Mode = CipherMode.CBC; rijndaelCipher.Padding = PaddingMode.PKCS7; ICryptoTransform transform = rijndaelCipher.CreateDecryptor(); byte[] plainText = transform.TransformFinalBlock(encryData, 0, encryData.Length); //string result = Encoding.Default.GetString(plainText); string result = Encoding.UTF8.GetString(plainText); dynamic model = Newtonsoft.Json.Linq.JToken.Parse(result) as dynamic; return1= model.phoneNumber; model.phoneNumber;为空
2021-11-29 - 小程序微信支付问题?
requestPayment:fail parameter error: parameter.package should be String instead of Undefined
2021-05-24 - 登录不了?
本机登录没有问题,真机测试没有问题,上传上去体验版登录不了,点登录出现 网络错误
2020-09-15