通过success获取frame层的index。
然后通过cancel事件,获取子页面数据。
拿获取高德地图坐标为例:
// 显示地图,设置坐标
function showMap() {
var tmpIndex = '';
layer.open({
type: 2,
title: '获取店铺坐标与地址',
shadeClose: true,
shade: 0.8,
area: ['990px', '680px'],
content: '{$Think.config.SHOP_ADMIN_URL}/benefitShop/setAddress',
success:function (layero,index) {
tmpIndex = index;
},
cancel: function () {
// 获取子弹出层数据
var addressComponentDom =layer.getChildFrame('#addressComponent', tmpIndex);
if (addressComponentDom.val() != '') {
var addressComponentJson = JSON.parse(addressComponentDom.val());
var formattedAddress = addressComponentJson.province+addressComponentJson.city+addressComponentJson.district+addressComponentJson.township+addressComponentJson.poisName;
var lnglatDom = layer.getChildFrame('#lnglat', tmpIndex);
$("#coordinate").val(lnglatDom.val());
$("#formattedAddress").val(formattedAddress);
$("#province").val(addressComponentJson.province);
$("#city").val(addressComponentJson.city);
$("#district").val(addressComponentJson.district);
$("#address").val(addressComponentJson.township+addressComponentJson.poisName);
}
}
});
}
通过index,进入frame层,获取相关的数据,设置到主页面,然后通过表单保存到数据库。