Skip to content

Commit

Permalink
修改版本号为2.2.0
Browse files Browse the repository at this point in the history
### 增加功能
- 增加接口:淘宝授权、获取信息与退出
### 优化功能
- 升级安卓插件版本:3.1.1.204 --2017-9-11
- 升级IOS插件版本:3.1.1.205 --2017-09-11
  • Loading branch information
ahzmr committed Sep 17, 2017
1 parent 918098e commit 940796d
Show file tree
Hide file tree
Showing 71 changed files with 481 additions and 596 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 版本变更记录
## 2.2.0 - 2017-09-17

### 增加功能
- 增加接口:淘宝授权、获取信息与退出

### 优化功能
- 升级安卓插件版本:3.1.1.204 --2017-9-11
- 升级IOS插件版本:3.1.1.205 --2017-09-11

## 2.0.0 - 2017-09-07
### 解决Bug
- 修改IOS实现,解决导致不能微信登录的Bug

## 2.0.0 - 2017-08-26
### 增加功能
- 增加安卓插件:安卓百川版本 3.1.1.202
- 增加IOS插件:IOS百川版本 3.1.1.200
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ Cordova plugin for Baichuan SDK (阿里百川Cordova插件)

支持平台:安卓、IOS

安卓百川版本:3.1.1.202
安卓百川版本:3.1.1.204 --2017-9-11

IOS百川版本:3.1.1.200
IOS百川版本:3.1.1.205 --2017-09-11

## 使用说明

### 淘宝授权与退出

```js
Baichuan.auth(action, success, error);

/**
* action: login/getSession/logout
*/
```

### 打开淘宝内购页面

