Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
doublescreen-front
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengguangpu
doublescreen-front
Commits
87d52a91
Commit
87d52a91
authored
Feb 06, 2020
by
jiangjiantao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
核销兑换券
parent
0b3d1e22
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
126 additions
and
34 deletions
+126
-34
app.js
app.js
+2
-1
apiurl.js
const/apiurl.js
+4
-1
scandialog.js
custom_widgets/scandialog/scandialog.js
+0
-3
mini.project.json
mini.project.json
+3
-0
home.axml
pages/home/home.axml
+6
-6
home.js
pages/home/home.js
+65
-21
scan.js
pages/scan/scan.js
+46
-2
No files found.
app.js
View file @
87d52a91
...
...
@@ -12,7 +12,8 @@ App({
//小程序容器版本
containerVersionCode
:
null
,
localAccountInfo
:
null
,
sn
:
""
//模拟器上需要sn有值
sn
:
"xx"
},
onLaunch
(
options
)
{
...
...
const/apiurl.js
View file @
87d52a91
//登陆
export
const
API_LOGIN
=
"store/cashier/login"
;
//查询商品
export
const
API_SCAN
=
"market/barcodeQuery"
;
//核销券
export
const
API_USE_COUPON
=
"coupon/use"
;
custom_widgets/scandialog/scandialog.js
View file @
87d52a91
...
...
@@ -17,10 +17,7 @@ Component({
resultSuccessText
:
""
,
resultFailureRemind
:
""
,
resultFailureText
:
""
,
displayDialog
:
0
,
},
// 可给外部传入的属性添加默认值
didMount
()
{
},
// 生命周期函数,加载成功
...
...
mini.project.json
0 → 100644
View file @
87d52a91
{
"component2"
:
true
}
\ No newline at end of file
pages/home/home.axml
View file @
87d52a91
<view class="page" >
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;background:url(/images/bg_home.png) no-repeat fixed top;background-size:100% 100%;"/>
<view style="position:absolute;width:100%;height:100%;left:0rpx;top:0rpx;background:url(/images/bg_home.png) no-repeat fixed top;background-size:100% 100%;"
onTap="homeTap"
/>
<scandialog displayDialog="{{scanDialogDisplay}}"
remindText="请扫描
订单编
码"
remindText="请扫描
兑换
码"
loadingText="识别中"
resultSuccessRemind="
退款成功
"
resultSuccess
Remind="退款完成!会在1~2个工作日 返还到您的付款账户
"
resultFailureRemind="
退款失败
"
resultFailureText="
核销失败!无效的订单码
"
resultSuccessRemind="
兑换码已识别
"
resultSuccess
Text="恭喜您!兑换成功
"
resultFailureRemind="
兑换码未识别
"
resultFailureText="
兑换失败,请稍后重试!
"
/>
</view>
\ No newline at end of file
pages/home/home.js
View file @
87d52a91
import
{
Page
}
from
'../../utils/scan'
;
import
{
API_USE_COUPON
}
from
'../../const/apiurl'
var
api
=
require
(
"../../utils/api.js"
);
Page
({
data
:
{
scanDialogDisplay
:
0
scanDialogDisplay
:
0
},
onLoad
()
{
},
onReady
(){
onReady
()
{
if
(
my
.
canIUse
(
'hideBackHome'
))
{
my
.
hideBackHome
();
}
},
scanDialog
(
ref
){
scanDialog
(
ref
)
{
// if(ref.getAttribute("id") == "drawbackDialog"){
// }else if(ref.getAttribute("id") == ""){
// }
},
homeTap
(){
homeTap
()
{
this
.
showDialog
();
//FIXME 这里是跳转到新的界面
my
.
navigateTo
({
url
:
"/pages/balance/balance"
});
//
my.navigateTo({
//
url: "/pages/balance/balance"
//
});
},
<<<<<<<
HEAD
//外接扫码枪事件
onKeyPress
(
r
)
{
console
.
log
(
"scan onKeyPress==>"
+
r
);
// this.getGoodInfoByBarcode(r);
console
.
log
(
" onKeyPress==>"
+
r
);
//核销券
if
(
this
.
data
.
scanDialogDisplay
==
1
)
{
this
.
verifyCoupon
(
r
)
return
;
}
my
.
navigateTo
({
url
:
"/pages/scan/scan?barcode="
+
r
,
});
},
=======
//显示弹窗,>1为显示,2loading 3 result success 4 result failed
showDialog
(){
this
.
setData
(
this
.
data
.
scanDialogDisplay
=
this
.
data
.
scanDialogDisplay
+
1
)
}
>>>>>>>
b85311896b3b12a7e29afcc50be66f821096a0f3
showDialog
()
{
this
.
setData
({
scanDialogDisplay
:
1
}
)
console
.
log
(
this
.
data
.
scanDialogDisplay
);
},
//核销券
verifyCoupon
(
code
)
{
this
.
setData
({
scanDialogDisplay
:
2
})
var
couponRequest
=
api
.
createCommonRequest
();
couponRequest
.
couponCode
=
code
;
console
.
log
(
"核销券的请求 ==>"
+
JSON
.
stringify
(
couponRequest
));
my
.
request
({
url
:
getApp
().
globalData
.
BASE_URL
+
API_USE_COUPON
,
method
:
'POST'
,
dataType
:
'json'
,
timeout
:
30000
,
data
:
couponRequest
,
success
:
(
res
)
=>
{
if
(
res
.
data
.
success
!=
true
)
{
this
.
setData
({
scanDialogDisplay
:
4
})
console
.
log
(
"核销券失败 ==>"
+
res
.
data
.
message
);
}
else
{
this
.
setData
({
scanDialogDisplay
:
3
})
console
.
log
(
"核销券成功 ==>"
+
JSON
.
stringify
(
res
));
}
},
fail
:
(
res
)
=>
{
this
.
setData
({
scanDialogDisplay
:
4
})
console
.
log
(
"核销券失败 ==>"
+
JSON
.
stringify
(
res
));
my
.
showToast
({
type
:
'exception'
,
content
:
api
.
decodeErrorMessage
(
res
.
error
),
duration
:
2000
});
}
});
},
...
...
pages/scan/scan.js
View file @
87d52a91
var
api
=
require
(
"../../utils/api.js"
);
import
{
Page
}
from
'../../utils/scan'
;
import
{
API_SCAN
}
from
'../../const/apiurl'
import
{
API_USE_COUPON
}
from
'../../const/apiurl'
Page
({
...
...
@@ -132,7 +133,6 @@ Page({
this
.
setData
({
goods
:
newgoods
})
}
//汇总
this
.
setData
({
totalQuantity
:
totalQuantityTemp
,
totalPrice
:
totalPriceTemp
,
...
...
@@ -145,6 +145,50 @@ Page({
my
.
navigateTo
({
url
:
"/pages/balance/balance?totalPrice="
+
this
.
data
.
totalPrice
+
"&totalQuantity="
+
this
.
data
.
totalQuantity
+
"&totalDisc="
+
this
.
data
.
totalDisc
,
});
}
},
//核销券
verifyCoupon
(
code
)
{
my
.
showLoading
({});
var
couponRequest
=
api
.
createCommonRequest
();
couponRequest
.
couponCode
=
barcode
;
console
.
log
(
"核销券的请求 ==>"
+
JSON
.
stringify
(
couponRequest
));
my
.
request
({
url
:
getApp
().
globalData
.
BASE_URL
+
API_USE_COUPON
,
method
:
'POST'
,
dataType
:
'json'
,
timeout
:
30000
,
data
:
couponRequest
,
success
:
(
res
)
=>
{
my
.
hideLoading
();
console
.
log
(
"核销券成功 ==>"
+
JSON
.
stringify
(
res
));
if
(
res
.
data
.
success
!=
true
)
{
my
.
showToast
({
type
:
'fail'
,
content
:
res
.
data
.
message
,
duration
:
2000
});
}
else
{
console
.
log
(
"核销券成功"
);
}
},
fail
:
(
res
)
=>
{
my
.
hideLoading
();
console
.
log
(
"核销券失败 ==>"
+
JSON
.
stringify
(
res
));
my
.
showToast
({
type
:
'exception'
,
content
:
api
.
decodeErrorMessage
(
res
.
error
),
duration
:
2000
});
}
});
},
});
\ No newline at end of file
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