common.js
8.52 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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',
// 嘀嘀虎服务 wxeb509497634291f1 ,glsxtest02 wx56bed167ad463f70
appid = index == 1 || index == 2 ? 'wxeb509497634291f1' : '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.list && data.list.forEach((val, index) => {
val.tabType = serviceType
val.isCollapse = true
val.startTime = val.startTime.split(' ')[0]
val.endTime = val.endTime.split(' ')[0]
// 活动中/活动未开始默认展开第一条 数据处理
// 处理不同模块的判断条件
let condition = false
let zc = val.activityStatus != 3 && index == 0 && pageNum == 1
let zc_3 = val.activityStatus == 3 && index == 0 && pageNum == 1
let pzj = val.activityStatus != 3 && index == 0
let bussinessScene = 3
if (serviceType == 0) {
condition = zc
} else {
condition = pzj
bussinessScene = 2
}
if (condition) {
val.isloading = true
ActivityApi.getActiveTaskList({ activityId: val.id, bussinessScene }, { isShowLoading: true }).then(res => {
res.forEach(a => {
a.platformMerchantMissionResponseList &&
a.platformMerchantMissionResponseList.forEach(k => {
k.detailInfo = { activityId: val.id, imgUrlList: [] }
k.platformMerchantMissionMaterialResponseList &&
k.platformMerchantMissionMaterialResponseList.forEach(i => {
// materialType 素材类型1文案 2图片 3视频 4专属链接
if (i.materialType == 1) {
// 文案
k.detailInfo.textContent = i.materialContent
}
if (i.materialType == 2 || i.materialType == 3) {
// 图片视频
k.detailInfo.imgUrlList.push({
url: i.materialContent,
type: i.materialType == 2 ? 'image' : 'video'
})
}
if (i.materialType == 4) {
// 链接
k.detailInfo.linkUrl = val.activityUrl
}
})
})
})
val.isloading = false
val.missionList = res
val.newtaskCalenderList = calenderFilter(JSON.parse(JSON.stringify(val.missionList)) || [], 7)
let d = new Date()
let nowDate = (d.getMonth() + 1).toString().padStart(2, '0') + '月' + d.getDate().toString().padStart(2, '0') + '日'
let ind = 0
val.calenderActiveIndex = 0
val.newtaskCalenderList.forEach((v, index) => {
v.forEach(k => {
k.time = (new Date(k.activityTime).getMonth() + 1).toString().padStart(2, '0') + '月' + new Date(k.activityTime).getDate().toString().padStart(2, '0') + '日'
k.ind = ind
let completeStatusNum = 0
k.platformMerchantMissionResponseList.forEach(i => {
if (i.completeStatus == 2) completeStatusNum++
})
if (nowDate == k.time) {
val.calenderActiveIndex = index
callBack && callBack({ activeDateIndex: ind })
}
// status 1过去日期任务全部完成 2过去日期任务有未完成的 3当前日期或未来日期
if (completeStatusNum == v.length && d.getTime() > new Date(`${k.activityTime.replace(/-/g, '/')} 23:59:59`).getTime()) {
k.status = 1
} else if (d.getTime() > new Date(`${k.activityTime.replace(/-/g, '/')} 23:59:59`).getTime()) {
k.status = 2
} else {
k.status = 3
}
ind++
})
})
val.isCollapse = false
let itemVal = `${listName}[${index}]`
callBack && callBack({ [itemVal]: val })
}).catch(err => {
console.log(err);
val.isloading = false
})
} else if (zc_3 && serviceType == 0) {
ActivityApi.getActivityEndInstallOrderList({ activityId: val.id }, { isShowLoading: true })
.then(res => {
val.isCollapse = false
res.orderList &&
res.orderList.forEach(it => {
it.time = it.createdDate ? new Date(it.createdDate).format('yyyy-MM-dd hh:mm') : ''
})
val.orderList = res.orderList
val.orderTotal = res.orderTotal
val.reInstallContactsName = res.reInstallContactsName
val.reInstallContactsPhone = res.reInstallContactsPhone
let itemVal = `${listName}[${index}]`
callBack && callBack({ [itemVal]: val })
})
.catch(err => {
val.isloading = false
})
}
})
const RESULT = {
[listName]: pageNum == 1 ? data.list : [...orginList, ...data.list],
activeTrigger: false,
total: data.total,
noResult: pageNum == 1 ? (data.list.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
}