wechat-miniprogram / wechat-miniprogram/miniprogram-demo

OSD 一直不识别是为什么呢?不会进入事件,addOSDMarker 返回的也是null

Open
#149 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
7.2k
Forks
2.2k
Avg merge
10h 34m
Merged PRs (30d)
2

Description

我用uniapp开发的,全部代码如下。不会进入事件

<script setup lang="ts">
import {onLoad} from "@dcloudio/uni-app";

let session :any= null
let markerId :any= null

onLoad((op:any)=>{
    // @ts-ignore
    const version = wx.getAppBaseInfo().SDKVersion
    console.log("url",version,op.url)
    // @ts-ignore
    session = wx.createVKSession({
        track: {
            OSD: true,
        }
    })
    addOSDMarker(op.url);
})

function startOSD(){
    session.start((err:any)=>{
        console.log("start err",err)
        session.on("addAnchors",(anchors :any[])=>{
            console.log("addAnchors",anchors)
        })
        session.on("updateAnchors",(anchors :any[])=>{
            console.log("updateAnchors",anchors)
        })
        session.on("removeAnchors",(anchors :any[])=>{
            console.log("removeAnchors",anchors)
        })
    })

}
function addOSDMarker(url:string) {
    // @ts-ignore
    const path = `${wx.env.USER_DATA_PATH}/find_osd_obj.jpg`
    // @ts-ignore
    wx.downloadFile({
        url: url,
        filePath:path,
        success: (obj:any) => {
            console.log("downloadFile success",obj)
            markerId = session.addOSDMarker(obj.filePath)
            console.log('addOSDMarker', markerId)
            startOSD()
        }
    })
}
function btnTest(){
    console.log("getAllOSDMarker",session.getAllOSDMarker())

}
</script>

<template>
    <camera type="webgl" style="width: 100%; height: 70vh;">
    </camera>
    <button @click="btnTest">测试</button>
</template>

<style scoped lang="scss">

</style>

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the inline uni-app TypeScript example, especially the onLoad handler, wx.createVKSession setup, addOSDMarker call, and startOSD event registration. Reproduce the reported null marker ID and missing anchor events, then consult the relevant API behavior and document a confirmed cause or correction for this example.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.