admin/app/shop/view/public/js/style2/common.js

88 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 商品选择器
* @param callback 回调函数
* @param selectId 已选商品id
* @param params mode模式(spu、sku), max_num最大数量min_num 最小数量, is_virtual 是否虚拟 0 1, disabled: 开启禁用已选 0 1promotion营销活动标识 pintuan、groupbuy、fenxiao
*/
function goodsSelect(callback, selectId, params={}) {
layui.use(['layer'], function () {
if (selectId.length) {
params.select_id = selectId.toString();
}
params.mode = params.mode ? params.mode : 'spu';
// params.disabled = params.disabled == 0 ? 0 : 1;
var url = ns.url("shop/goods/goodsselect", params);
//iframe层-父子操作
layer.open({
title: "商品选择",
type: 2,
area: ['1000px', '720px'],
fixed: false, //不固定
btn: ['保存', '返回'],
content: url,
yes: function (index, layero) {
var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象执行iframe页的方法
iframeWin.selectGoods(function (obj) {
if (typeof callback == "string") {
try {
eval(callback + '(obj)');
layer.close(index);
} catch (e) {
console.error('回调函数' + callback + '未定义');
}
} else if (typeof callback == "function") {
callback(obj);
layer.close(index);
}
});
}
});
});
}
/**
* 店铺笔记选择器
* @param callback 回调函数
* @param selectId 已选笔记id
* @param params modemin_num 最小数量
*/
function notesSelect(callback, selectId, params) {
layui.use(['layer'], function () {
if (selectId.length) {
params.select_id = selectId.toString();
}
var url = ns.url("notes://shop/notes/notesSelect", params);
//iframe层-父子操作
layer.open({
title: "店铺笔记选择",
type: 2,
area: ['1000px', '720px'],
fixed: false, //不固定
btn: ['保存', '返回'],
content: url,
yes: function (index, layero) {
var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象执行iframe页的方法
iframeWin.selectNotes(function (obj) {
if (typeof callback == "string") {
try {
eval(callback + '(obj)');
layer.close(index);
} catch (e) {
console.error('回调函数' + callback + '未定义');
}
} else if (typeof callback == "function") {
callback(obj);
layer.close(index);
}
});
}
});
});
}