media.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // 素材
  2. function openMedia(callback, imgNum) {
  3. layui.use(['layer'], function () {
  4. layer.open({
  5. type: 2,
  6. title: '素材管理',
  7. area: ['1050px', '600px'],
  8. fixed: false, //不固定
  9. btn: ['保存', '返回'],
  10. content: ns.url("giftcard://shop/media/media?mediaIds=" + mediaIds + "&imgNum=" + imgNum),
  11. yes: function (index, layero) {
  12. var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象,执行iframe页的方法:
  13. iframeWin.getCheckItem(function (obj) {
  14. if (typeof callback == "string") {
  15. try {
  16. eval(callback + '(obj)');
  17. layer.close(index);
  18. } catch (e) {
  19. console.error('回调函数' + callback + '未定义');
  20. }
  21. } else if (typeof callback == "function") {
  22. callback(obj);
  23. layer.close(index);
  24. }
  25. });
  26. }
  27. });
  28. });
  29. }