Sanakey
2020-10-20 0da8db73585b015a7bbaf3500b77142d41b7c2ff
提交 | 用户 | age
d98d05 1 // pages/authorize/authorize.js
S 2 import {Http} from "../../utils/http-p.js";
3
4 const Request = new Http();
5 let app = getApp();
6 let url = 'isTab';
0da8db 7 let selectedCartIds = '';
d98d05 8 Page({
S 9
10   /**
11    * 页面的初始数据
12    */
13   data: {},
14
15   /**
16    * 生命周期函数--监听页面加载
17    */
18   onLoad: function (options) {
19     let fromPage = options.fromPage || ''
20     if (fromPage == 'cart') {
21       url = 'normal'
0da8db 22       selectedCartIds = options.selectedCartIds;
d98d05 23     } else{
S 24       url = 'isTab'
25     }
26
27     Request.request({
28       url: '/wx/getCardUserInfo.do',
29       data: {
30         FromUserId: app.globalData.FromUserId
31       }
32     }).then((res) => {
33       console.log(res);
34       this.setData({
35         UserId: res.UserId,
36         Name: res.Name
37       });
38     });
39   },
40   goBack(e){
41     console.log('电话与头像授权完成',e)
42     wx.navigateBack({
43       delta: 0,
44     })
45   },
46
47   getPhoneNumber(e) {
48     console.log('getPhoneNumber', e);
49
50     if (e.detail.phoneNumber.errMsg == 'getPhoneNumber:ok') {
51       Request.request({
52         url: '/shopping/account.do',
53         data: {
54           m: 'telRegByAutoReg',
55           ReferralsCode: this.data.UserId,
56           ReferralsName: this.data.Name,
57           encryptedData: e.detail.phoneNumber.encryptedData,
58           iv: e.detail.phoneNumber.iv,
59           SessionKey: app.globalData.SessionKey
60         }
61       }).then((res) => {
62         console.log('/shopping/account.do', res);
63         if (res.cltcode) {
64           app.globalData.Cltcode = res.cltcode;
65           app.globalData.ReferralsName = res.ReferralsName;
66           if(url=='isTab'){
67             wx.switchTab({
68               url: '../user/user'
69             })
70           } else{
71             wx.redirectTo({
0da8db 72               url: '../order/order?selectedCartIds='+selectedCartIds
d98d05 73             })
S 74           }
75         }
76       });
77     } else{
78       console.log('取消授权');
79       wx.showToast({
80         title: '取消授权',
81         icon: 'none',
82         duration: 1000
83       });
84       // wx.switchTab({
85       //   url: url
86       // });
87     }
88
89
90
91   },
92   /**
93    * 生命周期函数--监听页面初次渲染完成
94    */
95   onReady: function () {
96
97   },
98
99   /**
100    * 生命周期函数--监听页面显示
101    */
102   onShow: function () {
103
104   },
105
106   /**
107    * 生命周期函数--监听页面隐藏
108    */
109   onHide: function () {
110
111   },
112
113   /**
114    * 生命周期函数--监听页面卸载
115    */
116   onUnload: function () {
117
118   },
119
120   /**
121    * 页面相关事件处理函数--监听用户下拉动作
122    */
123   onPullDownRefresh: function () {
124
125   },
126
127   /**
128    * 页面上拉触底事件的处理函数
129    */
130   onReachBottom: function () {
131
132   },
133
134 });