future пре 1 година
родитељ
комит
4ba4cc46c0
1 измењених фајлова са 38 додато и 0 уклоњено
  1. 38 0
      xs-app/framework/sdkUtil.ts

+ 38 - 0
xs-app/framework/sdkUtil.ts

@@ -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;
+		}
+	}
+}