//#import $owl_wxmessage_que:services/modelService.jsx
//#import $owlService:services/user/UserThirdUtil.jsx

var WxMessageUtil = (function () {
    var f = {
        doAddMessageQue: function (userId, template_id, page, jContent) {
            try {
                var jThirdOpenId = UserThirdUtil.getThirdOpenId("owl_user_third_openid_source_wx7a495c566f2277c0", "openid", userId);
                if (!jThirdOpenId || !jThirdOpenId.openid) {
                    //如果存在openid信息，则发送小程序订阅信息
                    $.log("WxMessageUtil...stop...openid is null...userId=" + userId + "...template_id=" + template_id);
                }

                var appid = "wx7a495c566f2277c0";

                var jMessageQue = {};
                jMessageQue.template_id = template_id;
                jMessageQue.user_id = userId;
                jMessageQue.openid = jThirdOpenId.openid;
                jMessageQue.appid = appid;
                jMessageQue.page = page;
                jMessageQue.content = JSON.stringify(jContent);

                owl_wxmessage_queService.add(jMessageQue);
                $.log("WxMessageUtil...add que ok...userId=" + userId + "...template_id=" + template_id + "...id=" + jMessageQue.id);
            } catch (e) {
                $.log("WxMessageUtil...userId=" + userId + "...template_id=" + template_id + "...id=" + jMessageQue.id + "...error=" + e);
            }
        }
    };
    return f;
})();