@dcloudio/uni-cli-shared 2.0.1-alpha-35520220824001 → 2.0.1-alpha-36020220830002

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.
@@ -1,137 +1,154 @@
1
1
  <template>
2
2
  <view @click="onclick">
3
- <slot
4
- :options="options"
5
- :data="adData"
6
- />
3
+ <slot :options="options" :data="adData" :loading="loading" :error="errorMessage" />
7
4
  </view>
8
5
  </template>
9
6
 
10
7
  <script>
11
- const AD_URL = 'https://wxac1.dcloud.net.cn/tuiaApplet/acs'
12
- const AD_REPORT_URL = 'https://wxac1.dcloud.net.cn/tuiaApplet/acs'
13
- const WEBVIEW_PATH = '/uni_modules/uni-ad-interactive/pages/uni-ad-interactive/uni-ad-interactive'
8
+ const AD_URL = 'https://wxac1.dcloud.net.cn/openPage/acs'
9
+ const AD_REPORT_URL = 'https://wxac1.dcloud.net.cn/openPage/acs'
10
+ //const WEBVIEW_PATH = '/uni_modules/uni-ad-interactive/pages/uni-ad-interactive/uni-ad-interactive'
14
11
 
15
- const events = {
16
- load: 'load',
17
- close: 'close',
18
- error: 'error'
19
- }
12
+ const events = {
13
+ load: 'load',
14
+ close: 'close',
15
+ error: 'error'
16
+ }
20
17
 
21
- const OpenTypes = {
22
- Interactive: 'interactive'
23
- }
18
+ const OpenTypes = {
19
+ Interactive: 'interactive'
20
+ }
24
21
 
