瀏覽代碼

Merge branch 'master' of http://git.ycjcjy.com/xiangsong/miniapp

张延森 4 年之前
父節點
當前提交
0eff47f439
共有 1 個檔案被更改,包括 11 行新增1 行删除
  1. 11
    1
      src/utils/request.js

+ 11
- 1
src/utils/request.js 查看文件

@@ -5,8 +5,18 @@ import $api from './api'
5 5
 const accountInfo = Taro.getAccountInfoSync()
6 6
 const appId = accountInfo.miniProgram.appId
7 7
 
8
+const entries = obj => {
9
+  const ownProps = Object.keys( obj )
10
+  let i = ownProps.length
11
+  const resArray = new Array(i)
12
+  while (i--)
13
+    resArray[i] = [ownProps[i], obj[ownProps[i]]]
14
+
15
+  return resArray
16
+}
17
+
8 18
 const query2String = query => {
9
-  return Object.entries(query || {}).map(pair => `${encodeURIComponent(pair[0])}=${encodeURIComponent(pair[1])}`).join('&')
19
+  return entries(query || {}).map(pair => `${encodeURIComponent(pair[0])}=${encodeURIComponent(pair[1])}`).join('&')
10 20
 }
11 21
 
12 22
 const transPathArgs = (path, args) => {