|
@@ -0,0 +1,38 @@
|
|
|
+import { config } from "../config/config"
|
|
|
+import { log } from "./log"
|
|
|
+import { tools } from "./tools"
|
|
|
+
|
|
|
+export class sdkUtil {
|
|
|
+
|
|
|
+ public static login(cb) {
|
|
|
+ switch (tools.platform){
|
|
|
+ case config.Platform.H5:
|
|
|
+ cb && cb('')
|
|
|
+ break
|
|
|
+ case config.Platform.WEIXIN:
|
|
|
+ wx.login({
|
|
|
+ success(res) {
|
|
|
+ let code = res.code
|
|
|
+ log.Debug("wx_code",code)
|
|
|
+ cb && cb(code)
|
|
|
+ },
|
|
|
+ fail(e) { log.Debug(`tt_login 调用失败:`,e) }
|
|
|
+ })
|
|
|
+ break;
|
|
|
+ case config.Platform.TOUTIAO:
|
|
|
+ tt.login({
|
|
|
+ force: true,
|
|
|
+ success(res) {
|
|
|
+ let code = res.code
|
|
|
+ let anonymousCode = res.anonymousCode
|
|
|
+ log.Debug("tt_code",code,anonymousCode)
|
|
|
+ cb && cb(code,anonymousCode)
|
|
|
+ },
|
|
|
+ fail(e) { log.Debug(`tt_login 调用失败:`,e) }
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|