瀏覽代碼

防止多次提交

cuixq 4 年之前
父節點
當前提交
80bd99072d
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. 18 0
      front-vue/src/utils/common.js

+ 18 - 0
front-vue/src/utils/common.js

@@ -1,3 +1,5 @@
+import { getToken } from '@/utils/auth'
+
 // 日期格式化
 export function convertCurrency(money) {
     debugger;
@@ -85,4 +87,20 @@ export function convertCurrency(money) {
     }
     console.log("=========>"+chineseStr);
     return chineseStr;
+}
+
+export function getRepeatToken() {
+    var authTokent = getToken();
+    var date = new Date();
+    if (authTokent != null) {
+        return authTokent + ":" + date.getHours() + date.getMinutes() + date.getSeconds();
+    } else {
+        charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+        var randomString = '';
+        for (var i = 0; i < 6; i++) {
+            var randomPoz = Math.floor(Math.random() * charSet.length);
+            randomString += charSet.substring(randomPoz,randomPoz+1);
+        }
+        return randomString + ":" + date.getTime()
+    }
 }