Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
nyx
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
发现
nyx
Commits
e9568380
Commit
e9568380
authored
Nov 18, 2020
by
jscat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nyx weapp: 流程更新
1. 为小程序添加正式的支付流程 2. 如果未授权, 则先授权, 后支付
parent
4a539323
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
163 行增加
和
8 行删除
+163
-8
app/nyx-dev/app.json
+2
-2
app/nyx-dev/config.js
+4
-1
app/nyx-dev/pages/mall/order/order.js
+147
-3
app/nyx-dev/pages/mall/order/order.wxml
+10
-2
没有找到文件。
app/nyx-dev/app.json
查看文件 @
e9568380
...
@@ -38,13 +38,13 @@
...
@@ -38,13 +38,13 @@
"list"
:
[
"list"
:
[
{
{
"pagePath"
:
"pages/activity/activity"
,
"pagePath"
:
"pages/activity/activity"
,
"text"
:
"
饮事
"
,
"text"
:
"
活动
"
,
"iconPath"
:
"./icon/my/activity.png"
,
"iconPath"
:
"./icon/my/activity.png"
,
"selectedIconPath"
:
"./icon/my/activity.png"
"selectedIconPath"
:
"./icon/my/activity.png"
},
},
{
{
"pagePath"
:
"pages/share/share"
,
"pagePath"
:
"pages/share/share"
,
"text"
:
"
互动
"
,
"text"
:
"
大厅
"
,
"iconPath"
:
"./icon/fair/fair.png"
,
"iconPath"
:
"./icon/fair/fair.png"
,
"selectedIconPath"
:
"./icon/fair/fair.png"
"selectedIconPath"
:
"./icon/fair/fair.png"
},
},
...
...
app/nyx-dev/config.js
查看文件 @
e9568380
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
// env = 0; //本地java测试,需要启动java后台
// env = 0; //本地java测试,需要启动java后台
// env = 1; //阿里云服务器测试版本
// env = 1; //阿里云服务器测试版本
// env = 2; //阿里云服务器生产版本
// env = 2; //阿里云服务器生产版本
var
env
=
1
;
var
env
=
2
;
var
debug
=
0
;
//是否打印调试信息
var
debug
=
0
;
//是否打印调试信息
var
host_key
=
"https://fun.hisuhong.com"
;
var
host_key
=
"https://fun.hisuhong.com"
;
...
@@ -76,5 +76,7 @@ var config={
...
@@ -76,5 +76,7 @@ var config={
collect_like_del_url
:
host_key
+
"/api/nyx/collect/like/del"
,
collect_like_del_url
:
host_key
+
"/api/nyx/collect/like/del"
,
check_text_url
:
host_key
+
"/api/nyx/wx/check/text"
,
check_text_url
:
host_key
+
"/api/nyx/wx/check/text"
,
check_pic_url
:
host_key
+
"/api/nyx/wx/check/pic"
,
check_pic_url
:
host_key
+
"/api/nyx/wx/check/pic"
,
pay_url
:
host_key
+
"/api/nyx/wx/pay/orders"
,
pay_callback_url
:
host_key
+
"/api/nyx/wx/pay/notify"
,
}
}
module
.
exports
=
config
;
module
.
exports
=
config
;
\ No newline at end of file
app/nyx-dev/pages/mall/order/order.js
查看文件 @
e9568380
...
@@ -437,8 +437,13 @@ Page({
...
@@ -437,8 +437,13 @@ Page({
jscat 2020/11/17 支付成功
jscat 2020/11/17 支付成功
*/
*/
toPay_ok
:
function
(
e
)
{
toPay_ok
:
function
(
e
)
{
var
datas
=
this
.
data
;
var
_this
=
this
;
var
strUrl
=
'https://wx.hisuhong.com/api/nyx/wx/pay/orders?openId=onuaY5fagtbB9zyEQ3fQ6jaesgrM&money=1&body=123'
var
nyxCode
=
_this
.
__data__
.
nyxCode
var
body
=
_this
.
__data__
.
orderInfo
.
member_name
var
money
=
_this
.
__data__
.
totalPrice
var
query_url
=
'?userId='
+
nyxCode
+
'&money='
+
money
+
'&body='
+
body
var
strUrl
=
config
.
pay_url
+
query_url
config
.
debug
==
1
?
console
.
log
(
"===toPay_ok strUrl "
+
strUrl
):
""
wx
.
request
({
wx
.
request
({
url
:
strUrl
,
url
:
strUrl
,
method
:
"GET"
,
method
:
"GET"
,
...
@@ -457,7 +462,7 @@ Page({
...
@@ -457,7 +462,7 @@ Page({
if
(
res
.
errMsg
==
"requestPayment:ok"
){
if
(
res
.
errMsg
==
"requestPayment:ok"
){
//这里是支付成功后的操作,你可以在此提交表单或者进行其他减少库存量等一系列操作
//这里是支付成功后的操作,你可以在此提交表单或者进行其他减少库存量等一系列操作
console
.
log
(
"pay:ok"
);
console
.
log
(
"pay:ok"
);
_this
.
toOrder
();
}
}
},
},
fail
:
function
(
res
)
fail
:
function
(
res
)
...
@@ -469,6 +474,86 @@ Page({
...
@@ -469,6 +474,86 @@ Page({
});
});
},
},
// 跳转到支付页面
// 目前暂时跳转到 /page/my/my.wxml
toOrder
:
function
(
e
)
{
var
_this
=
this
;
var
strUrl
=
config
.
order_add_url
config
.
debug
==
1
?
console
.
log
(
"===uploadOrder strUrl "
+
strUrl
):
""
//先设置支付按钮不可点击
var
canClick
=
false
;
_this
.
setData
({
canClick
})
// 订单处理, 添加到订单项的条件
// 1. 商品中某一类别的quantity>=1,
// 2. defaultStatus==1
var
items
=
_this
.
data
.
orderItems
var
orderItems
=
[]
for
(
var
i
=
0
;
i
<
items
.
length
;
i
++
)
{
if
(
items
[
i
].
quantity
>=
1
&&
items
[
i
].
defaultStatus
==
1
)
{
orderItems
.
push
(
items
[
i
])
}
}
wx
.
request
({
url
:
strUrl
,
method
:
'POST'
,
data
:
{
activityId
:
_this
.
__data__
.
orderInfo
[
"activity_id"
],
userId
:
_this
.
data
.
nyxCode
,
productImage
:
_this
.
__data__
.
orderInfo
[
'product_image'
],
totalPrice
:
_this
.
data
.
totalPrice
,
totalCount
:
_this
.
data
.
totalCount
,
orderItemString
:
JSON
.
stringify
(
orderItems
),
},
header
:
{
'content-type'
:
'application/x-www-form-urlencoded'
,
'Cookie'
:
wx
.
getStorageSync
(
'cookieKey'
),
},
dataType
:
"json"
,
success
:
function
(
res
)
{
if
(
res
.
data
.
resultCode
==
200
)
{
//表示提交成功
console
.
log
(
"===订单上传成功"
);
//重置数据
//设置支付按钮可点击
var
canClick
=
true
;
_this
.
setData
({
canClick
})
//回到首页
_this
.
toHome
();
}
else
if
(
res
.
data
.
resultCode
==
'000601'
)
{
//表示重复提交
console
.
log
(
"===订单重复提交触发"
);
//重置数据
//设置支付按钮可点击
var
canClick
=
true
;
var
showToast
=
true
;
_this
.
setData
({
canClick
,
showToast
})
wx
.
showToast
({
icon
:
'none'
,
title
:
'重复提交, 请3分钟后再试'
,
duration
:
2000
,
success
:
function
(){
setTimeout
(
function
(){
var
showToast
=
false
_this
.
setData
({
showToast
})
},
2000
)
}
})
}
}
})
},
//跳转到首页
//跳转到首页
toHome
:
function
(
e
)
{
toHome
:
function
(
e
)
{
var
_this
=
this
;
var
_this
=
this
;
...
@@ -503,5 +588,63 @@ Page({
...
@@ -503,5 +588,63 @@ Page({
},
},
// 授权入口: 获取用户授权信息
// authStatus=='00'
// jscat 2020/11/18
onGetUserInfo
:
function
(
e
)
{
var
_this
=
this
;
_this
.
getUserInfo
()
},
getUserInfo
()
{
let
_this
=
this
;
//先设置点击按钮不可点击
var
canClick
=
false
;
_this
.
setData
({
canClick
})
config
.
debug
==
1
?
console
.
log
(
"===getUserInfo"
):
""
// 获取用户信息
wx
.
getSetting
({
success
(
res
)
{
config
.
debug
==
1
?
console
.
log
(
"===getUserInfo_res_"
+
res
)
:
""
if
(
res
.
authSetting
[
'scope.userInfo'
])
{
// 判断获取用户信息是否授权
config
.
debug
==
1
?
console
.
log
(
"已授权====="
)
:
""
// 已经授权, 可以直接调用 getUserInfo 获取用户信息
let
promise_login
=
new
Promise
(
function
(
resolve
,
reject
)
{
app
.
login
(
resolve
,
reject
)
})
promise_login
.
then
(
function
(
value
)
{
console
.
log
(
"===enter promise_login then_pass_"
+
value
)
_this
.
toPay_ok
()
},
function
(
value
)
{
console
.
log
(
"===enter promise_login then_failed_"
+
value
)
});
}
else
{
config
.
debug
==
1
?
console
.
log
(
"未授权====="
)
:
""
//再设置支付按钮可点击
var
canClick
=
true
;
_this
.
setData
({
canClick
})
// 无法重新进行授权; jscat 20200901
// 因为 openSetting:fail can only be invoked by user TAP gesture.
wx
.
showModal
({
title
:
'授权提示'
,
content
:
'活动预订需要您的授权哦'
})
}
}
})
},
})
})
\ No newline at end of file
app/nyx-dev/pages/mall/order/order.wxml
查看文件 @
e9568380
...
@@ -71,14 +71,22 @@
...
@@ -71,14 +71,22 @@
<button class="button-red" bindtap="toBuy">立即购买</button>
<button class="button-red" bindtap="toBuy">立即购买</button>
</view>
</view>
</view> -->
</view> -->
<!-- toOrder 仅仅是先预定 -->
<!--
toOrder 仅仅是先预定
refer activity-submit.wxml
-->
<view class="weui-tabbar__item">
<view class="weui-tabbar__item">
<view class="note-row align" style="margin-bottom:0; justify-content: flex-end">
<view class="note-row align" style="margin-bottom:0; justify-content: flex-end">
<view style="font-size:30rpx;margin-right:20rpx;color:#000">合计:
<view style="font-size:30rpx;margin-right:20rpx;color:#000">合计:
<text style="color:#FF6600">¥{{totalPrice}}</text>
<text style="color:#FF6600">¥{{totalPrice}}</text>
</view>
</view>
<view style="width:200rpx">
<view style="width:200rpx">
<button class="button-red" disabled="{{!canClick}}" bindtap="toPay">确定({{totalCount}})</button>
<block wx:if="{{authStatus=='00'}}">
<button class="button-red" disabled="{{!canClick}}" open-type="getUserInfo" bindgetuserinfo="onGetUserInfo">授权&确定</button>
</block>
<block wx:else>
<button class="button-red" disabled="{{!canClick}}" bindtap="toPay_ok">确定({{totalCount}})</button>
</block>
</view>
</view>
</view>
</view>
</view>
</view>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论