|
@@ -57,62 +57,134 @@ FlutterMethodChannel *channel; |
|
@@ -57,62 +57,134 @@ FlutterMethodChannel *channel; |
|
57
|
}
|
57
|
}
|
|
58
|
|
58
|
|
|
59
|
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
59
|
- (void)shareImage:(FlutterMethodCall *)call result:(FlutterResult)result {
|
|
60
|
-
|
|
|
|
61
|
- WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
62
|
- WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
|
|
|
|
63
|
- attachment.filename = @"icon.jpg";
|
|
|
|
64
|
- attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
|
|
|
|
65
|
- // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
|
|
|
|
66
|
- // //下载图片
|
|
|
|
67
|
- // NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
68
|
- // attachment.data = data;
|
|
|
|
69
|
- req.attachment = attachment;
|
|
|
|
70
|
- [WWKApi sendReq:req];
|
60
|
+ [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"];
|
|
|
|
61
|
+
|
|
|
|
62
|
+ dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
|
|
|
|
63
|
+ dispatch_async(globalQueue, ^{
|
|
|
|
64
|
+
|
|
|
|
65
|
+
|
|
|
|
66
|
+ // 使用NSURLSession异步请求网络图片
|
|
|
|
67
|
+ NSURL *imageURL = [NSURL URLWithString:call.arguments[@"path"]];
|
|
|
|
68
|
+ NSURLRequest *request = [NSURLRequest requestWithURL:imageURL];
|
|
|
|
69
|
+
|
|
|
|
70
|
+ // 创建URLSession并开始任务
|
|
|
|
71
|
+ NSURLSession *session = [NSURLSession sharedSession];
|
|
|
|
72
|
+ NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:
|
|
|
|
73
|
+ ^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
|
|
|
74
|
+ if (error) {
|
|
|
|
75
|
+ // 处理错误
|
|
|
|
76
|
+ NSLog(@"Error: %@", error);
|
|
|
|
77
|
+ } else {
|
|
|
|
78
|
+ // 成功获取数据,转换为NSData
|
|
|
|
79
|
+ NSData *imageData = data;
|
|
|
|
80
|
+
|
|
|
|
81
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
82
|
+ WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
83
|
+ WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
|
|
|
|
84
|
+ // attachment.filename = @"icon.jpg";
|
|
|
|
85
|
+ // attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
|
|
|
|
86
|
+ // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
|
|
|
|
87
|
+ // //下载图片
|
|
|
|
88
|
+ // NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
89
|
+ attachment.filename = @"share_image";
|
|
|
|
90
|
+ attachment.data = imageData;
|
|
|
|
91
|
+ req.attachment = attachment;
|
|
|
|
92
|
+ [WWKApi sendReq:req];
|
|
|
|
93
|
+ authResult = result;
|
|
|
|
94
|
+ });
|
|
|
|
95
|
+
|
|
|
|
96
|
+
|
|
|
|
97
|
+
|
|
|
|
98
|
+ // 此处可以使用imageData,例如保存到本地或者用于其他处理
|
|
|
|
99
|
+ // 保存到本地示例代码
|
|
|
|
100
|
+ // [imageData writeToFile:@"/path/to/save/image.png" atomically:YES];
|
|
|
|
101
|
+
|
|
|
|
102
|
+ // 或者直接使用
|
|
|
|
103
|
+ // UIImage *image = [UIImage imageWithData:imageData];
|
|
|
|
104
|
+ }
|
|
|
|
105
|
+ }];
|
|
|
|
106
|
+
|
|
|
|
107
|
+ // 启动任务
|
|
|
|
108
|
+ [task resume];
|
|
|
|
109
|
+
|
|
|
|
110
|
+
|
|
|
|
111
|
+ });
|
|
|
|
112
|
+
|
|
|
|
113
|
+ // WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
114
|
+ // WWKMessageImageAttachment *attachment = [[WWKMessageImageAttachment alloc] init];
|
|
|
|
115
|
+ // attachment.filename = @"icon.jpg";
|
|
|
|
116
|
+ // attachment.path = [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"jpg"];
|
|
|
|
117
|
+ // // NSURL *imageURL = [NSURL URLWithString:@"http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png"];
|
|
|
|
118
|
+ // // //下载图片
|
|
|
|
119
|
+ // // NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
120
|
+ // // attachment.data = data;
|
|
|
|
121
|
+ // req.attachment = attachment;
|
|
|
|
122
|
+ // [WWKApi sendReq:req];
|
|
71
|
|
123
|
|
|
72
|
}
|
124
|
}
|
|
73
|
|
125
|
|
|
74
|
|
126
|
|
|
75
|
- (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
|
127
|
- (void)shareMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)result {
|
|
76
|
|
128
|
|
|
77
|
- WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
78
|
- WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
79
|
- attachment.userName = @"gh_487873d353b3@app"; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
80
|
- attachment.path = @"pages/customer/index.html?id=563971&hasInvitation=1&hasSellerShare=1&uid=7035";
|
|
|
|
81
|
-// attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bg_error" ofType:@"png"]], 1.0f);
|
|
|
|
82
|
- NSString *hdImageData = call.arguments[@"hdImageData"];
|
|
|
|
83
|
- NSURL *imageURL = [NSURL URLWithString:hdImageData];
|
|
|
|
84
|
- //下载图片
|
|
|
|
85
|
- NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
86
|
- attachment.hdImageData = data;
|
|
|
|
87
|
- // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"]], 1.0f);
|
|
|
|
88
|
- attachment.title = @"您预订的长安大排档总店(测试),已经安排,点击查看详情";
|
|
|
|
89
|
- req.attachment = attachment;
|
|
|
|
90
|
- [WWKApi sendReq:req];
|
|
|
|
91
|
- authResult = result;
|
|
|
|
92
|
-
|
|
|
|
93
|
- // dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
|
|
|
|
94
|
- // dispatch_async(globalQueue, ^{
|
|
|
|
95
|
- // NSString *hdImageData = call.arguments[@"hdImageData"];
|
|
|
|
96
|
- // NSURL *imageURL = [NSURL URLWithString:hdImageData];
|
|
|
|
97
|
- // //下载图片
|
|
|
|
98
|
- // NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
99
|
- // dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
100
|
- // WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
101
|
- // WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
102
|
- // attachment.userName = call.arguments[@"userName"]; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
103
|
- // attachment.path = call.arguments[@"path"];
|
|
|
|
104
|
-
|
|
|
|
105
|
- // attachment.hdImageData = data;
|
|
|
|
106
|
- // // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"]], 1.0f);
|
|
|
|
107
|
- // attachment.title = call.arguments[@"title"];
|
|
|
|
108
|
- // req.attachment = attachment;
|
|
|
|
109
|
- // [WWKApi sendReq:req];
|
|
|
|
110
|
- // // result([NSString stringWithFormat:@"%hhd",[WWKApi sendReq:req]);
|
|
|
|
111
|
-
|
|
|
|
112
|
-
|
|
|
|
113
|
- // });
|
|
|
|
114
|
-
|
|
|
|
115
|
- // });
|
129
|
+// WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
130
|
+// WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
131
|
+// attachment.userName = @"gh_487873d353b3@app"; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
132
|
+// attachment.path = @"pages/customer/index.html?id=563971&hasInvitation=1&hasSellerShare=1&uid=7035";
|
|
|
|
133
|
+// // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"bg_error" ofType:@"png"]], 1.0f);
|
|
|
|
134
|
+// NSString *hdImageData = call.arguments[@"hdImageData"];
|
|
|
|
135
|
+// NSURL *imageURL = [NSURL URLWithString:hdImageData];
|
|
|
|
136
|
+// //下载图片
|
|
|
|
137
|
+// NSData *data= [NSData dataWithContentsOfURL:imageURL];
|
|
|
|
138
|
+// attachment.hdImageData = data;
|
|
|
|
139
|
+// // attachment.hdImageData = UIImageJPEGRepresentation([UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"jpg"]], 1.0f);
|
|
|
|
140
|
+// attachment.title = @"您预订的长安大排档总店(测试),已经安排,点击查看详情";
|
|
|
|
141
|
+// req.attachment = attachment;
|
|
|
|
142
|
+// [WWKApi sendReq:req];
|
|
|
|
143
|
+// authResult = result;
|
|
|
|
144
|
+
|
|
|
|
145
|
+ dispatch_queue_t globalQueue = dispatch_get_global_queue(0, 0);
|
|
|
|
146
|
+ dispatch_async(globalQueue, ^{
|
|
|
|
147
|
+
|
|
|
|
148
|
+
|
|
|
|
149
|
+ // 使用NSURLSession异步请求网络图片
|
|
|
|
150
|
+ NSURL *imageURL = [NSURL URLWithString:call.arguments[@"hdImageData"]];
|
|
|
|
151
|
+ NSURLRequest *request = [NSURLRequest requestWithURL:imageURL];
|
|
|
|
152
|
+
|
|
|
|
153
|
+ // 创建URLSession并开始任务
|
|
|
|
154
|
+ NSURLSession *session = [NSURLSession sharedSession];
|
|
|
|
155
|
+ NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:
|
|
|
|
156
|
+ ^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
|
|
|
157
|
+ if (error) {
|
|
|
|
158
|
+ // 处理错误
|
|
|
|
159
|
+ NSLog(@"Error: %@", error);
|
|
|
|
160
|
+ } else {
|
|
|
|
161
|
+ // 成功获取数据,转换为NSData
|
|
|
|
162
|
+ NSData *imageData = data;
|
|
|
|
163
|
+
|
|
|
|
164
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
165
|
+
|
|
|
|
166
|
+
|
|
|
|
167
|
+ WWKSendMessageReq *req = [[WWKSendMessageReq alloc] init];
|
|
|
|
168
|
+ WWKMessageMiniAppAttachment *attachment = [[WWKMessageMiniAppAttachment alloc] init];
|
|
|
|
169
|
+ attachment.userName = call.arguments[@"userName"]; //必须是应用关联的小程序,注意要有@app后缀
|
|
|
|
170
|
+ attachment.path = call.arguments[@"path"];
|
|
|
|
171
|
+ attachment.hdImageData =imageData;
|
|
|
|
172
|
+
|
|
|
|
173
|
+ attachment.title = call.arguments[@"title"];
|
|
|
|
174
|
+ req.attachment = attachment;
|
|
|
|
175
|
+ [WWKApi sendReq:req];
|
|
|
|
176
|
+ authResult = result;
|
|
|
|
177
|
+
|
|
|
|
178
|
+ });
|
|
|
|
179
|
+
|
|
|
|
180
|
+ }}];
|
|
|
|
181
|
+
|
|
|
|
182
|
+
|
|
|
|
183
|
+ // 启动任务
|
|
|
|
184
|
+ [task resume];
|
|
|
|
185
|
+
|
|
|
|
186
|
+
|
|
|
|
187
|
+ });
|
|
116
|
|
188
|
|
|
117
|
|
189
|
|
|
118
|
|
190
|
|
|
@@ -176,7 +248,7 @@ FlutterMethodChannel *channel; |
|
@@ -176,7 +248,7 @@ FlutterMethodChannel *channel; |
|
176
|
NSString *corpId = call.arguments[@"corpId"]; // 第三方App所属企业的ID
|
248
|
NSString *corpId = call.arguments[@"corpId"]; // 第三方App所属企业的ID
|
|
177
|
NSString *agentId = call.arguments[@"agentId"]; // 第三方App在企业内部的ID
|
249
|
NSString *agentId = call.arguments[@"agentId"]; // 第三方App在企业内部的ID
|
|
178
|
// BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink];
|
250
|
// BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink];
|
|
179
|
- BOOL isWWKRegistered = [WWKApi registerApp:@"wwauthbdca186ec4257973000006" corpId:@"wwbdca186ec4257973" agentId:@"1000006"];
|
251
|
+ BOOL isWWKRegistered = [WWKApi registerApp:scheme corpId:corpId agentId:agentId];
|
|
180
|
result(@(isWWKRegistered));
|
252
|
result(@(isWWKRegistered));
|
|
181
|
// result(@(isWeChatRegistered));
|
253
|
// result(@(isWeChatRegistered));
|
|
182
|
}
|
254
|
}
|
|
@@ -236,17 +308,12 @@ FlutterMethodChannel *channel; |
|
@@ -236,17 +308,12 @@ FlutterMethodChannel *channel; |
|
236
|
authResult(mDic);
|
308
|
authResult(mDic);
|
|
237
|
// [channel invokeMethod:@"auth" arguments:mDic];
|
309
|
// [channel invokeMethod:@"auth" arguments:mDic];
|
|
238
|
}else if([resp isKindOfClass:[WWKSendMessageResp class]]){
|
310
|
}else if([resp isKindOfClass:[WWKSendMessageResp class]]){
|
|
239
|
-// WWKSendMessageResp *r = (WWKSendMessageResp *)resp;
|
|
|
|
240
|
-// NSMutableDictionary *mDic = [[NSMutableDictionary alloc]init];
|
|
|
|
241
|
-// if([self isBlankString:[NSString stringWithFormat:@"%d",r.errCode]]){
|
|
|
|
242
|
-// [mDic setObject:@"1" forKey:@"errCode"];
|
|
|
|
243
|
-// [mDic setObject:@"" forKey:@"code"];
|
|
|
|
244
|
-// }else{
|
|
|
|
245
|
-// [mDic setObject:@"0" forKey:@"errCode"];
|
|
|
|
246
|
-// [mDic setObject:r.errStr forKey:@"code"];
|
|
|
|
247
|
-// }
|
|
|
|
248
|
-// [mDic setObject:r.errStr forKey:@"errStr"];
|
|
|
|
249
|
-// authResult(mDic);
|
311
|
+
|
|
|
|
312
|
+ // NSMutableDictionary *mDic = [[NSMutableDictionary alloc]init];
|
|
|
|
313
|
+
|
|
|
|
314
|
+ // [mDic setObject:[NSString stringWithFormat:@"%@",resp.errStr]] forKey:@"errStr"];
|
|
|
|
315
|
+ // [mDic setObject:[NSString stringWithFormat:@"%d",resp.errCode]] forKey:@"errCode"];
|
|
|
|
316
|
+ // authResult(mDic);
|
|
250
|
}
|
317
|
}
|
|
251
|
|
318
|
|
|
252
|
}
|
319
|
}
|