Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
sheng du
ghpay
Commits
695b5023
Commit
695b5023
authored
5 months ago
by
sheng du
Browse files
Options
Download
Email Patches
Plain Diff
加密
parent
d8f70f62
Changes
47
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
333 additions
and
471 deletions
+333
-471
.gitignore
.gitignore
+5
-0
api/http.js
api/http.js
+117
-29
config/index.js
config/index.js
+2
-2
manifest.json
manifest.json
+1
-1
node_modules/charenc/LICENSE.mkd
node_modules/charenc/LICENSE.mkd
+0
-27
node_modules/charenc/README.js
node_modules/charenc/README.js
+0
-1
node_modules/charenc/charenc.js
node_modules/charenc/charenc.js
+0
-33
node_modules/charenc/package.json
node_modules/charenc/package.json
+0
-27
node_modules/crypt/LICENSE.mkd
node_modules/crypt/LICENSE.mkd
+0
-27
node_modules/crypt/README.mkd
node_modules/crypt/README.mkd
+0
-1
node_modules/crypt/crypt.js
node_modules/crypt/crypt.js
+0
-96
node_modules/crypt/package.json
node_modules/crypt/package.json
+0
-25
node_modules/is-buffer/LICENSE
node_modules/is-buffer/LICENSE
+0
-21
node_modules/is-buffer/README.md
node_modules/is-buffer/README.md
+0
-53
node_modules/is-buffer/index.js
node_modules/is-buffer/index.js
+0
-21
node_modules/is-buffer/package.json
node_modules/is-buffer/package.json
+0
-54
node_modules/is-buffer/test/basic.js
node_modules/is-buffer/test/basic.js
+0
-24
package-lock.json
package-lock.json
+119
-0
package.json
package.json
+1
-0
pages/pay/pay.vue
pages/pay/pay.vue
+88
-29
No files found.
.gitignore
0 → 100644
View file @
695b5023
unpackage
.DS_Store
node_modules
/dist
\ No newline at end of file
This diff is collapsed.
Click to expand it.
api/http.js
View file @
695b5023
...
...
@@ -6,8 +6,9 @@
*/
import
config
from
'
../config
'
;
import
utils
from
'
../utils
'
;
import
createSign
from
"
./createSignSdk.js
"
//
import createSign from "./createSignSdk.js"
import
randomString
from
'
../utils/randomString
'
;
import
CryptoJS
from
'
crypto-js
'
;
// 记录请求中的请求数,控制loading显示
let
requestCount
=
0
;
...
...
@@ -30,8 +31,6 @@ export function fetch(url, options) {
return
new
Promise
((
resolve
,
reject
)
=>
{
// config.apiRoot = config.url
uni
.
request
({
url
:
`
${
config
.
url
}${
url
}
`
,
data
:
options
.
data
,
...
...
@@ -40,22 +39,34 @@ export function fetch(url, options) {
success
:
(
res
)
=>
{
console
.
log
(
res
);
if
(
res
.
statusCode
==
200
)
{
if
(
res
.
data
.
code
==
-
2
)
{
let
resData
=
res
.
data
let
aesResObj
if
(
resData
&&
typeof
(
resData
)
===
'
string
'
)
{
// console.log('resultCryptoJS');
aesResObj
=
resultCryptoJS
(
resData
,
res
)
// return resolve(aesResObj || {});
// console.log(decryptedFn());
}
else
{
aesResObj
=
res
}
console
.
log
(
aesResObj
);
if
(
aesResObj
.
data
.
code
==
-
2
)
{
uni
.
showToast
({
icon
:
"
none
"
,
title
:
'
登录失效,请重新登录
'
,
duration
:
2000
})
}
else
{
if
(
r
es
.
data
.
status
==
'
NO
'
)
{
if
(
a
es
ResObj
.
data
.
status
==
'
NO
'
)
{
uni
.
showToast
({
icon
:
"
none
"
,
title
:
r
es
.
data
.
info
,
title
:
a
es
ResObj
.
data
.
info
,
duration
:
2000
})
reject
(
r
es
.
data
)
reject
(
a
es
ResObj
.
data
)
}
else
{
resolve
(
r
es
.
data
);
resolve
(
a
es
ResObj
.
data
);
}
}
}
else
{
...
...
@@ -86,6 +97,83 @@ export function fetch(url, options) {
});
}
const
resultCryptoJS
=
(
resData
,
res
)
=>
{
let
decryptedFn
=
(
word
)
=>
{
// let word = 'MYXCBCRv+hJq3/vG7SqtDQ==';
let
keyStr
=
'
ba8db3a7872eb0a0
'
;
let
ivStr
=
'
13dbe44ba54612ff
'
;
let
key
;
let
iv
;
if
(
keyStr
)
{
key
=
CryptoJS
.
enc
.
Utf8
.
parse
(
keyStr
);
iv
=
CryptoJS
.
enc
.
Utf8
.
parse
(
ivStr
);
}
const
base64
=
CryptoJS
.
enc
.
Base64
.
parse
(
word
);
const
src
=
CryptoJS
.
enc
.
Base64
.
stringify
(
base64
);
const
decrypted
=
CryptoJS
.
AES
.
decrypt
(
src
,
key
,
{
iv
,
// 偏移量
mode
:
CryptoJS
.
mode
.
CBC
,
padding
:
CryptoJS
.
pad
.
Pkcs7
// padding: CryptoJS.pad.ZeroPadding
});
const
decryptedStr
=
decrypted
.
toString
(
CryptoJS
.
enc
.
Utf8
);
return
decryptedStr
.
toString
();
}
let
aesRes
=
decryptedFn
(
resData
)
let
aesResObj
try
{
aesResObj
=
{
...
res
,
data
:
JSON
.
parse
(
aesRes
)
}
}
catch
(
e
)
{
// console.log(e);
aesResObj
=
{
...
res
// ...res.data,
// data: res.data.data || {}
}
//TODO handle the exception
}
return
aesResObj
}
const
generateRandomString
=
(
length
)
=>
{
const
characters
=
'
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
'
;
let
result
=
''
;
for
(
let
i
=
0
;
i
<
length
;
i
++
)
{
const
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
characters
.
length
);
result
+=
characters
[
randomIndex
];
}
return
result
;
}
// const getDataSign = (datas) => {
// let arr = []
// for (let key in datas) {
// if (datas[key]) {
// arr.push({
// key: key,
// val: datas[key]
// })
// }
// }
// // arr.sort((a, b) => a.key.charCodeAt(0) - b.key.charCodeAt(0))
// arr.sort((a, b) => a.key.localeCompare(b.key))
// let res = arr.map(item => `${item.key}=${item.val}`)
// // console.log(arr);
// let stringA = res.join('&')
// let stringSignTemp = stringA + "&key=2B39F1EBCD77E7917AA28BAA8C3AA71A"
// // console.log(stringSignTemp);
// let sign = md5(stringSignTemp).toUpperCase()
// // console.log(sign);
// return sign
// }
const
http
=
{
get
(
url
,
data
=
{},
options
=
{})
{
const
dataParams
=
data
...
...
@@ -96,10 +184,10 @@ const http = {
dataParams
.
params
.
randstr
=
randomString
.
randomStrings
(
6
);
dataParams
.
params
.
timestamp
=
parseInt
(
new
Date
().
getTime
()
/
1000
);
dataParams
.
params
.
platform
=
'
mini
'
;
// 平台标识
const
signs
=
createSign
({
...
dataParams
.
params
,
});
dataParams
.
params
.
sign
=
signs
.
sign
;
//
const signs = createSign({
//
...dataParams.params,
//
});
//
dataParams.params.sign = signs.sign;
}
catch
(
e
)
{
console
.
log
(
e
);
}
...
...
@@ -118,23 +206,23 @@ const http = {
dataParams
.
params
.
timestamp
=
parseInt
(
new
Date
().
getTime
()
/
1000
);
dataParams
.
params
.
platform
=
'
mini
'
;
// 平台标识
if
(
dataParams
.
params
)
{
try
{
let
signsJson
=
{}
Object
.
keys
(
dataParams
).
forEach
(
item
=>
{
if
(
item
!==
'
params
'
)
{
signsJson
[
item
]
=
dataParams
[
item
]
}
else
{
signsJson
=
{
...
signsJson
,
...
dataParams
[
item
]
}
}
})
const
signs
=
createSign
(
signsJson
);
dataParams
.
params
.
sign
=
signs
.
sign
;
}
catch
(
e
)
{
console
.
log
(
e
);
}
//
try {
//
let signsJson = {}
//
Object.keys(dataParams).forEach(item => {
//
if (item !== 'params') {
//
signsJson[item] = dataParams[item]
//
} else {
//
signsJson = {
//
...signsJson,
//
...dataParams[item]
//
}
//
}
//
})
//
const signs = createSign(signsJson);
//
dataParams.params.sign = signs.sign;
//
} catch (e) {
//
console.log(e);
//
}
// 将param放到url 参数里面
const
query
=
utils
.
buildQueryString
(
dataParams
.
params
);
url
+=
`?
${
query
}
`
;
...
...
This diff is collapsed.
Click to expand it.
config/index.js
View file @
695b5023
export
default
{
//
url: 'https://testmomp.cqringpark.com', //
正式用 (上线时需要替换的)
url
:
'
https://momp.cqringpark.com
'
,
// 正式用 (上线时需要替换的)
url
:
'
https://testmomp.cqringpark.com
'
,
//
测试
//
url: 'https://momp.cqringpark.com', // 正式用 (上线时需要替换的)
// url: 'http://172.16.0.6:81',
// url: 'http://172.16.0.124',
// grayUrl: 'https://grmomp.hklcn.com' ,// 灰度服务器
...
...
This diff is collapsed.
Click to expand it.
manifest.json
View file @
695b5023
...
...
@@ -60,7 +60,7 @@
},
"mp-alipay"
:
{
"usingComponents"
:
true
,
"appid"
:
"20210041
31620799
"
"appid"
:
"20210041
67658190
"
},
"mp-baidu"
:
{
"usingComponents"
:
true
...
...
This diff is collapsed.
Click to expand it.
node_modules/charenc/LICENSE.mkd
deleted
100644 → 0
View file @
d8f70f62
Copyright © 2011, Paul Vorbach. All rights reserved.
Copyright © 2009, Jeff Mott. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
*
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
*
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
*
Neither the name Crypto-JS nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
Click to expand it.
node_modules/charenc/README.js
deleted
100644 → 0
View file @
d8f70f62
**
enc
**
provides
crypto
character
encoding
utilities
.
This diff is collapsed.
Click to expand it.
node_modules/charenc/charenc.js
deleted
100644 → 0
View file @
d8f70f62
var
charenc
=
{
// UTF-8 encoding
utf8
:
{
// Convert a string to a byte array
stringToBytes
:
function
(
str
)
{
return
charenc
.
bin
.
stringToBytes
(
unescape
(
encodeURIComponent
(
str
)));
},
// Convert a byte array to a string
bytesToString
:
function
(
bytes
)
{
return
decodeURIComponent
(
escape
(
charenc
.
bin
.
bytesToString
(
bytes
)));
}
},
// Binary encoding
bin
:
{
// Convert a string to a byte array
stringToBytes
:
function
(
str
)
{
for
(
var
bytes
=
[],
i
=
0
;
i
<
str
.
length
;
i
++
)
bytes
.
push
(
str
.
charCodeAt
(
i
)
&
0xFF
);
return
bytes
;
},
// Convert a byte array to a string
bytesToString
:
function
(
bytes
)
{
for
(
var
str
=
[],
i
=
0
;
i
<
bytes
.
length
;
i
++
)
str
.
push
(
String
.
fromCharCode
(
bytes
[
i
]));
return
str
.
join
(
''
);
}
}
};
module
.
exports
=
charenc
;
This diff is collapsed.
Click to expand it.
node_modules/charenc/package.json
deleted
100644 → 0
View file @
d8f70f62
{
"author"
:
"Paul Vorbach <paul@vorb.de> (http://vorb.de)"
,
"name"
:
"charenc"
,
"description"
:
"character encoding utilities"
,
"tags"
:
[
"utf8"
,
"binary"
,
"byte"
,
"string"
],
"version"
:
"0.0.2"
,
"license"
:
"BSD-3-Clause"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git://github.com/pvorb/node-charenc.git"
},
"bugs"
:
{
"url"
:
"https://github.com/pvorb/node-charenc/issues"
},
"main"
:
"charenc.js"
,
"engines"
:
{
"node"
:
"*"
},
"__npminstall_done"
:
true
,
"_from"
:
"charenc@0.0.2"
,
"_resolved"
:
"https://registry.npmmirror.com/charenc/-/charenc-0.0.2.tgz"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
node_modules/crypt/LICENSE.mkd
deleted
100644 → 0
View file @
d8f70f62
Copyright © 2011, Paul Vorbach. All rights reserved.
Copyright © 2009, Jeff Mott. All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
*
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
*
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
*
Neither the name Crypto-JS nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
Click to expand it.
node_modules/crypt/README.mkd
deleted
100644 → 0
View file @
d8f70f62
**crypt**
provides utilities for encryption and hashing
This diff is collapsed.
Click to expand it.
node_modules/crypt/crypt.js
deleted
100644 → 0
View file @
d8f70f62
(
function
()
{
var
base64map
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
'
,
crypt
=
{
// Bit-wise rotation left
rotl
:
function
(
n
,
b
)
{
return
(
n
<<
b
)
|
(
n
>>>
(
32
-
b
));
},
// Bit-wise rotation right
rotr
:
function
(
n
,
b
)
{
return
(
n
<<
(
32
-
b
))
|
(
n
>>>
b
);
},
// Swap big-endian to little-endian and vice versa
endian
:
function
(
n
)
{
// If number given, swap endian
if
(
n
.
constructor
==
Number
)
{
return
crypt
.
rotl
(
n
,
8
)
&
0x00FF00FF
|
crypt
.
rotl
(
n
,
24
)
&
0xFF00FF00
;
}
// Else, assume array and swap all items
for
(
var
i
=
0
;
i
<
n
.
length
;
i
++
)
n
[
i
]
=
crypt
.
endian
(
n
[
i
]);
return
n
;
},
// Generate an array of any length of random bytes
randomBytes
:
function
(
n
)
{
for
(
var
bytes
=
[];
n
>
0
;
n
--
)
bytes
.
push
(
Math
.
floor
(
Math
.
random
()
*
256
));
return
bytes
;
},
// Convert a byte array to big-endian 32-bit words
bytesToWords
:
function
(
bytes
)
{
for
(
var
words
=
[],
i
=
0
,
b
=
0
;
i
<
bytes
.
length
;
i
++
,
b
+=
8
)
words
[
b
>>>
5
]
|=
bytes
[
i
]
<<
(
24
-
b
%
32
);
return
words
;
},
// Convert big-endian 32-bit words to a byte array
wordsToBytes
:
function
(
words
)
{
for
(
var
bytes
=
[],
b
=
0
;
b
<
words
.
length
*
32
;
b
+=
8
)
bytes
.
push
((
words
[
b
>>>
5
]
>>>
(
24
-
b
%
32
))
&
0xFF
);
return
bytes
;
},
// Convert a byte array to a hex string
bytesToHex
:
function
(
bytes
)
{
for
(
var
hex
=
[],
i
=
0
;
i
<
bytes
.
length
;
i
++
)
{
hex
.
push
((
bytes
[
i
]
>>>
4
).
toString
(
16
));
hex
.
push
((
bytes
[
i
]
&
0xF
).
toString
(
16
));
}
return
hex
.
join
(
''
);
},
// Convert a hex string to a byte array
hexToBytes
:
function
(
hex
)
{
for
(
var
bytes
=
[],
c
=
0
;
c
<
hex
.
length
;
c
+=
2
)
bytes
.
push
(
parseInt
(
hex
.
substr
(
c
,
2
),
16
));
return
bytes
;
},
// Convert a byte array to a base-64 string
bytesToBase64
:
function
(
bytes
)
{
for
(
var
base64
=
[],
i
=
0
;
i
<
bytes
.
length
;
i
+=
3
)
{
var
triplet
=
(
bytes
[
i
]
<<
16
)
|
(
bytes
[
i
+
1
]
<<
8
)
|
bytes
[
i
+
2
];
for
(
var
j
=
0
;
j
<
4
;
j
++
)
if
(
i
*
8
+
j
*
6
<=
bytes
.
length
*
8
)
base64
.
push
(
base64map
.
charAt
((
triplet
>>>
6
*
(
3
-
j
))
&
0x3F
));
else
base64
.
push
(
'
=
'
);
}
return
base64
.
join
(
''
);
},
// Convert a base-64 string to a byte array
base64ToBytes
:
function
(
base64
)
{
// Remove non-base-64 characters
base64
=
base64
.
replace
(
/
[^
A-Z0-9+
\/]
/ig
,
''
);
for
(
var
bytes
=
[],
i
=
0
,
imod4
=
0
;
i
<
base64
.
length
;
imod4
=
++
i
%
4
)
{
if
(
imod4
==
0
)
continue
;
bytes
.
push
(((
base64map
.
indexOf
(
base64
.
charAt
(
i
-
1
))
&
(
Math
.
pow
(
2
,
-
2
*
imod4
+
8
)
-
1
))
<<
(
imod4
*
2
))
|
(
base64map
.
indexOf
(
base64
.
charAt
(
i
))
>>>
(
6
-
imod4
*
2
)));
}
return
bytes
;
}
};
module
.
exports
=
crypt
;
})();
This diff is collapsed.
Click to expand it.
node_modules/crypt/package.json
deleted
100644 → 0
View file @
d8f70f62
{
"author"
:
"Paul Vorbach <paul@vorb.de> (http://vorb.de)"
,
"name"
:
"crypt"
,
"description"
:
"utilities for encryption and hashing"
,
"tags"
:
[
"hash"
,
"security"
],
"version"
:
"0.0.2"
,
"license"
:
"BSD-3-Clause"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git://github.com/pvorb/node-crypt.git"
},
"bugs"
:
{
"url"
:
"https://github.com/pvorb/node-crypt/issues"
},
"main"
:
"crypt.js"
,
"engines"
:
{
"node"
:
"*"
},
"__npminstall_done"
:
true
,
"_from"
:
"crypt@0.0.2"
,
"_resolved"
:
"https://registry.npmmirror.com/crypt/-/crypt-0.0.2.tgz"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
node_modules/is-buffer/LICENSE
deleted
100644 → 0
View file @
d8f70f62
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
This diff is collapsed.
Click to expand it.
node_modules/is-buffer/README.md
deleted
100644 → 0
View file @
d8f70f62
# is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[
travis-image
]:
https://img.shields.io/travis/feross/is-buffer/master.svg
[
travis-url
]:
https://travis-ci.org/feross/is-buffer
[
npm-image
]:
https://img.shields.io/npm/v/is-buffer.svg
[
npm-url
]:
https://npmjs.org/package/is-buffer
[
downloads-image
]:
https://img.shields.io/npm/dm/is-buffer.svg
[
downloads-url
]:
https://npmjs.org/package/is-buffer
[
standard-image
]:
https://img.shields.io/badge/code_style-standard-brightgreen.svg
[
standard-url
]:
https://standardjs.com
#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))
[
![saucelabs
][
saucelabs-image
]
][saucelabs-url]
[
saucelabs-image
]:
https://saucelabs.com/browser-matrix/is-buffer.svg
[
saucelabs-url
]:
https://saucelabs.com/u/is-buffer
## Why not use `Buffer.isBuffer`?
This module lets you check if an object is a
`Buffer`
without using
`Buffer.isBuffer`
(which includes the whole
[
buffer
](
https://github.com/feross/buffer
)
module in
[
browserify
](
http://browserify.org/
)
).
It's future-proof and works in node too!
## install
```
bash
npm
install
is-buffer
```
## usage
```
js
var
isBuffer
=
require
(
'
is-buffer
'
)
isBuffer
(
new
Buffer
(
4
))
// true
isBuffer
(
undefined
)
// false
isBuffer
(
null
)
// false
isBuffer
(
''
)
// false
isBuffer
(
true
)
// false
isBuffer
(
false
)
// false
isBuffer
(
0
)
// false
isBuffer
(
1
)
// false
isBuffer
(
1.0
)
// false
isBuffer
(
'
string
'
)
// false
isBuffer
({})
// false
isBuffer
(
function
foo
()
{})
// false
```
## license
MIT. Copyright (C)
[
Feross Aboukhadijeh
](
http://feross.org
)
.
This diff is collapsed.
Click to expand it.
node_modules/is-buffer/index.js
deleted
100644 → 0
View file @
d8f70f62
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
// The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
module
.
exports
=
function
(
obj
)
{
return
obj
!=
null
&&
(
isBuffer
(
obj
)
||
isSlowBuffer
(
obj
)
||
!!
obj
.
_isBuffer
)
}
function
isBuffer
(
obj
)
{
return
!!
obj
.
constructor
&&
typeof
obj
.
constructor
.
isBuffer
===
'
function
'
&&
obj
.
constructor
.
isBuffer
(
obj
)
}
// For Node v0.10 support. Remove this eventually.
function
isSlowBuffer
(
obj
)
{
return
typeof
obj
.
readFloatLE
===
'
function
'
&&
typeof
obj
.
slice
===
'
function
'
&&
isBuffer
(
obj
.
slice
(
0
,
0
))
}
This diff is collapsed.
Click to expand it.
node_modules/is-buffer/package.json
deleted
100644 → 0
View file @
d8f70f62
{
"name"
:
"is-buffer"
,
"description"
:
"Determine if an object is a Buffer"
,
"version"
:
"1.1.6"
,
"author"
:
{
"name"
:
"Feross Aboukhadijeh"
,
"email"
:
"feross@feross.org"
,
"url"
:
"http://feross.org/"
},
"bugs"
:
{
"url"
:
"https://github.com/feross/is-buffer/issues"
},
"dependencies"
:
{},
"devDependencies"
:
{
"standard"
:
"*"
,
"tape"
:
"^4.0.0"
,
"zuul"
:
"^3.0.0"
},
"keywords"
:
[
"buffer"
,
"buffers"
,
"type"
,
"core buffer"
,
"browser buffer"
,
"browserify"
,
"typed array"
,
"uint32array"
,
"int16array"
,
"int32array"
,
"float32array"
,
"float64array"
,
"browser"
,
"arraybuffer"
,
"dataview"
],
"license"
:
"MIT"
,
"main"
:
"index.js"
,
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git://github.com/feross/is-buffer.git"
},
"scripts"
:
{
"test"
:
"standard && npm run test-node && npm run test-browser"
,
"test-browser"
:
"zuul -- test/*.js"
,
"test-browser-local"
:
"zuul --local -- test/*.js"
,
"test-node"
:
"tape test/*.js"
},
"testling"
:
{
"files"
:
"test/*.js"
},
"__npminstall_done"
:
true
,
"_from"
:
"is-buffer@1.1.6"
,
"_resolved"
:
"https://registry.npmmirror.com/is-buffer/-/is-buffer-1.1.6.tgz"
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
node_modules/is-buffer/test/basic.js
deleted
100644 → 0
View file @
d8f70f62
var
isBuffer
=
require
(
'
../
'
)
var
test
=
require
(
'
tape
'
)
test
(
'
is-buffer
'
,
function
(
t
)
{
t
.
equal
(
isBuffer
(
Buffer
.
alloc
(
4
)),
true
,
'
new Buffer(4)
'
)
t
.
equal
(
isBuffer
(
Buffer
.
allocUnsafeSlow
(
100
)),
true
,
'
SlowBuffer(100)
'
)
t
.
equal
(
isBuffer
(
undefined
),
false
,
'
undefined
'
)
t
.
equal
(
isBuffer
(
null
),
false
,
'
null
'
)
t
.
equal
(
isBuffer
(
''
),
false
,
'
empty string
'
)
t
.
equal
(
isBuffer
(
true
),
false
,
'
true
'
)
t
.
equal
(
isBuffer
(
false
),
false
,
'
false
'
)
t
.
equal
(
isBuffer
(
0
),
false
,
'
0
'
)
t
.
equal
(
isBuffer
(
1
),
false
,
'
1
'
)
t
.
equal
(
isBuffer
(
1.0
),
false
,
'
1.0
'
)
t
.
equal
(
isBuffer
(
'
string
'
),
false
,
'
string
'
)
t
.
equal
(
isBuffer
({}),
false
,
'
{}
'
)
t
.
equal
(
isBuffer
([]),
false
,
'
[]
'
)
t
.
equal
(
isBuffer
(
function
foo
()
{}),
false
,
'
function foo () {}
'
)
t
.
equal
(
isBuffer
({
isBuffer
:
null
}),
false
,
'
{ isBuffer: null }
'
)
t
.
equal
(
isBuffer
({
isBuffer
:
function
()
{
throw
new
Error
()
}
}),
false
,
'
{ isBuffer: function () { throw new Error() } }
'
)
t
.
end
()
})
This diff is collapsed.
Click to expand it.
package-lock.json
0 → 100644
View file @
695b5023
{
"name"
:
"hudong_pay"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{
""
:
{
"dependencies"
:
{
"crypto-js"
:
"^4.2.0"
,
"md5"
:
"^2.3.0"
}
},
"node_modules/_charenc@0.0.2@charenc"
:
{
"name"
:
"charenc"
,
"version"
:
"0.0.2"
,
"license"
:
"BSD-3-Clause"
,
"engines"
:
{
"node"
:
"*"
}
},
"node_modules/_crypt@0.0.2@crypt"
:
{
"name"
:
"crypt"
,
"version"
:
"0.0.2"
,
"license"
:
"BSD-3-Clause"
,
"engines"
:
{
"node"
:
"*"
}
},
"node_modules/_is-buffer@1.1.6@is-buffer"
:
{
"name"
:
"is-buffer"
,
"version"
:
"1.1.6"
,
"license"
:
"MIT"
},
"node_modules/_md5@2.3.0@md5"
:
{
"name"
:
"md5"
,
"version"
:
"2.3.0"
,
"license"
:
"BSD-3-Clause"
,
"dependencies"
:
{
"charenc"
:
"0.0.2"
,
"crypt"
:
"0.0.2"
,
"is-buffer"
:
"~1.1.6"
}
},
"node_modules/_md5@2.3.0@md5/node_modules/charenc"
:
{
"resolved"
:
"node_modules/_charenc@0.0.2@charenc"
,
"link"
:
true
},
"node_modules/_md5@2.3.0@md5/node_modules/crypt"
:
{
"resolved"
:
"node_modules/_crypt@0.0.2@crypt"
,
"link"
:
true
},
"node_modules/_md5@2.3.0@md5/node_modules/is-buffer"
:
{
"resolved"
:
"node_modules/_is-buffer@1.1.6@is-buffer"
,
"link"
:
true
},
"node_modules/crypto-js"
:
{
"version"
:
"4.2.0"
,
"resolved"
:
"https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz"
,
"integrity"
:
"sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"node_modules/md5"
:
{
"resolved"
:
"node_modules/_md5@2.3.0@md5"
,
"link"
:
true
}
},
"dependencies"
:
{
"_charenc@0.0.2@charenc"
:
{
"version"
:
"npm:charenc@0.0.2"
},
"_crypt@0.0.2@crypt"
:
{
"version"
:
"npm:crypt@0.0.2"
},
"_is-buffer@1.1.6@is-buffer"
:
{
"version"
:
"npm:is-buffer@1.1.6"
},
"_md5@2.3.0@md5"
:
{
"version"
:
"npm:md5@2.3.0"
,
"requires"
:
{
"charenc"
:
"0.0.2"
,
"crypt"
:
"0.0.2"
,
"is-buffer"
:
"~1.1.6"
},
"dependencies"
:
{
"charenc"
:
{
"version"
:
"file:node_modules/_charenc@0.0.2@charenc"
},
"crypt"
:
{
"version"
:
"file:node_modules/_crypt@0.0.2@crypt"
},
"is-buffer"
:
{
"version"
:
"file:node_modules/_is-buffer@1.1.6@is-buffer"
}
}
},
"crypto-js"
:
{
"version"
:
"4.2.0"
,
"resolved"
:
"https://registry.npmmirror.com/crypto-js/-/crypto-js-4.2.0.tgz"
,
"integrity"
:
"sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
},
"md5"
:
{
"version"
:
"file:node_modules/_md5@2.3.0@md5"
,
"requires"
:
{
"charenc"
:
"0.0.2"
,
"crypt"
:
"0.0.2"
,
"is-buffer"
:
"~1.1.6"
},
"dependencies"
:
{
"charenc"
:
{
"version"
:
"file:node_modules/_charenc@0.0.2@charenc"
},
"crypt"
:
{
"version"
:
"file:node_modules/_crypt@0.0.2@crypt"
},
"is-buffer"
:
{
"version"
:
"file:node_modules/_is-buffer@1.1.6@is-buffer"
}
}
}
}
}
This diff is collapsed.
Click to expand it.
package.json
View file @
695b5023
{
"dependencies"
:
{
"
crypto-js
"
:
"
^4.2.0
"
,
"
md5
"
:
"
^2.3.0
"
}
}
This diff is collapsed.
Click to expand it.
pages/pay/pay.vue
View file @
695b5023
<
template
>
<view
class=
"flex-center"
>
<view
class=
"text"
>
{{
text
}}
</view>
<view
class=
"text"
v-if=
"payInfo"
>
<view
class=
""
>
缴费类型:
{{
payInfo
.
hdpt_type_name
||
''
}}
</view>
<view
class=
""
>
缴费金额:
{{
payInfo
.
hdpt_pay_money
||
''
}}
</view>
<view
class=
""
>
备注:
{{
payInfo
.
hdpt_remark
||
''
}}
</view>
</view>
<view>
<button
class=
'chaxun
'
open-type=
"launchApp"
@
launchapp=
"launchApp"
@
error=
"launchAppError"
<button
class=
'chaxun
btn'
v-if=
"isPay"
open-type=
"launchApp"
@
launchapp=
"launchApp"
@
error=
"launchAppError"
size=
"mini"
>
返回APP
</button>
<view
class=
'pay-btn btn'
v-else
@
click=
"goPay"
size=
"mini"
>
立即支付
</view>
</view>
</view>
</
template
>
...
...
@@ -16,7 +21,13 @@
text
:
'
支付中...
'
,
pay_order_id
:
''
,
url
:
''
,
token
:
''
token
:
''
,
isPay
:
false
,
payInfo
:
{
// hdpt_pay_money: "0.01",
// hdpt_remark: "asd",
// hdpt_type_name: "罚款"
}
}
},
onLoad
(
params
)
{
...
...
@@ -38,6 +49,7 @@
icon
:
'
none
'
,
title
:
'
获取订单失败
'
})
this
.
isPay
=
true
this
.
text
=
'
支付失败,请返回App重新支付
'
}
},
...
...
@@ -60,42 +72,72 @@
pay_order_id
:
that
.
pay_order_id
,
pay_mode
:
pay_mode
}).
then
(
payInfo
=>
{
console
.
log
(
payInfo
.
data
.
timeStamp
,
payInfo
.
data
.
nonceStr
,
payInfo
.
data
.
package
,
payInfo
.
data
.
signType
,
payInfo
.
data
.
sign
,
payInfo
.
data
.
zfb_data_package
);
that
.
payInfo
=
payInfo
.
data
console
.
log
(
that
.
payInfo
);
if
(
payInfo
.
data
)
{
uni
.
requestPayment
({
orderInfo
:
payInfo
.
data
.
zfb_data_package
,
timeStamp
:
payInfo
.
data
.
timestamp
,
nonceStr
:
payInfo
.
data
.
noncestr
,
package
:
payInfo
.
data
.
package
,
signType
:
payInfo
.
data
.
signType
,
paySign
:
payInfo
.
data
.
sign
,
success
:
(
res
)
=>
{
console
.
log
(
res
);
console
.
log
(
'
支付成功
'
);
that
.
text
=
'
支付成功,请返回App
'
uni
.
showToast
({
title
:
'
支付成功
'
})
},
fail
:
(
err
)
=>
{
console
.
log
(
'
支付失败
'
);
that
.
text
=
'
支付失败,请返回App重新支付
'
console
.
log
(
err
);
}
});
//
uni.requestPayment({
//
orderInfo: payInfo.data.zfb_data_package,
//
timeStamp: payInfo.data.timestamp,
//
nonceStr: payInfo.data.noncestr,
//
package: payInfo.data.package,
//
signType: payInfo.data.signType,
//
paySign: payInfo.data.sign,
//
success: (res) => {
//
console.log(res);
//
console.log('支付成功');
//
that.text = '支付成功,请返回App'
//
uni.showToast({
//
title: '支付成功'
//
})
//
},
//
fail: (err) => {
//
console.log('支付失败');
//
that.text = '支付失败,请返回App重新支付'
//
console.log(err);
//
}
//
});
}
else
{
console
.
log
(
'
获取支付参数失败
'
);
}
}).
catch
(()
=>
{
that
.
isPay
=
true
console
.
log
(
that
.
isPay
);
});
}
},
fail
(
err
)
{
console
.
log
(
'
wxlogin失败
'
);
this
.
isPay
=
true
}
})
},
goPay
()
{
let
that
=
this
uni
.
requestPayment
({
orderInfo
:
this
.
payInfo
.
zfb_data_package
,
timeStamp
:
this
.
payInfo
.
timestamp
,
nonceStr
:
this
.
payInfo
.
noncestr
,
package
:
this
.
payInfo
.
package
,
signType
:
this
.
payInfo
.
signType
,
paySign
:
this
.
payInfo
.
sign
,
success
:
(
res
)
=>
{
console
.
log
(
res
);
console
.
log
(
'
支付成功
'
);
that
.
text
=
'
支付成功,请返回App
'
uni
.
showToast
({
title
:
'
支付成功
'
})
this
.
isPay
=
true
},
fail
:
(
err
)
=>
{
console
.
log
(
'
支付失败
'
);
that
.
text
=
'
支付失败,请返回App重新支付
'
console
.
log
(
err
);
this
.
isPay
=
true
}
});
},
launchApp
(
e
)
{
console
.
log
(
e
);
...
...
@@ -110,14 +152,31 @@
<
style
lang=
"less"
>
.flex-center {
display: flex;
justify-content: center;
//
justify-content: center;
flex-flow: column;
align-items: center;
width: 100%;
height: 100vh;
.text {
padding: 30rpx
padding: 30rpx;
padding-top: 100rpx;
width: 650rpx;
line-height: 60rpx;
}
}
.btn {
width: 550rpx;
height: 80rpx;
line-height: 80rpx;
font-size: 28rpx;
border-radius: 10rpx;
border: 1px solid #c1c1c1;
text-align: center;
position: fixed;
bottom: 200rpx;
left: 100rpx;
}
</
style
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment