Browse Source

批量发布

yangc 7 years ago
parent
commit
5093837627
3 changed files with 72 additions and 72 deletions
  1. 4 71
      components/applyPurchase/BatchPublish.vue
  2. 1 1
      nuxt.config.js
  3. 67 0
      utils/baseUtils.js

+ 4 - 71
components/applyPurchase/BatchPublish.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="batch-publish">
-    <p><img src="/images/applyPurchase/batch-icon.png" alt="">共上传<b class="blue-text">{{bomNumber.successImport || 0}}</b>个产品其中<span class="red-text">{{bomNumber.nullField || 0}}</span>个产品的必填项缺失,请在当前页完善信息</p>
+    <p><img src="/images/applyPurchase/batch-icon.png" alt="">共上传<b class="blue-text">{{bomNumber.successImport || 0}}</b>个产品其中<span class="red-text">{{bomNumber.nullField || 0}}</span>个产品的必填项缺失,请在当前页完善信息</p>
     <table v-if="bomList.content.length">
       <thead>
         <tr>
@@ -228,6 +228,7 @@
     }
     return fmt
   }
+  import { enidfilter } from '~utils/baseUtils'
   import Page from '~components/common/page/pageComponent.vue'
   export default {
     data () {
@@ -909,12 +910,11 @@
                   message: response.data.message,
                   type: 'success'
                 })
-                let _self = this
                 window.setTimeout(function () {
-                  window.location.href = '/user#/order/pay/' + _self.enidfilter(response.data.data.orderid)
+                  window.open('/user#/order/pay/' + enidfilter(response.data.data.orderid))
                 }, 1000)
               } else {
-                window.location.href = '/user#/order/pay/' + this.enidfilter(response.data.data.orderid)
+                window.open('/user#/order/pay/' + enidfilter(response.data.data.orderid))
               }
             } else {
               if (response.data.data && response.data.data.unvailable === 1) {
@@ -930,73 +930,6 @@
             }
           })
       },
