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