tremble 2 年之前
當前提交
382a9f89cd
共有 17 個文件被更改,包括 666 次插入0 次删除
  1. 31 0
      .eslintrc.js
  2. 19 0
      app.js
  3. 14 0
      app.json
  4. 13 0
      app.wxss
  5. 185 0
      pages/index/index.js
  6. 5 0
      pages/index/index.json
  7. 21 0
      pages/index/index.wxml
  8. 147 0
      pages/index/index.wxss
  9. 18 0
      pages/logs/logs.js
  10. 4 0
      pages/logs/logs.json
  11. 6 0
      pages/logs/logs.wxml
  12. 8 0
      pages/logs/logs.wxss
  13. 52 0
      project.config.json
  14. 29 0
      project.private.config.json
  15. 7 0
      sitemap.json
  16. 8 0
      utils/socket.io-mp.js
  17. 99 0
      utils/util.js

+ 31 - 0
.eslintrc.js

@@ -0,0 +1,31 @@
+/*
+ * Eslint config file
+ * Documentation: https://eslint.org/docs/user-guide/configuring/
+ * Install the Eslint extension before using this feature.
+ */
+module.exports = {
+  env: {
+    es6: true,
+    browser: true,
+    node: true,
+  },
+  ecmaFeatures: {
+    modules: true,
+  },
+  parserOptions: {
+    ecmaVersion: 2018,
+    sourceType: 'module',
+  },
+  globals: {
+    wx: true,
+    App: true,
+    Page: true,
+    getCurrentPages: true,
+    getApp: true,
+    Component: true,
+    requirePlugin: true,
+    requireMiniProgram: true,
+  },
+  // extends: 'eslint:recommended',
+  rules: {},
+}

+ 19 - 0
app.js

@@ -0,0 +1,19 @@
+// app.js
+App({
+  onLaunch() {
+    // 展示本地存储能力
+    const logs = wx.getStorageSync('logs') || []
+    logs.unshift(Date.now())
+    wx.setStorageSync('logs', logs)
+
+    // 登录
+    wx.login({
+      success: res => {
+        // 发送 res.code 到后台换取 openId, sessionKey, unionId
+      }
+    })
+  },
+  globalData: {
+    userInfo: null
+  }
+})

+ 14 - 0
app.json

@@ -0,0 +1,14 @@
+{
+  "pages": [
+    "pages/index/index",
+    "pages/logs/logs"
+  ],
+  "window": {
+    "backgroundTextStyle": "light",
+    "navigationBarBackgroundColor": "#000",
+    "navigationBarTitleText": "",
+    "navigationBarTextStyle": "black"
+  },
+  "style": "v2",
+  "sitemapLocation": "sitemap.json"
+}

+ 13 - 0
app.wxss

@@ -0,0 +1,13 @@
+/**app.wxss**/
+page{
+  width: 100%;
+  height: 100%;
+}
+.container {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: space-between;
+  box-sizing: border-box;
+} 

+ 185 - 0
pages/index/index.js