-      enidfilter: function (str) {
-        if (str) {
-          let encryptStr = '' // 最终返回的加密后的字符串
-          // 产生三位随机数
-          let num = ''
-          for (let i = 0; i < 3; i++) {
-            num += Math.floor(Math.random() * 10)
-          }
-          encryptStr += num // 产生3位随机数
-
-          // 16位加密
-          let tempspit = ''
-          let strspit = str.toString().toLowerCase()
-          if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
-            /**
-             * Unicode汉字、英文字母、数字的unicode范围
-             *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
-             *数字:[0x30,0x39](或十进制[48, 57])
-             *小写字母:[0x61,0x7a](或十进制[97, 122])
-             *大写字母:[0x41,0x5a](或十进制[65, 90]
-             * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
-             * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
-             */
-            let s = strspit.split('')
-            for (let i = 0; i < s.length; i++) {
-              s[i] = s[i].charCodeAt() // 先转换成Unicode编码
-              s[i] = s[i].toString(16)
-              // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
-              if (s[i].length === 1) {
-                s[i] = '0' + s[i]
-              }
-              tempspit = tempspit + s[i]
-            }
-            tempspit = tempspit + '{' + 1 // 1代表字符
-          } else { // 数字直接转换成16进制
-            strspit = parseInt(strspit)
-              .toString(16)
-            tempspit = strspit + '{' + 0 // 0代表纯数字
-          }
-
-          let temp = tempspit.split('{') // 对要加密的字符转换成16进制
-          let numLength = temp[0].length // 转换后的字符长度
-          numLength = numLength.toString(16) // 字符长度换算成16进制
-          if (numLength.length === 1) { // 如果是1,补一个0
-            numLength = '0' + numLength
-          } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
-            return ''
-          }
-          encryptStr += numLength
-          if (temp[1] === '0') {
-            encryptStr += 0
-          } else if (temp[1] === '1') {
-            encryptStr += 1
-          }
-          encryptStr += temp[0]
-          if (encryptStr.length < 20) { // 如果小于20位,补上随机数
-            // 产生三位随机数
-            let numtwo = ''
-            for (let i = 0; i < 20 - encryptStr.length; i++) {
-              numtwo += Math.floor(Math.random() * 10)
-            }
-            let ran = numtwo // 产生3位随机数
-            encryptStr += ran
-          }
-          return encryptStr
-        }
-      },
       linkSaler: function (commodity) {
         // 获得窗口的垂直位置
         let iTop = (window.screen.availHeight - 30 - 780) / 2

+ 1 - 1
nuxt.config.js

@@ -1,6 +1,6 @@
 const path = require('path')
 const isProdMode = Object.is(process.env.NODE_ENV, 'production')
-const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://192.168.253.60:9090/platform-b2c/' : 'http://192.168.253.121:9090/platform-b2c/')
+const baseUrl = process.env.BASE_URL || (isProdMode ? 'http://192.168.253.60:9090/platform-b2c/' : 'http://10.1.51.124:8080/platform-b2c/')
 const commonUrl = process.env.COMMON_URL || (isProdMode ? 'https://api-inquiry.usoftmall.com/' : 'http://218.17.158.219:24000/')
 
 module.exports = {

+ 67 - 0
utils/baseUtils.js

@@ -0,0 +1,67 @@
+export const enidfilter = (str) => {
+  if (str) {
+    let encryptStr = '' // 最终返回的加密后的字符串
+    // 产生三位随机数
+    let num = ''
+    for (let i = 0; i < 3; i++) {
+      num += Math.floor(Math.random() * 10)
+    }
+    encryptStr += num // 产生3位随机数
+
+    // 16位加密
+    let tempspit = ''
+    let strspit = str.toString().toLowerCase()
+    if (strspit.match(/^[-+]?\d*$/) === null) { // 非整数字符,对每一个字符都转换成16进制,然后拼接
+      /**
+       * Unicode汉字、英文字母、数字的unicode范围
+       *汉字:[0x4e00,0x9fa5](或十进制[19968,40869])
+       *数字:[0x30,0x39](或十进制[48, 57])
+       *小写字母:[0x61,0x7a](或十进制[97, 122])
+       *大写字母:[0x41,0x5a](或十进制[65, 90]
+       * 'a'的Unicode编码:'&#97;',charCodeAt()的值是97
+       * '码'的Unicode编码:'\u7801', new String('码').charCodeAt()的值是30721,30721的16进制表示是7801
+       */
+      let s = strspit.split('')
+      for (let i = 0; i < s.length; i++) {
+        s[i] = s[i].charCodeAt() // 先转换成Unicode编码
+        s[i] = s[i].toString(16)
+        // 因为在服务器是每两位当做一个字符进行解析的,所以这里每个字符的Unicode编码范围必须在0——255之间。数字和大小写满足该要求,特殊字符则不一定,如果后续有特殊字符的要求,需要重写编码器和解码器
+        if (s[i].length === 1) {
+          s[i] = '0' + s[i]
+        }
+        tempspit = tempspit + s[i]
+      }
+      tempspit = tempspit + '{' + 1 // 1代表字符
+    } else { // 数字直接转换成16进制
+      strspit = parseInt(strspit)
+        .toString(16)
+      tempspit = strspit + '{' + 0 // 0代表纯数字
+    }
+
+    let temp = tempspit.split('{') // 对要加密的字符转换成16进制
+    let numLength = temp[0].length // 转换后的字符长度
+    numLength = numLength.toString(16) // 字符长度换算成16进制
+    if (numLength.length === 1) { // 如果是1,补一个0
+      numLength = '0' + numLength
+    } else if (numLength.length > 3) { // 转换后的16进制字符长度如果大于2位数,则返回,不支持
+      return ''
+    }
+    encryptStr += numLength
+    if (temp[1] === '0') {
+      encryptStr += 0
+    } else if (temp[1] === '1') {
+      encryptStr += 1
+    }
+    encryptStr += temp[0]
+    if (encryptStr.length < 20) { // 如果小于20位,补上随机数
+      // 产生三位随机数
+      let numtwo = ''
+      for (let i = 0; i < 20 - encryptStr.length; i++) {
+        numtwo += Math.floor(Math.random() * 10)
+      }
+      let ran = numtwo // 产生3位随机数
+      encryptStr += ran
+    }
+    return encryptStr
+  }
+}