当前位置:   article > 正文

超详细,wepy小程序如何引入第三方插件wxPano

wxpano

微信官方地址:wxPano | 小程序插件 | 微信公众平台

效果在最下面!

  第一步:

在微信小程序管理后台拉到最下面,设置——第三方服务——添加插件输入wxPano

 第二步:在app.wpy中添加

  1. plugins: {
  2. wxPano: {
  3. version: '2.1.4',
  4. provider: 'wx386c038238531f87',
  5. },
  6. },

 注意:添加完成后小程序开发工具会出现添加了一个插件信息

  第三步:在需要使用的页面中添加

  1. usingComponents: {
  2. pano: 'plugin://wxPano/pano',
  3. },
var wxPano = requirePlugin('wxPano')

这里是重案例拷贝过来的,下面照样贴下代码就ok了

  1. <template>
  2. <view>
  3. <pano panolist="{{panolist}}" entryid="{{entrypanoid}}" entryname="{{entrypanoname}}" width="320" height="240" key="{{key}}" autoinit="{{false}}">
  4. <cover-view style="position: fixed;top:80%;width:100%;text-align:center;">
  5. <cover-view style="width:50%;text-align:center;float:left;" bindtap="covertap">跳转全景图</cover-view>
  6. <cover-view style="width:50%;text-align:center;float:left;" bindtap="setCameraLookAt">切换视角</cover-view>
  7. <cover-view style="width:50%;text-align:center;float:left;" bindtap="enableTouch">打开触摸</cover-view>
  8. <cover-view style="width:50%;text-align:center;float:left;" bindtap="disableTouch">关闭触摸</cover-view>
  9. <cover-view style="width:50%;text-align:center;float:left;" bindtap="getPanoInfo">获取当前全景信息</cover-view>
  10. </cover-view>
  11. </pano>
  12. </view>
  13. </template>

  1. var wxPano = requirePlugin('wxPano')
  2. export default class CaseDetail extends wepy.page {
  3. config = {
  4. usingComponents: {
  5. pano: 'plugin://wxPano/pano',
  6. },
  7. }
  8. components = {
  9. }
  10. mixins = []
  11. data = {
  12. krpanoList: [
  13. 'https://game.flyh5.cn/resources/game/wechat/szq/krpano/krpano_01.jpg',
  14. 'https://game.flyh5.cn/resources/game/wechat/szq/krpano/krpano_02.jpg',
  15. 'https://game.flyh5.cn/resources/game/wechat/szq/krpano/krpano_03.jpg',
  16. 'https://game.flyh5.cn/resources/game/wechat/szq/krpano/krpano_04.jpg',
  17. ],
  18. }
  19. onReady() {
  20. wxPano.onReady = function() {
  21. //wxPano初始化完成后会触发此事件
  22. }
  23. wxPano.config({
  24. panolist: [
  25. {
  26. name: 'xindamen',
  27. src: 'https://www.aiotforest.com/pano2048-1024.jpg',
  28. infospots: [
  29. //信息标记
  30. {
  31. type: 'modal',
  32. modal: {
  33. title: 'wxPano',
  34. content: '欢迎使用wxPano',
  35. },
  36. position: { x: 0.092, y: 0.434 },
  37. size: 1,
  38. icon: 'info',
  39. bindcamera: true,
  40. bindsize: 0.5,
  41. bindicon: 'info',
  42. bindopacity: 0.75,
  43. bindposition: { x: 0.5, y: 0.75 },
  44. },
  45. {
  46. type: 'page',
  47. page: function() {
  48. wx.navigateTo({
  49. url: 'ar',
  50. success(evt) {
  51. console.log(evt)
  52. },
  53. })
  54. },
  55. position: { x: 0.437, y: 0.447 },
  56. size: 1,
  57. icon: 'info',
  58. },
  59. ],
  60. },
  61. ],
  62. request: wx.request,
  63. loader: 'GLLoader',
  64. entryname: 'xindamen',
  65. })
  66. }
  67. //---------------------------------------------
  68. covertap() {
  69. var panoId = wxPano.addPano({
  70. name: 'dongdamen',
  71. src: 'https://www.aiotforest.com/pano-1-2048-1024.jpg',
  72. infospots: [
  73. {
  74. type: 'pano',
  75. entryname: 'xindamen',
  76. position: { x: 0.695, y: 0.503 },
  77. size: 1,
  78. icon: 'arrow',
  79. },
  80. {
  81. type: 'modal',
  82. modal: {
  83. title: '东大门',
  84. content: '对面有公交站和唐家湾轻轨站',
  85. },
  86. position: { x: 0.092, y: 0.434 },
  87. size: 1,
  88. icon: 'info',
  89. },
  90. ],
  91. })
  92. wxPano.navigateMethod({
  93. type: 'pano',
  94. entryname: 'dongdamen',
  95. })
  96. }
  97. setCameraLookAt() {
  98. wxPano.setCameraLookAt({
  99. x: 0.5,
  100. y: 0.5,
  101. })
  102. }
  103. enableTouch() {
  104. wxPano.enableTouch()
  105. }
  106. disableTouch() {
  107. wxPano.disableTouch()
  108. }
  109. getPanoInfo() {
  110. console.log(wxPano.getPanoInfo())
  111. }

 效果如图:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/326119
推荐阅读
相关标签
  

闽ICP备14008679号