function e(e, t, s) {
    return t in e ? Object.defineProperty(e, t, {
        value: s,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = s, e;
}

function t(e, t) {
    if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});
var s = function() {
    function e(e, t) {
        for (var s = 0; s < t.length; s++) {
            var a = t[s];
            a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), 
            Object.defineProperty(e, a.key, a);
        }
    }
    return function(t, s, a) {
        return s && e(t.prototype, s), a && e(t, a), t;
    };
}(), a = function() {
    function a(s, i, n) {
        t(this, a), this.page = s, this.options = n, this.address = {}, this.currentArea = 0;
        var r = this;
        this.page.openRegionsModal = function(e) {
            r.openRegionsModal(e);
        }, this.page.closeRegionsModal = function() {
            r.closeRegionsModal();
        }, this.dataName = i, this.page.setData(e({}, i, {}));
    }
    return s(a, [ {
        key: "openRegionsModal",
        value: function(t) {
            this.page.setData({
                disabled:1
            });
            var s = this, a = t.currentTarget.dataset.id, i = t.currentTarget.dataset.name;        
            isNaN(parseInt(a)) || !parseInt(a) ? (a = 0, this.currentArea = 0) : (0 == this.currentArea ? (this.address.province_name = i, 
            this.address.province = a, this.address.city_name = "", this.address.city = 0, this.address.district_name = "", 
            this.address.district = 0, this.address.twon_name = "", this.address.twon = 0) : 1 == this.currentArea ? (this.address.city_name = i, 
            this.address.city = a) : 2 == this.currentArea ? (this.address.district_name = i, 
            this.address.district = a) : 3 == this.currentArea && (this.address.twon_name = i, 
            this.address.twon = a), this.currentArea++), "function" == typeof this.options.selectCall && this.options.selectCall(t, a, i, this.address), 
              this.currentArea !== this.options.endAreaLevel ? 
              getApp().request.get("/api/weshop/region/page", {
                data: {
                    parent_id: a,
                    pageSize:1000
                },
                success: function(t) {
                    t.data.data.pageData && t.data.data.pageData.length > 0 ? s.page.setData(e({}, s.dataName, {
                        regions: t.data.data.pageData,
                        showRegionsModal: !0
                    })) : s.endCall(a, i);
                }
            }) : this.endCall(a, i);
        }
    }, {
        key: "closeRegionsModal",
        value: function() {
            this.page.setData({disabled:0});
            this.page.setData(e({}, this.dataName, {
                showCategoryModal: !1
            }));
        }
    }, {
        key: "endCall",
        value: function(e, t) {
            this.closeRegionsModal(), "function" == typeof this.options.endAreaLevelCall && this.options.endAreaLevelCall(e, t, this.address);
        }
    } ]), a;
}();

exports.default = a;