diff --git a/pages/getphone/getphone.js b/pages/getphone/getphone.js new file mode 100644 index 0000000..d000bf6 --- /dev/null +++ b/pages/getphone/getphone.js @@ -0,0 +1,137 @@ +var t = require("../../utils/common.js");var os=getApp().globalData.setting; +Page({ + data:{ + store:null, + imghots: os.imghost, + }, + + onLoad: function (options) { + //--判断是否有接受到邀请人的ID-- + if(options.first_leader){ + this.setData({first_leader:options.first_leader}); + } + }, + onShow:function(){ + var th=this,app = getApp(); + var sessionKey = getApp().globalData.sessionKey; + var openid = getApp().globalData.openid; + + if (openid == "" || openid == null) { + + if (getApp().globalData.userInfo) + openid = getApp().globalData.userInfo.weapp_openid; + } + var r = getApp().globalData.getu; + + if (openid == "" || openid == null || r==null ){ + getApp().globalData.user_id=null; + getApp().globalData.userInfo=null; + console.log("openid"); + wx.navigateTo({ url: '/pages/togoin/togoin', }) + return false; + } + var user_info=getApp().globalData.userInfo; + console.log("getphone"); + + if(user_info!=null && user_info.mobile!=undefined && user_info.mobile!="" && user_info.mobile!=null){ + wx.navigateBack({ + delta: 1 + }) + } + + app.getConfig(function(e){ + th.setData({ store:e}); + }) + }, + + getphone: function(e) { + var that = this; + var app=getApp(),a=app; + //此处授权得到userInfo + console.log("getphone"); + + e=e.detail; + console.log(e); + //接下来写业务代码登录 + //最后,记得返回刚才的页面 + if (e.encryptedData==undefined){ + /*--- + wx.navigateTo({ + url: '/pages/user/binding_info/binding_info', + })--*/ + return app.my_warnning("登录需要授权手机号码!", 0, that); + return false; + } + var r=getApp().globalData.getu; + var sessionKey = getApp().globalData.sessionKey; + var openid = getApp().globalData.openid; + + console.log(sessionKey,openid); + that.save_the_data(r,e,sessionKey,openid) + + }, + + save_the_data:function (r,e,sessionKey,openid) { + var app=getApp(),a=app,th=this; + var dd = { + oauth: "miniapp", + nickname: r.nickName, + head_pic: r.avatarUrl, + sex: r.gender, + terminal: "miniapp", + sessionKey: sessionKey, + openid:openid, + encryptedData: e.encryptedData, + iv: e.iv, + store_id: getApp().globalData.setting.stoid, + }; + //--如果有邀请人的时候-- + if(th.data.first_leader){ + dd.first_leader=th.data.first_leader; + } + + console.log(dd); + app.request.get("/api/weshop/users/thirdLogin", { + data: dd, + success: function (e) { + console.log("thirdLogin"); + console.log(e); + if (e.data.code == 0) { + app.globalData.user_id = e.data.data.user_id; + } else { + return app.showWarning("授权登入失败!"+e.data.msg); + } + + wx.setStorageSync("userinfo",e.data.data); + wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(a.globalData.userInfo.head_pic); + wx.navigateBack({ delta: 1}) + + }, + failStatus: function (t) { + /*--- + return "100" === t.data.result ? (i.goHome(), wx.navigateTo({ + url: "/pages/user/binding_info/binding_info?nickName=" + r.nickName + "&userHeadPic=" + r.avatarUrl + }), !1) : (i.clearAuth(), i.alertLoginErrorAndGoHome(t.data.msg), a.request.post("/api/user/logout", { + isShowLoading: !1, + data: { + token: a.request.getToken() + }, + failStatus: function () { + return !1; + } + }), !1);--*/ + return app.my_warnning("授权登入失败,请稍后再试!", 0, that); + }, + fail: function (t) { + return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1; + } + }); + }, + + cancle_bind: function () { + getApp().goto('/pages/user/index/index'); + } + + + +}); diff --git a/pages/getphone/getphone.json b/pages/getphone/getphone.json new file mode 100644 index 0000000..fb13409 --- /dev/null +++ b/pages/getphone/getphone.json @@ -0,0 +1,6 @@ +{ + "navigationBarTitleText": "绑定手机", + "usingComponents": { + "warn": "/components/long_warn/long_warn" + } +} diff --git a/pages/getphone/getphone.wxml b/pages/getphone/getphone.wxml new file mode 100644 index 0000000..e511fa5 --- /dev/null +++ b/pages/getphone/getphone.wxml @@ -0,0 +1,10 @@ + + + + {{store.store_name}} + {{store.store_desc}} + + 暂不绑定 + + + \ No newline at end of file diff --git a/pages/getphone/getphone.wxss b/pages/getphone/getphone.wxss new file mode 100644 index 0000000..3756909 --- /dev/null +++ b/pages/getphone/getphone.wxss @@ -0,0 +1,40 @@ +.all_page{ + position: fixed; + height: 100%; + width: 100%; + background: #fff; + justify-content: center;/*水平居中*/ +} +.all_page .content{ + font-size: 30rpx; + text-align: center; + height: 400px; + width: 100%; + position: absolute; + top: 50%; + margin-top:-200px; +} +.logo{width: 140rpx; height: 140rpx; border-radius:50% } +.all_page .content .title{ + font-size: 36rpx; margin: 20rpx 0 +} + +.all_page .btn{ + height: 80rpx; + line-height: 80rpx; + width: 580rpx; + background: #fc661f; + color:#fff; + font-size: 32rpx; + margin-top: 100rpx; + border-radius: 5rpx; +} +.all_page .btn2{ + height: 80rpx; + line-height: 80rpx; + width: 580rpx; + color:#999; + font-size: 32rpx; + border-radius: 5rpx; + margin-top: 10rpx; +} \ No newline at end of file