fs-alipay-ad-component 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/LICENSE +22 -0
- package/README.md +92 -0
- package/es/.DS_Store +0 -0
- package/es/api/generator/api.js +2498 -0
- package/es/api/generator/base.js +47 -0
- package/es/api/generator/common.js +225 -0
- package/es/api/generator/configuration.js +94 -0
- package/es/api/generator/index.js +17 -0
- package/es/config/index.js +33 -0
- package/es/index/index.acss +0 -0
- package/es/index/index.axml +8 -0
- package/es/index/index.js +203 -0
- package/es/index/index.json +3 -0
- package/es/utils/aliApi.js +49 -0
- package/es/utils/constant.js +142 -0
- package/es/utils/http.js +141 -0
- package/es/utils/logger.js +32 -0
- package/es/utils/slsTracker.js +33 -0
- package/es/utils/utils.js +69 -0
- package/package.json +70 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
|
|
2
|
+
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* 广告客户端-2023
|
|
7
|
+
* www.adcomeon.com
|
|
8
|
+
*
|
|
9
|
+
* The version of the OpenAPI document: 1.0.0
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
13
|
+
* https://openapi-generator.tech
|
|
14
|
+
* Do not edit the class manually.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
export var BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @export
|
|
23
|
+
*/
|
|
24
|
+
export var COLLECTION_FORMATS = {
|
|
25
|
+
csv: ",",
|
|
26
|
+
ssv: " ",
|
|
27
|
+
tsv: "\t",
|
|
28
|
+
pipes: "|"
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
* @class RequiredError
|
|
35
|
+
* @extends {Error}
|
|
36
|
+
*/
|
|
37
|
+
export var RequiredError = /*#__PURE__*/function (_Error) {
|
|
38
|
+
_inheritsLoose(RequiredError, _Error);
|
|
39
|
+
function RequiredError(field, msg) {
|
|
40
|
+
var _this;
|
|
41
|
+
_this = _Error.call(this, msg) || this;
|
|
42
|
+
_this.field = field;
|
|
43
|
+
_this.name = "RequiredError";
|
|
44
|
+
return _this;
|
|
45
|
+
}
|
|
46
|
+
return RequiredError;
|
|
47
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
|
+
/* tslint:disable */
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
/**
|
|
9
|
+
* 广告客户端-2023
|
|
10
|
+
* www.adcomeon.com
|
|
11
|
+
*
|
|
12
|
+
* The version of the OpenAPI document: 1.0.0
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
16
|
+
* https://openapi-generator.tech
|
|
17
|
+
* Do not edit the class manually.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
|
|
22
|
+
import { RequiredError } from './base';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
*/
|
|
28
|
+
export var DUMMY_BASE_URL = 'https://example.com';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @throws {RequiredError}
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export var assertParamExists = function assertParamExists(functionName, paramName, paramValue) {
|
|
36
|
+
if (paramValue === null || paramValue === undefined) {
|
|
37
|
+
throw new RequiredError(paramName, "Required parameter " + paramName + " was null or undefined when calling " + functionName + ".");
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @export
|
|
44
|
+
*/
|
|
45
|
+
export var setApiKeyToObject = /*#__PURE__*/function () {
|
|
46
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(object, keyParamName, configuration) {
|
|
47
|
+
var localVarApiKeyValue;
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!(configuration && configuration.apiKey)) {
|
|
52
|
+
_context.next = 12;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
if (!(typeof configuration.apiKey === 'function')) {
|
|
56
|
+
_context.next = 7;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
_context.next = 4;
|
|
60
|
+
return configuration.apiKey(keyParamName);
|
|
61
|
+
case 4:
|
|
62
|
+
_context.t0 = _context.sent;
|
|
63
|
+
_context.next = 10;
|
|
64
|
+
break;
|
|
65
|
+
case 7:
|
|
66
|
+
_context.next = 9;
|
|
67
|
+
return configuration.apiKey;
|
|
68
|
+
case 9:
|
|
69
|
+
_context.t0 = _context.sent;
|
|
70
|
+
case 10:
|
|
71
|
+
localVarApiKeyValue = _context.t0;
|
|
72
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
73
|
+
case 12:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context.stop();
|
|
76
|
+
}
|
|
77
|
+
}, _callee);
|
|
78
|
+
}));
|
|
79
|
+
return function setApiKeyToObject(_x, _x2, _x3) {
|
|
80
|
+
return _ref.apply(this, arguments);
|
|
81
|
+
};
|
|
82
|
+
}();
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
*
|
|
86
|
+
* @export
|
|
87
|
+
*/
|
|
88
|
+
export var setBasicAuthToObject = function setBasicAuthToObject(object, configuration) {
|
|
89
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
90
|
+
object["auth"] = {
|
|
91
|
+
username: configuration.username,
|
|
92
|
+
password: configuration.password
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @export
|
|
100
|
+
*/
|
|
101
|
+
export var setBearerAuthToObject = /*#__PURE__*/function () {
|
|
102
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(object, configuration) {
|
|
103
|
+
var accessToken;
|
|
104
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
105
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
if (!(configuration && configuration.accessToken)) {
|
|
108
|
+
_context2.next = 12;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (!(typeof configuration.accessToken === 'function')) {
|
|
112
|
+
_context2.next = 7;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
_context2.next = 4;
|
|
116
|
+
return configuration.accessToken();
|
|
117
|
+
case 4:
|
|
118
|
+
_context2.t0 = _context2.sent;
|
|
119
|
+
_context2.next = 10;
|
|
120
|
+
break;
|
|
121
|
+
case 7:
|
|
122
|
+
_context2.next = 9;
|
|
123
|
+
return configuration.accessToken;
|
|
124
|
+
case 9:
|
|
125
|
+
_context2.t0 = _context2.sent;
|
|
126
|
+
case 10:
|
|
127
|
+
accessToken = _context2.t0;
|
|
128
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
129
|
+
case 12:
|
|
130
|
+
case "end":
|
|
131
|
+
return _context2.stop();
|
|
132
|
+
}
|
|
133
|
+
}, _callee2);
|
|
134
|
+
}));
|
|
135
|
+
return function setBearerAuthToObject(_x4, _x5) {
|
|
136
|
+
return _ref2.apply(this, arguments);
|
|
137
|
+
};
|
|
138
|
+
}();
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
*
|
|
142
|
+
* @export
|
|
143
|
+
*/
|
|
144
|
+
export var setOAuthToObject = /*#__PURE__*/function () {
|
|
145
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(object, name, scopes, configuration) {
|
|
146
|
+
var localVarAccessTokenValue;
|
|
147
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
148
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
149
|
+
case 0:
|
|
150
|
+
if (!(configuration && configuration.accessToken)) {
|
|
151
|
+
_context3.next = 12;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
if (!(typeof configuration.accessToken === 'function')) {
|
|
155
|
+
_context3.next = 7;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
_context3.next = 4;
|
|
159
|
+
return configuration.accessToken(name, scopes);
|
|
160
|
+
case 4:
|
|
161
|
+
_context3.t0 = _context3.sent;
|
|
162
|
+
_context3.next = 10;
|
|
163
|
+
break;
|
|
164
|
+
case 7:
|
|
165
|
+
_context3.next = 9;
|
|
166
|
+
return configuration.accessToken;
|
|
167
|
+
case 9:
|
|
168
|
+
_context3.t0 = _context3.sent;
|
|
169
|
+
case 10:
|
|
170
|
+
localVarAccessTokenValue = _context3.t0;
|
|
171
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
172
|
+
case 12:
|
|
173
|
+
case "end":
|
|
174
|
+
return _context3.stop();
|
|
175
|
+
}
|
|
176
|
+
}, _callee3);
|
|
177
|
+
}));
|
|
178
|
+
return function setOAuthToObject(_x6, _x7, _x8, _x9) {
|
|
179
|
+
return _ref3.apply(this, arguments);
|
|
180
|
+
};
|
|
181
|
+
}();
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
*
|
|
185
|
+
* @export
|
|
186
|
+
*/
|
|
187
|
+
export var setSearchParams = function setSearchParams(url) {
|
|
188
|
+
var searchParams = new URLSearchParams(url.search);
|
|
189
|
+
for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
190
|
+
objects[_key - 1] = arguments[_key];
|
|
191
|
+
}
|
|
192
|
+
for (var _i = 0, _objects = objects; _i < _objects.length; _i++) {
|
|
193
|
+
var object = _objects[_i];
|
|
194
|
+
for (var key in object) {
|
|
195
|
+
if (Array.isArray(object[key])) {
|
|
196
|
+
searchParams["delete"](key);
|
|
197
|
+
for (var _iterator = _createForOfIteratorHelperLoose(object[key]), _step; !(_step = _iterator()).done;) {
|
|
198
|
+
var item = _step.value;
|
|
199
|
+
searchParams.append(key, item);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
searchParams.set(key, object[key]);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
url.search = searchParams.toString();
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* @export
|
|
212
|
+
*/
|
|
213
|
+
export var serializeDataIfNeeded = function serializeDataIfNeeded(value, requestOptions, configuration) {
|
|
214
|
+
var nonString = typeof value !== 'string';
|
|
215
|
+
var needsSerialization = nonString && configuration && configuration.isJsonMime ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString;
|
|
216
|
+
return needsSerialization ? JSON.stringify(value !== undefined ? value : {}) : value || "";
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
*
|
|
221
|
+
* @export
|
|
222
|
+
*/
|
|
223
|
+
export var toPathString = function toPathString(url) {
|
|
224
|
+
return url.pathname + url.search + url.hash;
|
|
225
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* 广告客户端-2023
|
|
5
|
+
* www.adcomeon.com
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export var Configuration = /*#__PURE__*/function () {
|
|
16
|
+
/**
|
|
17
|
+
* parameter for apiKey security
|
|
18
|
+
* @param name security name
|
|
19
|
+
* @memberof Configuration
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* parameter for basic security
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @memberof Configuration
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* parameter for basic security
|
|
31
|
+
*
|
|
32
|
+
* @type {string}
|
|
33
|
+
* @memberof Configuration
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* parameter for oauth2 security
|
|
38
|
+
* @param name security name
|
|
39
|
+
* @param scopes oauth2 scope
|
|
40
|
+
* @memberof Configuration
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* override base path
|
|
45
|
+
*
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @memberof Configuration
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* base options for axios calls
|
|
52
|
+
*
|
|
53
|
+
* @type {any}
|
|
54
|
+
* @memberof Configuration
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The FormData constructor that will be used to create multipart form data
|
|
59
|
+
* requests. You can inject this here so that execution environments that
|
|
60
|
+
* do not support the FormData class can still run the generated client.
|
|
61
|
+
*
|
|
62
|
+
* @type {new () => FormData}
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
function Configuration(param) {
|
|
66
|
+
if (param === void 0) {
|
|
67
|
+
param = {};
|
|
68
|
+
}
|
|
69
|
+
this.apiKey = param.apiKey;
|
|
70
|
+
this.username = param.username;
|
|
71
|
+
this.password = param.password;
|
|
72
|
+
this.accessToken = param.accessToken;
|
|
73
|
+
this.basePath = param.basePath;
|
|
74
|
+
this.baseOptions = param.baseOptions;
|
|
75
|
+
this.formDataCtor = param.formDataCtor;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Check if the given MIME is a JSON MIME.
|
|
80
|
+
* JSON MIME examples:
|
|
81
|
+
* application/json
|
|
82
|
+
* application/json; charset=UTF8
|
|
83
|
+
* APPLICATION/JSON
|
|
84
|
+
* application/vnd.company+json
|
|
85
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
86
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
87
|
+
*/
|
|
88
|
+
var _proto = Configuration.prototype;
|
|
89
|
+
_proto.isJsonMime = function isJsonMime(mime) {
|
|
90
|
+
var jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
91
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
92
|
+
};
|
|
93
|
+
return Configuration;
|
|
94
|
+
}();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* 广告客户端-2023
|
|
5
|
+
* www.adcomeon.com
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { DefaultApiFetch } from "./api";
|
|
16
|
+
export default DefaultApiFetch;
|
|
17
|
+
export * from "./api";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
export var OSS_URL = 'https://fs-ad-web-resources.oss-cn-hangzhou.aliyuncs.com/mina';
|
|
3
|
+
export var MOCK_URL = 'http://127.0.0.1:4523/mock/1080865/'; // mock地址
|
|
4
|
+
|
|
5
|
+
export default function getEnv() {
|
|
6
|
+
// 环境变量类型,值为:test、beta、prod
|
|
7
|
+
var ENVIRONMENT_TYPE = 'prod';
|
|
8
|
+
var XCXVERSION = '0.0.1'; // 组件版本号
|
|
9
|
+
var APP_ID = "fs-alipay-ad-component-" + ENVIRONMENT_TYPE;
|
|
10
|
+
var environmentObj = {
|
|
11
|
+
test: {
|
|
12
|
+
ALI_LOG_PROJECT_NAME: 'fshows-ecs-pro',
|
|
13
|
+
ALI_LOG_SEEDS_STORE: 'web-ad-consumer-log',
|
|
14
|
+
REQUEST_URL: 'http://advertising-test.adcomeon.com/api'
|
|
15
|
+
},
|
|
16
|
+
beta: {
|
|
17
|
+
XCXVERSION: XCXVERSION,
|
|
18
|
+
ALI_LOG_PROJECT_NAME: 'fshows-ecs-pro',
|
|
19
|
+
ALI_LOG_SEEDS_STORE: 'web-ad-consumer-log',
|
|
20
|
+
REQUEST_URL: 'https://advertising-beta.adcomeon.com/api'
|
|
21
|
+
},
|
|
22
|
+
prod: {
|
|
23
|
+
ALI_LOG_PROJECT_NAME: 'fshows-ecs-pro',
|
|
24
|
+
ALI_LOG_SEEDS_STORE: 'web-ad-admin-bsite-log',
|
|
25
|
+
REQUEST_URL: 'https://advertising.adcomeon.com/api'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
return _extends({}, environmentObj[ENVIRONMENT_TYPE], {
|
|
29
|
+
XCXVERSION: XCXVERSION,
|
|
30
|
+
APP_ID: APP_ID,
|
|
31
|
+
ENVIRONMENT_TYPE: ENVIRONMENT_TYPE // 正式站
|
|
32
|
+
});
|
|
33
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Descripttion:
|
|
3
|
+
* @Author: guoxt
|
|
4
|
+
* @Date: 2022-04-15 17:01:37
|
|
5
|
+
* @LastEditors: guoxt
|
|
6
|
+
* @LastEditTime: 2023-08-30 16:51
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ACTION_TYPE, TRACKER, AD_TYPE_ID, MEDIA_ID, DEFAULT_PRE_INFO } from '../utils/constant';
|
|
10
|
+
import { getRandomString } from '../utils/utils';
|
|
11
|
+
import { aliShowToast, aliNavigateToMiniProgram } from '../utils/aliApi';
|
|
12
|
+
import tracker from '../utils/slsTracker';
|
|
13
|
+
import { DefaultApiFetch } from '../api/generator/api';
|
|
14
|
+
Component({
|
|
15
|
+
data: {
|
|
16
|
+
AD_TYPE_ID: AD_TYPE_ID,
|
|
17
|
+
innerOrderId: '',
|
|
18
|
+
showAdDom: false,
|
|
19
|
+
// 是否展示广告组件
|
|
20
|
+
adInfo: {},
|
|
21
|
+
// 广告信息
|
|
22
|
+
adPreconditionInfo: DEFAULT_PRE_INFO // 广告前置信息
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
props: {
|
|
26
|
+
orderId: '',
|
|
27
|
+
// 订单号
|
|
28
|
+
openId: '',
|
|
29
|
+
// 用户openId
|
|
30
|
+
flowMasterId: '',
|
|
31
|
+
// 流量主标识
|
|
32
|
+
clientSession: '',
|
|
33
|
+
// 小程序clientSession字段(付呗自用)
|
|
34
|
+
fubeiUser: {},
|
|
35
|
+
// 付呗自用
|
|
36
|
+
minaVersion: '',
|
|
37
|
+
// 宿主小程序版本号
|
|
38
|
+
onAdInfoReady: function onAdInfoReady() {}
|
|
39
|
+
},
|
|
40
|
+
didMount: function didMount() {
|
|
41
|
+
var _this$props = this.props,
|
|
42
|
+
openId = _this$props.openId,
|
|
43
|
+
flowMasterId = _this$props.flowMasterId;
|
|
44
|
+
if (!openId || !flowMasterId) {
|
|
45
|
+
aliShowToast('缺少必传参数');
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.initData();
|
|
49
|
+
tracker.trackerEvent('支付宝广告组件加载', TRACKER.attached);
|
|
50
|
+
this.getAdData();
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
/**
|
|
54
|
+
* @function 初始化数据
|
|
55
|
+
*/
|
|
56
|
+
initData: function initData() {
|
|
57
|
+
var _this$props2 = this.props,
|
|
58
|
+
openId = _this$props2.openId,
|
|
59
|
+
flowMasterId = _this$props2.flowMasterId,
|
|
60
|
+
orderId = _this$props2.orderId,
|
|
61
|
+
clientSession = _this$props2.clientSession,
|
|
62
|
+
minaVersion = _this$props2.minaVersion;
|
|
63
|
+
this.setData({
|
|
64
|
+
innerOrderId: orderId || getRandomString()
|
|
65
|
+
});
|
|
66
|
+
// 挂载全局变量
|
|
67
|
+
my._AgentData = {
|
|
68
|
+
flowMasterId: flowMasterId,
|
|
69
|
+
openId: openId,
|
|
70
|
+
minaVersion: minaVersion,
|
|
71
|
+
orderId: this.data.innerOrderId,
|
|
72
|
+
clientSession: clientSession || getRandomString()
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* @function 获取广告数据
|
|
77
|
+
*/
|
|
78
|
+
getAdData: function getAdData() {
|
|
79
|
+
var _this = this;
|
|
80
|
+
// 获取广告前置信息
|
|
81
|
+
this.getAdPrecondition().then(function () {
|
|
82
|
+
// 获取广告信息
|
|
83
|
+
_this.getAdInfo();
|
|
84
|
+
})["catch"](function () {
|
|
85
|
+
// 获取广告信息
|
|
86
|
+
_this.getAdInfo();
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* @function 获取广告前置信息
|
|
91
|
+
*/
|
|
92
|
+
getAdPrecondition: function getAdPrecondition() {
|
|
93
|
+
var _this2 = this;
|
|
94
|
+
var params = {};
|
|
95
|
+
params.orderId = this.data.innerOrderId;
|
|
96
|
+
if (this.props.fubeiUser.merchantId) {
|
|
97
|
+
params.merchantId = this.props.fubeiUser.merchantId;
|
|
98
|
+
}
|
|
99
|
+
if (this.props.fubeiUser.storeId) {
|
|
100
|
+
params.storeId = this.props.fubeiUser.storeId;
|
|
101
|
+
}
|
|
102
|
+
return DefaultApiFetch.adClientGetAdPreconditionPost(params).then(function (res) {
|
|
103
|
+
_this2.setData({
|
|
104
|
+
adPreconditionInfo: res
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* @function 获取广告信息
|
|
110
|
+
*/
|
|
111
|
+
getAdInfo: function getAdInfo() {
|
|
112
|
+
var _this3 = this;
|
|
113
|
+
var _this$data = this.data,
|
|
114
|
+
_this$data$adPrecondi = _this$data.adPreconditionInfo,
|
|
115
|
+
agent = _this$data$adPrecondi.agent,
|
|
116
|
+
area = _this$data$adPrecondi.area,
|
|
117
|
+
industry = _this$data$adPrecondi.industry,
|
|
118
|
+
mobile = _this$data$adPrecondi.mobile,
|
|
119
|
+
innerOrderId = _this$data.innerOrderId;
|
|
120
|
+
var _this$props3 = this.props,
|
|
121
|
+
flowMasterId = _this$props3.flowMasterId,
|
|
122
|
+
openId = _this$props3.openId;
|
|
123
|
+
return DefaultApiFetch.adClientGetAdInfoPost({
|
|
124
|
+
openId: openId,
|
|
125
|
+
flowMasterId: flowMasterId,
|
|
126
|
+
agent: agent,
|
|
127
|
+
area: area,
|
|
128
|
+
industry: industry,
|
|
129
|
+
mobile: mobile,
|
|
130
|
+
orderId: innerOrderId,
|
|
131
|
+
mediaId: MEDIA_ID.alipayMina
|
|
132
|
+
}).then(function (res) {
|
|
133
|
+
if (res) {
|
|
134
|
+
_this3.setData({
|
|
135
|
+
adInfo: res
|
|
136
|
+
});
|
|
137
|
+
_this3.props.onAdInfoReady();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* @function 展示广告,曝光上报
|
|
143
|
+
* @description 外部调用showAd方法,展示广告
|
|
144
|
+
*/
|
|
145
|
+
showAd: function showAd() {
|
|
146
|
+
this.handleShowAd();
|
|
147
|
+
this.handleExposureDataReport();
|
|
148
|
+
},
|
|
149
|
+
/**
|
|
150
|
+
* @function 展示广告
|
|
151
|
+
*/
|
|
152
|
+
handleShowAd: function handleShowAd() {
|
|
153
|
+
this.setData({
|
|
154
|
+
showAdDom: true
|
|
155
|
+
});
|
|
156
|
+
// 小程序广告直接跳转
|
|
157
|
+
var typeId = this.data.adInfo.typeId;
|
|
158
|
+
if (typeId === AD_TYPE_ID.minaAd) {
|
|
159
|
+
this.callAlipay();
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* @function 唤起支付宝小程序
|
|
164
|
+
* @author by
|
|
165
|
+
*/
|
|
166
|
+
callAlipay: function callAlipay() {
|
|
167
|
+
var _this$data$adInfo$cre = this.data.adInfo.creativeList[0],
|
|
168
|
+
appid = _this$data$adInfo$cre.appid,
|
|
169
|
+
pagePath = _this$data$adInfo$cre.pagePath,
|
|
170
|
+
queryObj = _this$data$adInfo$cre.queryObj;
|
|
171
|
+
aliNavigateToMiniProgram({
|
|
172
|
+
appId: appid,
|
|
173
|
+
path: pagePath,
|
|
174
|
+
query: JSON.parse(queryObj)
|
|
175
|
+
}).then(function () {
|
|
176
|
+
tracker.trackerEvent('支付宝小程序广告-跳转小程序成功', TRACKER[AD_TYPE_ID.minaAd].linkMiniprogramSuccess);
|
|
177
|
+
})["catch"](function () {
|
|
178
|
+
tracker.trackerEvent('支付宝小程序广告-跳转小程序失败', TRACKER[AD_TYPE_ID.minaAd].linkMiniprogramFailed);
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* @function 曝光上报
|
|
183
|
+
*/
|
|
184
|
+
handleExposureDataReport: function handleExposureDataReport() {
|
|
185
|
+
var adInfo = this.data.adInfo;
|
|
186
|
+
var openId = this.props.openId;
|
|
187
|
+
var _this$data$adPrecondi2 = this.data.adPreconditionInfo,
|
|
188
|
+
agent = _this$data$adPrecondi2.agent,
|
|
189
|
+
area = _this$data$adPrecondi2.area,
|
|
190
|
+
industry = _this$data$adPrecondi2.industry,
|
|
191
|
+
mobile = _this$data$adPrecondi2.mobile;
|
|
192
|
+
DefaultApiFetch.adClientDataReportPost({
|
|
193
|
+
openId: openId,
|
|
194
|
+
actionType: ACTION_TYPE.exposure,
|
|
195
|
+
baseData: adInfo,
|
|
196
|
+
areaData: area,
|
|
197
|
+
mobileData: mobile,
|
|
198
|
+
agentData: agent,
|
|
199
|
+
industryData: industry
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
/*
|
|
3
|
+
* @Descripttion:
|
|
4
|
+
* @Author: baiyang
|
|
5
|
+
* @Date: 2022-04-20 11:53:19
|
|
6
|
+
* @LastEditors: guoxt
|
|
7
|
+
* @LastEditTime: 2023-02-28 10:24
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import logger from './logger';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @function 提示
|
|
14
|
+
* @param {string} text
|
|
15
|
+
* @param {number} time
|
|
16
|
+
* @author: by
|
|
17
|
+
*/
|
|
18
|
+
export var aliShowToast = function aliShowToast(text, time) {
|
|
19
|
+
if (time === void 0) {
|
|
20
|
+
time = 1000;
|
|
21
|
+
}
|
|
22
|
+
return my.showToast({
|
|
23
|
+
content: text,
|
|
24
|
+
duration: time
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export function aliNavigateToMiniProgram(_ref) {
|
|
28
|
+
var appId = _ref.appId,
|
|
29
|
+
path = _ref.path,
|
|
30
|
+
query = _ref.query,
|
|
31
|
+
_ref$extraData = _ref.extraData,
|
|
32
|
+
extraData = _ref$extraData === void 0 ? {} : _ref$extraData;
|
|
33
|
+
return new Promise(function (resolve, reject) {
|
|
34
|
+
my.navigateToMiniProgram({
|
|
35
|
+
appId: appId,
|
|
36
|
+
path: path,
|
|
37
|
+
query: query,
|
|
38
|
+
extraData: extraData,
|
|
39
|
+
success: function success(res) {
|
|
40
|
+
resolve(res);
|
|
41
|
+
logger.info("\u8DF3\u8F6C\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\u6210\u529F:appId=" + appId + ",path=" + path + ",query=" + JSON.stringify(query));
|
|
42
|
+
},
|
|
43
|
+
fail: function fail(res) {
|
|
44
|
+
reject(res);
|
|
45
|
+
logger.error("\u8DF3\u8F6C\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\u5931\u8D25:appId=" + appId + ",path=" + path + ",query=" + JSON.stringify(query) + ",error=" + JSON.stringify(res));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|