promise.js
2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
import App from '../../utils/api.js'
Page({
data:{
isselect:false
},
onShow:function(){
this.alert=this.selectComponent('#confirmalert');
},
login:function(){
this.getsellerlist();
},
getsellerlist(){
App.Seller.GetSystemByOpenid({openid:this.data.openid}).then((json)=>{
console.log(json)
if(json.ret==200){
if(json.data.auth==0){
wx.navigateTo({ //无商家
url:'l_info'
})
}else{
if(json.data.length==1){
wx.redirectTo({
url:'../me/s_index?sellerid='+json.data[0].seller.id
})
}else{
wx.reLaunch({
url:'../currency/c_store'
})
}
}
}
})
},
//重新调起授权后,想接口获取信息
login_start(iv,encryptedData){
console.log(iv,encryptedData)
var that=this;
wx.login({
//获取code
success: (login_res)=>{
console.log('cc',login_res.code)
var data = {
code: login_res.code,
appid: 'wx418f1d7cdeda26c1',
iv:iv,
encryptedData:encryptedData
}
App.Wechat.WxLogin(data).then((json)=>{
if(json.ret==200){
console.log(json);
if(json.data && json.data.openid){
this.setData({
openid:json.data.openid
})
util.cache('openid',json.data.openid)
}
this.getsellerlist();
}
})
}
})
},
select:function(){
this.setData({
isselect:!this.data.isselect
})
},
getuserinfo:function(e){
console.log(e)
if(e.detail && e.detail.errMsg=='getUserInfo:ok'){
this.setData({
username:e.detail.userInfo.nickName
})
wx.setStorageSync('nickname',e.detail.userInfo.nickName)
var iv=e.detail.iv;
var encryptedData=e.detail.encryptedData;
this.login_start(iv,encryptedData)
}else{
this.alert.show('需要授权才能继续访问');
}
},
reject:function(){
let len=getCurrentPages().length;
wx.navigateBack({
delta: len
})
},
lookagree:function(){
wx.navigateTo({
url:'agreement'
})
}
})