tremble 3 anni fa
parent
commit
f3a0e7eb84

+ 2 - 1
app.js

@@ -9,7 +9,8 @@ App({
   },
   globalData: {
     userInfo: null,
-    m_file: null
+    m_file: null,
+    scenes:[]
   },
 
   onHide(){

+ 1 - 0
app.json

@@ -1,5 +1,6 @@
 {
   "pages": [
+    "pages/start/index",
     "pages/index/index",
     "pages/work/index"
   ],

+ 69 - 36
config/index.js

@@ -1,4 +1,4 @@
-export const API_BASE_URL = "ws://192.168.0.151:9999";
+export const API_BASE_URL = "ws://120.24.252.95:9999";
 // ws://192.168.0.134:7015
 // wss://4dart.4dage.com/4dart
 // 88888888
@@ -6,55 +6,63 @@ export const VIDEO_BASE_URL = "https://houseoss.4dkankan.com/";
 export const CDN_URL = "https://culture.4dage.com/air_show/resource";
 
 export let app = {
-  id: "88888888",
+  id: "13750062488",
   longtime:null,
   websocket: null,
   is_connect_ok: null,
   is_send_msg: null,
   noOperationTimeout: 35,
-  closeByVideoHandle: false,
-  showAlert(msg, comfirm,confirmText='确定') {
-    if (comfirm) {
-      return (() => {
-        wx.showModal({
-          title: "提示",
-          confirmText,
-          content: msg,
-          showCancel: false,
-          success(res) {
-            if (res.confirm) {
-              comfirm();
-            }
-          },
-        });
-      })();
-    }
-    return (() => {
-      wx.showModal({
-        title: "提示",
-        showCancel: false,
-        content: msg,
-        success() {},
-      });
-    })();
-  },
+  
   send(msg) {
     if (!app.websocket) {
       return
     }
     if (msg === "request") {
-      app.websocket.send({ data: msg + " " + this.id });
+      app.websocket.emit(msg + " " + this.id);
     } else if (msg === "close") {
-      app.websocket.send({ data: msg + " 0" });
+      app.websocket.emit({ data: msg + " 0" });
     } else {
       if (app.is_connect_ok == null) {
-        app.websocket.send({ data: "request " + this.id });
+        app.websocket.emit({ data: "request " + this.id });
       }
       setTimeout(function () {
-        app.websocket.send({ data: msg });
+        app.websocket.emit({ data: msg });
       }, 300);
     }
   },
+
+  emitEvent:{
+    close(){
+      app.websocket.emit('Close','close',function (data) {
+        console.log(data,'close');
+      })
+    },
+    request(cb=null){
+      app.websocket.emit('Request',app.id,function (data) {
+        cb && cb(data)
+      })
+    },
+    switchMachine(scene){
+      app.websocket.emit('Switch',scene,function (data) { 
+        console.log(data,scene);
+      })
+    },
+
+    Photo(photo,cb=null){
+      app.websocket.emit('Photo',photo+app.id,function (data) {
+        console.log(data,photo+app.id);
+        cb && cb(data)
+      })
+    },
+
+    Video(video,cb=null){
+      app.websocket.emit('Video',video+app.id,function (data) {
+        console.log(data,video+app.id);
+        cb && cb(data)
+      })
+    },
+  },
+
   showLoading: function () {
     return (() => {
       wx.showLoading({
@@ -70,6 +78,31 @@ export let app = {
       } catch (error) {}
     })();
   },
+  showAlert(msg, comfirm,confirmText='确定') {
+    if (comfirm) {
+      return (() => {
+        wx.showModal({
+          title: "提示",
+          confirmText,
+          content: msg,
+          showCancel: false,
+          success(res) {
+            if (res.confirm) {
+              comfirm();
+            }
+          },
+        });
+      })();
+    }
+    return (() => {
+      wx.showModal({
+        title: "提示",
+        showCancel: false,
+        content: msg,
+        success() {},
+      });
+    })();
+  },
   sendCheck() {
 
     console.log(this.is_connect,this.is_connect_ok,this.is_other_used);
@@ -77,7 +110,7 @@ export let app = {
     if (!this.is_connect) {
       this.hideLoading()
       app.showAlert("服务器连接失败,请重新连接", () => {
-        app.send("request");
+        app.emitEvent.request();
       },'重新连接');
       return false;
     } else if (this.is_connect_ok === false) {
@@ -90,14 +123,14 @@ export let app = {
           });
         });
         setTimeout(() => {
-          app.send("request");
+          app.emitEvent.request();
         }, 1000);
       },'重新连接');
       return false;
     } else if (this.is_other_used) {
       this.hideLoading()
       app.showAlert("当前画屏正在被使用,请稍后", () => {
-        app.send("request");
+        app.emitEvent.request();
       });
       return false;
 
@@ -118,7 +151,7 @@ export let app = {
 
     this.operationTimer = setTimeout(function () {
       if (app.is_connect_ok) {
-        app.send("close");
+        app.emitEvent.close();
         this.is_other_used = true
         this.is_connect_ok = false
         app.checkOperationTimeout(true);

+ 88 - 211
pages/index/index.js

@@ -6,10 +6,18 @@ import { isPhoneX } from "./../../utils/tools";
 
 import { CDN_URL, API_BASE_URL, VIDEO_BASE_URL, app } from "../../config/index";
 
+let socket_io = require("../../utils/socket.io-mp.js")
+
 let timer = null;
 
 var g_app = getApp();
 
+let TYPESTR = {
+  0:'media',
+  1:'pic'
+}
+
+
 import Router from "../../utils/routes";
 
 VueLikePage([], {
@@ -18,40 +26,22 @@ VueLikePage([], {
     isIphoneX: false,
     canTap: true,
     rndWord: randomWord(false, 8),
-    background: [
-      {
-        img: "lunbo1.png",
-        id: "1",
-      },
-      {
-        img: "lunbo2.png",
-        id: "2",
-      },
-      {
-        img: "lunbo3.png",
-        id: "3",
-      },
-    ],
-
     scenes: [
       {
-        img: "1.png",
-        id: "1",
+        id: "4",
       },
       {
-        img: "2.png",
-        id: "2",
+        id: "5",
       },
       {
-        img: "3.png",
-        id: "3",
+        id: "6",
       },
     ],
     autoplay: true,
     interval: 3000,
     duration: 500,
     current: 0,
-    currentScene: 1,
+    currentScene: 4,
     daojishi: 0,
     isShot: false,
     isRecord: false,
@@ -127,166 +117,57 @@ VueLikePage([], {
         return;
       }
 
-      app.websocket = wx.connectSocket({
-        url: API_BASE_URL,
-        timeout: 180 * 1000,
-        success: () => {},
+      app.websocket = socket_io(API_BASE_URL,{
+        transports: ['websocket']
       });
 
-      app.websocket.onOpen(() => {
-        app.is_connect = true;
-        app.is_connect_ok = null;
-        app.send("request");
-      });
+      app.websocket.on('connect', () => {
+        console.log('SOCKET连接成功');
+        app.emitEvent.request(data=>{
+          console.log(data,1111111);
+        });
+      })
 
-      app.websocket.onMessage((msg) => {
-        console.log(msg);
-        app.hideLoading();
-        if (typeof msg.data == "string") {
-          switch (msg.data) {
-            case "error 101":
-              console.log("发送的消息有误");
-              break;
-            case "error 302":
-              app.hideLoading();
-              app.showAlert("网络异常,生成失败");
-              break;
-            case "error 404":
-              app.showAlert("网络异常,请稍后再试");
-              break;
-            case "error 500":
-              app.is_connect_ok = false;
-              app.is_other_used = true;
-
-              if (app.is_send_msg) {
-                app.showAlert("服务器连接失败,请重新连接", () => {
-                  wx.reLaunch({
-                    url: "index",
-                  });
-                },'重新连接');
-              }
-              break;
+      app.websocket.on('ForceOffline', () => {
+        app.showAlert("服务器连接失败,请稍后再试", () => {
+          wx.reLaunch({
+            url: "/pages/start/index",
+          });
+        });
+        
+        console.log('ForceOffline成功');
+      })
 
-            case "error 808":
-              app.is_connect_ok = true;
-              app.is_other_used = true;
-              if (app.is_send_msg) {
-                app.showAlert("当前画屏正在被使用,请稍后");
-              }
-              break;
+    },
 
-            case "error 909":
-              if (app.is_send_msg) {
-                app.showAlert("录像失败");
-              }
-              break;
-            case "ok 200":
-              console.log("切换画风成功");
-              break;
-            case "ok 201":
-              app.is_connect_ok = false;
-              app.is_other_used = true;
-              app.checkOperationTimeout(true);
-              break;
-            case "ok 300":
-              app.is_other_used = null;
-              app.is_connect_ok = true;
-              app.checkOperationTimeout();
-              this.reset();
-              break;
-            case "ok 301":
-              console.log("拍照成功,开始等待照片");
-
-              // 轮询拿视频/图片
-              this.clearLongTime();
-              app.longtime = setInterval(() => {
-                let link = "",
-                  m_type = "";
-                if (this.data.type == "0") {
-                  link = `${VIDEO_BASE_URL}4dvedio/vedio${this.data.rndWord}.mp4`;
-                  m_type = "video";
-                } else {
-                  link = `${VIDEO_BASE_URL}4dpic/pic${this.data.rndWord}.jpg`;
-                  m_type = "jpeg";
-                }
-
-                console.log(link, 1111);
-                console.log(m_type, 1111);
-
-                wx.downloadFile({
-                  url: link,
-                  success: (res) => {
-                    //判断是否为数组
-                    let typeType =
-                    (Object.prototype.toString.call(res.header["Content-Type"]) == "[object String]")?
-                    res.header["Content-Type"] : res.header["Content-Type"][0]
-
-                    console.log(typeType,8888);
-
-                    //判断不是xml文件
-                    if (typeType.indexOf(m_type) > -1) {
-                      this.clearLongTime();
-                      g_app.globalData.m_file = res.tempFilePath;
-                      this.gotoWork();
-                    }
-                  },
-                  fail: (e) => {
-                    console.log(e, 1111);
+    checkTextDetail:function () {
+      wx.showModal({
+        title: '作品标识码(在首页获取作品)',
+        content: TYPESTR[this.data.type]+this.data.rndWord + app.id,
+        showCancel: false,
+        confirmText: '复制文本',
+        success: (result) => {
+          if (result.confirm) {
+            wx.setClipboardData({
+              data: TYPESTR[this.data.type]+this.data.rndWord + app.id,
+              success: () => {
+                wx.getClipboardData({
+                  success: () => {
+                    setTimeout(() => {
+                      wx.navigateBack({
+                        delta: 3
+                      });
+                    }, 1000);
                   },
                 });
-              }, 5 * 1000);
-
-              // 3分钟后不可以就弹出生成失败
-              timer = setTimeout(() => {
-                this.clearLongTime();
-                app.hideLoading();
-                app.showAlert("生成失败,请重新连接", () => {
-                  wx.reLaunch({
-                    url: "index",
-                  });
-                });
-              }, 180 * 1000);
-
-              break;
-
-            default:
-              try {
-              // var json = JSON.parse(msg.data);
-                // if (json.url) {
-                //   if (json.url.indexOf(this.data.rndWord) > -1) {
-                //     timer && clearTimeout(timer);
-                //     timer = null
-                //     this.clearLongTime()
-                //     this.gotoWork();
-                //   }
-                // }
-              } catch (error) {
-                console.error(error);
               }
-
-              break;
+            });
+              
           }
-          app.is_send_msg = false;
-        } else {
-          console.log("error 600");
-        }
+        },
       });
-
-      app.websocket.onClose((res) => {
-        app.is_connect = false;
-        app.checkOperationTimeout(true);
-        app.hideLoading();
-        app.websocket = null;
         
-        if (!app.longtime&&!app.closeByVideoHandle) {
-          app.showAlert("服务器连接已关闭,请重新连接", () => {
-            wx.reLaunch({
-              url: "index",
-            });
-          },'重新连接');
-          app.closeByVideoHandle = false
-        }
-      });
+      
     },
     onLoad: function () {
       isPhoneX().then((res) => {
@@ -294,7 +175,14 @@ VueLikePage([], {
           isIphoneX: res,
         });
       });
-      this.handleWebSocket();
+      let tmp = g_app.globalData.scenes.map(item=>{
+        return {id:item}
+      })
+
+      this.setData({
+        scenes: tmp,
+        currentScene:tmp[0].id
+      })
     },
 
     daojishiFn(key, time, fn = () => {}) {
@@ -319,7 +207,7 @@ VueLikePage([], {
     },
 
     shot: function (e) {
-      app.checkOperationTimeout(true);
+      // app.checkOperationTimeout(true);
 
       let { id } = e.currentTarget.dataset;
 
@@ -328,11 +216,9 @@ VueLikePage([], {
         rndWord: randomWord(false, 8),
       });
 
-      if (!app.sendCheck()) {
-        return;
-      }
-
-
+      // if (!app.sendCheck()) {
+      //   return;
+      // }
 
       //录像
       if (id == "0") {
@@ -347,10 +233,11 @@ VueLikePage([], {
             daojishi: 3,
           });
 
-          app.send("switch " + this.data.currentScene);
+          app.emitEvent.switchMachine(this.data.currentScene)
+          
 
           setTimeout(() => {
-            app.send("photo " + "0#" + this.data.rndWord);
+            app.emitEvent.Video(TYPESTR[this.data.type]+this.data.rndWord)
             
             // 为了同步机器的倒计时
             setTimeout(() => {
@@ -364,19 +251,13 @@ VueLikePage([], {
                     title: "生成视频中...",
                   });
                   setTimeout(() => {
-                     this.closeServer(()=>{
-                      wx.showLoading({
-                        title: "生成视频中...",
-                      });
-                    });
-                  }, 20 * 1000);
+                     wx.hideLoading()
+                     this.checkTextDetail()
+                  }, 1000);
                 });
               });
             }, 500);
-
           }, 1000);
-
-          
         }, 500);
       }
 
@@ -394,20 +275,22 @@ VueLikePage([], {
           });
 
 
-          app.send("switch " + this.data.currentScene);
+          app.emitEvent.switchMachine(this.data.currentScene)
 
           setTimeout(() => {
-            app.send("photo " + "1#" + this.data.rndWord);
+            app.emitEvent.Photo(TYPESTR[this.data.type]+this.data.rndWord)
 
                // 为了同步机器的倒计时
               setTimeout(() => {
                 this.daojishiFn("daojishi", this.data.daojishi, () => {
-                  this.closeServer(()=>{
-                    wx.showLoading({
-                      title: "生成图片中...",
-                      // mask: true,
-                    });
+                  wx.showLoading({
+                    title: "生成图片中...",
+                    // mask: true,
                   });
+                  setTimeout(() => {
+                    this.checkTextDetail()
+                    wx.hideLoading()
+                  }, 1000);
                 });
               }, 500);
 
@@ -448,21 +331,15 @@ VueLikePage([], {
         app.hideLoading();
       }, 3 * 1000);
 
-      if (!app.sendCheck()) {
-        this.setData({
-          canTap: true,
-        });
-        app.hideLoading();
-      } else {
-        wx.showLoading({
-          title: "切换中...",
-          mask: true,
-        });
-        this.setData({
-          currentScene: id
-        });
-        app.send("switch " + id);
-      }
+    
+      wx.showLoading({
+        title: "切换中...",
+        mask: true,
+      });
+      this.setData({
+        currentScene: id
+      });
+      app.emitEvent.switchMachine(id)
     },
   },
 });

+ 3 - 3
pages/index/index.wxml

@@ -5,10 +5,10 @@
     <view class="swp">
       <swiper class="swiper" indicator-dots="{{indicatorDots}}" bindchange="swiperChange"
         autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
-        <block wx:for="{{background}}" wx:key="index">
+        <block wx:for="{{scenes}}" wx:key="index">
           <swiper-item>
             <view class="swiper-item">
-              <image src="{{cdn_url}}/images/{{item.img}}" mode="aspectFill" />
+              <image src="{{cdn_url}}/images/{{item.id}}.png" mode="aspectFill" />
             </view>
           </swiper-item>
         </block>
@@ -27,7 +27,7 @@
       
     <view class="lunbo">
       <block wx:for="{{scenes}}" wx:key="index">
-        <image bindtap="tapSelect" data-id="{{item.id}}" src="{{cdn_url}}/images/{{item.id}}{{item.id == currentScene ? '-active' : ''}}.png" mode="widthFix" />
+        <image bindtap="tapSelect" data-id="{{item.id}}" src="{{cdn_url}}/images/{{item.id}}{{item.id == currentScene ? '-active' : ''}}.png" mode="aspectFill" />
       </block>
     </view>
       

+ 12 - 3
pages/index/index.wxss

@@ -68,10 +68,19 @@
 }
 
 .body .lunbo{
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
   width: 100%;
+  display: inline-block;
+  overflow-x: auto;
+  white-space: nowrap;
+  /* justify-content: space-between;
+  align-items: center;
+  flex-wrap: wrap; */
+}
+
+.body .lunbo > image{
+  width: 31%;
+  height: 380rpx;
+  margin: 0 1%;
 }
 
 

+ 0 - 69
pages/select/index.js

@@ -1,69 +0,0 @@
-// index.js
-// 获取应用实例
-const app = getApp()
-import {
-  VueLikePage
-} from '../../utils/page'
-
-import { CDN_URL } from '../../config/index'
-
-import Router from '../../utils/routes'
-
-let DEMO = [
-  {
-    name:'诸葛亮',
-    id:'1'
-  },
-  {
-    name:'关羽',
-    id:'2'
-  },
-  {
-    name:'赵云',
-    id:'3'
-  },
-  {
-    name:'曹操',
-    id:'4'
-  },
-  {
-    name:'吕布',
-    id:'5'
-  },
-  {
-    name:'蔡文姬',
-    id:'6'
-  },
-]
-
-VueLikePage([],{
-  data:{
-    cdn_url:CDN_URL,
-    bg:CDN_URL+'/images/bg@2x.png',
-    demo:DEMO,
-    showDemo:false,
-    isBigScreen:app.globalData.deviceInfo.screenWidth>320
-  },
-  methods:{
-    onLoad:function () {
-      wx.hideHomeButton()
-    },
-    toggleDemo(){
-      this.setData({
-        showDemo: !this.data.showDemo
-      })
-    },
-    toDemo(e){
-        const { id,name } = e.currentTarget.dataset
-        Router.push({
-            url: 'example',
-            query: {
-              id,
-              name
-            }
-        })
-        
-    }
-  }
-})
-

+ 0 - 29
pages/select/index.wxml

@@ -1,29 +0,0 @@
-<!--pages/select/index.wxml-->
-<view class="container">
-    <view class="app" style="background-image:url({{bg}});--margin: {{isBigScreen?'10rpx':'20rpx'}};">
-        <view class="ai_top">
-            <view class="ai_title">选择喜爱的三国人物,拍照换装</view>
-            <view class="ai_pic">
-               <view data-id="{{item.id}}" data-name="{{item.name}}" bindtap="toDemo" wx:for='{{demo}}' wx:key="{{item.id}}">
-                <image src="{{cdn_url}}/images/demo/{{item.id}}.png" mode="widthFix" />
-                <text>{{item.name}}</text>
-               </view>
-            </view>
-        </view>
-        <view class="ai_bottom" >
-            <view bindtap="toggleDemo">
-                <image src="{{cdn_url}}/images/reg_btn@2x.png" mode="widthFix" />
-                <text>换装示例</text>
-            </view>
-        </view>
-    </view>
-    <view class="show_con" wx:if="{{showDemo}}">
-        <view class="show_mask"></view>
-        <view class="show_demo">
-            <image src="{{cdn_url}}/images/demo.jpg" mode="widthFix" />
-            <text bindtap="toggleDemo" class="iconfont iconquxiao"></text>
-        </view>
-    </view>
-      
-</view>
-  

+ 0 - 119
pages/select/index.wxss

@@ -1,119 +0,0 @@
-/* pages/select/index.wxss */
-
-.app {
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  width: 100%;
-  height: 100%;
-  color: #fff;
-  /* linear-gradient(180deg, #D8585E 0%, #630005 100%) */
-  background-size:100% 100%;
-  overflow: hidden;
-}
-
-.ai_top{
-  width: 100%;
-  height: 76%;
-  text-align: center;
-  display: block;
-}
-
-.ai_title{
-  margin: 6% auto;
-  width: 100%;
-}
-
-.ai_pic{
-  display: inline-block;
-  width: calc(100% - calc(var(--margin) * 2) * 2);
-}
-.ai_pic >view{
-  display: inline-block;
-  list-style: none;
-  width: calc((100% - var(--margin) * 2) / 3);
-  margin-bottom: calc(var(--margin) * 2);
-}
-
-.ai_pic > .active{
-  border-radius: 14rpx;
-  background: linear-gradient(180deg, #FFE5A5 0%, #DFA827 93%, #F3C24A 100%);
-  box-shadow: 0px 10rpx 20rpx rgba(74, 11, 11, 0.48);
-}
-
-.ai_pic >view > image{
-  width: calc(100% - var(--margin) * 2);
-  border-radius: 10rpx;
-}
-
-.ai_pic >view> text{
-  display: inline-block;
-  margin-bottom: calc(var(--margin) * 2);
-}
-
-.ai_pic > .active > text{
-  color: #962C30;
-}
-
-
-.ai_bottom{
-  width: 100%;
-  display: inline-block;
-  text-align: center;
-  position: relative;
-  font-size: 0;
-  margin-top: 100rpx;
-}
-
-.ai_bottom >view {
-  width: 280rpx;
-  margin: 0 auto;
-  display: inline-block;
-}
-
-.ai_bottom >view > image{
-  width: 100%;
-}
-
-.ai_bottom  >view > text{
-  font-size: 28rpx;
-  position: absolute;
-  top: 50%;
-  left: 50%;
-  line-height: 100%;
-  transform: translate(-50%,-50%);
-}
-
-.show_mask{
-  position: fixed;
-  top: 0;
-  left: 0;
-  background: rgba(0, 0, 0, 0.6);
-  width: 100%;
-  height: 100%;
-}
-
-
-.show_demo{
-  position: fixed;
-  top: 50%;
-  left: 50%;
-  transform: translate(-50%,-50%);
-  z-index: 9999;
-  text-align: center;
-  width: 80%;
-}
-
-
-
-.show_demo image{
-  width: 100%;
-  border-radius: 20rpx;
-  border: 2px solid #C9C9C9;
-}
-
-.show_demo text{
-  color: #fff;
-  margin-top: 20rpx;
-  font-size: 80rpx;
-  display: inline-block;
-}

+ 184 - 0
pages/start/index.js

@@ -0,0 +1,184 @@
+// index.js
+// 获取应用实例
+import { VueLikePage } from "../../utils/page";
+import { CDN_URL, API_BASE_URL, VIDEO_BASE_URL, app } from "../../config/index";
+import Router from "../../utils/routes";
+let socket_io = require("../../utils/socket.io-mp.js");
+var g_app = getApp();
+
+VueLikePage([], {
+  data: {
+    cdn_url: CDN_URL,
+    rndWord: "",
+    showModal: false,
+    type:0
+  },
+  methods: {
+    onLoad: function () {},
+
+    disconnect() {
+      app.websocket.disconnect();
+      app.websocket = null;
+    },
+
+    wish_put: function (e) {
+      this.setData({
+        rndWord: e.detail.value,
+      });
+    },
+
+    back() {
+      this.setData({
+        showModal: false,
+      });
+    },
+
+    ok() {
+      let link = "",
+        m_type = "";
+
+      if (this.data.rndWord.substring(0,3) == "pic") {
+        this.setData({
+          type:1
+        })
+        link = `${VIDEO_BASE_URL}4dpic/${this.data.rndWord}.jpg`;
+        m_type = "jpeg";
+      } else {
+        link = `${VIDEO_BASE_URL}4dvedio/${this.data.rndWord}.mp4`;
+        m_type = "video";
+        this.setData({
+          type:0
+        })
+      }
+
+      console.log(link);
+
+      wx.downloadFile({
+        url: link,
+        success: (res) => {
+          console.log(res);
+          if (res.statusCode == '404') {
+            return app.showAlert("作品暂未生成,请稍后再试");
+          }
+          //判断是否为数组
+          let typeType =
+            Object.prototype.toString.call(res.header["Content-Type"]) == "[object String]" ? res.header["Content-Type"] : res.header["Content-Type"][0];
+
+
+          //判断不是xml文件
+          if (typeType.indexOf(m_type) > -1) {
+
+            g_app.globalData.m_file = res.tempFilePath;
+            this.gotoWork();
+          }
+        },
+        fail: () => {
+          app.showAlert("作品暂未生成,请稍后再试");
+        },
+      });
+      this.setData({
+        showModal: false,
+      });
+    },
+
+    gotoWork() {
+      Router.push({
+        url: "work",
+        query: {
+          type: this.data.type,
+          id: this.data.currentScene,
+          rdw: encodeURIComponent(this.data.rndWord),
+        },
+      });
+    },
+
+    getWork() {
+      this.setData({
+        showModal: true,
+      });
+      // Router.push({
+      //   url: "work",
+      // });
+    },
+
+    onShow(){
+      if (app.websocket) {
+        this.disconnect();
+      }
+    },
+
+    checkTextDetail: function () {
+      wx.showModal({
+        title: "作品标识码",
+        content: this.data.rndWord,
+        showCancel: true,
+        confirmText: "复制文本",
+        success: (result) => {
+          if (result.confirm) {
+            wx.setClipboardData({
+              data: this.data.rndWord,
+              success: () => {
+                wx.getClipboardData({
+                  success: (data) => {
+                    console.log(data);
+                  },
+                });
+              },
+            });
+          }
+        },
+      });
+    },
+
+    bindStart: function () {
+      if (app.websocket) {
+        return;
+      }
+
+      app.websocket = socket_io(API_BASE_URL, {
+        transports: ["websocket"],
+      });
+
+      app.websocket.on("connect", () => {
+        console.log("SOCKET连接成功");
+        app.emitEvent.request((data) => {
+          app.websocket.on("ForceOffline", () => {
+            console.log("ForceOffline成功");
+            app.showAlert("服务器连接失败,请稍后再试", () => {
+              wx.reLaunch({
+                url: "start",
+              });
+            });
+            this.disconnect();
+          });
+
+          app.websocket.on("error", () => {
+            this.disconnect();
+            app.showAlert("服务器异常,请稍后再试");
+          });
+
+
+          if (data == 808) {
+            return app.showAlert("机器被占用,请稍后再试");
+          }
+
+          console.log(data,4545454);
+          try {
+            var json = JSON.parse(data);
+            g_app.globalData.scenes = [...json.scenes];
+            if (g_app.globalData.scenes.length > 0) {
+              Router.push({
+                url: "index",
+              });
+            } else {
+              app.showAlert("暂无场景");
+            }
+          } catch (error) {
+            this.disconnect();
+            app.showAlert("网络异常,请稍后再试");
+          }
+        });
+      });
+    },
+  },
+});

pages/select/index.json → pages/start/index.json


+ 37 - 0
pages/start/index.wxml

@@ -0,0 +1,37 @@
+<!--pages/select/index.wxml-->
+<view class="container">
+    <image class="c_bg"  src="{{cdn_url}}/images/bg.jpg" mode="scaleToFill" />
+    <view class="btn_con">
+        <view bindtap="bindStart">
+            <view class="use">
+                开始使用
+            </view>
+        </view>
+        <view bindtap="getWork">
+            <view class="use">
+                获取作品
+            </view>
+        </view>
+    </view>
+
+    <view class="body"  wx:if='{{showModal}}'>
+        <view class="model" catchtouchmove='preventTouchMove'></view>
+        <view class="modalDlg" catchtouchmove='preventTouchMove'>
+        <view class='windowRow'>
+            <text class='userTitle'>作品标识码
+        </text>
+            <view class='back' bindtap='back'>
+            返回
+            </view>
+        </view>
+        <view class='wishName'>
+            <input bindinput='wish_put' placeholder='请输入作品标识码' class='wish_put'></input>
+        </view>
+        <view class='wishbnt'>
+            <button class='wishbnt_bt' bindtap='ok'>确定</button>
+        </view>
+    </view>
+        </view>
+
+</view>
+  

+ 118 - 0
pages/start/index.wxss

@@ -0,0 +1,118 @@
+.container{
+  padding: 0;
+}
+
+.c_bg{
+  position: fixed;
+  left: 0;
+  top: 0;
+  height: 100%;
+  z-index: -1;
+  width: 100%;
+}
+.btn_con{
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%,-50%);
+  color: #fff;
+  text-align: center;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  flex-direction: column;
+  font-size: 34rpx;
+}
+
+.btn_con .use{
+  width: 220rpx;
+  height: 220rpx;
+  border-radius: 50%;
+  background: #ff8512;
+  overflow: hidden;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  box-shadow: 0 0 12rpx rgba(0, 0, 0, 0.5);
+  margin: 40rpx 0;
+}
+
+.body{
+  width: 100%;
+  height: 100%;
+  background-color: rgba(0, 0, 0, 0.5);
+  position: fixed;
+  z-index: 9999;
+  display: flex;
+  left: 0;
+  top: 0;
+}
+
+
+
+.modalDlg{
+  width: 80%;
+  position: absolute;
+  left: 50%;
+  top: 50%;
+  transform: translate(-50%,-50%);
+  z-index: 9999;
+  background-color: #fff;
+  border-radius: 4rpx;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  padding: 28rpx 28rpx 40rpx;
+}
+
+.windowRow{
+  display: flex;
+  flex-direction: row;
+  justify-content: space-between;
+  height: 100rpx;
+  width: 100%;
+  box-sizing: border-box;
+}
+
+.back{
+  text-align: center;
+  color: rgba(0, 0, 0, 0.5);
+  font-size: 28rpx;
+}
+
+.userTitle{
+  font-size: 32rpx;
+}
+
+.wishName{
+  width: 100%;
+  justify-content: center;
+  flex-direction: row;
+  display: flex;
+  margin-bottom: 20rpx;
+}
+
+.wish_put{
+  width: 80%;
+  border: 1px solid rgba(0, 0, 0, 0.1);
+  padding-left: 10rpx;
+  height: 80rpx;
+  line-height: 80rpx;
+  font-size: 28rpx;
+  margin-bottom: 28rpx;
+}
+
+.wishbnt{
+  width: 100%;
+  font-size: 30rpx;
+}
+
+
+.wishbnt .wishbnt_bt{
+  background-color: #ff8512;
+  color: #fbf1e8;
+  font-size: 30rpx;
+  border: 0;
+  line-height: 40rpx;
+  width: 40%!important;
+}

+ 7 - 5
pages/work/index.js

@@ -22,9 +22,9 @@ VueLikePage([], {
 
       let link = "";
       if (type == "0") {
-        link = `${VIDEO_BASE_URL}4dvedio/vedio${rdw}.mp4`;
+        link = `${VIDEO_BASE_URL}4dvedio/${rdw}.mp4`;
       } else {
-        link = `${VIDEO_BASE_URL}4dpic/pic${rdw}.jpg`;
+        link = `${VIDEO_BASE_URL}4dpic/${rdw}.jpg`;
       }
 
       this.setData({
@@ -39,9 +39,11 @@ VueLikePage([], {
       });
     },
     cancel() {
-      wx.reLaunch({
-        url: "/pages/index/index",
-      });
+      // wx.reLaunch({
+      //   url: "/pages/work/index",
+      // });
+
+      wx.navigateBack();
     },
     saveAlbum() {
       let type = this.data.type;

+ 1 - 1
pages/work/index.wxml

@@ -1,5 +1,5 @@
 <view class='container'>
-  <image wx:if="{{id}}" class="work_bg" src="{{cdn_url}}/images/shotbg_{{id}}.jpg" mode="aspectFill" />
+  <image class="work_bg" src="{{cdn_url}}/images/bg.jpg" mode="aspectFill" />
   <view class="w_body">
     <view class="w_video" >
       <video wx:if="{{type=='0'}}" style="opacity:{{loadCompele?1:0}}" bindloadedmetadata="loadcompele" src="{{url_link}}" loop autoplay controls="{{false}}" enable-progress-gesture="{{false}}"></video>

+ 1 - 1
pages/work/index.wxss

@@ -42,7 +42,7 @@
   left: 0;
   width: 100%;
   height: 100%;
-  background: rgba(25, 25, 25, 0.9);
+  background: rgba(25, 25, 25, 0.1);
 }
 
 

+ 2 - 2
project.private.config.json

@@ -26,8 +26,8 @@
         },
         {
           "name": "pages/camera/index",
-          "pathName": "pages/camera/index",
-          "query": "id=1",
+          "pathName": "pages/index/index",
+          "query": "",
           "scene": null
         },
         {

+ 2 - 0
utils/routes.js

@@ -10,6 +10,8 @@ const routes = {
   select: "/pages/select/index",
   example: "/pages/example/index",
   camera: "/pages/camera/index",
+  index: "/pages/index/index",
+  start: "/pages/start/index",
   work: "/pages/work/index"
 }