index.js 2.81 KB
function o(o) {
    return o && o.__esModule ? o : {
        default: o
    };
}

var e = o(require("../../utils/restapi.js")), n = o(require("./service.js")), t = getApp();

Page({
    data: {
        agree: !1,
        protocol: !0,
        service: n.default
    },
    noScroll: function() {},
    showProtocol: function(e) {
        // this.setData({
        //     protocol: !1
        // });
        let id = e.currentTarget.dataset.id;
        let url = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/html/privacy.html'
        if(id == 'agreement'){
            url = 'https://img01.glsx.com.cn/weapp/resource/saas/scrm/html/agreement.html'
        }
        wx.navigateTo({
          url: '/pages/webpage/webpage?path=' + encodeURIComponent(url),
        })
    },
    choose: function() {
        this.setData({
            agree: !this.data.agree
        });
    },
    closeProtocol: function() {
        this.setData({
            protocol: !0
        });
    },
    agree: function() {
        this.setData({
            agree: !0,
            protocol: !0
        });
    },
    getUserInfo: function(o) {
        console.log(o);
        var e = this;
        o.detail.userInfo && wx.getUserInfo({
            withCredentials: !0,
            lang: "zh_CN",
            success: function(o) {
                console.log("授权:", o), e.data.gender = o.userInfo.gender, wx.checkSession({
                    success: function() {
                        e.authUserInfo(o);
                    },
                    fail: function() {
                        wx.login({
                            success: function(n) {
                                t.globalData.code = n.code, e.authUserInfo(o);
                            }
                        });
                    }
                });
            },
            fail: function(o) {
                console.log(o);
            }
        });
    },
    authUserInfo: function(o) {
        var n = t.globalData.sceneData, a = this;
        o.code = t.globalData.code, o.appId = t.globalData.appId, o.gender = a.data.gender, 
        o.sceneUrl = n.path, n.query.employeeId && (o.sceneParam = n.query.employeeId), 
        e.default.authUserInfo(o, function(o) {
            console.log("授权用户信息登录", o), 0 == o.returnCode ? wx.redirectTo({
                url: "../login/index/index"
            }) : wx.showToast({
                title: o.message,
                icon: "none"
            });
        }, function() {
            wx.showToast({
                title: "授权用户信息失败",
                icon: "none"
            });
        });
    },
    onLoad: function(o) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});