c_store.js
4.34 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// pages/currency/c_store.js
var util = require('../../utils/util.js')
var uri = require('../../utils/uri.js')
import App from '../../utils/api.js'
Page({
data: {
storehidden:false,
historyhidden:true,
searchhidden:true,
isloading:false
},
onLoad: function (options) {
util.setBarTitle('选择店铺');
this.setData({
openid:util.cache('openid'),
})
this.alert=this.selectComponent('#confirmalert');
},
onShow: 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:'../login/l_login'
// })
}else{
this.setData({
sellerlist:json.data,
isloading:true
})
}
}
})
},
chooseStore:function (e) {
util.cache('role_name',e.currentTarget.dataset.rolename);
if(util.cache('e.currentTarget.dataset.nickname')!=''){
util.cache('nick_name',e.currentTarget.dataset.nickname);
}else{
wx.removeStorage({key:'nick_name'})
}
wx.reLaunch({
url:"../me/s_index?sellerid="+e.currentTarget.dataset.id
})
util.cache('identity',e.currentTarget.dataset.identity)
},
historyStore:function(e){
wx.removeStorage({key:'identity'})
util.cache('sellerid',e.currentTarget.dataset.id)
wx.reLaunch({
url:"../me/s_index?sellerid="+e.currentTarget.dataset.id
})
},
//通过openid识别当前用户身份、打开的商户信息
getInfo:function(){
util.post(uri.CGI__USER_GETSYSTEMBYOPENID,{openid:this.data.openid},uri.CGI__USER_GETSYSTEMBYOPENID__CODE)
},
showstorelist:function () {
this.setData({
storehidden:!this.data.storehidden
})
},
showhistorylist:function () {
this.setData({
historyhidden:!this.data.historyhidden
})
},
searchseller:function(e){
var inputval=e.detail.value;
if(util.removespace(inputval)!=''){
this.setData({
storehidden:true,
searchhidden:false
})
var parmsdata={
x:1,
y:5,
sign:util.removespace(inputval)
}
if(this.data.manage==2){
parmsdata.openid=this.data.openid;
}
util.post(uri.CGI_USER_GETSELLERLISTBYISADMIN,parmsdata,uri.CGI_USER_GETSELLERLISTBYISADMIN__CODE)
}else{
this.setData({
storehidden:false,
searchhidden:true
})
}
},
selectseller:function(e){
var id=e.currentTarget.dataset.id;
util.post(uri.CGI_USER_VISITLOG,{sellerid:id},uri.CGI_USER_VISITLOG__CODE);
wx.removeStorage({key:'identity'})
util.cache('sellerid',id)
this.setData({
thisid:id
})
},
//重新调起授权后,想接口获取信息
login_start:function(iv,encryptedData){
console.log(iv,encryptedData)
var that=this;
wx.login({
//获取code
success: function(login_res) {
console.log('cc',login_res.code)
var data = {
code: login_res.code,
appid: 'wx28fa5be22ae0ad55',
//secret: 'cf7059061bb79d764a9bba55d7197b12',
iv:iv,
encryptedData:encryptedData
}
//获取openid
wx.request({
url: "https://xt.colorcun.com/WechatApi/Api/dcLogin",
data: data,
header: {
'content-type': 'application/json'
},
success: function(res) {
that.loginseller();
}
})
}
})
},
getuserinfo:function(e){
console.log(e)
if(e.detail && e.detail.errMsg=='getUserInfo:ok'){
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('需要授权才能继续访问');
}
},
loginseller:function(){
wx.navigateTo({ //无商家
url:'../login/l_info'
})
},
netchange:function(){
this.onShow();
}
})