@@ -0,0 +1,185 @@
+// index.js
+
+// 获取应用实例
+const app = getApp()
+
+//正式环境
+let API_BASE_URL = 'wss://uspace.4dage.com/'
+let PAGE_URL = 'https://uspace.4dage.com/'
+//测试环境,上传发布版本要注释以下代码
+//API_BASE_URL = 'ws://test-xspace.4dage.com/'
+//PAGE_URL = 'https://test-xspace.4dage.com/'
+
+
+Page({
+  data: {
+    motto: 'Hello World',
+    userInfo: {},
+    url: '',
+    hasUserInfo: false,
+    PageOrientation: 'portrait',
+    canIUse: wx.canIUse('button.open-type.getUserInfo'),
+    sIdAndrIdQuery: '',
+    loadCompele: false,
+    inputNickName: '',
+    phone: ''
+  },
+
+  onShareAppMessage() {
+    // const promise = new Promise(resolve => {
+    //   setTimeout(() => {
+    //     resolve({
+    //       title: '四维元宇宙'
+    //     })
+    //   }, 1000)
+    // })
+    return {
+      title: '四维元宇宙',
+      //path: '/page/user?id=123',
+      //promise 
+    }
+  },
+
+  onShareTimeline() {
+
+  },
+
+  bindKeyInput(e) {
+    this.setData({
+      inputNickName: e.detail.value
+    })
+  },
+
+  onLoad(options) {
+    // 1、获取二维码传参
+    if (options.scene) {
+      this.setData({
+        sIdAndrIdQuery: decodeURIComponent(options.scene),
+      })
+    }
+
+    if (wx.getStorageSync('phone')) {
+      this.setData({
+        phone: wx.getStorageSync('phone')
+      })
+    }
+
+    if (wx.getStorageSync('nickName')) {
+      console.log(wx.getStorageSync('nickName'))
+      this.setData({
+        inputNickName: wx.getStorageSync('nickName')
+      })
+    }
+  },
+
+  loadcompele() {
+    this.setData({
+      loadCompele: true
+    })
+  },
+
+
+  enterUrl() {
+    this.setData({
+      url: `${PAGE_URL}?avatarUrl=${encodeURIComponent(this.data.avatarUrl)}&nickName=${encodeURIComponent(this.data.nickName)}${this.data.sIdAndrIdQuery?('&'+this.data.sIdAndrIdQuery):''}`,
+    })
+
+    wx.setPageOrientation({
+      orientation: 'landscape',
+    })
+  },
+
+  saveNumber(num) {
+    let userinfo = wx.getStorageSync('userInfo')
+    wx.request({
+      // url: 'http://192.168.20.55:8040/' + `api/wx/save/wxUser`,
+      url: PAGE_URL + `api/wx/save/wxUser`,
+      method: 'post',
+      data: {
+        ...userinfo,
+        phone: num
+      },
+      dataType: 'json',
+      success: res => {
+
+      },
+      fail: err => {
+        console.log(err)
+      },
+      complete: complete => {
+
+      }
+    })
+  },
+
+  getPhoneNumber(e) {
+    console.log(e.detail.code)
+    if (e.detail.code) {
+      wx.request({
+        // url: 'http://192.168.20.55:8040/' + `api/wx/getPhone/${e.detail.code}`,
+        url: PAGE_URL + `api/wx/getPhone/${e.detail.code}`,
+        method: 'get',
+        dataType: 'json',
+
+        success: res => {
+          console.log(res)
+          if (res.data.code > -1) {
+            wx.setStorageSync('phone', res.data.data.phoneNumber)
+            this.saveNumber(res.data.data.phoneNumber)
+          }
+        },
+        fail: err => {
+          console.log(err)
+        },
+        complete: complete => {
+
+        }
+      })
+    }
+  },
+
+  getUserProfile(e) {
+    if (wx.getStorageSync('avatarUrl') && wx.getStorageSync('nickName')) {
+      wx.setStorageSync('nickName', this.data.inputNickName)
+
+      this.setData({
+        avatarUrl: wx.getStorageSync('avatarUrl'),
+        nickName: wx.getStorageSync('nickName')
+      })
+      this.enterUrl()
+    } else {
+      // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
+      wx.getUserProfile({
+        desc: '使用您的昵称,作为数字人的昵称', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+        success: (res) => {
+          wx.setStorageSync('userInfo', res.userInfo)
+          let {
+            nickName,
+            avatarUrl
+          } = res.userInfo
+
+
+          this.setData({
+            avatarUrl: avatarUrl,
+            nickName: this.data.inputNickName.trim() || nickName
+          })
+
+          wx.setStorageSync('avatarUrl', this.data.avatarUrl)
+          wx.setStorageSync('nickName', this.data.nickName)
+
+
+          this.enterUrl()
+        },
+        fail: (error) => {
+          console.log(error);
+          //如果用户拒绝,使用默认昵称
+          this.setData({
+            avatarUrl: null,
+            nickName: this.data.inputNickName.trim() || '微信用户'
+          })
+          this.enterUrl()
+        }
+      })
+    }
+  }
+})

+ 5 - 0
pages/index/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {},
+  "pageOrientation": "portrait",
+  "navigationStyle": "custom"
+}

+ 21 - 0
pages/index/index.wxml

@@ -0,0 +1,21 @@
+<!--index.wxml-->
+<view class="container" wx:if="{{!url}}">
+  <video style="opacity:{{loadCompele?1:0}}" bindloadedmetadata="loadcompele" src="https://culture.4dage.com/demo/meta_fdkk/video.mp4" loop autoplay controls="{{false}}" enable-progress-gesture="{{false}}" object-fit="cover"></video>
+
+  <view class="uigather">
+    <!-- <image style="width: 750rpx; height: 562rpx; display: block; box-sizing: border-box" src="https://culture.4dage.com/demo/meta_fdkk/index1.png" class="index1" mode="widthFix" /> -->
+    <image src="https://app.4dage.com/metaverse/assets/icons1.png" class="index2" mode="aspectFit" />
+    <image src="https://culture.4dage.com/demo/meta_fdkk/index3.png" class="index3" mode="widthFix" />
+    <view class="getUserInfo">
+      <input type="nickname" bindinput="bindKeyInput" value="{{inputNickName}}" maxlength="20" placeholder="请输入昵称" class="nameinput" />
+      <button class='bangding' bindgetphonenumber="getPhoneNumber" bindtap="getUserProfile" open-type="{{!phone&&'getPhoneNumber'}}" >开始体验</button>
+      <text>请授予我们获取您的手机号码的权限,以便为您提供更好的服务</text>
+    </view>
+    <image src="https://culture.4dage.com/demo/meta_fdkk/logo.png" class="logo" mode="aspectFit" />
+  </view>
+
+
+</view>
+
+
+<web-view wx:else bindmessage="onChangePageOrientation" src="{{url}}"></web-view>

