chenlei 4 hónapja
szülő
commit
786a695fb7

+ 1 - 1
project.private.config.json

@@ -3,7 +3,7 @@
   "projectname": "karamay_wx",
   "setting": {
     "compileHotReLoad": true,
-    "urlCheck": true,
+    "urlCheck": false,
     "coverView": true,
     "lazyloadPlaceholderEnable": false,
     "skylineRenderEnable": false,

BIN
subPackages/images/icon_menu.png


+ 65 - 3
subPackages/pages/ar/constants.js

@@ -1,3 +1,65 @@
-export const MARKER_MAP = {
-  10001: 2
-}
+export const MARKER_LIST = [
+  'https://houseoss.4dkankan.com/project/kelamayi/1/IMG_20250811_124756.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/1/IMG_20250811_124804.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/1/1 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/1/1 (3).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/2/IMG_20250811_124615.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/2/IMG_20250811_124626.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/2/2 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/2/2 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/2/2 (3).jpg',
+  
+  'https://houseoss.4dkankan.com/project/kelamayi/3/IMG_20250811_124636.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/3/3 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/3/3 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/3/3 (4).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/4/4 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/4/4 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/4/4 (4).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/4/4 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/5/5 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/5/5 (3).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/5/5 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/6/IMG_20250811_124652.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/6/6 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/6/6 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/6/6 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/7/IMG_20250811_124709.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/7/7 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/7/7 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/7/7 (6).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/7/7 (7).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/8/IMG_20250811_124729.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/8/IMG_20250811_124733.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/8/8 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/8/8 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/8/8 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/9/IMG_20250811_124744.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/9/IMG_20250811_124747.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/9/9 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/9/9 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/10/IMG_20250811_124808.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/10/IMG_20250811_124814.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/10/10 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/10/10 (4).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/10/10 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/11/IMG_20250811_124822.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/11/IMG_20250811_124829.jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/11/11 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/11/11 (3).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/11/11 (5).jpg',
+
+  'https://houseoss.4dkankan.com/project/kelamayi/12/12 (1).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/12/12 (2).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/12/12 (3).jpg',
+  'https://houseoss.4dkankan.com/project/kelamayi/12/12 (4).jpg',
+]

+ 49 - 16
subPackages/pages/ar/index.js

@@ -1,7 +1,7 @@
 import getBehavior from './behavior'
 import yuvBehavior from './yuvBehavior'
 import { getCachedImage, hash } from '../../utils/index'
-import { MARKER_MAP } from './constants'
+import { MARKER_LIST } from './constants'
 
 const NEAR = 0.01
 const FAR = 1000
@@ -14,10 +14,30 @@ Component({
     markerImgList: [], // 使用的 marker 列表
     chooseImgList: [], // 使用的 图片 列表
     hintBoxList: [], // 显示提示盒子列表
+    markerMap: {},
+    forzen: false,
+    showVideo: false,
+    markerIndex: 1, // 使用的 marker 索引
   },
-  markerIndex: 0, // 使用的 marker 索引
   hintInfo: undefined, // 提示框信息
+  pageLifetimes: {
+    show() {
+      setTimeout(() => {
+        this.setData({
+          forzen: false
+        })
+      }, 1000)
+    }
+  },
   methods: {
+    handleEnded() {
+      wx.navigateTo({
+        url: '/pages/webview/index?url=' + encodeURIComponent(`https://sit-kelamayi.4dage.com/zuan/#/info/${this.data.markerIndex}`),
+      })
+      this.setData({
+        showVideo: false
+      })
+    },
     // 对应案例的初始化逻辑,由统一的 behavior 触发
     init() {
       // 初始化 Three.js,用于模型相关的渲染
@@ -30,8 +50,6 @@ Component({
       // start完毕后,进行更新渲染循环
       this.initVK()
 
-      this.markerIndex = 0
-
       // 添加 识别包围盒子
       // this.add3DBox()
     },
@@ -48,25 +66,32 @@ Component({
         gl: this.gl
       })
 
-      session.start(err => {
+      session.start(async err => {
         if (err) return console.error('VK error: ', err)
 
         console.log('@@@@@@@@ VKSession.version', session.version)
 
         try {
-          const promises = [
-            'https://houseoss.4dkankan.com/project/kelamayi/ylzt-1.png',
-          ].map(url => {
+          const promises = MARKER_LIST.map(async url => {
             const cacheKey = 'image_marker_' + hash(url)
-            return getCachedImage(url, cacheKey)
+            const sysPath = await getCachedImage(url, cacheKey)
+            return [sysPath, url]
+          })
+          wx.showLoading({
+            title: '资源加载中...',
           })
-          Promise.all(promises).then(paths => {
-            for (const path of paths) {
-              session.addMarker(path)
+          await Promise.all(promises).then(arr => {
+            for (const [path, url] of arr) {
+              console.log('marker添加成功:', path)
+              const id = session.addMarker(path)
+              console.log('markerId:', id)
+              this.data.markerMap[id] = url
             }
           })
         } catch(err) {
           console.log(err)
+        } finally {
+          wx.hideLoading()
         }
 
         //  VKSession EVENT resize
@@ -93,10 +118,18 @@ Component({
             size
           }
 
-          if (MARKER_MAP[markerId]) {
-            wx.navigateTo({
-              url: '/pages/webview/index?url=' + encodeURIComponent(`https://sit-kelamayi.4dage.com/zuan/#/info/${MARKER_MAP[markerId]}?x=h`),
-            })
+          const url = this.data.markerMap[markerId]
+          if (url) {
+            const match = url.match(/\/kelamayi\/(\d+)/);
+            const id = match ? match[1] : null;
+            console.log('识别到的图片:', url, id)
+            if (id && !this.data.forzen) {
+              this.setData({
+                forzen: true,
+                markerIndex: Number(id),
+                showVideo: true
+              })
+            }
           }
         })
 

+ 4 - 2
subPackages/pages/ar/index.wxml

@@ -1,11 +1,13 @@
 <view class="page wrap-fix">
   <view class="canvas-wrap" style="width: {{widthScale * 100}}%; height: {{heightScale * 100}}%">
     <canvas type="webgl" id="canvas"></canvas>
-    
+
     <!-- <view class="hint-box"  wx:for="{{hintBoxList}}"  wx:for-item="hintBox" wx:key="hintBoxId"
       style="left: {{hintBox.left}}%; top: {{hintBox.top}}%; width: {{hintBox.width}}px;  height: {{hintBox.height}}px;"
     >
       <p class="hint-id">识别id: {{hintBox.markerId}}</p>
     </view> -->
   </view>
-</view>
+
+  <video wx:if="{{showVideo}}" muted autoplay controls="{{false}}" object-fit="cover" class="video" src="https://houseoss.4dkankan.com/project/kelamayi/video/{{markerIndex}}.mp4" bindended="handleEnded" />
+</view>

+ 9 - 0
subPackages/pages/ar/index.wxss

@@ -39,4 +39,13 @@
   top: 0;
   width: 100%;
   height: 100%;
+}
+
+.video {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  z-index: 999;
 }

+ 15 - 3
subPackages/utils/index.js

@@ -1,11 +1,23 @@
+let preMarkerIndex = 0
+const fs = wx.getFileSystemManager()
+
 const downloadAndCache = (url, cacheKey) => {
   return new Promise((resolve, reject) => {
     wx.downloadFile({
       url,
       success(res) {
         if (res.statusCode === 200) {
-          wx.setStorageSync(cacheKey, res.tempFilePath)
-          resolve(res.tempFilePath)
+          preMarkerIndex++
+          const fileEnd = res.tempFilePath.split('.').slice(-1)[0]
+          const filePath = `${wx.env.USER_DATA_PATH}/marker-ar-${preMarkerIndex}.${fileEnd}`
+          fs.saveFile({
+            filePath,
+            tempFilePath: res.tempFilePath,
+            success(res) {
+              wx.setStorageSync(cacheKey, res.savedFilePath)
+              resolve(res.savedFilePath)
+            }
+          })
         } else {
           reject(new Error('download failed:' + res.statusCode))
         }
@@ -15,7 +27,7 @@ const downloadAndCache = (url, cacheKey) => {
   })
 }
 
-export const clearImageCache = (caheKey => {
+export const clearImageCache = (cacheKey => {
   if (cacheKey) {
     const cachedPath = wx.getStorageSync(cacheKey)
     if (cachedPath) {