import * as dd from 'dingtalk-jsapi';
export function getCode() {
  return new Promise((resolve, reject) => {
    let corpId = 'ding3d771cecb9f68bfe35c2f4657eb6378f';
    if (dd.env.platform !== "notInDingTalk") {
      dd.ready(() => {
        dd.runtime.permission.requestAuthCode({
          corpId: corpId,
          onSuccess: (info) => {
          	resolve(info.code)
          },
          onFail: (err) => {
            alert(JSON.stringify(err));
            reject(err);
          },
        });
      });
    } else {
      reject(new Error('Not in DingTalk environment'));
    }
  });
}
