
2***@qq.com
- 发布:2024-10-28 08:35
- 更新:2024-10-28 11:53
- 阅读:197
h5获取canvasCode 返回空 uni.createSelectorQuery().in(this).select('#myCanvas').fields()
分类:uni-app
2***@qq.com (作者)
<template>
<view style="position: relative;width:100%;height:100%;margin:0;padding:0;">
<view style="height: 130px;position:absolute;width:100%;z-index:999;margin:0;padding:0;top:0;left:0;">
<view class="ccard-item flex" style="text-overflow: ellipsis; padding: 5px">
<picker @change="bindPickerChange" class="cuspicker" range-key="lable" :range="partNumberList"
style="width: 100%; border: 1px solid #cccccc; height: 40rpx; padding: 5px;border-radius: 20px;">
<text class="cuIcon-close" style="float: right;font-size:32rpx;" @click.stop="clearValue"></text>
<view class="picker cuspicker_item" style="padding-left: 4px;">{{partNumber?partNumber:'请选择料号' }}
</view>
</picker>
</view>
<view style="padding: 5px; font-weight: 500; font-size: 14px;">
车辆装载展示
</view>
<view class="vehicle">
<view>
<view class="ccard-item flex" style="text-overflow: ellipsis;">
<text class="title">供应商:</text>
<text>{{model.supplier}}</text>
</view>
</view>
<view>
<view class="ccard-item flex" style="text-overflow: ellipsis;">
<text class="title">容器:</text>
<text>{{model.boxTypeName}}</text>
</view>
</view>
<view>
<view class="ccard-item flex" style="text-overflow: ellipsis;">
<text class="title">物料:</text>
<text>{{model.productName}}</text>
</view>
</view>
<view>
<view class="ccard-item flex" style="text-overflow: ellipsis;">
<text class="title">数量:</text>
<text>{{model.qty}}</text>
</view>
</view>
</view>
</view>
<view style="z-index:1;" class="canvas-container">
<canvas class='myCanvas' id='myCanvas' ref="myCanvas" canvas-id="myCanvas" type="webgl"
style="'width:400px; height:'400px'" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd"
@click="mouseClick" />
</view>
</view>
</template>
<script>
import * as THREE from './threeWeapp/three.weapp.js'
import {
getCurrentInstance
} from 'vue';
import {
OrbitControls
} from './three/OrbitControls.js'
export default {
data() {
return {
mSceneWidth: 0, // 手机屏幕宽度
mSceneHeight: 0, // 手机屏幕高度
worldFocus: null, // 世界焦点(模型放置,相机围绕的中心)
mCanvasId: null,
mSence: null,
mCamera: null,
redCube: null,
renderAnimFrameId: null, // 渲染帧动画id
shipmentId: null,
model: {
supplier: '',
boxTypeName: '',
productName: '',
qty: ''
},
SELECTED: null,
partNumber: '',
partNumberList: ['中国', '美国', '巴西', '日本'],
};
},
// 页面加载时
onLoad(option) {
this.shipmentId = option.shipmentId;
// 获取手机屏幕宽高
this.mSceneWidth = uni.getWindowInfo().windowWidth;
this.mSceneHeight = uni.getWindowInfo().windowHeight
// 设置世界中心
this.worldFocus = new THREE.Vector3(0, 0, 0);
},
// 页面加载完毕后
onReady() {
const systemInfo = uni.getSystemInfoSync();
if (systemInfo.uniPlatform === 'mp-weixin') {
uni.createSelectorQuery().select('#myCanvas').node().exec((res) => { // 获取 canvasId
this.mCanvasId = res[0].node._canvasId;
// 注册画布
const mCanvas = THREE.global.registerCanvas(this.mCanvasId, res[0].node);
const params = {
shipmentId: this.shipmentId
}
this.$store.dispatch('miniApp/wxGetVirtualShipmentFor3D', params).then((res) => {
</script>
<style>
.vehicle {
padding: 20rpx;
}
</style>
2024-10-28 14:08
2***@qq.com (作者)
返回的是空对象
2024-10-28 14:09