// 加载图片裁切组件的 依赖. 官网 https://www.npmjs.com/package/photoclip
function loadJs(src) {
  return new Promise((resolve, reject) => {
    let sc = document.createElement('script');
    sc.src = src;
    document.querySelector('body').appendChild(sc);
    sc.onload = function() {
      // console.log('src' + src, '加载完毕');
      resolve(true);
    };
    sc.onerror = function() {
      console.log('js文件' + src, '加载失败');
      resolve(false);
    };
  });
}
export default async function importDependence() {
  const a = await loadJs('/config/dependence/iscroll-zoom-min.js');
  const b = await loadJs('/config/dependence/hammer.min.js');
  const c = await loadJs('/config/dependence/lrz.all.bundle.js');
  const d = await loadJs('/config/dependence/PhotoClip.js');
  if (a && b && c && d) {
    return new Promise((resolve, reject) => resolve(true));
  }
  return new Promise((resolve, reject) => resolve(false));
}

// export function importPhotoClip() {
//   const path = require('path').resolve(__dirname, '');
//   const path1 = window.location.origin + path + '/photoClip/iscroll-zoom-min.js';
//   const path2 = window.location.origin + path + '/photoClip/hammer.min.js';
//   const path3 = window.location.origin + path + '/photoClip/lrz.all.bundle.js';
//   const path4 = window.location.origin + path + '/photoClip/PhotoClip.js';
//   const a = require('./js/iscroll-zoom-min.js');
//   console.log(a);
// }
