路泰科技体检小程序UI设计新版本
1
wwl
5 天以前 a6cdbcfe28fcc40ebb4919f57d60fb20122e8e57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
 * @fileoverview txv-video 插件
 * Include txv-video (https://github.com/tvfe/txv-miniprogram-plugin)
 */
const TxvVideo = function (vm) {
  this.vm = vm
}
 
// #ifdef MP-WEIXIN || MP-QQ
try {
  const TxvContext = requirePlugin('tencentvideo')
 
  TxvVideo.prototype.onLoad = function () {
    setTimeout(() => {
      for (let i = 0; i < this.videos.length; i++) {
        const ctx = TxvContext.getTxvContext(this.videos[i])
        ctx.id = this.videos[i]
        this.vm._videos.push(ctx)
      }
    }, 50)
  }
} catch (e) {
  console.error('使用txv-video扩展需注册腾讯视频插件')
}
 
TxvVideo.prototype.onUpdate = function (_, config) {
  config.trustTags['txv-video'] = true
  this.videos = []
}
 
TxvVideo.prototype.onParse = function (node, parser) {
  if (node.name === 'iframe' && (node.attrs.src || '').includes('vid')) {
    const vid = node.attrs.src.match(/vid=([^&\s]+)/)
    if (vid) {
      node.name = 'txv-video'
      node.attrs.vid = vid[1]
      this.videos.push(vid[1])
      node.attrs.src = undefined
      parser.expose()
    }
  }
}
 
// #endif
 
module.exports = TxvVideo