Commit c8cb138c8d2f24f4a57d84735dbafcd4dfc7f2c5
1 parent
f71e9125
添加支付宝白名单 , 检测支付宝和微信是否安装
Showing
2 changed files
with
40 additions
and
19 deletions
metaCode/Classes/Main/HomePage/Controller/ShopPayController/CNLiveShopPayController.swift
| @@ -34,6 +34,8 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | @@ -34,6 +34,8 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | ||
| 34 | var orderNumber:String | 34 | var orderNumber:String |
| 35 | var orderInfoModel:CNLivePayOrderInfoModel? | 35 | var orderInfoModel:CNLivePayOrderInfoModel? |
| 36 | var currentSeleWechat = true | 36 | var currentSeleWechat = true |
| 37 | + var wechatIsInstall = true //微信是否安装 | ||
| 38 | + var alipayIsInstall = true //支付宝是否安装 | ||
| 37 | var payType:CNLivePayType? | 39 | var payType:CNLivePayType? |
| 38 | 40 | ||
| 39 | let kCNLiveShopPayNeedPaymentCellIdentifier = "kCNLiveShopPayNeedPaymentCellIdentifier" | 41 | let kCNLiveShopPayNeedPaymentCellIdentifier = "kCNLiveShopPayNeedPaymentCellIdentifier" |
| @@ -83,25 +85,20 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | @@ -83,25 +85,20 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | ||
| 83 | NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActiveNotification(_:)), name: UIApplication.didBecomeActiveNotification, object: nil) | 85 | NotificationCenter.default.addObserver(self, selector: #selector(didBecomeActiveNotification(_:)), name: UIApplication.didBecomeActiveNotification, object: nil) |
| 84 | self.getOrderInfoMessage() | 86 | self.getOrderInfoMessage() |
| 85 | self.initUI() | 87 | self.initUI() |
| 88 | + | ||
| 86 | if WXApi.isWXAppInstalled(){ | 89 | if WXApi.isWXAppInstalled(){ |
| 87 | - print("wx已安装") | 90 | + self.wechatIsInstall = true |
| 88 | }else{ | 91 | }else{ |
| 89 | - print("wx未安装") | 92 | + self.wechatIsInstall = false |
| 90 | } | 93 | } |
| 91 | - let urlScheme = "alipay" | ||
| 92 | - if UIApplication.shared.canOpenURL(URL(string: urlScheme)!) { | ||
| 93 | - print("已安装") | ||
| 94 | - } else { | ||
| 95 | - print("未安装") | ||
| 96 | - } | ||
| 97 | - let wxUrlScheme = "weixin://" | 94 | + |
| 95 | + let urlScheme = "alipay://" | ||
| 98 | if UIApplication.shared.canOpenURL(URL(string: urlScheme)!) { | 96 | if UIApplication.shared.canOpenURL(URL(string: urlScheme)!) { |
| 99 | - print("已安装") | 97 | + self.alipayIsInstall = true |
| 100 | } else { | 98 | } else { |
| 101 | - print("未安装") | 99 | + self.alipayIsInstall = false |
| 102 | } | 100 | } |
| 103 | 101 | ||
| 104 | - | ||
| 105 | } | 102 | } |
| 106 | // MARK: - 获取订单信息 并且进行检测 | 103 | // MARK: - 获取订单信息 并且进行检测 |
| 107 | func getOrderInfoMessage(){ | 104 | func getOrderInfoMessage(){ |
| @@ -127,8 +124,16 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | @@ -127,8 +124,16 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | ||
| 127 | } | 124 | } |
| 128 | 125 | ||
| 129 | @objc func payBtnAction(){ | 126 | @objc func payBtnAction(){ |
| 130 | - showLoading(message: "") | ||
| 131 | 127 | ||
| 128 | + if self.currentSeleWechat == true && self.wechatIsInstall == false{ | ||
| 129 | + showMessage(message: "请安装微信") | ||
| 130 | + return | ||
| 131 | + } | ||
| 132 | + if self.currentSeleWechat == false && self.alipayIsInstall == false{ | ||
| 133 | + showMessage(message: "请安装支付宝") | ||
| 134 | + return | ||
| 135 | + } | ||
| 136 | + showLoading(message: "") | ||
| 132 | let orderId = self.orderInfoModel?.orderId | 137 | let orderId = self.orderInfoModel?.orderId |
| 133 | var userId = self.orderInfoModel?.user_id | 138 | var userId = self.orderInfoModel?.user_id |
| 134 | if userId?.count == 0{ | 139 | if userId?.count == 0{ |
| @@ -142,7 +147,7 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | @@ -142,7 +147,7 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | ||
| 142 | 147 | ||
| 143 | let paramDict = NSMutableDictionary() | 148 | let paramDict = NSMutableDictionary() |
| 144 | paramDict.setValue(orderId, forKey: "orderId") | 149 | paramDict.setValue(orderId, forKey: "orderId") |
| 145 | - paramDict.setValue(userId, forKey: "userId") | 150 | + paramDict.setValue(userId, forKey: "user_id") |
| 146 | paramDict.setValue(descStr, forKey: "descStr") | 151 | paramDict.setValue(descStr, forKey: "descStr") |
| 147 | paramDict.setValue(price, forKey: "price") | 152 | paramDict.setValue(price, forKey: "price") |
| 148 | paramDict.setValue("1", forKey: "orderType") | 153 | paramDict.setValue("1", forKey: "orderType") |
| @@ -239,22 +244,31 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | @@ -239,22 +244,31 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | ||
| 239 | } | 244 | } |
| 240 | if indexPath.row == 0{ | 245 | if indexPath.row == 0{ |
| 241 | //微信支付 | 246 | //微信支付 |
| 242 | - cell.titleLabel.text = "微信支付" | 247 | + |
| 243 | cell.iconImgView.image = UIImage(named: "dd_weixin") | 248 | cell.iconImgView.image = UIImage(named: "dd_weixin") |
| 244 | if self.currentSeleWechat == true{ | 249 | if self.currentSeleWechat == true{ |
| 245 | cell.selectImgView.isHidden = false | 250 | cell.selectImgView.isHidden = false |
| 246 | }else{ | 251 | }else{ |
| 247 | cell.selectImgView.isHidden = true | 252 | cell.selectImgView.isHidden = true |
| 248 | } | 253 | } |
| 254 | + if self.wechatIsInstall{ | ||
| 255 | + cell.titleLabel.text = "微信支付" | ||
| 256 | + }else{ | ||
| 257 | + cell.titleLabel.text = "微信未安装,无法使用微信支付" | ||
| 258 | + } | ||
| 249 | }else{ | 259 | }else{ |
| 250 | //支付宝支付 | 260 | //支付宝支付 |
| 251 | - cell.titleLabel.text = "支付宝支付" | ||
| 252 | cell.iconImgView.image = UIImage(named: "dd_zhifubao") | 261 | cell.iconImgView.image = UIImage(named: "dd_zhifubao") |
| 253 | if self.currentSeleWechat == true{ | 262 | if self.currentSeleWechat == true{ |
| 254 | cell.selectImgView.isHidden = true | 263 | cell.selectImgView.isHidden = true |
| 255 | }else{ | 264 | }else{ |
| 256 | cell.selectImgView.isHidden = false | 265 | cell.selectImgView.isHidden = false |
| 257 | } | 266 | } |
| 267 | + if self.alipayIsInstall{ | ||
| 268 | + cell.titleLabel.text = "支付宝支付" | ||
| 269 | + }else{ | ||
| 270 | + cell.titleLabel.text = "支付宝未安装,无法使用支付宝支付" | ||
| 271 | + } | ||
| 258 | } | 272 | } |
| 259 | return cell | 273 | return cell |
| 260 | } | 274 | } |
| @@ -262,11 +276,19 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | @@ -262,11 +276,19 @@ class CNLiveShopPayController:CNLiveBaseViewController,UITableViewDelegate,UITab | ||
| 262 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 276 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 263 | if indexPath.section == 1{ | 277 | if indexPath.section == 1{ |
| 264 | if indexPath.row == 0{ | 278 | if indexPath.row == 0{ |
| 279 | + if self.wechatIsInstall == false{ | ||
| 280 | + showMessage(message: "请安装微信") | ||
| 281 | + return | ||
| 282 | + } | ||
| 265 | if self.currentSeleWechat == true{ | 283 | if self.currentSeleWechat == true{ |
| 266 | return | 284 | return |
| 267 | } | 285 | } |
| 268 | self.currentSeleWechat = true | 286 | self.currentSeleWechat = true |
| 269 | }else{ | 287 | }else{ |
| 288 | + if self.alipayIsInstall == false{ | ||
| 289 | + showMessage(message: "请安装支付宝") | ||
| 290 | + return | ||
| 291 | + } | ||
| 270 | if self.currentSeleWechat == false{ | 292 | if self.currentSeleWechat == false{ |
| 271 | return | 293 | return |
| 272 | } | 294 | } |
metaCode/Info.plist
| @@ -54,6 +54,8 @@ | @@ -54,6 +54,8 @@ | ||
| 54 | <key>LSApplicationQueriesSchemes</key> | 54 | <key>LSApplicationQueriesSchemes</key> |
| 55 | <array> | 55 | <array> |
| 56 | <string>wechat</string> | 56 | <string>wechat</string> |
| 57 | + <string>alipay</string> | ||
| 58 | + <string>alipays</string> | ||
| 57 | <string>weixin</string> | 59 | <string>weixin</string> |
| 58 | <string>weixinULAPI</string> | 60 | <string>weixinULAPI</string> |
| 59 | <string>mqqOpensdkSSoLogin</string> | 61 | <string>mqqOpensdkSSoLogin</string> |
| @@ -74,9 +76,6 @@ | @@ -74,9 +76,6 @@ | ||
| 74 | <string>mqqwpa</string> | 76 | <string>mqqwpa</string> |
| 75 | <string>mqzone</string> | 77 | <string>mqzone</string> |
| 76 | <string>mqqopensdkminiapp</string> | 78 | <string>mqqopensdkminiapp</string> |
| 77 | - | ||
| 78 | -<!-- <string>sinaweibo</string>--> | ||
| 79 | -<!-- <string>sinaweibohd</string>--> | ||
| 80 | </array> | 79 | </array> |
| 81 | <key>NSAppTransportSecurity</key> | 80 | <key>NSAppTransportSecurity</key> |
| 82 | <dict> | 81 | <dict> |