智莺生活APP的阿里百川 Flutter 插件
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

README.md 6.5 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <!--
  2. * @Description:
  3. * @Author: wuxing
  4. * @Date: 2019-08-28 21:00:18
  5. * @LastEditors: wuxing
  6. * @LastEditTime: 2019-11-21 21:34:22
  7. -->
  8. # flutter_alibc
  9. Flutter版本的阿里百川
  10. android V4.0.0.8版本
  11. ios V4.0.1.6 版本
  12. pub地址:[flutter_alibc](https://pub.dev/packages/flutter_alibc)
  13. github地址:[flutter_alibc](https://github.com/FlutterTaoBaoKe/flutter_alibc.git)
  14. 可以给个star🐴,混口饭吃
  15. 支持Android和iOS
  16. 邮箱:
  17. Android:983598009@qq.com
  18. iOS:329106954@qq.com
  19. P.S:另有开普勒插件[flutter_kepler](https://github.com/FlutterTaoBaoKe/flutter_kepler)
  20. ## Getting Started
  21. ### 工程性配置
  22. 参考[阿里百川官网](https://baichuan.taobao.com/docs/doc.htm?spm=a3c0d.7629140.0.0.3043be48zxxuk5&treeId=129&articleId=118102&docType=1)
  23. ### 引入
  24. [如何引入项目](https://pub.dev/packages/flutter_alibc#-installing-tab-)
  25. iOS请在podfile文件非注释的第一行,加入淘宝源,如果有其他源,请放在其他源下方,没有其他源只需要加这一个即可
  26. ```
  27. source 'http://repo.baichuan-ios.taobao.com/baichuanSDK/AliBCSpecs.git'
  28. ```
  29. 看不懂这句话就看下demo中的example/ios/podfile文件第4行代码,第3行是其他源的示例可以不加
  30. ### 支持swift了
  31. ### 感谢[@a4081675](https://github.com/a4081675)同学
  32. [issues44](https://github.com/FlutterTaoBaoKe/flutter_alibc/issues/44)
  33. ### 方法说明
  34. * 头文件引入
  35. ```
  36. import 'package:flutter_alibc/flutter_alibc.dart';
  37. ```
  38. * 初始化
  39. ```
  40. /**
  41. * 初始化
  42. * version:当前app版本
  43. * appName:当前app名称
  44. * result:{
  45. * errorCode, //0为初始化成功,其他为失败
  46. * errorMessage, //message
  47. * }
  48. */
  49. var result = await FlutterAlibc.initAlibc(version:"",appName:"");
  50. ```
  51. * 登录淘宝
  52. ```
  53. /**
  54. * 登录淘宝
  55. * version:当前app版本
  56. * appName:当前app名称
  57. * result:{
  58. * errorCode, //0为初始化成功,其他为失败
  59. * errorMessage, //message
  60. * data:{ //登录成功的情况下返回data,为用户数据
  61. * //nick 用户昵称,avatarUrl 头像地址
  62. * nick,avatarUrl,openId,openSid,topAccessToken,topAuthCode
  63. * }
  64. * }
  65. * 备注:登录过会直接返回淘宝用户的信息,不会多次唤醒淘宝,请放心
  66. */
  67. var result = await FlutterAlibc.loginTaoBao();
  68. ```
  69. * 淘宝登出
  70. ```
  71. FlutterAlibc.loginOut();
  72. ```
  73. * 淘客登录,二次授权获取access_token
  74. ```
  75. /**
  76. * @description: 获取access_token
  77. * @param
  78. * url:用于授权登录的url
  79. * openType:打开类型,默认auto
  80. * isNeedCustomNativeFailMode:是否需要设置唤端失败策略,默认false
  81. * nativeFailMode:唤端失败策略,默认None
  82. * schemeType:唤起哪个端,默认天猫
  83. * taokeParams:淘客数据
  84. * backUrl: 跳转回来的url
  85. * @return: {accessToken:""}//获取成功为token,获取失败为空字符串
  86. */
  87. var result = await FlutterAlibc.taoKeLogin(
  88. url:"", //必须参数,用于授权登录的url
  89. openType : AlibcOpenType.AlibcOpenTypeAuto,
  90. isNeedCustomNativeFailMode : false,
  91. nativeFailMode : AlibcNativeFailMode.AlibcNativeFailModeNone,
  92. schemeType : AlibcSchemeType.AlibcSchemeTmall,
  93. taokeParams : {},
  94. backUrl:"",
  95. );
  96. ```
  97. * 唤起淘宝,openByUrl方式
  98. ```
  99. /**
  100. * @description: 通过url打开,包括h5,唤起手淘等
  101. * @param
  102. * url:目标url
  103. * openType:打开类型,默认auto
  104. * isNeedCustomNativeFailMode:是否需要设置唤端失败策略,默认false
  105. * nativeFailMode:唤端失败策略,默认None
  106. * schemeType:唤起哪个端,默认天猫
  107. * taokeParams:淘客数据
  108. * backUrl: 跳转回来的url
  109. * @return: {
  110. * errorCode,
  111. * errorMessage,
  112. * type, //0为添加购物车,1为付款成功
  113. * payResult, //type为1时返回
  114. * }
  115. */
  116. var result = await FlutterAlibc.openByUrl(
  117. url:"", //必须参数
  118. openType : AlibcOpenType.AlibcOpenTypeAuto,
  119. isNeedCustomNativeFailMode : false,
  120. nativeFailMode : AlibcNativeFailMode.AlibcNativeFailModeNone,
  121. schemeType : AlibcSchemeType.AlibcSchemeTmall,
  122. taokeParams : {},
  123. backUrl:"",
  124. );
  125. ```
  126. * 唤起淘宝,openItemDetail方式
  127. ```
  128. /**
  129. * @description: 打开商品详情
  130. * @param
  131. * itemID 商品id,可以是真实的也可以是混淆的,必须参数
  132. * trackParam 需要额外追踪的业务数据
  133. * 其他同上
  134. * @return: 同openByUrl
  135. */
  136. var result = await FlutterAlibc.openItemDetail(
  137. itemID:"", //必须参数
  138. openType : AlibcOpenType.AlibcOpenTypeAuto,
  139. isNeedCustomNativeFailMode : false,
  140. nativeFailMode : AlibcNativeFailMode.AlibcNativeFailModeNone,
  141. schemeType : AlibcSchemeType.AlibcSchemeTmall,
  142. taokeParams : {},
  143. trackParam : {}, //需要额外追踪的业务数据
  144. backUrl:"",
  145. );
  146. ```
  147. * 打开店铺,openShop方式
  148. ```
  149. /**
  150. * @description: 打开店铺
  151. * @param
  152. * shopId 店铺id,必须参数
  153. * 其他同上
  154. * @return: 同openByUrl
  155. */
  156. var result = await FlutterAlibc.openShop(
  157. shopId:"", //必须参数
  158. openType : AlibcOpenType.AlibcOpenTypeAuto,
  159. isNeedCustomNativeFailMode : false,
  160. nativeFailMode : AlibcNativeFailMode.AlibcNativeFailModeNone,
  161. schemeType : AlibcSchemeType.AlibcSchemeTmall,
  162. taokeParams : {},
  163. trackParam : {}, //需要额外追踪的业务数据
  164. backUrl:"",
  165. );
  166. ```
  167. * 打开购物车,openCart方式
  168. ```
  169. /**
  170. * @description: 打开购物车
  171. * @param
  172. * 无必须参数
  173. * 其他同上
  174. * @return: 同openByUrl
  175. */
  176. var result = await FlutterAlibc.openCart(
  177. openType : AlibcOpenType.AlibcOpenTypeAuto,
  178. isNeedCustomNativeFailMode : false,
  179. nativeFailMode : AlibcNativeFailMode.AlibcNativeFailModeNone,
  180. schemeType : AlibcSchemeType.AlibcSchemeTmall,
  181. taokeParams : {},
  182. trackParam : {}, //需要额外追踪的业务数据
  183. backUrl:"",
  184. );
  185. ```
  186. * 是否设置同步打点
  187. ```
  188. FlutterAlibc.syncForTaoke(true);
  189. ````
  190. * 是否使用Native Alipay
  191. ```
  192. FlutterAlibc.useAlipayNative(true);
  193. ```