common.js
3.36 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
import USERAPI from '~/api/usersApi/index'
import environment from '~/utils/request/environment'
import ActivityApi from '~/api/activityApi/index'
const taskLoginAndRegister = (query, callBack) => {
if (!query) return callBack && callBack()
const options = { ...query, ...query.options }
delete options.options
console.log(options);
if (options.merchantId) {
const sessionId = wx.$storage.get('sessionId')
if (!sessionId) {
let para = {
merchantId: options.merchantId,
type: 1,
pages: options.pages
}
let temp = encodeURIComponent(JSON.stringify(para))
wx.navigateTo({
url: '/packageStoreAssistant/packageAuth/pages/authentication/register/register?data=' + temp,
});
} else {
const USERINFO = wx.$storage.get('userInfo')
if (USERINFO.merchantId == options.merchantId) {
USERAPI.checkSession().then(({
code
}) => {
if (code == '0') {
callBack && callBack()
} else {
wx.$router.reLaunch('/packageStoreAssistant/packageAuth/pages/authentication/login/login', options)
}
})
} else {
let para = {
merchantId: options.merchantId,
type: 1,
pages: options.pages
}
let temp = encodeURIComponent(JSON.stringify(para))
wx.navigateTo({
url: '/packageStoreAssistant/packageAuth/pages/authentication/register/register?data=' + temp,
});
}
}
} else {
callBack && callBack()
}
}
const authAvatarAndNickName = () => {
const {
domain,
index
} = environment,
redirectUrl = `${domain}/wx-oauth`,
// redirectUrl = 'http://scrm.dev.glsx.com.cn/wx-oauth',
// 云商 wx1cf40dc91c28a7fd ,glsxtest02 wx56bed167ad463f70
appid = index == 1 || index == 2 ? 'wx1cf40dc91c28a7fd' : 'wx56bed167ad463f70',
wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
console.log(redirectUrl, appid)
wx.navigateTo({
url: `/pages/webView/webView?url=${encodeURIComponent(wxUrl)}`,
})
}
const handlerMiss = (data, query, callBack) => {
if (!data) return
if (!query) return
let { pageNum, orginList, serviceType, listName } = query
data.data && data.data.forEach((val, index) => {
val.tabType = serviceType
val.isCollapse = true
val.startTime = val.startTime.split(' ')[0]
val.endTime = val.endTime.split(' ')[0]
})
const RESULT = {
[listName]: pageNum == 1 ? data.data : [...orginList, ...data.data],
activeTrigger: false,
total: data.count,
noResult: pageNum == 1 ? (data.data.length ? false : true) : false
}
callBack && callBack(RESULT)
}
const calenderFilter = (arr, length) => {
var _arr = []
while (arr.length) {
_arr.push(arr.splice(0, length))
}
return _arr
}
module.exports = {
taskLoginAndRegister,
authAvatarAndNickName,
handlerMiss
}