mkfashion-sdk 2.4.2 → 2.4.3
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/index.html +24 -15
- package/mkfashion-sdk-2.4.3.tgz +0 -0
- package/package.json +1 -1
- package/src/mkfashion.js +24 -4
- package/mkfashion-sdk-2.4.0.tgz +0 -0
- package/mkfashion-sdk-2.4.1.tgz +0 -0
- package/mkfashion-sdk-2.4.2.tgz +0 -0
package/index.html
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="pt-BR">
|
|
3
|
+
|
|
3
4
|
<head>
|
|
4
5
|
<meta charset="UTF-8">
|
|
5
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
7
|
<title>Provador Virtual</title>
|
|
7
8
|
<script src="./src/mkfashion.js"></script>
|
|
8
9
|
</head>
|
|
10
|
+
|
|
9
11
|
<body>
|
|
10
12
|
|
|
11
13
|
<button id="btn-provar" style="display: none;">Provar Virtualmente</button>
|
|
12
14
|
|
|
13
15
|
<script>
|
|
14
|
-
(function() {
|
|
16
|
+
(function () {
|
|
15
17
|
var projectid = '698c806c1d3129430f15ddde';
|
|
16
18
|
var identifier = '8964289003742';
|
|
17
19
|
|
|
18
20
|
function initMkFashion() {
|
|
19
|
-
mkfashion.addToCart(function(payload) {
|
|
21
|
+
mkfashion.addToCart(function (payload) {
|
|
20
22
|
console.log('Adicionando ao carrinho:', payload);
|
|
21
23
|
|
|
22
24
|
var variantSku = payload.selectedIdentifier;
|
|
@@ -33,27 +35,33 @@
|
|
|
33
35
|
}]
|
|
34
36
|
})
|
|
35
37
|
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
.then(function (response) {
|
|
39
|
+
return response.json();
|
|
40
|
+
})
|
|
41
|
+
.then(function (data) {
|
|
42
|
+
console.log('Produto adicionado:', data);
|
|
43
|
+
// document.dispatchEvent(new CustomEvent('cart:updated'));
|
|
44
|
+
})
|
|
45
|
+
.catch(function (error) {
|
|
46
|
+
console.error('Erro carrinho:', error);
|
|
47
|
+
});
|
|
46
48
|
});
|
|
47
49
|
|
|
50
|
+
mkfashion.onInteraction((payload) => {
|
|
51
|
+
if(payload.action == "retry"){
|
|
52
|
+
cosole.log('Interação com o botão de retry')
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
48
56
|
mkfashion.isAvailable(projectid, identifier)
|
|
49
|
-
.then(function(disponivel) {
|
|
57
|
+
.then(function (disponivel) {
|
|
50
58
|
if (disponivel) {
|
|
51
59
|
var button = document.getElementById('btn-provar');
|
|
52
60
|
|
|
53
61
|
if (button) {
|
|
54
62
|
button.style.display = 'inline-block';
|
|
55
63
|
|
|
56
|
-
button.onclick = function() {
|
|
64
|
+
button.onclick = function () {
|
|
57
65
|
mkfashion.open({
|
|
58
66
|
projectid: projectid,
|
|
59
67
|
identifier: identifier
|
|
@@ -62,7 +70,7 @@
|
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
})
|
|
65
|
-
.catch(function(error) {
|
|
73
|
+
.catch(function (error) {
|
|
66
74
|
console.error('Erro disponibilidade MK Fashion:', error);
|
|
67
75
|
});
|
|
68
76
|
}
|
|
@@ -84,4 +92,5 @@
|
|
|
84
92
|
</script>
|
|
85
93
|
|
|
86
94
|
</body>
|
|
95
|
+
|
|
87
96
|
</html>
|
|
Binary file
|
package/package.json
CHANGED
package/src/mkfashion.js
CHANGED
|
@@ -17,12 +17,12 @@ const mkfashion = {
|
|
|
17
17
|
|
|
18
18
|
// ============ CONFIGURACAO ============
|
|
19
19
|
|
|
20
|
-
appUrl: 'https://mkfashion.mk3dlabs.com/visualizer',
|
|
20
|
+
//appUrl: 'https://mkfashion.mk3dlabs.com/visualizer',
|
|
21
21
|
apiUrl: 'https://mkfashion-new-api.mk3dlabs.com',
|
|
22
22
|
debug: false,
|
|
23
23
|
|
|
24
24
|
// DEV - Descomentar para desenvolvimento local
|
|
25
|
-
|
|
25
|
+
appUrl: 'http://localhost:5174/visualizer',
|
|
26
26
|
// apiUrl: 'http://localhost:3007',
|
|
27
27
|
|
|
28
28
|
// ============ ESTADO INTERNO ============
|
|
@@ -44,7 +44,8 @@ const mkfashion = {
|
|
|
44
44
|
onAddToCart: null,
|
|
45
45
|
onGenerationComplete: null,
|
|
46
46
|
onProductLoaded: null,
|
|
47
|
-
onError: null
|
|
47
|
+
onError: null,
|
|
48
|
+
onInteraction: null
|
|
48
49
|
},
|
|
49
50
|
|
|
50
51
|
// ============ METODOS PUBLICOS ============
|
|
@@ -184,6 +185,19 @@ const mkfashion = {
|
|
|
184
185
|
}
|
|
185
186
|
},
|
|
186
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Registra callback para eventos de interação do usuário dentro do provador.
|
|
190
|
+
*
|
|
191
|
+
* Payload:
|
|
192
|
+
* { category, action, projectId, identifier, ...extra }
|
|
193
|
+
*/
|
|
194
|
+
onInteraction(callback) {
|
|
195
|
+
if (typeof callback === 'function') {
|
|
196
|
+
this._callbacks.onInteraction = callback
|
|
197
|
+
this._log('Callback onInteraction registrado')
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
|
|
187
201
|
/** Recarrega o iframe com a mesma configuração */
|
|
188
202
|
restart() {
|
|
189
203
|
if (!this._iframe || !this._config) {
|
|
@@ -209,7 +223,8 @@ const mkfashion = {
|
|
|
209
223
|
onAddToCart: null,
|
|
210
224
|
onGenerationComplete: null,
|
|
211
225
|
onProductLoaded: null,
|
|
212
|
-
onError: null
|
|
226
|
+
onError: null,
|
|
227
|
+
onInteraction: null
|
|
213
228
|
}
|
|
214
229
|
this._log('Destruído')
|
|
215
230
|
},
|
|
@@ -697,6 +712,11 @@ const mkfashion = {
|
|
|
697
712
|
this._triggerCallback('onGenerationComplete', data)
|
|
698
713
|
break
|
|
699
714
|
|
|
715
|
+
case 'interaction':
|
|
716
|
+
this._log('Interação', data)
|
|
717
|
+
this._triggerCallback('onInteraction', data)
|
|
718
|
+
break
|
|
719
|
+
|
|
700
720
|
case 'generation_error':
|
|
701
721
|
this._log('Erro na geracao', data)
|
|
702
722
|
this._triggerCallback('onError', data)
|
package/mkfashion-sdk-2.4.0.tgz
DELETED
|
Binary file
|
package/mkfashion-sdk-2.4.1.tgz
DELETED
|
Binary file
|
package/mkfashion-sdk-2.4.2.tgz
DELETED
|
Binary file
|