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

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.
@@ -27,6 +27,12 @@ export default {
27
27
  loadnext: {
28
28
  type: [Boolean, String],
29
29
  default: false
30
+ },
31
+ urlCallback: {
32
+ type: Object,
33
+ default () {
34
+ return {}
35
+ }
30
36
  }
31
37
  },
32
38
  data () {
@@ -58,7 +64,31 @@ export default {
58
64
  show () {
59
65
  this.errorMessage = null
60
66
  this._ad = this.selectComponent('.uniad-plugin')
61
- this._ad.show()
67
+ if (this._hasCallback()) {
68
+ const userCryptoManager = wx.getUserCryptoManager()
69
+ userCryptoManager.getLatestUserKey({
70
+ success: ({
71
+ encryptKey,
72
+ iv,
73
+ version,
74
+ expireTime
75
+ }) => {
76
+ this._ad.show({
77
+ userId: this.urlCallback.userId || '',
78
+ extra: this.urlCallback.extra || '',
79
+ encryptKey,
80
+ iv,
81
+ version,
82
+ expireTime
83
+ })
84
+ },
85
+ fail: (err) => {
86
+ this._dispatchEvent(EventType.Error, err)
87
+ }
88
+ })
89
+ } else {
90
+ this._ad.show()
91
+ }
62
92
  },
63
93
 
64
94
  _onclick () {
@@ -80,6 +110,11 @@ export default {
80
110
  return result
81
111
  },
82
112
 
113
+ _hasCallback () {
114
+ return false
115
+ // return (typeof this.urlCallback === 'object' && Object.keys(this.urlCallback).length > 0)
116
+ },
117
+
83
118
  _onmpload (e) {
84
119
  this.loading = false
85
120
  this._dispatchEvent(EventType.Load, {})
@@ -87,6 +122,31 @@ export default {
87
122
 
88
123
  _onmpclose (e) {
89
124
  this._dispatchEvent(EventType.Close, e.detail)
125
+ if (e.detail.adsdata) {
126
+ const adv = e.detail.adv
127
+ const adsdata = e.detail.adsdata
128
+ const version = e.detail.version
129
+
130
+ /* eslint-disable no-undef */
131
+ uniCloud.callFunction({
132
+ name: 'uniAdCallback',
133
+ data: {
134
+ adv: adv,
135
+ adsdata: adsdata,
136
+ version: version
137
+ },
138
+ secretType: 'both',
139
+ success: (res) => {
140
+ },
141
+ fail: (err) => {
142
+ this._dispatchEvent(EventType.Error, err)
143
+ }
144
+ })
145
+
146
+ delete e.detail.adv
147
+ delete e.detail.adsdata
148
+ delete e.detail.version
149
+ }
90
150
  },
91
151
 
92
152
  _onmperror (e) {
package/lib/preprocess.js CHANGED
@@ -5,7 +5,10 @@ const DEFAULT_KEYS = [
5
5
  'APP',
6
6
  'APP-PLUS-NVUE',
7
7
  'APP-VUE',
8
- 'APP-NVUE'
8
+ 'APP-NVUE',
9
+ 'APP-ANDROID',
10
+ 'APP-IOS',
11
+ 'WEB'
9
12
  ]
10
13
 
11
14
  function normalize (name) {
@@ -44,14 +47,25 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) {
44
47
  nvueContext.APP_PLUS = true
45
48
  nvueContext.APP_NVUE = true
46
49
  nvueContext.APP_PLUS_NVUE = true
47
- }
48
50
 
51
+ if (process.env.UNI_APP_PLATFORM === 'android') {
52
+ defaultContext.APP_ANDROID = true
53
+ } else if (process.env.UNI_APP_PLATFORM === 'ios') {
54
+ defaultContext.APP_IOS = true
55
+ } else {
56
+ defaultContext.APP_ANDROID = true
57
+ defaultContext.APP_IOS = true
58
+ }
59
+ }
60
+ if (name === 'h5') {
61
+ defaultContext.WEB = true
62
+ }
49
63
  if (name.startsWith('mp-')) {
50
64
  vueContext.MP = true
51
65
  }
52
66
 
53
67
  if (name.startsWith('app-')) {
54
- vueContext.APP = true
68
+ vueContext.APP = true
55
69
  nvueContext.APP = true
56
70
  }
57
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.1-alpha-36020220830002",
3
+ "version": "2.0.1-alpha-36120220907001",
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": "c3cd2073bb4e67dcb6d6a1ac9e98a461fc4ebd33"
28
+ "gitHead": "2290dd0b6f192129af9c6be83819277dff40fc66"
29
29
  }