lushuncheng hace 4 años
padre
commit
faae36a505
Se han modificado 3 ficheros con 4245 adiciones y 0 borrados
  1. 243 0
      public/demo.html
  2. 51 0
      public/opensina.html
  3. 3951 0
      sql.sql

+ 243 - 0
public/demo.html

@@ -0,0 +1,243 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+    <style>
+      .click {
+        width: 200px;
+        height: 60px;
+        border: 1px solid #ccc;
+        margin: 0 auto;
+        margin-bottom: 10px;
+        line-height: 60px;
+        text-align: center;
+        border-radius: 10px;
+      }
+    </style>
+    <script src="https://cdn.bootcss.com/crypto-js/4.0.0/crypto-js.min.js" type="text/javascript"></script>
+    <script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js" type="text/javascript"></script>
+  </head>
+
+  <body>
+    <button id="login">登录</button>
+    <button id="config">获取配置</button>
+    <button id="start">开始游戏</button>
+    <button id="end">游戏结束</button>
+    <button id="topList">排行榜</button>
+    <button id="reward">抽奖</button>
+    <button id="saveAddress">上报地址</button>
+    <button id="sms">发送短信验证码</button>
+    <input type="text" name="mobile" id="mobile" value="" />
+    <input type="text" name="code" id="code" value="" />
+    <button id="copy">测试复制</button>
+    <div id="data"></div>
+    <div id="loginResult"></div>
+    <div id="configResult"></div>
+    <div id="startResult"></div>
+    <div id="endResult"></div>
+    <div id="topListResult"></div>
+    <div id="rewardResult"></div>
+    <div id="saveAddressResult"></div>
+    <div id="smsResult"></div>
+    <input style="display: absolute; z-index: -1; height: 0; width: 0" id="copyTest" />
+    <script type="text/javascript">
+      var ua = navigator.userAgent.toLocaleUpperCase().indexOf("WEIBO") >= 0;
+      alert(ua);
+      if (!ua) {
+        let url = "https://sina.shuncheng.lu/demo.html"; // 要打开的 H5 页面的地址
+        let scheme = `sinaweibo://browser?url=` + encodeURIComponent(url);
+        window.location.href = `https://m.weibo.cn/feature/openapp?scheme=` + encodeURIComponent(scheme);
+      }
+      function getQueryString(name) {
+        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+        let r = window.location.search.substr(1).match(reg);
+        if (r != null) return unescape(r[2]);
+        return null;
+      }
+      $("#login").click(function () {
+        getCode("1");
+        // callNative('sendCode', '');
+      });
+      $("#copy").click(function () {
+        document.getElementById("copyTest").val(new Date());
+        document.getElementById("copyTest").select();
+        if (document.execCommand("copy")) {
+          document.execCommand("copy");
+          alert("复制成功");
+        }
+      });
+      // 判断平台
+      var u = navigator.userAgent;
+      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
+      var isiOS = !!u.match(/(iPhone|iPad|iPod)/gi); //ios终端
+      var isWeChat = u.toLowerCase().match(/MicroMessenger/i) == "micromessenger"; //微信终端
+      function getInfo(data) {
+        // 暴露公用方法 ios 安卓调用H5
+        dataDom.innerHTML = data;
+      }
+      var loginToken = "a0f18fa6b1f04232be549b6bb0186529";
+      var gameID = "";
+      var gameResult = {
+        score: 301,
+        list: [
+          {
+            clicktime: 1602222222,
+            score: 301,
+          },
+        ],
+      };
+      var orderID = "";
+      var mobile = "";
+      var code = "";
+      function getCode(data) {
+        // 获取客户端传回来的code
+        // 此处请求后端接口,将端给的code传给后端进行登录
+
+        let params = { token: loginToken };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/index/checkLogin", params, function (res) {
+          loginToken = res.data.token;
+          dataDom.innerHTML = res.data.token;
+        });
+      }
+      $("#config").click(function () {
+        let params = { token: loginToken };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/login", params, function (res) {
+          $("#configResult").html(res);
+          let decrypted = Decrypt(res.data);
+          $("#configResult").html(decrypted);
+        });
+      });
+      $("#start").click(function () {
+        let params = { token: loginToken };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/startGame", params, function (res) {
+          $("#startResult").html(JSON.stringify(res));
+          let decrypted = res.data;
+          gameID = decrypted.gameID;
+        });
+      });
+      $("#topList").click(function () {
+        let params = { token: loginToken };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/topList", params, function (res) {
+          $("#topListResult").html(JSON.stringify(res));
+          // let decrypted = (Decrypt(res.data));
+          // $('#topListResult').html(decrypted);
+          // decrypted = JSON.parse(decrypted);
+          // gameID = decrypted.gameID;
+        });
+      });
+      $("#end").click(function () {
+        let params = { token: loginToken, gameID: gameID, score: 300, gameData: gameResult };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/endGame", params, function (res) {
+          $("#endResult").html(JSON.stringify(res));
+          // let decrypted = (Decrypt(res.data));
+          // $('#endResult').html(decrypted);
+          // decrypted = JSON.parse(decrypted);
+          // gameID = decrypted.gameID;
+        });
+      });
+      $("#reward").click(function () {
+        let params = { token: loginToken, gameID: gameID };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/reward", params, function (res) {
+          $("#rewardResult").html(JSON.stringify(res));
+          orderID = res.data.orderID;
+          // let decrypted = (Decrypt(res.data));
+          // $('#endResult').html(decrypted);
+          // decrypted = JSON.parse(decrypted);
+          // gameID = decrypted.gameID;
+        });
+      });
+      $("#sms").click(function () {
+        mobile = $("#mobile").val();
+        let params = { token: loginToken, mobile: mobile };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/sendSmsCode", params, function (res) {
+          $("#smsResult").html(JSON.stringify(res));
+          // orderID = res.data.orderID;
+          // let decrypted = (Decrypt(res.data));
+          // $('#endResult').html(decrypted);
+          // decrypted = JSON.parse(decrypted);
+          // gameID = decrypted.gameID;
+        });
+      });
+
+      $("#saveAddress").click(function () {
+        code = $("#code").val();
+        let params = {
+          token: loginToken,
+          orderID: orderID,
+          isTopTen: false,
+          name: "人人粉我",
+          address: "上海东方明珠",
+          mobile: mobile,
+          code: code,
+        };
+        // let encryptedData = Encrypt(JSON.stringify(params));
+        $.post("https://sina.shuncheng.lu/index/saveAddress", params, function (res) {
+          $("#saveAddressResult").html(JSON.stringify(res));
+          // orderID = res.data.orderID;
+          // let decrypted = (Decrypt(res.data));
+          // $('#endResult').html(decrypted);
+          // decrypted = JSON.parse(decrypted);
+          // gameID = decrypted.gameID;
+        });
+      });
+      // 触发方法
+      function callNative(name, value) {
+        dataDom.innerHTML = navigator.userAgent;
+        try {
+          if (isWeChat && weChatUrl != null) {
+            // 微信
+            location.href = weChatUrl;
+          } else if (isAndroid) {
+            // H5调用安卓
+            // 我传值
+            dataDom.innerHTML = "设置值2";
+            client.call(name, value);
+          } else if (isiOS) {
+            // H5调用ios
+            dataDom.innerHTML = "设置值2";
+            window.webkit.messageHandlers.calliOS.postMessage({ name, value });
+          }
+        } catch (e) {
+          dataDom.innerHTML = "设置值3" + e;
+        }
+      }
+      let dataDom = document.getElementById("data");
+      function setData() {
+        // 触发调用
+        dataDom.innerHTML = "设置值1";
+        // 下載圖片
+        // downloadImg: 调用原生的方法名
+        // 图片url: 写入需要传入的url
+        // callNative('downloadImg', '图片url')
+        // 调用code
+        callNative("sendCode", "");
+      }
+      /**
+       * 解密
+       * @param word
+       * @returns {*}
+       */
+      function Decrypt(word) {
+        var key = CryptoJS.enc.Utf8.parse("yushenjianglinle");
+        var decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
+        return CryptoJS.enc.Utf8.stringify(decrypt).toString();
+      }
+      //加密
+      function Encrypt(word) {
+        var key = CryptoJS.enc.Utf8.parse("yushenjianglinle");
+        let srcs = CryptoJS.enc.Utf8.parse(word);
+        let encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
+        return encrypted.toString();
+      }
+    </script>
+  </body>
+</html>