```js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-baichuan",
"version": "2.1.0",
"version": "2.2.0",
"description": "codrova/phonegap wrapper for baichuan sdk",
"scripts": {
},
Expand Down
7 changes: 3 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-baichuan"
version="2.1.0">
version="2.2.0">

<name>BaiChuanCordova</name>
<description>Cordova plugin for Baichuan</description>
Expand All @@ -13,15 +12,14 @@
<repo>https://github.com/wenin819/cordova-plugin-baichuan</repo>
<issue>https://github.com/wenin819/cordova-plugin-baichuan/issues</issue>

<preference name="APPKEY" />

<!-- js module-->
<js-module name="baichuan" src="www/baichuan.js">
<clobbers target="Baichuan"/>
</js-module>

<!-- ios -->
<platform name="ios">
<preference name="APPKEY" />
<config-file target="config.xml" parent="/*">
<feature name="BaichuanPlugin">
<param name="ios-package" value="BaichuanPlugin" />
Expand Down Expand Up @@ -64,6 +62,7 @@
<source-file src="src/ios/AppDelegate+Baichuan.m" />

<resource-file src="src/ios/libs/Resources/AlibabaAuthSDK.bundle"/>
<resource-file src="src/ios/libs/Resources/AlipaySDK.bundle"/>
<resource-file src="src/ios/libs/Resources/ALPLinkPartnerSDK.bundle"/>
<resource-file src="src/ios/libs/Resources/NBResource.bundle"/>

Expand Down
69 changes: 69 additions & 0 deletions src/android/BaichuanPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zhijianhuo.cordova.plugin;

import com.ali.auth.third.core.model.Session;
import com.alibaba.baichuan.android.trade.AlibcTrade;
import com.alibaba.baichuan.android.trade.AlibcTradeSDK;
import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback;
Expand All @@ -16,12 +17,15 @@
import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType;
import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult;
import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams;
import com.alibaba.baichuan.trade.biz.login.AlibcLogin;
import com.alibaba.baichuan.trade.biz.login.AlibcLoginCallback;
import com.alibaba.baichuan.trade.common.utils.JSONUtils;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
Expand All @@ -33,6 +37,8 @@

public class BaichuanPlugin extends CordovaPlugin {

private static final String TAG = "BaichuanPlugin";

private Boolean sdk_inited = false;

public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
Expand Down Expand Up @@ -108,6 +114,8 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
return showPage(args.getJSONObject(0), args.optJSONObject(1), args.optJSONObject(2), args.optJSONObject(3), callbackContext);
} else if ("setting".equals(action)) {
return setting(args.getJSONObject(0), callbackContext);
} else if ("auth".equals(action)) {
return auth(args.getString(0), callbackContext);
}
callbackContext.error("Invalid Action");
return false;
Expand All @@ -118,6 +126,67 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo
}
}

private boolean auth(String action, final CallbackContext callbackContext) throws JSONException {
final AlibcLogin alibcLogin = AlibcLogin.getInstance();
switch (action) {
case "login":
alibcLogin.showLogin(new AlibcLoginCallback() {
@Override
public void onSuccess(int i) {
returnSession(callbackContext);
}
@Override
public void onFailure(int i, String s) {
callbackContext.error(s);
}
});
break;
case "getSession":
returnSession(callbackContext);
break;
case "logout":
alibcLogin.logout(new AlibcLoginCallback() {
@Override
public void onSuccess(int i) {
callbackContext.success();
}

@Override
public void onFailure(int i, String s) {
callbackContext.error(s);
}
});
break;
default:
callbackContext.error("Invalid Action");
return false;
}
return true;
}

private void returnSession(CallbackContext callbackContext) {
final AlibcLogin alibcLogin = AlibcLogin.getInstance();
JSONObject jsonObject = new JSONObject();
boolean login = alibcLogin.isLogin();
try {
jsonObject.put("login", login);
if(login) {
Session session = alibcLogin.getSession();
jsonObject.put("userid", session.userid);
jsonObject.put("nick", session.nick);
jsonObject.put("avatarUrl", session.avatarUrl);
jsonObject.put("openId", session.openId);
jsonObject.put("openSid", session.openSid);
jsonObject.put("topAccessToken", session.topAccessToken);
jsonObject.put("topAuthCode", session.topAuthCode);
jsonObject.put("topExpireTime", session.topExpireTime);
}
} catch (JSONException e) {
callbackContext.error("转化数据失败,失败原因为:" + e.getMessage());
}
success(callbackContext, jsonObject);
}

private boolean setting(JSONObject settings, CallbackContext callbackContext) throws JSONException {
Iterator<String> keys = settings.keys();
for (String key; keys.hasNext(); ) {
Expand Down
19 changes: 10 additions & 9 deletions src/android/android-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ repositories {

dependencies {

// fastjson
//fastjson(以使用方接入版本为准)
compile 'com.alibaba:fastjson:1.2.9'

//支付
//支付(以支付宝官网公布的百川版本为准)
compile 'com.alibaba.alipay:alipaySingle:20160825@jar'

//登陆
compile 'com.ali.auth.sdk:alibabauth_core:1.1.4@jar'
compile 'com.ali.auth.sdk:alibabauth_ui:1.1.4@aar'
compile 'com.ali.auth.sdk:alibabauth_ext:1.1.4@jar'
compile 'com.ali.auth.sdk:alibabauth_core:1.4.3@jar'
compile 'com.ali.auth.sdk:alibabauth_ui:1.4.3@aar'
compile 'com.ali.auth.sdk:alibabauth_ext:1.4.3@jar'
//【可选】仅供特殊合作伙伴使用
compile 'com.ali.auth.sdk:alibabauth_accountlink:1.1.4@jar'

Expand All @@ -37,10 +37,11 @@ dependencies {
compile 'com.alibaba.mtl:app-monitor-sdk:2.5.1.3_for_bc_proguard@jar'

//联盟SDK
compile 'com.alimama.tunion.sdk:tuniontradesdk:0.3.0'
compile 'com.alimama.tunion.sdk:tuniontradesdk:0.3.2@aar'

//电商SDK
compile 'com.alibaba.sdk.android:alibc_trade_common:3.1.1.202'
compile 'com.alibaba.sdk.android:alibc_trade_biz:3.1.1.202'
compile 'com.alibaba.sdk.android:alibc_trade_sdk:3.1.1.202'
compile 'com.alibaba.sdk.android:alibc_trade_common:3.1.1.204'
compile 'com.alibaba.sdk.android:alibc_trade_biz:3.1.1.204'
compile 'com.alibaba.sdk.android:alibc_trade_sdk:3.1.1.204'

}
1 change: 1 addition & 0 deletions src/ios/BaichuanPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@interface BaichuanPlugin : CDVPlugin

- (void)pluginInitialize;
- (void)auth:(CDVInvokedUrlCommand *)command;
- (void)setting:(CDVInvokedUrlCommand *)command;
- (void)showPage:(CDVInvokedUrlCommand*)command;

Expand Down
44 changes: 44 additions & 0 deletions src/ios/BaichuanPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#import <Cordova/CDVInvokedUrlCommand.h>
#import "BaichuanPlugin.h"
#import "AlibabaAuthSDK.framework/Headers/ALBBSDK.h"
#import <AlibcTradeSDK/AlibcTradeSDK.h>

@implementation BaichuanPlugin
Expand Down Expand Up @@ -41,6 +42,49 @@ - (AlibcTradeTaokeParams *)getTaokeParams:(NSDictionary *)taokeArgs {
return taoKeParams;
}

- (void)auth:(CDVInvokedUrlCommand *)command {
NSString *action = [command argumentAtIndex:0];
ALBBSDK *albbsdk = [ALBBSDK sharedInstance];
if([@"login" isEqualToString:action]) {
[albbsdk auth:[self viewController] successCallback:^(ALBBSession *session) {
[self returnSession:command];
} failureCallback:^(ALBBSession *session, NSError *error) {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:error.description];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
} else if([@"getSession" isEqualToString:action]) {
[self returnSession:command];
} else if([@"logout" isEqualToString:action]) {
[albbsdk logoutWithCallback:^() {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
} else {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid Action"];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
}

- (void)returnSession:(CDVInvokedUrlCommand *)command {
ALBBSession *session = [ALBBSession sharedInstance];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
BOOL login = [session isLogin];
dict[@"login"] = @(login);
if(login) {
ALBBUser *user = [session getUser];
dict[@"nick"] = user.nick;
dict[@"avatarUrl"] = user.avatarUrl;
dict[@"openId"] = user.openId;
dict[@"openSid"] = user.openSid;
dict[@"topAccessToken"] = user.topAccessToken;
dict[@"topAuthCode"] = user.topAuthCode;
}

CDVPluginResult *pluginResult;
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

- (void)setting:(CDVInvokedUrlCommand *)command {
if (command.arguments.count < 1) {
CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"参数不正确"];
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// ALPAppShare.h
// AlibcLinkPartnerSDK
//
// Created by czp on 17/3/9.
// Copyright © 2017年 czp. All rights reserved.
//

#import <UIKit/UIKit.h>

// type定义
#define ALIBC_APPSHARE_TYPE_ID @"id"
#define ALIBC_APPSHARE_TYPE_RED @"red"
#define ALIBC_APPSHARE_TYPE_DEEP @"deep"

@interface ALPAppShare : NSObject

/**
* 写入共享的信息
* @info 具体信息(info 中内容必须是可序列化类型,参考NSKeyedArchiver)
* @type 类型
*
*/
+ (void)writeInfo:(NSDictionary*)info byType:(NSString*)type;

/**
* 删除共享的信息
* @type 类型
*/
+ (void)removeInfoByType:(NSString*)type;

/**
* 读取共享信息
* @type 类型
* @return 具体信息
*/
+ (NSDictionary*)readInfoByType:(NSString*)type;

@end

This file was deleted.

Loading

0 comments on commit 940796d

Please sign in to comment.