// 用户同意
let paramter = ["appid" : WEIXIN_APPID,
"secret" : WEIXIN_APP_SECRET,
"code" : resp.code,
"grant_type" : "authorization_code"]
MBProgressHUD.showMessage("")
WebDataResponseInterface.shareInstance.sessionManagerOriginWebData(strUrl: "https://api.weixin.qq.com", strApi: "/sns/oauth2/access_token", parameters: paramter as NSDictionary, resquestType: RequestType.GET, outRequestTime: 20, AESCPwd: nil, isTipInfo: true, responseProgress: { _ in}, responseSuccess: { (objectSuccess) in
MBProgressHUD.hide()
let dataDict = objectSuccess as! NSDictionary
if dataDict["errcode"] == nil {
myPrint(message: "openID: \(String(describing: dataDict["openid"]!))")
// 获取用户信息
self.getWeixinThirdPartyLoginUserInfo(openId: String(describing: dataDict["openid"]!), accessToken: String(describing: dataDict["access_token"]!))
} else {
myPrint(message: "errcode:\(String(describing: dataDict["errcode"]!)), errmsg:\(String(describing: dataDict["errmsg"]!))")
// 获取本地缓存的用户信息
self.wxAccountTitleLabel.text = "微信账户"
self.wxAccountValueLabel.text = UserDefaults.standard.string(forKey: "wx_nickname")
self.wxOpenID = UserDefaults.standard.string(forKey: "wx_openID")
self.currentModifyMerchant.wxAccount = self.wxAccountValueLabel.text
self.currentModifyMerchant.wxOpenID = self.wxOpenID
// 修改微信账户信息
self.modifyMerchantWeiXinAccountInfo(nickName: self.currentModifyMerchant.wxAccount!, openID: self.wxOpenID!)
}
}) { (error) in
MBProgressHUD.hide()
}
调用的请求的这段代码,不要放在DispatchQueue.main.asyncAfter 中执行,否则会出现此问题;