diff --git a/app.js b/app.js index 27d1550..f969143 100644 --- a/app.js +++ b/app.js @@ -135,6 +135,49 @@ App({ } }) } + else { + //--拿下code-- + wx.login({ + success: function (o) { + var dd = { + js_code: o.code, + store_id: os.stoid, + }; + //-- 导购会员ID -- + if (app.globalData.guide_id) { + dd.guide_id = app.globalData.guide_id; + } + + app.request.get("/api/weshop/users/openidandkey", { + data: dd, + success: function (e) { + if (e.data.code == 0) { + //如果有会员的话,没有sessionKey + if (!e.data.data.sessionKey) { + // getApp().showWarning("登录成功"); + + app.globalData.userInfo = e.data.data; + app.globalData.user_id = e.data.data.user_id; + app.globalData.openid = e.data.data.weapp_openid; + //把会员的信息存在内存 + wx.setStorageSync("userinfo", e.data.data); + + //调用接口判断是不是会员 + app.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + e.data.data.user_id, {}).then(res => { + if (res.data.code == 0) { + app.globalData.guide_id = res.data.data.id; + app.globalData.guide_pick_id = res.data.data.pickup_id + } + }) + + + } + } + } + }) + } + }) + } // else if(app.globalData.user_id){ //-- 启用默认的user_id -- // app.promiseGet("/api/weshop/users/get/" + app.globalData.setting.stoid + "/" + app.globalData.user_id,{}).then(res=>{