unionShare.js
6.23 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
import { API_HOST, SERVICE_HOST } from '../../../../libs/config';
import { GET, POST } from '../../../../libs/request';
import {
logEvent,
YB_PAGE_OPEN_L,
YB_SHARE_PROMOTION_C,
YB_SHARE_RESULT_L,
} from '../../../../libs/analytics.js'
let app = getApp();
let PV_ID = new Date().getTime() + '';
Page({
/**
* 页面的初始数据
*/
data: {
isShowSnapshoot: false,
from_page_name: '',
from_page_param: '',
current_page_name: 'unionShare',
current_page_param: '',
sourceType: 'product_union',
snapshootShareData: {},
shareCommand: '',
content: '',
shortUrl: '',
rebateContent: '',
contentSwitch: true,
contentShow: false,
user_union_type_imageUrl: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let timestamp = options.timestamp;
let from_page_name = options.page_name;
let from_page_param = options.page_param;
let sourceType = 'product_union';
let value = wx.getStorageSync(timestamp);
try {
wx.setStorageSync(timestamp, null);//清除内存
} catch (e) {
}
if (from_page_name == 'productDetail') {
sourceType = 'product_union'
} else if (from_page_name == 'goodsList' || from_page_name == 'search') {
sourceType = 'list_union'
} else if (from_page_name == 'webview') {
sourceType = 'h5_union'
}
let user_union_type_imageUrl = app.globalData.user_union_type_imageUrl;
this.setData({
from_page_name,
from_page_param,
sourceType,
snapshootShareData: value,
user_union_type_imageUrl,
})
console.log(this.data.snapshootShareData);
this.getShareCodeInfo();
var pages = getCurrentPages()
var currentPage = pages[pages.length - 1]
var url = currentPage.route
let params = {
PAGE_NAME: this.data.current_page_name,
PAGE_PARAM: this.data.current_page_param,
FROM_PAGE_NAME: this.data.from_page_name,
FROM_PAGE_PARAM: this.data.from_page_param,
PV_ID: PV_ID,
PAGE_PATH: url
};
logEvent(YB_PAGE_OPEN_L, params);
},
onShareAppMessage: function (res) {
let params = {
PAGE_PATH: this.data.snapshootShareData.sharePath,
SHARE_TYPE: 1,
};
logEvent(YB_SHARE_PROMOTION_C, params);
let param = {
FROM: res.from,
SHARE_RESUIL: 0,
TITLE: '创建推广',
DESC: this.data.snapshootShareData.content,
PATH: this.data.snapshootShareData.sharePath,
SHARE_TYPE: 1,
}
return {
title: this.data.snapshootShareData.title, // 分享标题
imageUrl: this.data.snapshootShareData.default_image,
desc: this.data.snapshootShareData.content, // 分享描述
path: this.data.snapshootShareData.sharePath, // 分享路径
success: function (res) {
param.SHARE_RESUIL = 1
logEvent(YB_SHARE_RESULT_L, param);
},
fail: function (res) {
param.SHARE_RESUIL = 2
logEvent(YB_SHARE_RESULT_L, param);
}
}
},
getShareCodeInfo: function(){
let gender = app.globalData.selectedChannel == 'boy' ? '1,3' : '2,3';
let type = 1;
if (this.data.from_page_name == 'productDetail') {
type = 1;
} else if (this.data.from_page_name == 'webview') {
type = 2;
} else if (this.data.from_page_name == 'goodsList' || this.data.from_page_name == 'search') {
type = 3;
}
let param = {
method: 'app.union.shareOrder.getShareCodeInfo',
unionType: app.globalData.user_union_type,
type,
skn: type == 1 && this.data.snapshootShareData && this.data.snapshootShareData.product_skn? this.data.snapshootShareData.product_skn: '',
shareId: type == 2 && this.data.snapshootShareData && this.data.snapshootShareData.shareId ? this.data.snapshootShareData.shareId : '',
msort: type == 3 && this.data.snapshootShareData && this.data.snapshootShareData.msort ? this.data.snapshootShareData.msort : '',
misort: type == 3 && this.data.snapshootShareData && this.data.snapshootShareData.misort ? this.data.snapshootShareData.misort : '',
gender,
query: type == 3 && this.data.snapshootShareData && this.data.snapshootShareData.query ? this.data.snapshootShareData.query : '',
title: this.data.snapshootShareData ? this.data.snapshootShareData.title: '',
}
if (this.data.from_page_name == 'goodsList'){
param.actiontype = 1;
param.title = this.data.snapshootShareData.goodListName;
} else if (this.data.from_page_name == 'search') {
param.title = this.data.snapshootShareData.keyword;
}
if (this.data.from_page_name == 'goodsList' && this.data.snapshootShareData.sort) {
param.sort = this.data.snapshootShareData.sort;
}
let that = this;
GET(API_HOST, param)
.then(data => {
if (data.code == 200) {
let shareCommand = data.data.shareCommand ? data.data.shareCommand : '';
let content = data.data.content ? data.data.content : '';
let shortUrl = data.data.shortUrl;
let rebateContent = data.data.rebateContent;
let contentSwitch = data.data.contentSwitch;
that.setData({
shareCommand,
content,
shortUrl,
rebateContent,
contentSwitch,
contentShow: true,
});
}
})
.catch(error => {
// console.log(error)
});
},
sharePicture: function () {
this.setData({
isShowSnapshoot: true,
});
let params = {
PAGE_PATH: this.data.snapshootShareData.sharePath,
SHARE_TYPE: 2,
};
logEvent(YB_SHARE_PROMOTION_C, params);
},
save: function() {
wx.setClipboardData({
data: this.data.content,
success: function (res) {
},
})
let params = {
PAGE_PATH: this.data.snapshootShareData.sharePath,
SHARE_TYPE: 3,
};
logEvent(YB_SHARE_PROMOTION_C, params);
},
lookDetail: function () {
wx.navigateTo({
url: '../../../../pages/webview/webview?url=' + 'https://activity.yoho.cn/feature/2213.html?title=说明详情',
})
},
bindInput: function(e){
let value = e.detail.value;
this.setData({
content: value
})
},
hiddenSheet: function(){
this.setData({
isShowSnapshoot: false
})
},
})