+ 147 - 0
pages/index/index.wxss

@@ -0,0 +1,147 @@
+/**index.wxss**/
+.container {
+  background-color: #ffffff;
+  position: relative;
+  height: 100%;
+  width: 100%;
+  /* background-image: url(https://culture.4dage.com/demo/meta_fdkk/bg.jpg);  */
+  background-position: center bottom;
+  background-size: cover;
+}
+
+.container>video {
+  height: 100%;
+  width: 100%;
+  position: absolute;
+  z-index: 1;
+  background: none;
+  top: 0;
+  left: 0;
+  transition: all ease 0.5s;
+}
+
+.uigather {
+  position: fixed;
+  z-index: 99;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: flex-start;
+  height: 100%;
+  top: 10%;
+  width: 100%;
+}
+
+.uigather image {
+  width: 100%;
+  pointer-events: none;
+}
+
+.uigather .index2 {
+  margin-top: 10%;
+  width: 80%;
+}
+
+.uigather .index3 {
+  position: absolute;
+  bottom: 0;
+  left: 50%;
+  transform: translateX(-50%);
+}
+
+.uigather .logo {
+  position: absolute;
+  bottom: 2%;
+  width: 50%;
+  left: 50%;
+  transform: translateX(-50%);
+}
+
+.getUserInfo {
+  position: absolute;
+  bottom: 32%;
+  left: 50%;
+  pointer-events: auto !important;
+  z-index: 999;
+  transform: translateX(-50%);
+  text-align: center;
+  max-width: 56%;
+  width: 100%;
+}
+
+.getUserInfo .nameinput {
+  background-image: url(https://app.4dage.com/metaverse/assets/bg_tool.png);
+  background-size: 100% 100%;
+  margin: 0 auto 20rpx;
+  height: 70rpx;
+  line-height: 70rpx;
+  color: antiquewhite;
+  width: 80%;
+}
+
+
+.getUserInfo>.bangding {
+  background-image: url(https://app.4dage.com/metaverse/assets/btn1.png);
+  background-size: 100% 100%;
+  background-color: none;
+  padding: 0 40rpx;
+  white-space: nowrap;
+  height: 80rpx;
+  width: 80%;
+  margin: 0 auto;
+  text-align: center;
+  color: rgb(27, 27, 27);
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  font-size: 36rpx;
+  box-sizing: border-box;
+  padding: 0;
+}
+
+.getUserInfo> text {
+  font-size: 24rpx;
+  display: inline-block;
+  width: 100%;
+  color: #fff;
+  text-align: center;
+  margin-top: 8px;
+  line-height: 1.5;
+}
+
+.bangding::after{
+  border: none;
+}
+
+
+@media only screen and (min-width: 768px) and (max-width:1199px) {
+  .uigather .index2 {
+    margin-top: -8%;
+  }
+
+  .getUserInfo {
+    position: absolute;
+    bottom: 22%;
+    left: 50%;
+    pointer-events: auto !important;
+    z-index: 999;
+    transform: translateX(-50%);
+    max-width: 60%;
+  }
+
+  .getUserInfo>view {
+    background-image: url(https://culture.4dage.com/demo/meta_fdkk/button.png);
+    background-size: 100% 100%;
+    background-color: none;
+    white-space: nowrap;
+    height: 100rpx;
+    text-align: center;
+    color: #fff;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    font-size: 36rpx;
+    font-weight: bold;
+    width: 100%;
+  }
+}

+ 18 - 0
pages/logs/logs.js

@@ -0,0 +1,18 @@
+// logs.js
+const util = require('../../utils/util.js')
+
+Page({
+  data: {
+    logs: []
+  },
+  onLoad() {
+    this.setData({
+      logs: (wx.getStorageSync('logs') || []).map(log => {
+        return {
+          date: util.formatTime(new Date(log)),
+          timeStamp: log
+        }
+      })
+    })
+  }
+})

+ 4 - 0
pages/logs/logs.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "查看启动日志",
+  "usingComponents": {}
+}

+ 6 - 0
pages/logs/logs.wxml

@@ -0,0 +1,6 @@
+<!--logs.wxml-->
+<view class="container log-list">
+  <block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
+    <text class="log-item">{{index + 1}}. {{log.date}}</text>
+  </block>
+</view>

+ 8 - 0
pages/logs/logs.wxss

@@ -0,0 +1,8 @@
+.log-list {
+  display: flex;
+  flex-direction: column;
+  padding: 40rpx;
+}
+.log-item {
+  margin: 10rpx;
+}

+ 52 - 0
project.config.json

@@ -0,0 +1,52 @@
+{
+  "description": "项目配置文件",
+  "packOptions": {
+    "ignore": [],
+    "include": []
+  },
+  "setting": {
+    "bundle": false,
+    "userConfirmedBundleSwitch": false,
+    "urlCheck": true,
+    "scopeDataCheck": false,
+    "coverView": true,
+    "es6": true,
+    "postcss": true,
+    "compileHotReLoad": false,
+    "lazyloadPlaceholderEnable": false,
+    "preloadBackgroundData": false,
+    "minified": true,
+    "autoAudits": false,
+    "newFeature": false,
+    "uglifyFileName": false,
+    "uploadWithSourceMap": true,
+    "useIsolateContext": true,
+    "nodeModules": false,
+    "enhance": true,
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": true,
+    "showShadowRootInWxmlPanel": true,
+    "packNpmManually": false,
+    "enableEngineNative": false,
+    "packNpmRelationList": [],
+    "minifyWXSS": true,
+    "showES6CompileOption": false,
+    "minifyWXML": true,
+    "babelSetting": {
+      "ignore": [],
+      "disablePlugins": [],
+      "outputPath": ""
+    },
+    "condition": false
+  },
+  "compileType": "miniprogram",
+  "libVersion": "2.19.4",
+  "appid": "wxccde54bffe44af9d",
+  "projectname": "miniprogram-92",
+  "condition": {},
+  "editorSetting": {
+    "tabIndent": "insertSpaces",
+    "tabSize": 2
+  }
+}

+ 29 - 0
project.private.config.json

@@ -0,0 +1,29 @@
+{
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "projectname": "%2525E5%252585%252583%2525E5%2525AE%252587%2525E5%2525AE%252599demo",
+  "setting": {
+    "compileHotReLoad": true,
+    "urlCheck": false
+  },
+  "libVersion": "2.25.4",
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "",
+          "pathName": "pages/webpage/webpage",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/index/index",
+          "query": "rId=12345&sId=5555",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  }
+}

+ 7 - 0
sitemap.json

@@ -0,0 +1,7 @@
+{
+  "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
+  "rules": [{
+  "action": "allow",
+  "page": "*"
+  }]
+}

文件差異過大導致無法顯示
+ 8 - 0
utils/socket.io-mp.js


+ 99 - 0
utils/util.js

@@ -0,0 +1,99 @@
+const formatTime = date => {
+  const year = date.getFullYear()
+  const month = date.getMonth() + 1
+  const day = date.getDate()
+  const hour = date.getHours()
+  const minute = date.getMinutes()
+  const second = date.getSeconds()
+
+  return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
+}
+
+const formatNumber = n => {
+  n = n.toString()
+  return n[1] ? n : `0${n}`
+}
+
+
+const randomWord=(randomFlag, min, max)=> {
+  let str = "";
+  let range = min;
+  let arr = [
+    "0",
+    "1",
+    "2",
+    "3",
+    "4",
+    "5",
+    "6",
+    "7",
+    "8",
+    "9",
+    "a",
+    "b",
+    "c",
+    "d",
+    "e",
+    "f",
+    "g",
+    "h",
+    "i",
+    "j",
+    "k",
+    "l",
+    "m",
+    "n",
+    "o",
+    "p",
+    "q",
+    "r",
+    "s",
+    "t",
+    "u",
+    "v",
+    "w",
+    "x",
+    "y",
+    "z",
+    "A",
+    "B",
+    "C",
+    "D",
+    "E",
+    "F",
+    "G",
+    "H",
+    "I",
+    "J",
+    "K",
+    "L",
+    "M",
+    "N",
+    "O",
+    "P",
+    "Q",
+    "R",
+    "S",
+    "T",
+    "U",
+    "V",
+    "W",
+    "X",
+    "Y",
+    "Z",
+  ];
+  // 随机产生
+  if (randomFlag) {
+    range = Math.round(Math.random() * (max - min)) + min;
+  }
+  for (var i = 0; i < range; i++) {
+    let pos = Math.round(Math.random() * (arr.length - 1));
+    str += arr[pos];
+  }
+  return str;
+}
+
+module.exports = {
+  formatTime,
+  randomWord
+}