+ 51 - 0
public/opensina.html

@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Document</title>
+    <style>
+      .click {
+        width: 200px;
+        height: 60px;
+        border: 1px solid #ccc;
+        margin: 0 auto;
+        margin-bottom: 10px;
+        line-height: 60px;
+        text-align: center;
+        border-radius: 10px;
+      }
+    </style>
+    <script src="https://cdn.bootcss.com/crypto-js/4.0.0/crypto-js.min.js" type="text/javascript"></script>
+    <script src="https://cdn.staticfile.org/jquery/3.5.1/jquery.min.js" type="text/javascript"></script>
+  </head>
+
+  <body>
+    <button id="login">登录</button>
+    <button id="config">获取配置</button>
+    <button id="start">开始游戏</button>
+    <button id="end">游戏结束</button>
+    <button id="topList">排行榜</button>
+    <button id="reward">抽奖</button>
+    <button id="saveAddress">上报地址</button>
+    <button id="sms">发送短信验证码</button>
+    <input type="text" name="mobile" id="mobile" value="" />
+    <input type="text" name="code" id="code" value="" />
+    <button id="copy">测试复制</button>
+    <div id="data"></div>
+    <div id="loginResult"></div>
+    <div id="configResult"></div>
+    <div id="startResult"></div>
+    <div id="endResult"></div>
+    <div id="topListResult"></div>
+    <div id="rewardResult"></div>
+    <div id="saveAddressResult"></div>
+    <div id="smsResult"></div>
+    <input style="display: absolute; z-index: -1; height: 0; width: 0" id="copyTest" />
+    <script type="text/javascript">
+      let url = "https://sina.shuncheng.lu/demo.html"; // 要打开的 H5 页面的地址
+      let scheme = `sinaweibo://browser?url=` + encodeURIComponent(url);
+      window.location.href = `https://m.weibo.cn/feature/openapp?scheme=` + encodeURIComponent(scheme);
+    </script>
+  </body>
+</html>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 3951 - 0
sql.sql


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio