enter.js
1.87 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
var util = require('../../../utils/util.js')
import App from '../../../utils/api.js'
Page({
onLoad(opt){
if(util.cache('openid')){
if(opt.id && opt.share){
util.cache('lookseller',opt.id);
wx.redirectTo({
url:'../seller/menu?id='+opt.id
})
}else{
this.setData({
openid:util.cache('openid')
})
if(util.cache('lookseller')){
wx.redirectTo({
url:'../seller/menu?id='+util.cache('lookseller')
})
}else{
this.getsellerlist();
}
}
}else{
this.getopenid()
}
this.opt=opt;
},
getopenid(){
wx.login({
//获取code
success: (login_res)=>{
console.log('cc',login_res.code)
var data = {
code: login_res.code,
appid: 'wx418f1d7cdeda26c1',
}
//获取openid
App.Wechat.GetSellerOpenidByCode(data).then((json)=>{
var openid = JSON.parse(json.data[0]).openid;//返回openid
this.setData({
openid:openid
})
util.cache('openid',openid);
if(this.opt.id && this.opt.share){
wx.redirectTo({
url:'../seller/menu?id='+opt.id
})
}else{
this.getsellerlist();
}
})
},
fail:(res)=>{
console.log('dddddd',res)
}
})
},
getsellerlist(){
App.Seller.GetSystemByOpenid({openid:this.data.openid}).then((json)=>{
console.log(json)
if(json.ret==200){
if(json.data.auth==0){
wx.reLaunch({
url:'../../me/s_index'
})
}else{
if(json.data.length==1){
wx.reLaunch({
url:'../../me/s_index?sellerid='+json.data[0].seller.id
})
}else{
if(util.cache('sellerid')){
wx.reLaunch({
url:'../../me/s_index?sellerid='+util.cache('sellerid')
})
}else{
wx.reLaunch({
url:'../../currency/c_store'
})
}
}
}
}
})
},
})