Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shop_mobile_uni
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑秀明
shop_mobile_uni
Commits
d3083f70
Commit
d3083f70
authored
Jun 28, 2020
by
王建威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序支付
parent
a1e87df7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
60 deletions
+105
-60
index.html
index.html
+38
-0
manifest.json
manifest.json
+1
-1
package.json
package.json
+1
-1
wxpay.vue
pages/wxpay/wxpay.vue
+65
-58
No files found.
index.html
View file @
d3083f70
...
...
@@ -48,6 +48,44 @@
$draggable
.
on
(
'staticClick'
,
function
(
event
,
pointer
)
{
$
(
'#qidian_dom'
).
click
();
})
const
{
origin
}
=
window
.
location
;
let
url
=
''
;
// 测试环境
if
(
origin
.
indexOf
(
'local'
)
>
-
1
||
origin
.
indexOf
(
'test'
)
>
-
1
){
if
(
origin
.
indexOf
(
'test'
)
>
-
1
){
url
=
`
${
origin
}
/mobile/index.php?`
;
}
else
{
url
=
'https://test.pet-dbc.cn/mobile/index.php?'
;
}
}
else
if
(
origin
.
indexOf
(
'jingxiang'
)
>
-
1
){
url
=
'https://jingxiang.pet-dbc.cn/mobile/index.php?'
;
}
else
{
url
=
'https://shop.pet-dbc.cn/mobile/index.php?'
;
}
var
search
=
window
.
location
.
href
.
split
(
'?'
);
if
(
search
[
1
])
{
var
arr
=
search
[
1
].
split
(
'&'
);
arr
.
every
((
item
,
index
)
=>
{
var
kv
=
item
.
split
(
'='
);
if
(
kv
[
0
]
===
'openId'
)
{
localStorage
.
openId
=
kv
[
1
];
$
.
ajax
({
url
:
url
+
'app=weixin&act=autoLogin'
,
type
:
'get'
,
data
:
{
openid
:
kv
[
1
]
},
dataType
:
'json'
,
success
:
function
(
res
)
{
alert
(
JSON
.
stringify
(
res
))
}
})
}
if
(
kv
[
0
]
===
'inionid'
)
{
localStorage
.
unionid
=
kv
[
1
];
}
});
}
</script>
<!-- built files will be auto injected -->
</body>
...
...
manifest.json
View file @
d3083f70
...
...
@@ -51,7 +51,7 @@
"mode"
:
"history"
,
"base"
:
"/uni"
},
"publicPath"
:
"https://dbc-static.oss-cn-beijing.aliyuncs.com/dbc-shop/uni/
mirror
/1.0.13/"
,
"publicPath"
:
"https://dbc-static.oss-cn-beijing.aliyuncs.com/dbc-shop/uni/
test
/1.0.13/"
,
"optimization"
:
{
"treeShaking"
:
{
"enable"
:
true
...
...
package.json
View file @
d3083f70
{
"name"
:
"shop_mobile_uni"
,
"version"
:
"1.0.1
3
"
,
"version"
:
"1.0.1
4
"
,
"description"
:
"谛宝多多商城"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
,
...
...
pages/wxpay/wxpay.vue
View file @
d3083f70
...
...
@@ -78,65 +78,72 @@
},
2000
);
return
;
}
WeixinJSBridge
.
invoke
(
'getBrandWCPayRequest'
,
{
"appId"
:
res
.
app_id
,
//公众号名称,由商户传入
"timeStamp"
:
res
.
timeStamp
,
//时间戳,自1970年以来的秒数
"nonceStr"
:
res
.
nonce_str
,
//随机串
"package"
:
res
.
package
,
"signType"
:
res
.
sign_type
,
//微信签名方式:
"paySign"
:
res
.
pay_sign
//微信签名
},
function
(
res
)
{
WeixinJSBridge
.
log
(
res
.
err_msg
);
const
url
=
window
.
location
.
origin
;
if
(
res
.
err_msg
===
"get_brand_wcpay_request:ok"
)
{
uni
.
navigateTo
({
url
:
'/pages/payresult/payresult'
})
}
else
if
(
res
.
err_msg
===
"get_brand_wcpay_request:cancel"
)
{
uni
.
showToast
({
title
:
'已取消支付,请重新支付'
,
duration
:
2000
,
icon
:
'none'
});
setTimeout
(()
=>
{
history
.
back
();
},
2000
);
}
else
if
(
res
.
err_msg
===
"get_brand_wcpay_request:fail"
)
{
// Toast.fail('支付失败', 3);
uni
.
showToast
({
title
:
'支付失败,请重新支付'
,
duration
:
2000
,
icon
:
'none'
});
// 回退上一页重新支付
setTimeout
(()
=>
{
history
.
back
();
},
2000
);
// 提示支付失败,关闭当前页面
// setTimeout(function() {
//这个可以关闭安卓系统的手机
// document.addEventListener(
// "WeixinJSBridgeReady",
// function() {
// WeixinJSBridge.call("closeWindow");
// },
// false
// );
// //这个可以关闭ios系统的手机
// WeixinJSBridge.call("closeWindow");
// this.$jump(`${url}?app=member`);
// }, 300);
}
else
{
uni
.
showToast
({
title
:
'未知错误,刷新重试'
,
duration
:
2000
,
icon
:
'none'
});
}
wx
.
miniProgram
.
getEnv
(
function
(
res
)
{
if
(
res
.
miniprogram
){
var
path
=
'/pages/pay/index?payParam='
+
encodeURIComponent
(
JSON
.
stringify
(
res
))
+
'&type=uni'
;
wx
.
miniProgram
.
navigateTo
({
url
:
path
});
}
else
{
WeixinJSBridge
.
invoke
(
'getBrandWCPayRequest'
,
{
"appId"
:
res
.
app_id
,
//公众号名称,由商户传入
"timeStamp"
:
res
.
timeStamp
,
//时间戳,自1970年以来的秒数
"nonceStr"
:
res
.
nonce_str
,
//随机串
"package"
:
res
.
package
,
"signType"
:
res
.
sign_type
,
//微信签名方式:
"paySign"
:
res
.
pay_sign
//微信签名
},
function
(
res
)
{
WeixinJSBridge
.
log
(
res
.
err_msg
);
const
url
=
window
.
location
.
origin
;
if
(
res
.
err_msg
===
"get_brand_wcpay_request:ok"
)
{
uni
.
navigateTo
({
url
:
'/pages/payresult/payresult'
})
}
else
if
(
res
.
err_msg
===
"get_brand_wcpay_request:cancel"
)
{
uni
.
showToast
({
title
:
'已取消支付,请重新支付'
,
duration
:
2000
,
icon
:
'none'
});
setTimeout
(()
=>
{
history
.
back
();
},
2000
);
}
else
if
(
res
.
err_msg
===
"get_brand_wcpay_request:fail"
)
{
// Toast.fail('支付失败', 3);
uni
.
showToast
({
title
:
'支付失败,请重新支付'
,
duration
:
2000
,
icon
:
'none'
});
// 回退上一页重新支付
setTimeout
(()
=>
{
history
.
back
();
},
2000
);
// 提示支付失败,关闭当前页面
// setTimeout(function() {
//这个可以关闭安卓系统的手机
// document.addEventListener(
// "WeixinJSBridgeReady",
// function() {
// WeixinJSBridge.call("closeWindow");
// },
// false
// );
// //这个可以关闭ios系统的手机
// WeixinJSBridge.call("closeWindow");
// this.$jump(`${url}?app=member`);
// }, 300);
}
else
{
uni
.
showToast
({
title
:
'未知错误,刷新重试'
,
duration
:
2000
,
icon
:
'none'
});
}
}
);
}
);
})
},
goBack
(){
this
.
$backup
();
...
...
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