@dcloudio/uni-cli-shared 2.0.2-alpha-3080520230615001 → 2.0.2-alpha-3080620230620001
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.
|
@@ -8,9 +8,12 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script>
|
|
11
|
-
// #
|
|
11
|
+
// #ifdef APP
|
|
12
12
|
import adMixin from "./ad.mixin.js"
|
|
13
13
|
// #endif
|
|
14
|
+
// #ifdef H5
|
|
15
|
+
import adMixin from "./ad.mixin.web.js"
|
|
16
|
+
// #endif
|
|
14
17
|
// #ifdef MP-WEIXIN
|
|
15
18
|
import adMixin from "./ad.mixin.mp.js"
|
|
16
19
|
// #endif
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
const AD_SERVER_URL = 'https://hac1.dcloud.net.cn/h5/gs'
|
|
2
|
+
|
|
3
|
+
const EventType = {
|
|
4
|
+
Load: 'load',
|
|
5
|
+
Close: 'close',
|
|
6
|
+
Error: 'error'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const ProviderType = 'wm'
|
|
10
|
+
|
|
11
|
+
class Process {
|
|
12
|
+
static Start (cmd, args) {
|
|
13
|
+
return new Process().openScheme(cmd)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
constructor () {
|
|
17
|
+
this._a = null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
openScheme (url) {
|
|
21
|
+
if (this._a == null) {
|
|
22
|
+
this._a = document.createElement('a')
|
|
23
|
+
}
|
|
24
|
+
this._a.href = url
|
|
25
|
+
this._a.click()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
props: {
|
|
31
|
+
options: {
|
|
32
|
+
type: [Object, Array],
|
|
33
|
+
default () {
|
|
34
|
+
return {}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
adpid: {
|
|
38
|
+
type: [Number, String],
|
|
39
|
+
default: ''
|
|
40
|
+
},
|
|
41
|
+
preload: {
|
|
42
|
+
type: [Boolean, String],
|
|
43
|
+
default: true
|
|
44
|
+
},
|
|
45
|
+
loadnext: {
|
|
46
|
+
type: [Boolean, String],
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
urlCallback: {
|
|
50
|
+
type: Object,
|
|
51
|
+
default () {
|
|
52
|
+
return {}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
data () {
|
|
57
|
+
return {
|
|
58
|
+
adData: null,
|
|
59
|
+
loading: false,
|
|
60
|
+
showModel: false,
|
|
61
|
+
errorMessage: null
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
created () {
|
|
65
|
+
this._loading = false
|
|
66
|
+
this.adConfigData = null
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
load () {
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
this._onmpload()
|
|
72
|
+
}, 200)
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
show (options) {
|
|
76
|
+
if (!this._isMobile()) {
|
|
77
|
+
this._dispatchEvent(EventType.Error, {
|
|
78
|
+
errCode: -1,
|
|
79
|
+
errMsg: '当前设备环境无效'
|
|
80
|
+
})
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.errorMessage = null
|
|
85
|
+
if (this._loading) {
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
this._loading = true
|
|
89
|
+
|
|
90
|
+
this._requestScheme(options)
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
getProvider () {
|
|
94
|
+
return ProviderType
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
_onclick () {
|
|
98
|
+
if (this.disabled) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.show()
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
_requestScheme (options = {}) {
|
|
106
|
+
const urlCallback = options.urlCallback || this.urlCallback
|
|
107
|
+
uni.request({
|
|
108
|
+
url: AD_SERVER_URL,
|
|
109
|
+
method: 'POST',
|
|
110
|
+
data: {
|
|
111
|
+
adpid: this.adpid,
|
|
112
|
+
userId: urlCallback.userId,
|
|
113
|
+
extra: urlCallback.extra
|
|
114
|
+
},
|
|
115
|
+
timeout: 5000,
|
|
116
|
+
dataType: 'json',
|
|
117
|
+
success: (res) => {
|
|
118
|
+
if (res.statusCode !== 200) {
|
|
119
|
+
this._dispatchEvent(EventType.Error, {
|
|
120
|
+
errCode: res.statusCode,
|
|
121
|
+
errMsg: res.statusCode
|
|
122
|
+
})
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const responseData = res.data
|
|
127
|
+
if (responseData.ret === 0) {
|
|
128
|
+
Process.Start(responseData.data.openlink)
|
|
129
|
+
} else {
|
|
130
|
+
this._dispatchEvent(EventType.Error, {
|
|
131
|
+
errCode: responseData.ret,
|
|
132
|
+
errMsg: responseData.msg
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
fail: (err) => {
|
|
137
|
+
this.$emit(EventType.Error, {
|
|
138
|
+
errCode: '',
|
|
139
|
+
errMsg: err.errMsg
|
|
140
|
+
})
|
|
141
|
+
},
|
|
142
|
+
complete: () => {
|
|
143
|
+
this.loading = false
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
_isMobile () {
|
|
149
|
+
return /android|iphone/i.test(navigator.userAgent.toLowerCase())
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
_onmpload (e) {
|
|
153
|
+
this.loading = false
|
|
154
|
+
this._dispatchEvent(EventType.Load, {})
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
_onmpclose (e) {
|
|
158
|
+
this._dispatchEvent(EventType.Close, e.detail)
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
_onmperror (e) {
|
|
162
|
+
this.loading = false
|
|
163
|
+
this.errorMessage = JSON.stringify(e.detail)
|
|
164
|
+
this._dispatchEvent(EventType.Error, e.detail)
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
_dispatchEvent (type, data) {
|
|
168
|
+
this.$emit(type, {
|
|
169
|
+
detail: data
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "2.0.2-alpha-
|
|
3
|
+
"version": "2.0.2-alpha-3080620230620001",
|
|
4
4
|
"description": "uni-cli-shared",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"postcss-urlrewrite": "^0.2.2",
|
|
27
27
|
"strip-json-comments": "^2.0.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "e0464c9d34f8d3bb838abf4014dc3acce072ee21"
|
|
30
30
|
}
|