Commit 0f19752e1c538b90699039bc7cc395130d993b8c
1 parent
13e85312
绑定手机
Showing
4 changed files
with
193 additions
and
0 deletions
pages/getphone/getphone.js
0 → 100644
1 | +var t = require("../../utils/common.js");var os=getApp().globalData.setting; | |
2 | +Page({ | |
3 | + data:{ | |
4 | + store:null, | |
5 | + imghots: os.imghost, | |
6 | + }, | |
7 | + | |
8 | + onLoad: function (options) { | |
9 | + //--判断是否有接受到邀请人的ID-- | |
10 | + if(options.first_leader){ | |
11 | + this.setData({first_leader:options.first_leader}); | |
12 | + } | |
13 | + }, | |
14 | + onShow:function(){ | |
15 | + var th=this,app = getApp(); | |
16 | + var sessionKey = getApp().globalData.sessionKey; | |
17 | + var openid = getApp().globalData.openid; | |
18 | + | |
19 | + if (openid == "" || openid == null) { | |
20 | + | |
21 | + if (getApp().globalData.userInfo) | |
22 | + openid = getApp().globalData.userInfo.weapp_openid; | |
23 | + } | |
24 | + var r = getApp().globalData.getu; | |
25 | + | |
26 | + if (openid == "" || openid == null || r==null ){ | |
27 | + getApp().globalData.user_id=null; | |
28 | + getApp().globalData.userInfo=null; | |
29 | + console.log("openid"); | |
30 | + wx.navigateTo({ url: '/pages/togoin/togoin', }) | |
31 | + return false; | |
32 | + } | |
33 | + var user_info=getApp().globalData.userInfo; | |
34 | + console.log("getphone"); | |
35 | + | |
36 | + if(user_info!=null && user_info.mobile!=undefined && user_info.mobile!="" && user_info.mobile!=null){ | |
37 | + wx.navigateBack({ | |
38 | + delta: 1 | |
39 | + }) | |
40 | + } | |
41 | + | |
42 | + app.getConfig(function(e){ | |
43 | + th.setData({ store:e}); | |
44 | + }) | |
45 | + }, | |
46 | + | |
47 | + getphone: function(e) { | |
48 | + var that = this; | |
49 | + var app=getApp(),a=app; | |
50 | + //此处授权得到userInfo | |
51 | + console.log("getphone"); | |
52 | + | |
53 | + e=e.detail; | |
54 | + console.log(e); | |
55 | + //接下来写业务代码登录 | |
56 | + //最后,记得返回刚才的页面 | |
57 | + if (e.encryptedData==undefined){ | |
58 | + /*--- | |
59 | + wx.navigateTo({ | |
60 | + url: '/pages/user/binding_info/binding_info', | |
61 | + })--*/ | |
62 | + return app.my_warnning("登录需要授权手机号码!", 0, that); | |
63 | + return false; | |
64 | + } | |
65 | + var r=getApp().globalData.getu; | |
66 | + var sessionKey = getApp().globalData.sessionKey; | |
67 | + var openid = getApp().globalData.openid; | |
68 | + | |
69 | + console.log(sessionKey,openid); | |
70 | + that.save_the_data(r,e,sessionKey,openid) | |
71 | + | |
72 | + }, | |
73 | + | |
74 | + save_the_data:function (r,e,sessionKey,openid) { | |
75 | + var app=getApp(),a=app,th=this; | |
76 | + var dd = { | |
77 | + oauth: "miniapp", | |
78 | + nickname: r.nickName, | |
79 | + head_pic: r.avatarUrl, | |
80 | + sex: r.gender, | |
81 | + terminal: "miniapp", | |
82 | + sessionKey: sessionKey, | |
83 | + openid:openid, | |
84 | + encryptedData: e.encryptedData, | |
85 | + iv: e.iv, | |
86 | + store_id: getApp().globalData.setting.stoid, | |
87 | + }; | |
88 | + //--如果有邀请人的时候-- | |
89 | + if(th.data.first_leader){ | |
90 | + dd.first_leader=th.data.first_leader; | |
91 | + } | |
92 | + | |
93 | + console.log(dd); | |
94 | + app.request.get("/api/weshop/users/thirdLogin", { | |
95 | + data: dd, | |
96 | + success: function (e) { | |
97 | + console.log("thirdLogin"); | |
98 | + console.log(e); | |
99 | + if (e.data.code == 0) { | |
100 | + app.globalData.user_id = e.data.data.user_id; | |
101 | + } else { | |
102 | + return app.showWarning("授权登入失败!"+e.data.msg); | |
103 | + } | |
104 | + | |
105 | + wx.setStorageSync("userinfo",e.data.data); | |
106 | + wx.setStorageSync("isAuth", !0), app.globalData.userInfo = e.data.data, app.globalData.userInfo.head_pic = t.getFullUrl(a.globalData.userInfo.head_pic); | |
107 | + wx.navigateBack({ delta: 1}) | |
108 | + | |
109 | + }, | |
110 | + failStatus: function (t) { | |
111 | + /*--- | |
112 | + return "100" === t.data.result ? (i.goHome(), wx.navigateTo({ | |
113 | + url: "/pages/user/binding_info/binding_info?nickName=" + r.nickName + "&userHeadPic=" + r.avatarUrl | |
114 | + }), !1) : (i.clearAuth(), i.alertLoginErrorAndGoHome(t.data.msg), a.request.post("/api/user/logout", { | |
115 | + isShowLoading: !1, | |
116 | + data: { | |
117 | + token: a.request.getToken() | |
118 | + }, | |
119 | + failStatus: function () { | |
120 | + return !1; | |
121 | + } | |
122 | + }), !1);--*/ | |
123 | + return app.my_warnning("授权登入失败,请稍后再试!", 0, that); | |
124 | + }, | |
125 | + fail: function (t) { | |
126 | + return i.clearAuth(), i.alertLoginErrorAndGoHome(), !1; | |
127 | + } | |
128 | + }); | |
129 | + }, | |
130 | + | |
131 | + cancle_bind: function () { | |
132 | + getApp().goto('/pages/user/index/index'); | |
133 | + } | |
134 | + | |
135 | + | |
136 | + | |
137 | +}); | ... | ... |
pages/getphone/getphone.json
0 → 100644
pages/getphone/getphone.wxml
0 → 100644
1 | +<view class="all_page"> | |
2 | + <view class="content"> | |
3 | + <view><image class='logo' src="{{imghots+store.store_logo}}"> </image></view> | |
4 | + <view class="title">{{store.store_name}}</view> | |
5 | + <view>{{store.store_desc}}</view> | |
6 | + <button class="btn" open-type="getPhoneNumber" bindgetphonenumber="getphone">绑定会员</button> | |
7 | + <text class="btn2" bindtap="cancle_bind">暂不绑定</text> | |
8 | + </view> | |
9 | +</view> | |
10 | +<warn id="warn"></warn> | |
0 | 11 | \ No newline at end of file | ... | ... |
pages/getphone/getphone.wxss
0 → 100644
1 | +.all_page{ | |
2 | + position: fixed; | |
3 | + height: 100%; | |
4 | + width: 100%; | |
5 | + background: #fff; | |
6 | + justify-content: center;/*水平居中*/ | |
7 | +} | |
8 | +.all_page .content{ | |
9 | + font-size: 30rpx; | |
10 | + text-align: center; | |
11 | + height: 400px; | |
12 | + width: 100%; | |
13 | + position: absolute; | |
14 | + top: 50%; | |
15 | + margin-top:-200px; | |
16 | +} | |
17 | +.logo{width: 140rpx; height: 140rpx; border-radius:50% } | |
18 | +.all_page .content .title{ | |
19 | + font-size: 36rpx; margin: 20rpx 0 | |
20 | +} | |
21 | + | |
22 | +.all_page .btn{ | |
23 | + height: 80rpx; | |
24 | + line-height: 80rpx; | |
25 | + width: 580rpx; | |
26 | + background: #fc661f; | |
27 | + color:#fff; | |
28 | + font-size: 32rpx; | |
29 | + margin-top: 100rpx; | |
30 | + border-radius: 5rpx; | |
31 | +} | |
32 | +.all_page .btn2{ | |
33 | + height: 80rpx; | |
34 | + line-height: 80rpx; | |
35 | + width: 580rpx; | |
36 | + color:#999; | |
37 | + font-size: 32rpx; | |
38 | + border-radius: 5rpx; | |
39 | + margin-top: 10rpx; | |
40 | +} | |
0 | 41 | \ No newline at end of file | ... | ... |