tremble 2 年之前
父节点
当前提交
18019e64c0
共有 13 个文件被更改,包括 583 次插入282 次删除
  1. 1 2
      app.json
  2. 40 36
      config/index.js
  3. 241 118
      pages/index/index.js
  4. 49 15
      pages/index/index.wxml
  5. 111 14
      pages/index/index.wxss
  6. 66 28
      pages/work/index.js
  7. 1 1
      pages/work/index.wxml
  8. 1 1
      pages/work/index.wxss
  9. 14 16
      project.config.json
  10. 8 14
      project.private.config.json
  11. 3 5
      utils/socket.io-mp.js
  12. 32 32
      utils/tools.js
  13. 16 0
      utils/utils.js

+ 1 - 2
app.json

@@ -1,13 +1,12 @@
 {
   "pages": [
-    "pages/start/index",
     "pages/index/index",
     "pages/work/index"
   ],
   "window": {
     "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#fff",
-    "navigationBarTitleText": "第十三届珠海航展",
+    "navigationBarTitleText": "太空启幕",
     "navigationBarTextStyle": "black"
   },
   "style": "v2",

+ 40 - 36
config/index.js

@@ -1,18 +1,19 @@
-export const API_BASE_URL = "ws://120.24.252.95:9999";
-// ws://192.168.0.134:7015
-// wss://4dart.4dage.com/4dart
+export const API_BASE_URL = "wss://sxb-socket.4dkankan.com";
+// export const API_BASE_URL = "ws://192.168.20.18:14000";
+// ws://192.168.20.18:14000
+// wss://sxb-socket.4dkankan.com
 // 88888888
 export const VIDEO_BASE_URL = "https://houseoss.4dkankan.com/";
 export const CDN_URL = "https://culture.4dage.com/air_show/resource";
 
 export let app = {
   id: "13750062488",
-  longtime:null,
+  longtime: null,
   websocket: null,
   is_connect_ok: null,
   is_send_msg: null,
-  noOperationTimeout: 35,
-  
+  noOperationTimeout: 60,
+
   send(msg) {
     if (!app.websocket) {
       return
@@ -20,44 +21,50 @@ export let app = {
     if (msg === "request") {
       app.websocket.emit(msg + " " + this.id);
     } else if (msg === "close") {
-      app.websocket.emit({ data: msg + " 0" });
+      app.websocket.emit({
+        data: msg + " 0"
+      });
     } else {
       if (app.is_connect_ok == null) {
-        app.websocket.emit({ data: "request " + this.id });
+        app.websocket.emit({
+          data: "request " + this.id
+        });
       }
       setTimeout(function () {
-        app.websocket.emit({ data: msg });
+        app.websocket.emit({
+          data: msg
+        });
       }, 300);
     }
   },
 
-  emitEvent:{
-    close(){
-      app.websocket.emit('Close','close',function (data) {
-        console.log(data,'close');
+  emitEvent: {
+    close() {
+      app.websocket && app.websocket.emit('Close', 'close', function (data) {
+        console.log(data, 'close');
       })
     },
-    request(cb=null){
-      app.websocket.emit('Request',app.id,function (data) {
+    request(cb = null, authorCode = null) {
+      app.websocket.emit('Request', `${app.id}#${authorCode}`, function (data) {
         cb && cb(data)
       })
     },
-    switchMachine(scene){
-      app.websocket.emit('Switch',scene,function (data) { 
-        console.log(data,scene);
+    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);
+    Photo(photo, cb = null) {
+      app.websocket.emit('Photo', photo, function (data) {
+        console.log(data, photo);
         cb && cb(data)
       })
     },
 
-    Video(video,cb=null){
-      app.websocket.emit('Video',video+app.id,function (data) {
-        console.log(data,video+app.id);
+    Video(video, cb = null) {
+      app.websocket.emit('Video', video, function (data) {
+        console.log(data, video);
         cb && cb(data)
       })
     },
@@ -78,7 +85,7 @@ export let app = {
       } catch (error) {}
     })();
   },
-  showAlert(msg, comfirm,confirmText='确定') {
+  showAlert(msg, comfirm, confirmText = '确定') {
     if (comfirm) {
       return (() => {
         wx.showModal({
@@ -105,13 +112,13 @@ export let app = {
   },
   sendCheck() {
 
-    console.log(this.is_connect,this.is_connect_ok,this.is_other_used);
-    
+    console.log(this.is_connect, this.is_connect_ok, this.is_other_used);
+
     if (!this.is_connect) {
       this.hideLoading()
       app.showAlert("服务器连接失败,请重新连接", () => {
         app.emitEvent.request();
-      },'重新连接');
+      }, '重新连接');
       return false;
     } else if (this.is_connect_ok === false) {
       this.hideLoading()
@@ -125,7 +132,7 @@ export let app = {
         setTimeout(() => {
           app.emitEvent.request();
         }, 1000);
-      },'重新连接');
+      }, '重新连接');
       return false;
     } else if (this.is_other_used) {
       this.hideLoading()
@@ -140,8 +147,8 @@ export let app = {
 
     return true;
   },
- 
-  checkOperationTimeout(stop) {
+
+  checkOperationTimeout(stop,cb=()=>{}) {
     this.operationTimer && clearTimeout(this.operationTimer);
     this.operationTimer = null;
     if (stop) {
@@ -150,13 +157,10 @@ export let app = {
     }
 
     this.operationTimer = setTimeout(function () {
-      if (app.is_connect_ok) {
-        app.emitEvent.close();
         this.is_other_used = true
         this.is_connect_ok = false
         app.checkOperationTimeout(true);
-        app.showAlert("抱歉,因您长时间使用,让下一位小伙伴体验吧");
-      }
+        cb()
     }, (this.noOperationTimeout || 120) * 1000);
   },
-};
+};

+ 241 - 118
pages/index/index.js

@@ -1,10 +1,21 @@
 // index.js
 // 获取应用实例
-import { VueLikePage } from "../../utils/page";
-import { randomWord } from "../../utils/utils";
-import { isPhoneX } from "./../../utils/tools";
-
-import { CDN_URL, API_BASE_URL, VIDEO_BASE_URL, app } from "../../config/index";
+import {
+  VueLikePage
+} from "../../utils/page";
+import {
+  randomWord
+} from "../../utils/utils";
+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")
 
@@ -13,8 +24,8 @@ let timer = null;
 var g_app = getApp();
 
 let TYPESTR = {
-  0:'media',
-  1:'pic'
+  0: 'media',
+  1: 'pic'
 }
 
 
@@ -26,105 +37,140 @@ VueLikePage([], {
     isIphoneX: false,
     canTap: true,
     rndWord: randomWord(false, 8),
-    scenes: [
+    scenes: [{
+        id: "1",
+      },
+      {
+        id: "2",
+      },
       {
-        id: "4",
+        id: "14",
       },
       {
-        id: "5",
+        id: "15",
       },
       {
-        id: "6",
+        id: "16",
       },
     ],
+    records: [],
     autoplay: true,
     interval: 3000,
     duration: 500,
     current: 0,
-    currentScene: 4,
+    currentScene: 1,
     daojishi: 0,
     isShot: false,
     isRecord: false,
     recordjishi: 10,
     type: "",
+    authorCode: '',
+    isOtherZhanYong: true
   },
   methods: {
 
+    scanCode: function (e) {
+      wx.scanCode({
+        onlyFromCamera: true,
+        success(res) {
+          wx.reLaunch({
+            url: `/${res.path}`
+          })
+        }
+      })
+    },
+
     swiperChange: function (e) {
       this.setData({
         current: e.detail.current,
       });
     },
 
-    onShow(){
+    onShow() {
       this.setData({
         rndWord: randomWord(false, 8)
       })
     },
 
+    gotoRecord(e) {
+      let {
+        id
+      } = e.currentTarget.dataset;
+
+      let item = this.data.records.find(i => i.id == id)
+
+
+      Router.push({
+        url: "work",
+        query: item.codeData,
+      });
+
+      console.log(item)
+    },
+
     gotoWork() {
+      //日期 new Date().Format("yyyy.MM.dd hh.mm.ss");  
+      //编号 new Date().Format("yyyyMMddhhmmss");  
       timer && clearTimeout(timer);
       timer = null;
+
+      let record = {
+        type: this.data.type,
+        id: this.data.currentScene,
+        rdw: encodeURIComponent(this.data.authorCode),
+      }
+
       Router.push({
         url: "work",
-        query: {
-          type: this.data.type,
-          id: this.data.currentScene,
-          rdw: encodeURIComponent(this.data.rndWord),
-        },
+        query: record,
       });
+
+      this.setData({
+        records: [{
+          id: new Date().Format("yyyyMMddhhmmss"),
+          date: new Date().Format("yyyy.MM.dd hh.mm.ss"),
+          type: this.data.type,
+          codeData: record
+        }].concat(this.data.records).slice(0, 15)
+      })
+
+      wx.setStorageSync('records', JSON.stringify(this.data.records))
+
       this.reset();
     },
 
-    reset() {
+    reset(noswitch=false) {
       this.setData({
         daojishi: 0,
         isShot: false,
         isRecord: false,
         currentScene: 1,
         recordjishi: 10,
-        type: "",
       });
-      this.clearLongTime();
-      app.websocket && app.websocket.send({ data: "switch 1" });
+      if(!noswitch){
+        app.websocket && app.websocket.send({
+          data: "switch 1"
+        });
+      }
+
       setTimeout(() => {
         app.hideLoading();
       });
     },
 
-    clearLongTime() {
-      app.longtime && clearInterval(app.longtime);
-      app.longtime = null;
-    },
-
-    closeServer(cb=null) {
-      app.closeByVideoHandle = true
-      if (app.websocket) {
-        app.send("close");
-        app.websocket.close();
-        app.websocket = null;
-      }
-      
-      if (app.longtime) {
-        setTimeout(() => {
-          cb && cb()
-        },100);
-      }
-    },
-
     handleWebSocket: function () {
       if (app.websocket) {
         return;
       }
 
-      app.websocket = socket_io(API_BASE_URL,{
+      app.websocket = socket_io(API_BASE_URL, {
         transports: ['websocket']
       });
 
       app.websocket.on('connect', () => {
         console.log('SOCKET连接成功');
-        app.emitEvent.request(data=>{
-          console.log(data,1111111);
+        app.emitEvent.request(data => {
+          console.log(data, 1111111);
         });
       })
 
@@ -134,55 +180,48 @@ VueLikePage([], {
             url: "/pages/start/index",
           });
         });
-        
+
         console.log('ForceOffline成功');
       })
 
     },
 
-    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);
-                  },
-                });
-              }
-            });
-              
-          }
-        },
-      });
-        
-      
+    onHide: function () {
+      this.disconnect();
     },
-    onLoad: function () {
+
+
+    onLoad: function (options) {
+      // 1、获取二维码传参
+      if (options.authorCode) {
+        this.setData({
+          authorCode: decodeURIComponent(options.authorCode),
+        })
+        this.start(this.data.authorCode)
+      }
+
+      if (wx.getStorageSync('records')) {
+        this.setData({
+          records: JSON.parse(wx.getStorageSync('records'))
+        })
+      }
+
+      // wx.setStorageSync('records', JSON.stringify(this.data.records))
+
+
       isPhoneX().then((res) => {
         this.setData({
           isIphoneX: res,
         });
       });
-      let tmp = g_app.globalData.scenes.map(item=>{
-        return {id:item}
-      })
-
-      this.setData({
-        scenes: tmp,
-        currentScene:tmp[0].id
-      })
+      // let tmp = g_app.globalData.scenes.map(item=>{
+      //   return {id:item}
+      // })
+
+      // this.setData({
+      //   scenes: tmp,
+      //   currentScene:tmp[0].id
+      // })
     },
 
     daojishiFn(key, time, fn = () => {}) {
@@ -207,13 +246,13 @@ VueLikePage([], {
     },
 
     shot: function (e) {
-      // app.checkOperationTimeout(true);
-
-      let { id } = e.currentTarget.dataset;
+      app.checkOperationTimeout(true);
+      let {
+        id
+      } = e.currentTarget.dataset;
 
       this.setData({
         type: id,
-        rndWord: randomWord(false, 8),
       });
 
       // if (!app.sendCheck()) {
@@ -234,26 +273,29 @@ VueLikePage([], {
           });
 
           app.emitEvent.switchMachine(this.data.currentScene)
-          
+
 
           setTimeout(() => {
-            app.emitEvent.Video(TYPESTR[this.data.type]+this.data.rndWord)
-            
+            app.emitEvent.Video(this.data.authorCode)
+
             // 为了同步机器的倒计时
             setTimeout(() => {
               this.daojishiFn("daojishi", this.data.daojishi, () => {
                 this.setData({
                   isRecord: true,
                 });
-    
+
                 this.daojishiFn("recordjishi", this.data.recordjishi, () => {
                   wx.showLoading({
                     title: "生成视频中...",
                   });
                   setTimeout(() => {
-                     wx.hideLoading()
-                     this.checkTextDetail()
-                  }, 1000);
+                    // 不发送switch
+                    this.gotoWork()
+                    this.disconnect(true)
+                    wx.hideLoading()
+                    // 上传倒计时
+                  }, 30 * 1000);
                 });
               });
             }, 500);
@@ -269,6 +311,7 @@ VueLikePage([], {
         this.setData({
           isShot: true,
         });
+
         setTimeout(() => {
           this.setData({
             daojishi: 3,
@@ -278,44 +321,46 @@ VueLikePage([], {
           app.emitEvent.switchMachine(this.data.currentScene)
 
           setTimeout(() => {
-            app.emitEvent.Photo(TYPESTR[this.data.type]+this.data.rndWord)
+            app.emitEvent.Photo(this.data.authorCode)
 
-               // 为了同步机器的倒计时
-              setTimeout(() => {
-                this.daojishiFn("daojishi", this.data.daojishi, () => {
-                  wx.showLoading({
-                    title: "生成图片中...",
-                    // mask: true,
-                  });
-                  setTimeout(() => {
-                    this.checkTextDetail()
-                    wx.hideLoading()
-                  }, 1000);
+            // 为了同步机器的倒计时
+            setTimeout(() => {
+              this.daojishiFn("daojishi", this.data.daojishi, () => {
+                wx.showLoading({
+                  title: "生成图片中...",
+                  // mask: true,
                 });
-              }, 500);
+                setTimeout(() => {
+                  // 不发送switch
+                  this.gotoWork()
+                  this.disconnect(true)
+                  wx.hideLoading()
+                }, 4 * 1000);
+              });
+            }, 500);
 
           }, 1000);
 
-          
+
         }, 500);
       }
 
-      // 1秒后拍照
-      setTimeout(() => {
-        
-      }, 1000);
     },
 
     tapSelect: function (e) {
-      app.checkOperationTimeout();
+      app.checkOperationTimeout(false, () => {
+        app.showAlert("抱歉,因您长时间使用,让下一位小伙伴体验吧", () => {
+          this.disconnect();
+        });
+      });
 
       if (!this.data.canTap) {
         return;
       }
 
-      this.clearLongTime();
-
-      let { id } = e.currentTarget.dataset;
+      let {
+        id
+      } = e.currentTarget.dataset;
       if (id == this.data.currentScene) {
         return;
       }
@@ -331,7 +376,7 @@ VueLikePage([], {
         app.hideLoading();
       }, 3 * 1000);
 
-    
+
       wx.showLoading({
         title: "切换中...",
         mask: true,
@@ -341,5 +386,83 @@ VueLikePage([], {
       });
       app.emitEvent.switchMachine(id)
     },
+
+    disconnect(noswitch=false) {
+      this.reset(noswitch);
+      if (app.websocket) {
+        app.emitEvent.close()
+        app.websocket.disconnect();
+        app.websocket = null;
+        this.setData({
+          isOtherZhanYong: true
+        })
+      }
+    },
+
+
+
+    start: function (authorCode) {
+      if (app.websocket) {
+        return;
+      }
+
+      app.websocket = socket_io(API_BASE_URL, {
+        transports: ["websocket"],
+      });
+
+      app.websocket.on("connect", () => {
+        console.log("SOCKET连接成功");
+        wx.showLoading({
+          mask: true,
+          title: '正在连接机器',
+        })
+
+        let linktimer = setTimeout(() => {
+          clearTimeout(linktimer)
+          wx.showToast({
+            title: '网络异常,请稍后再试',
+            icon: 'none'
+          })
+          wx.hideLoading()
+        }, 5000);
+        app.emitEvent.request((data) => {
+          // 校验成功后解除被他人占用情况
+          clearTimeout(linktimer)
+          wx.hideLoading()
+          this.setData({
+            isOtherZhanYong: false
+          })
+          app.checkOperationTimeout(false, () => {
+            app.showAlert("抱歉,因您长时间使用,让下一位小伙伴体验吧", () => {
+              this.disconnect();
+            });
+          });
+          app.websocket.on("ForceOffline", () => {
+            console.log("ForceOffline成功");
+            app.checkOperationTimeout(true);
+            this.disconnect();
+          });
+
+          app.websocket.on("error", () => {
+            this.disconnect();
+            app.showAlert("服务器异常,请稍后再试");
+          });
+
+
+          if (data == 808) {
+            // return app.showAlert("机器被占用,请稍后再试");
+            app.checkOperationTimeout(true);
+            this.disconnect();
+          }
+
+          if (data == 404 || data == 505) {
+            app.checkOperationTimeout(true);
+            this.disconnect();
+            // app.showAlert("网络异常,请稍后再试");
+          }
+          console.log(data, 'data')
+        }, authorCode);
+      });
+    },
   },
-});
+});

+ 49 - 15
pages/index/index.wxml

@@ -3,12 +3,11 @@
   <image class="c_bg" src="{{cdn_url}}/images/bg.jpg" mode="scaleToFill" />
   <view class="body">
     <view class="swp">
-      <swiper class="swiper" indicator-dots="{{indicatorDots}}" bindchange="swiperChange"
-        autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
+      <swiper class="swiper" indicator-dots="{{indicatorDots}}" bindchange="swiperChange" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
         <block wx:for="{{scenes}}" wx:key="index">
           <swiper-item>
             <view class="swiper-item">
-              <image src="{{cdn_url}}/images/{{item.id}}.png" mode="aspectFill" />
+              <image src="{{cdn_url}}/images/lunbo{{item.id}}.jpg" mode="aspectFill" />
             </view>
           </swiper-item>
         </block>
@@ -17,23 +16,58 @@
         <block wx:for="{{background}}" wx:key="index">
           <image src="{{cdn_url}}/images/{{index == current ? 'dot_active.png' : 'dot_default.png'}}" mode="aspectFill" />
         </block>
-      </view>  
+      </view>
     </view>
 
     <view class="title">
-        <image src="{{cdn_url}}/images/change_title.png" mode="widthFix" />
-        <image src="{{cdn_url}}/images/logo.png" mode="widthFix" />
+      <image src="{{cdn_url}}/images/xuanze_new.png" mode="widthFix" />
+      <text>选择您喜欢的场景</text>
     </view>
-      
-    <view class="lunbo">
+
+    <view class="lunbo" style="pointer-events: {{isOtherZhanYong?'none':'auto'}};opacity:{{isOtherZhanYong?'0.6':'1'}}">
       <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="aspectFill" />
       </block>
     </view>
-      
-    <view class="btn_paise"  style="--bottom: {{isIphoneX?'10%':'4%'}};">
-      <image bindtap="shot" data-id="1" src="{{cdn_url}}/images/photo_btn.png" mode="widthFix" />
-      <image bindtap="shot" data-id="0" src="{{cdn_url}}/images/record_btn.png" mode="widthFix" />
+
+    <view class="title">
+      <image src="{{cdn_url}}/images/paishe_new.png" mode="widthFix" />
+      <text>点击记录,下载拍摄结果,仅保留近15条内容</text>
+    </view>
+
+    <view class="record" style="--paddingbtm: {{records.length<=0?'50rpx':'180rpx'}};">
+      <block wx:for="{{records}}" wx:key="index">
+        <view data-id="{{item.id}}" bindtap="gotoRecord">
+          <text>记录编号:{{item.id}}</text>
+          <view>
+            <text>场景名 | {{item.type=='1'?'拍照':'录像'}}</text>
+            <text>{{item.date}}</text>
+          </view>
+        </view>
+      </block>
+      <view class="norecord" style="text-align: center;" wx:if="{{records.length<=0}}">
+        <view class="record-title">历史记录</view>
+        <view class="norecord-text">暂无记录</view>
+      </view>
+    </view>
+
+
+    <view class="btn_paise" style="--bottom: {{isIphoneX?'10%':'4%'}};">
+      <block wx:if="{{!isOtherZhanYong}}">
+        <view class="paizhao">
+          <image bindtap="shot" data-id="1" src="{{cdn_url}}/images/paizhao_new.png" mode="widthFix" />
+        </view>
+        <view class="luxiang">
+          <image bindtap="shot" data-id="0" src="{{cdn_url}}/images/luxiang_new.png" mode="widthFix" />
+        </view>
+      </block>
+
+      <view class="rescan" wx:else>
+        <text>其他游客使用中,请稍后重新扫码</text>
+        <view bindtap="scanCode">
+          <image src="{{cdn_url}}/images/chongxinsaoma.png" mode="widthFix" />
+        </view>
+      </view>
     </view>
 
   </view>
@@ -49,13 +83,13 @@
         </view>
       </view>
     </view>
-  
+
     <view class="record {{(isRecord&&recordjishi) ? '' :'hidden'}}">
       <image src="{{cdn_url}}/images/record.png" mode="widthFix" />
       <text>录制中{{recordjishi? '('+recordjishi+'s)':''}}…</text>
     </view>
-    
+
 
   </view>
 
-</view>
+</view>

+ 111 - 14
pages/index/index.wxss

@@ -14,11 +14,8 @@
 
 .body{
   width: 100%;
-  height: 100%;
-  position: fixed;
-  top: 50%;
-  left: 0;
-  transform: translateY(-50%);
+  min-height: 100%;
+  overflow-y: auto;
 }
 
 .swp{
@@ -58,15 +55,22 @@
   width: 90%;
   margin: 20rpx 5% 30rpx;
   display: flex;
-  justify-content: space-between;
-  align-items: center;
+  align-items: flex-end;
   height: 80rpx;
 }
 .body .title image{
-  width: 30%;
+  width: 22%;
   height: 100%;
 }
 
+.body .title text{
+  display: inline-block;
+  color: #999999;
+  margin-left: 30rpx;
+  margin-bottom: -4rpx;
+  font-size: 24rpx;
+}
+
 .body .lunbo{
   width: 100%;
   display: inline-block;
@@ -78,26 +82,119 @@
 }
 
 .body .lunbo > image{
-  width: 31%;
-  height: 380rpx;
+  width: 28%;
+  height: 336rpx;
   margin: 0 1%;
 }
 
+.body .record{
+  padding-bottom: var(--paddingbtm);
+}
+
+.body .record >view{
+  background-color: #fff;
+  width: 90%;
+  margin:  0 auto 28rpx;
+  padding: 20rpx;
+  box-shadow: 0 0 16rpx 2rpx rgba(0,0,0,0.1);
+  border-radius: 10rpx;
+  opacity: 1;
+}
+
+.body .record >view > text{
+  font-weight: bold;
+  font-size: 32rpx;
+  color: #666666;
+}
+
+.body .record >view > view{
+  color: #999999;
+  margin-top: 20rpx;
+  display: flex;
+  justify-content: space-between;
+  align-items: flex-end;
+}
+.body .record >view > view>text{
+  font-size: 28rpx;
+}
+
+.body .record >view > view>text:last-of-type{
+  font-size: 24rpx;
+}
+
+
+.body .record .norecord >view{
+  margin-top: 0;
+}
+.body .record .norecord > .record-title{
+  color: #000;
+  font-size: 30rpx;
+  font-weight: bold;
+}
+
+.body .record .norecord > .norecord-text{
+  text-align: center;
+  width: 100%;
+  display: inline-block;
+  margin-top: 20rpx;
+  font-size: 28rpx;
+}
 
 .body .btn_paise{
   position: fixed;
   z-index: 99;
   left: 50%;
   transform: translateX(-50%);
-  width: 60%;
-  bottom: var(--bottom);
+  width: 100%;
+  /* bottom: var(--bottom); */
+  bottom: 0;
   display: flex;
   justify-content: space-between;
+  font-size: 0;
+  max-height: 180rpx;
 }
 
-.body .btn_paise > image{
-  width: 44%;
+.body .btn_paise > view{
+  width: 50%;
+  text-align: center;
   height: auto;
+  padding: 30rpx 0;
+  font-size: 0;
+}
+.body .btn_paise > .rescan{
+  width: 100%;
+  padding: 0;
+  background: #FFFFFF;
+  box-shadow: 0 -4rpx 4rpx 2rpx rgba(0,0,0,0.1);
+}
+.body .btn_paise > .rescan> text {
+  font-size: 28rpx;
+  color: #999999;
+  background-color: #fff;
+  padding: 10rpx 0;
+  display: inline-block;
+  width: 100%;
+}
+.body .btn_paise > .rescan> view {
+  background-color: #FF8500;
+  width: 100%;
+  padding: 20rpx 0;
+}
+
+.body .btn_paise > .rescan> view > image{
+  width: 50%;
+}
+
+.body .btn_paise > view > image{
+  width: 50%;
+}
+
+.body .btn_paise .luxiang{
+  background-color: #00B3EC;
+}
+
+.body .btn_paise .paizhao{
+  background-color: #FF8500;
 }
 
 

+ 66 - 28
pages/work/index.js

@@ -1,8 +1,14 @@
 // index.js
 // 获取应用实例
-import { VueLikePage } from "../../utils/page";
-
-import { CDN_URL, API_BASE_URL, VIDEO_BASE_URL } from "../../config/index";
+import {
+  VueLikePage
+} from "../../utils/page";
+import {
+  CDN_URL,
+  API_BASE_URL,
+  VIDEO_BASE_URL,
+  app
+} from "../../config/index";
 
 
 var g_app = getApp();
@@ -12,13 +18,18 @@ VueLikePage([], {
     cdn_url: CDN_URL,
     baseUrl: API_BASE_URL + "/",
     url_link: "",
-    id: "",
+    id: "1",
     type: "",
     loadCompele: false,
+    filePath: ''
   },
   methods: {
     onLoad: function (options) {
-      let { rdw, id, type } = options;
+      let {
+        rdw,
+        id,
+        type
+      } = options;
 
       let link = "";
       if (type == "0") {
@@ -32,6 +43,12 @@ VueLikePage([], {
         id,
         type,
       });
+
+      this.downloadF(data => {
+        this.setData({
+          filePath: data
+        })
+      })
     },
     loadcompele() {
       this.setData({
@@ -45,6 +62,45 @@ VueLikePage([], {
 
       wx.navigateBack();
     },
+
+    downloadF(cb = () => {}) {
+      let link = this.data.url_link,
+        m_type = "";
+
+      if (this.data.type == "1") {
+        m_type = "jpeg";
+      } else {
+        m_type = "video";
+      }
+
+
+      wx.downloadFile({
+        url: link,
+        success: (res) => {
+          if (res.statusCode == '404') {
+            return app.showAlert("作品暂未生成,请稍后再试", () => {
+              wx.navigateBack()
+            });
+          }
+          //判断是否为数组
+          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) {
+            cb(res.tempFilePath)
+          }
+        },
+        fail: () => {
+          app.showAlert("作品暂未生成,请稍后再试");
+        },
+      });
+      this.setData({
+        showModal: false,
+      });
+    },
+
     saveAlbum() {
       let type = this.data.type;
 
@@ -53,11 +109,11 @@ VueLikePage([], {
         mask: true,
       });
 
-      if (g_app.globalData.m_file) {
+      if (this.data.filePath) {
         let api =
           type == "0" ? "saveVideoToPhotosAlbum" : "saveImageToPhotosAlbum";
         wx[api]({
-          filePath: g_app.globalData.m_file,
+          filePath: this.data.filePath,
           success() {
             wx.showModal({
               title: "提示",
@@ -66,14 +122,13 @@ VueLikePage([], {
             });
           },
           fail: (e) => {
-            if (!(e.errMsg.indexOf('cancel')>-1)) {
+            if (!(e.errMsg.indexOf('cancel') > -1)) {
               wx.showModal({
                 title: "提示",
-                content: "保存失败,请稍后再试",
+                content: "保存失败,请检查是否开启相册保存权限,可在「右上角」 - 「设置」里查看",
                 showCancel: false,
               });
             }
-            
           },
           complete: () => {
             wx.hideLoading();
@@ -81,23 +136,6 @@ VueLikePage([], {
         });
       }
 
-      // let link = this.data.url_link;
-
-      // wx.downloadFile({
-      //   url: link,
-      //   success: function (res) {
-      //     var tempFilePath = res.tempFilePath;
-
-      //   },
-      //   fail: function (res) {
-      //     wx.showModal({
-      //       title:'提示',
-      //       content:'下载失败,请稍后再试',
-      //       showCancel:false
-      //     })
-      //     wx.hideLoading()
-      //   }
-      // });
     },
   },
-});
+});

+ 1 - 1
pages/work/index.wxml

@@ -1,5 +1,5 @@
 <view class='container'>
-  <image class="work_bg" src="{{cdn_url}}/images/bg.jpg" mode="aspectFill" />
+  <image class="work_bg" src="{{cdn_url}}/images/shotbg_{{id}}.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.1);
+  background: rgba(0, 0, 0, 0.7);
 }
 
 

+ 14 - 16
project.config.json

@@ -1,7 +1,8 @@
 {
-  "description": "项目配置文件",
+  "description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
   "packOptions": {
-    "ignore": []
+    "ignore": [],
+    "include": []
   },
   "setting": {
     "urlCheck": false,
@@ -23,37 +24,30 @@
     "compileHotReLoad": false,
     "lazyloadPlaceholderEnable": false,
     "useMultiFrameRuntime": true,
-    "useApiHook": true,
-    "useApiHostProcess": true,
+    "useApiHook": false,
+    "useApiHostProcess": false,
     "babelSetting": {
       "ignore": [],
       "disablePlugins": [],
       "outputPath": ""
     },
-    "enableEngineNative": false,
     "useIsolateContext": false,
     "userConfirmedBundleSwitch": false,
     "packNpmManually": false,
     "packNpmRelationList": [],
     "minifyWXSS": true,
     "disableUseStrict": false,
+    "minifyWXML": true,
     "showES6CompileOption": false,
     "useCompilerPlugins": false,
-    "minifyWXML": true
+    "ignoreUploadUnusedFiles": true,
+    "useStaticServer": true,
+    "condition": false
   },
   "compileType": "miniprogram",
   "libVersion": "2.19.5",
-  "appid": "wxb4c0527aa20a6e9a",
+  "appid": "wx5362d6bccaa0e033",
   "projectname": "AI_change",
-  "debugOptions": {
-    "hidedInDevtools": []
-  },
-  "scripts": {},
-  "staticServerOptions": {
-    "baseURL": "",
-    "servePath": ""
-  },
-  "isGameTourist": false,
   "condition": {
     "search": {
       "list": []
@@ -73,5 +67,9 @@
     "miniprogram": {
       "list": []
     }
+  },
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
   }
 }

+ 8 - 14
project.private.config.json

@@ -1,21 +1,13 @@
 {
   "setting": {},
   "condition": {
-    "plugin": {
-      "list": []
-    },
-    "game": {
-      "list": []
-    },
-    "gamePlugin": {
-      "list": []
-    },
     "miniprogram": {
       "list": [
         {
-          "name": "pages/test/index",
-          "pathName": "pages/test/test",
-          "query": "",
+          "name": "pages/index/index",
+          "pathName": "pages/index/index",
+          "query": "authorCode=12345678",
+          "launchMode": "default",
           "scene": null
         },
         {
@@ -33,7 +25,8 @@
         {
           "name": "pages/work/index",
           "pathName": "pages/work/index",
-          "query": "type=1&id=1&rdw=IiVnXAz8",
+          "query": "type=0&id=1&rdw=kHYlUzoX",
+          "launchMode": "default",
           "scene": null
         },
         {
@@ -44,5 +37,6 @@
         }
       ]
     }
-  }
+  },
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
 }

文件差异内容过多而无法显示
+ 3 - 5
utils/socket.io-mp.js


+ 32 - 32
utils/tools.js

@@ -33,35 +33,35 @@ export function isPhoneX () {
   })
 }
 
-export function getLocation () {
-  return new Promise ( (resolve, reject) => {
-    wx.getLocation({
-      type: 'wgs84',
-      success: function (res) {
-          var latitude = res.latitude;
-          var longitude = res.longitude;
-          getApp().globalData.qqmapsdk.reverseGeocoder({
-              location: {
-                  latitude: latitude,
-                  longitude: longitude
-              },
-              success: function (res) {
-                  var ad_info = res.result.ad_info;
-                  let city = ad_info.city.replace('市', '');
-                  resolve(city)
-              },
-              fail:function (res) {
-                  wx.showModal({
-                      title: '定位失败',
-                  });
-              }
-          });
-      },
-      fail(err) {
-          wx.showModal({
-              title: '定位失败,请手动选择城市',
-          });
-      }
-  })
-})
-}
+// export function getLocation () {
+//   return new Promise ( (resolve, reject) => {
+//     wx.getLocation({
+//       type: 'wgs84',
+//       success: function (res) {
+//           var latitude = res.latitude;
+//           var longitude = res.longitude;
+//           getApp().globalData.qqmapsdk.reverseGeocoder({
+//               location: {
+//                   latitude: latitude,
+//                   longitude: longitude
+//               },
+//               success: function (res) {
+//                   var ad_info = res.result.ad_info;
+//                   let city = ad_info.city.replace('市', '');
+//                   resolve(city)
+//               },
+//               fail:function (res) {
+//                   wx.showModal({
+//                       title: '定位失败',
+//                   });
+//               }
+//           });
+//       },
+//       fail(err) {
+//           wx.showModal({
+//               title: '定位失败,请手动选择城市',
+//           });
+//       }
+//   })
+// })
+// }

+ 16 - 0
utils/utils.js

@@ -1,3 +1,19 @@
+Date.prototype.Format =  function (fmt) {  // author: meizz 
+  var o = {
+     "M+":  this.getMonth() + 1,  // 月份 
+     "d+":  this.getDate(),  // 日 
+     "h+":  this.getHours(),  // 小时 
+     "m+":  this.getMinutes(),  // 分 
+     "s+":  this.getSeconds(),  // 秒 
+     "q+": Math.floor(( this.getMonth() + 3) / 3),  // 季度 
+     "S":  this.getMilliseconds()  // 毫秒 
+ };
+  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, ( this.getFullYear() + "").substr(4 - RegExp.$1.length));
+  for ( var k  in o)
+  if ( new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
+  return fmt;
+}
+
 export function bindInput(event) {
   var obj = {},
     key = event.target.dataset['key'];