轉(zhuǎn)自:http://www.cnblogs.com/littleBit/p/5977572.html
1.app跳轉(zhuǎn)微信
1腌歉、app跳轉(zhuǎn)微信公眾號在工程中添加pch文件,導(dǎo)入 WXApi.h頭文件,并在你需要跳轉(zhuǎn)的界面增加WXApiDelegate協(xié)議在你的跳轉(zhuǎn)方法中添加一下代碼:
JumpToBizProfileReq *req = [JumpToBizProfileReq new];
req.username = @"gh_64a69d298ecf"; // 原始ID
req.profileType = WXBizProfileType_Normal;
req.extMsg = @"";[WXApi sendReq:req];
這樣APP就可以掉起微信界面,進(jìn)入微信公眾號(如果之前沒有關(guān)注過此微信公眾號,就會進(jìn)入微信公眾號的關(guān)注界面)
2秕磷、APP跳轉(zhuǎn)到微信相關(guān)的其他網(wǎng)頁(如微信小店相關(guān)商品信息界面)
OpenWebviewReq *req = [OpenWebviewReq new];
req.url = @"需要微信內(nèi)置瀏覽器打開的網(wǎng)址";
[WXApi sendReq:req];
PS:原始ID: 申請公共號時系統(tǒng)給你的唯一編號,有此 id你更改微信號后依然能綁定公共號APPID: 開通 api 服務(wù)時,系統(tǒng)給你的唯一編號APPSECRET: 通俗一點兒來說就是密鑰
生成訂單相關(guān)代碼
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *signParaDic = @{@"schoolId":schoolId,
@"studentId":studentId,
@"parentId":parentId,
@"parentTel":phone,
@"totalFee":[NSString stringWithFormat:@"%i",payProduct.totalFee],
@"productId":[NSString stringWithFormat:@"%i",payProduct.productId],
@"productName":payProduct.productName};
NSString *sign = [EncodeParameter md5:signParaDic];
NSDictionary *parameters = @{@"schoolId":schoolId,
@"parentId":parentId,
@"studentId":studentId,
@"parentTel":phone,
@"totalFee":[NSString stringWithFormat:@"%i",payProduct.totalFee],
@"productId":[NSString stringWithFormat:@"%i",payProduct.productId],
@"productName":payProduct.productName,
@"sign":sign};
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:WechatPlaceOrderAPI parameters:parameters error:nil];
_palceOrderOperation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
//NSDictionary *resDic = (NSDictionary *)responseObject;
NSNumber *code = [resDic objectForKey:@"result"];
NSString *msg = [resDic objectForKey:@"message"];
if ([code integerValue] == Success) {
WeChatPreOrder *preOrder = [[WeChatPreOrder alloc] initWithDic:resDic];
if (self.delegate && [self.delegate respondsToSelector:@selector(placeOrderSucess:preOder:)]) {
[self.delegate placeOrderSucess:self preOder:preOrder];
}} else if ([code integerValue] == 300) {
if (self.delegate && [self.delegate respondsToSelector:@selector(placeOrderFailed:error:)]) {
[self.delegate placeOrderFailed:self error:msg];
}}else { if (self.delegate && [self.delegate respondsToSelector:@selector(placeOrderFailed:error:)]) {
[self.delegate placeOrderFailed:self error:RequestError];
} }} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (self.delegate && [self.delegate respondsToSelector:@selector(placeOrderFailed:error:)]) {
[self.delegate placeOrderFailed:self error:RequestError];
}}];