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

var t = require("util.js");

module.exports = {
    app: function() {
        return getApp();
    },

    //------------获取全路径的图片地址-----------
    getFullUrl: function(e) {
       if(e==undefined || e=="") return "";
       if(e.indexOf("http")!=-1) return e;
       e=this.app().globalData.setting.imghost + e;
       return e;
    },
    getConfigByName: function(e, t, r) {
        for (var a = 0; a < e.length; a++) if (e[a].name === t && (void 0 === r || void 0 !== r && e[a].inc_type === r)) return e[a].value;
        return console.warn(t), console.warn(e), null;
    },
   
    //--------跳转到支付页面--------
    jumpToCart4: function(e, r) {
        var a = {
            order_sn: e.order_sn,
            order_amount: e.order_amount
        };

        //t=1正常单  2组合单
        if(e.type==1){ a.type=1; }
        e.master_order_sn && (a.master_order_sn = e.master_order_sn);
        var n = "/pages/cart/cart4/cart4?" + t.Obj2Str(a);
        r ? wx.redirectTo({
            url: n
        }) : wx.navigateTo({
            url: n
        });
    },
    getCapache: function() {
        return this.app().request.modifyUrl("/api/user/verify?is_image=1&t=" + Date.parse(new Date()));
    },
    wxParseAddFullImageUrl: function(t, r) {
        if (void 0 !== t.data[r].images) {
            for (var a = t.data[r], n = 0; n < a.images.length; n++) a.images[n].attr.src = this.getFullUrl(a.images[n].attr.src), 
            a.imageUrls[n] = this.getFullUrl(a.imageUrls[n]);
            console.log(a), t.setData(e({}, r, a));
        }
    },
    sendSmsCode: function(e, t, r) {
        a = this;
        if (!e) return a.app().showWarning("手机号码不能为空");
        void 0 !== t && null !== t || (t = 6);
        var a = this;
        this.app().request.post("/home/api/send_validate_code", {
            data: {
                mobile: e,
                scene: t,
                type: "mobile"
            },
            success: function(e) {
                "function" == typeof r && r(), a.app().confirmBox(e.data.msg);
            }
        });
    },
    sendBindSmsCode: function(e, t) {
        r = this;
        if (!e) return r.app().showWarning("手机号码不能为空");
        var r = this;
        this.app().request.post("/home/api/send_validate_code", {
            data: {
                mobile: e,
                scene: "1",
                type: "user_reg"
            },
            success: function(e) {
                "function" == typeof t && t(), r.app().confirmBox(e.data.msg);
            }
        });
    }
};