25
- export default {
26
- name: 'AdInteractive',
27
- props: {
28
- options: {
29
- type: [Object, Array],
30
- default () {
31
- return {}
22
+ export default {
23
+ name: 'AdInteractive',
24
+ props: {
25
+ options: {
26
+ type: [Object, Array],
27
+ default () {
28
+ return {}
29
+ }
30
+ },
31
+ disabled: {
32
+ type: [Boolean, String],
33
+ default: false
34
+ },
35
+ adpid: {
36
+ type: [Number, String],
37
+ default: ''
38
+ },
39
+ openType: {
40
+ type: String,
41
+ default: 'interactive'
42
+ },
43
+ openPagePath: {
44
+ type: String,
45
+ default: ""
32
46
  }
33
47
  },
34
- adpid: {
35
- type: [Number, String],
36
- default: ''
37
- },
38
- openUrl: {
39
- type: String,
40
- default: WEBVIEW_PATH
41
- }
42
- },
43
- data () {
44
- return {
45
- adData: {}
46
- }
47
- },
48
- created () {
49
- this._uniAdPlugin = null
50
- this._interactiveUrl = null
51
- if (this.openType === OpenTypes.Interactive) {
52
- this.getAdData()
53
- }
54
- },
55
- methods: {
56
- show () {
57
- if (this._uniAdPlugin === null) {
58
- this._uniAdPlugin = this.selectComponent('.uni-ad-plugin')
48
+ data() {
49
+ return {
50
+ adData: null,
51
+ loading: false,
52
+ errorMessage: ""
59
53
  }
60
- this._uniAdPlugin.show()
61
54
  },
62
- getAdData () {
63
- if (!this.adpid) {
64
- this.$emit(events.error, {
65
- code: -5002,
66
- message: 'invalid adpid'
67
- })
68
- return
55
+ created() {
56
+ this._uniAdPlugin = null
57
+ this._interactiveUrl = null
58
+ if (this.openPagePath) {
59
+ this.getAdData()
69
60
  }
61
+ },
62
+ methods: {
63
+ show() {
64
+ if (this._uniAdPlugin === null) {
65
+ this._uniAdPlugin = this.selectComponent('.uni-ad-plugin')
66
+ }
67
+ this._uniAdPlugin.show()
68
+ },
69
+ getAdData() {
70
+ if (!this.adpid) {
71
+ this.$emit(events.error, {
72
+ code: -5002,
73
+ message: 'invalid adpid'
74
+ })
75
+ return
76
+ }
70
77
 
71
- uni.request({
72
- url: AD_URL,
73
- method: 'POST',
74
- data: {
75
- adpid: this.adpid
76
- },
77
- timeout: 5000,
78
- dataType: 'json',
79
- success: (res) => {
80
- console.log(res.data)
78
+ this.loading = true
81
79
 
82
- if (res.statusCode !== 200) {
83
- this.$emit(events.error, {
84
- code: res.statusCode,
85
- message: res.statusCode
86
- })
87
- return
88
- }
80
+ uni.request({
81
+ url: AD_URL,
82
+ method: 'POST',
83
+ data: {
84
+ adpid: this.adpid
85
+ },
86
+ timeout: 5000,
87
+ dataType: 'json',
88
+ success: (res) => {
89
+ if (res.statusCode !== 200) {
90
+ this.$emit(events.error, {
91
+ errCode: res.statusCode,
92
+ errMsg: res.statusCode
93
+ })
94
+ return
95
+ }
89
96
 
90
- const responseData = res.data
91
- if (responseData.ret === 0) {
92
- this._interactiveUrl = responseData.data.adp_url
93
- this.adData.imgUrl = responseData.data.icon_url
94
- this.adData.openUrl = this.openUrl + '?url=' + encodeURIComponent(this._interactiveUrl)
95
- this.$emit(events.load, {})
96
- } else {
97
+ const responseData = res.data
98
+ if (responseData.ret === 0) {
99
+ this._interactiveUrl = responseData.data.adp_url
100
+ this.adData = {
101
+ imgUrl: responseData.data.icon_url,
102
+ openPath: this.openPagePath + '?url=' + encodeURIComponent(this._interactiveUrl)
103
+ }
104
+ this.$emit(events.load, this.adData)
105
+ } else {
106
+ const errMsg = {
107
+ errCode: responseData.ret,
108
+ errMsg: responseData.msg
109
+ }
110
+ this.errorMessage = errMsg
111
+ this.$emit(events.error, errMsg)
112
+ }
113
+ },
114
+ fail: (err) => {
97
115
  this.$emit(events.error, {
98
- code: responseData.ret,
99
- message: responseData.msg
116
+ errCode: '',
117
+ errMsg: err.errMsg
100
118
  })
119
+ },
120
+ complete: () => {
121
+ this.loading = false
101
122
  }
102
- },
103
- fail: (err) => {
104
- this.$emit(events.error, {
105
- code: '',
106
- message: err.errMsg
107
- })
123
+ })
124
+ },
125
+ onclick() {
126
+ if (this.disabled) {
127
+ return
128
+ }
129
+ if (!this._interactiveUrl) {
130
+ return
108
131
  }
109
- })
110
- },
111
- onclick () {
112
- if (this.openType !== OpenTypes.Interactive || !this._interactiveUrl) {
113
- return
114
- }
115
132
 
116
- uni.navigateTo({
117
- url: this.adData.openUrl
118
- })
133
+ uni.navigateTo({
134
+ url: this.adData.openPath
135
+ })
119
136
 
120
- this._report()
121
- },
122
- _report () {
123
- uni.request({
124
- url: AD_REPORT_URL,
125
- data: {
126
- adpid: this.adpid,
127
- t: '10019'
128
- },
129
- timeout: 5000,
130
- dataType: 'json'
131
- })
137
+ this._report()
138
+ },
139
+ _report() {
140
+ uni.request({
141
+ url: AD_REPORT_URL,
142
+ data: {
143
+ adpid: this.adpid,
144
+ t: '10019'
145
+ },
146
+ timeout: 5000,
147
+ dataType: 'json'
148
+ })
149
+ }
132
150
  }
133
151
  }
134
- }
135
152
  </script>
136
153
 
137
154
  <style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.1-alpha-35520220824001",
3
+ "version": "2.0.1-alpha-36020220830002",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -25,5 +25,5 @@
25
25
  "postcss-urlrewrite": "^0.2.2",
26
26
  "strip-json-comments": "^2.0.1"
27
27
  },
28
- "gitHead": "1073084863774ca9497f28782d47abf8c44b3661"
28
+ "gitHead": "c3cd2073bb4e67dcb6d6a1ac9e98a461fc4ebd33"
29
29
  }