Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
dev
/
zhiliang-light-mp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2d22b076
authored
2019-08-23 17:24:55 +0800
by
simon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.加扫码功能 2.修复bug
1 parent
80e76f2b
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
169 additions
and
63 deletions
src/component/order-submit-success-tips-comp/order-submit-success-tips-comp.wxml
src/component/product-detail-comp/product-detail-comp.scss
src/http/fetch-api.js
src/pages/authorize/authorize.js
src/pages/gift-detail/gift-detail.js
src/pages/gift-detail/gift-detail.wxml
src/pages/index/index.js
src/pages/index/index.wxml
src/pages/my-qrcode/my-qrcode.js
src/pages/scan-result/scan-result.js
src/pages/scan-result/scan-result.wxml
src/pages/user-center/user-center.js
src/utils/util.js
src/component/order-submit-success-tips-comp/order-submit-success-tips-comp.wxml
View file @
2d22b07
...
...
@@ -10,6 +10,6 @@
<view wx:if="{{item.commodityType == 'packet'}}" class="tips">
后台审核通过后,红包将会通过公众号消息或微信服务消息发送,届时请及时领取!
</view>
<view wx:else class="tips">您可以在“
个人中心
→我的订单”中查看物流进度</view>
<view wx:else class="tips">您可以在“
礼物兑换
→我的订单”中查看物流进度</view>
</view>
</view>
...
...
src/component/product-detail-comp/product-detail-comp.scss
View file @
2d22b07
...
...
@@ -8,20 +8,20 @@
.cont
{
background
:
#FFFFFF
;
@extend
.shadow
;
width
:
6
7
0px
;
width
:
6
4
0px
;
margin
:
0
auto
;
min-height
:
900px
;
@extend
.bb
;
padding
:
20px
30px
20px
;
.tit
{
font-size
:
40
px
;
font-size
:
36
px
;
text-align
:
center
;
}
.img-wrap
{
$imgWidth
:
61
0px
;
$imgHeight
:
4
80px
;
$imgWidth
:
58
0px
;
$imgHeight
:
5
80px
;
margin
:
20px
0
;
width
:
$imgWidth
;
height
:
$imgHeight
;
...
...
@@ -42,16 +42,15 @@
.desc
{
color
:
#333333
;
font-size
:
28px
;
height
:
32
0px
;
height
:
23
0px
;
line-height
:
48px
;
}
}
.close
{
width
:
82px
;
height
:
112px
;
margin
:
0
auto
40
px
;
margin
:
0
auto
24
px
;
.btn
{
width
:
82px
;
...
...
src/http/fetch-api.js
View file @
2d22b07
...
...
@@ -11,6 +11,7 @@ function wxLogin() {
success
:
function
(
res
)
{
// isWxLogin = true;
Store
.
setItem
(
'wxcode'
,
res
.
code
);
console
.
log
(
"wxLogin code:"
,
res
.
code
);
resolve
();
}
});
...
...
@@ -68,6 +69,7 @@ function login() {
wx
.
login
({
success
:
function
(
res
)
{
Store
.
setItem
(
'wxcode'
,
res
.
code
);
console
.
log
(
"auth code:"
,
res
.
code
);
view
.
showAuth
();
}
});
...
...
src/pages/authorize/authorize.js
View file @
2d22b07
...
...
@@ -16,11 +16,11 @@ Page({
onReady
()
{
// app.store.clear("sessionId");
let
_this
=
this
;
wx
.
login
({
success
:
function
(
res
)
{
_this
.
data
.
loginData
=
res
;
}
});
//
wx.login({
//
success: function (res) {
//
_this.data.loginData = res;
//
}
//
});
},
bindGetUserInfo
(
e
)
{
wx
.
showLoading
();
...
...
src/pages/gift-detail/gift-detail.js
View file @
2d22b07
...
...
@@ -119,7 +119,7 @@ Page({
wx
.
showModal
({
title
:
'兑换确认'
,
content
:
`将花费
${
item
.
commodityPrice
}
兑换
${
item
.
commodityTitle
}
一份`
,
content
:
`将花费
${
item
.
commodityPrice
}
积分
兑换
${
item
.
commodityTitle
}
一份`
,
success
(
res
)
{
if
(
res
.
confirm
)
{
app
.
post
({
...
...
src/pages/gift-detail/gift-detail.wxml
View file @
2d22b07
...
...
@@ -42,7 +42,7 @@
<view class="label">收货地址</view>
<view class="cont">{{defaultReceiver.receiverAddress}}</view>
</view>
<textarea value="{{remark}}" bindinput="bindRemarkInput" placeholder="备注您的其他要求" class="form-remark"></textarea>
<textarea
wx:if="{{!orderSubmitSuccessCompVisible && !commonTipsCompVisible}}"
value="{{remark}}" bindinput="bindRemarkInput" placeholder="备注您的其他要求" class="form-remark"></textarea>
</view>
<!-- 添加地址按钮 -->
<view wx:else bindtap="onAddressAddHandler" class="manage-add">我的收货地址</view>
...
...
src/pages/index/index.js
View file @
2d22b07
import
{
getBindtapData
getBindtapData
,
getQueryByUrl
}
from
'../../utils/util'
;
let
app
=
getApp
();
...
...
@@ -15,7 +16,9 @@ Page({
curProductDetail
:
{},
// 选中的产品详情
qrCodeCode
:
""
,
userInfo
:
{},
//用户信息
code
:
""
,
// 手输入码
code
:
""
,
// 手输入码 / 扫出的积分码
memberCode
:
""
,
// 扫出的用户码
// integralCode: "", // 扫出的积分码
},
onShareAppMessage
()
{},
showAuth
()
{
...
...
@@ -24,30 +27,48 @@ Page({
})
},
onLoad
(
options
)
{
let
q
=
decodeURIComponent
(
options
.
q
);
if
(
q
)
{
// 获取会员码
let
m
=
getQueryByUrl
(
"m"
,
q
);
if
(
m
)
{
this
.
setData
({
memberCode
:
m
})
}
this
.
queryProduct
();
this
.
queryBanner
();
let
scene
=
decodeURIComponent
(
options
.
scene
)
||
""
;
// scene = "ab4cbd54dcf04d29a6c23d00a900b332"
if
(
scene
)
{
// 获取积分码
let
c
=
getQueryByUrl
(
"c"
,
q
);
if
(
c
)
{
this
.
setData
({
scene
code
:
c
})
}
}
this
.
queryProduct
();
this
.
queryBanner
();
this
.
initData
();
},
onShow
()
{
console
.
log
(
"onShow memberCode:"
,
this
.
data
.
memberCode
);
console
.
log
(
"onShow code:"
,
this
.
data
.
code
);
},
initData
()
{
let
{
scene
memberCode
,
code
}
=
this
.
data
;
if
(
scene
)
{
// 可能要拉授权
// 如果存在扫码参数,则需要拉用户身份(未授权的情况下 要拉授权)
this
.
queryMember
().
then
((
result
)
=>
{
this
.
queryScanPersonQrcode
().
then
((
result
)
=>
{}).
catch
((
err
)
=>
{});
});
this
.
queryScanPersonQrcode
().
then
((
result2
)
=>
{
if
(
code
)
{
this
.
onSearchHandler
();
}
});
});
},
...
...
@@ -127,24 +148,25 @@ Page({
/**
* 扫个人码
* 如果没有码,直接返回
*/
queryScanPersonQrcode
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
{
scen
e
memberCod
e
}
=
this
.
data
;
if
(
scen
e
)
{
if
(
memberCod
e
)
{
app
.
post
({
toast
:
false
,
url
:
app
.
api
.
scanPersonQrcode
,
data
:
{
memberCode
:
scen
e
memberCode
:
memberCod
e
}
}).
then
((
result
)
=>
{
this
.
setData
({
prizeInfo
:
result
})
resolve
();
})
}
else
{
resolve
();
}
});
},
...
...
@@ -159,19 +181,45 @@ Page({
productDetailVisible
:
true
})
},
/**
* 点击扫码按钮
*/
onScanHandler
()
{
let
_this
=
this
;
wx
.
scanCode
({
onlyFromCamera
:
true
,
success
(
res
)
{
// 扫码结果
let
result
=
res
.
result
;
let
{
qrCodeCode
,
memberCode
}
=
result
;
let
q
=
res
.
result
;
console
.
log
(
"q:"
,
q
)
// 获取会员码
let
m
=
getQueryByUrl
(
"m"
,
q
);
console
.
log
(
"m:"
,
m
)
if
(
m
)
{
_this
.
setData
({
memberCode
:
m
})
_this
.
queryScanPersonQrcode
();
}
// 获取积分码
let
c
=
getQueryByUrl
(
"c"
,
q
);
if
(
c
)
{
app
.
router
.
push
({
path
:
"scanResult"
,
query
:
{
code
:
c
}
})
}
else
{
wx
.
showModal
({
content
:
'未发现积分码,换一个二维码试试'
,
showCancel
:
false
,
success
(
res
)
{}
})
}
},
fail
(
err
)
{
console
.
log
(
"err:"
,
err
);
...
...
@@ -183,10 +231,22 @@ Page({
* 点击搜索
*/
onSearchHandler
()
{
let
code
=
this
.
data
.
code
;
this
.
setData
({
code
:
""
})
if
(
code
.
length
!=
16
)
{
wx
.
showModal
({
content
:
'请输入16位积分码'
,
showCancel
:
false
,
success
(
res
)
{}
})
return
;
}
app
.
router
.
push
({
path
:
"scanResult"
,
query
:
{
code
:
this
.
data
.
code
code
:
code
}
})
},
...
...
src/pages/index/index.wxml
View file @
2d22b07
...
...
@@ -14,10 +14,10 @@
<image class="icon" mode="aspectFit" src="../../image/icon/icon-search.png" />
</view>
<!-- 隐藏扫描二维码 -->
<
!-- <
view class="search-line"></view>
<view class="search-line"></view>
<view bindtap="onScanHandler" class="search-scan">
<image class="icon" mode="aspectFit" src="../../image/icon/icon-scan.png" />
</view>
-->
</view>
</view>
</view>
<view class="top-space"></view>
...
...
src/pages/my-qrcode/my-qrcode.js
View file @
2d22b07
...
...
@@ -21,6 +21,9 @@ Page({
initData
()
{
// 获取用户信息 小程序码
this
.
queryMember
().
then
((
result
)
=>
{
wx
.
showLoading
({
title
:
'二维码生成中···'
,
});
// 获取海报数据
let
posterData
=
this
.
getPosterConfig
();
// 绘制设置海报
...
...
src/pages/scan-result/scan-result.js
View file @
2d22b07
import
{
getBindtapData
,
getQueryByUrl
}
from
'../../utils/util'
;
let
app
=
getApp
();
Page
({
data
:
{
...
...
@@ -14,21 +19,11 @@ Page({
},
onLoad
(
options
)
{
// 扫小程序码进入
let
scene
=
decodeURIComponent
(
options
.
scene
)
||
""
;
// scene = "02llmPvYl1CFN2bc"
if
(
scene
)
{
this
.
setData
({
scene
})
}
// 手输码
let
code
=
options
.
code
||
""
;
console
.
log
(
"code:"
,
code
);
if
(
code
)
{
this
.
setData
({
scen
e
:
code
cod
e
:
code
})
}
...
...
@@ -65,13 +60,13 @@ Page({
queryScanIntegralQrcode
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
{
scen
e
cod
e
}
=
this
.
data
;
if
(
scen
e
)
{
if
(
cod
e
)
{
app
.
post
({
url
:
app
.
api
.
scanIntegralQrcode
,
data
:
{
qrCodeCode
:
scen
e
qrCodeCode
:
cod
e
}
}).
then
((
result
)
=>
{
this
.
setData
({
...
...
@@ -101,6 +96,42 @@ Page({
});
},
/**
* 点击扫码按钮
*/
onScanHandler
()
{
let
_this
=
this
;
wx
.
scanCode
({
onlyFromCamera
:
true
,
success
(
res
)
{
// 扫码结果
let
q
=
res
.
result
;
// 获取积分码
let
c
=
getQueryByUrl
(
"c"
,
q
);
if
(
c
)
{
// app.router.push({
// path: "scanResult",
// query: {
// code: c
// }
// })
_this
.
queryScanIntegralQrcode
();
}
else
{
wx
.
showModal
({
content
:
'未发现积分码,换一个二维码试试'
,
showCancel
:
false
,
success
(
res
)
{}
})
}
},
fail
(
err
)
{
console
.
log
(
"err:"
,
err
);
}
})
},
/**
* 查看我的积分
*/
...
...
src/pages/scan-result/scan-result.wxml
View file @
2d22b07
...
...
@@ -13,7 +13,7 @@
积分
</view>
<view class="btn-wrap">
<
!-- <view class="btn">再扫一次</view> --
>
<
view bindtap="onScanHandler" class="btn">再扫一次</view
>
<view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view>
</view>
</view>
...
...
@@ -25,7 +25,7 @@
<!-- 其他异常 -->
<text wx:else class="tips tips1">此产品码已被扫过!\n若有异常,请联系客服</text>
<view class="btn-wrap">
<
!-- <view class="btn">再扫一次</view> --
>
<
view bindtap="onScanHandler" class="btn">再扫一次</view
>
<view bindtap="onMyIntegralHandler" class="btn btn2">查看我的积分</view>
<!-- <view class="btn btn2">联系客服</view> -->
</view>
...
...
src/pages/user-center/user-center.js
View file @
2d22b07
...
...
@@ -90,11 +90,11 @@ Page({
toast
:
false
,
url
:
app
.
api
.
sign
,
}).
then
((
result
)
=>
{
this
.
queryMember
().
then
((
result
)
=>
{
this
.
querySignInfo
().
then
((
result
2
)
=>
{
this
.
queryMember
().
then
((
result
2
)
=>
{
this
.
querySignInfo
().
then
((
result
3
)
=>
{
// 签到成功
this
.
setData
({
signPrize
:
result
2
,
signPrize
:
result
,
giftSignTipsCompVisible
:
true
})
})
...
...
src/utils/util.js
View file @
2d22b07
...
...
@@ -122,6 +122,16 @@ function formatWeek(week) {
return
result
;
}
/**
* 根据url获取参数
* @param {*} name
*/
function
getQueryByUrl
(
name
,
url
)
{
return
decodeURIComponent
((
new
RegExp
(
'[?|&]'
+
name
+
'='
+
'([^&;]+?)(&|#|;|$)'
).
exec
(
url
)
||
[,
""
])[
1
].
replace
(
/
\+
/g
,
'%20'
))
||
null
;
}
/**
* 获取点击传值
* @param {*} evt
...
...
@@ -232,5 +242,6 @@ module.exports = {
formatWeek
:
formatWeek
,
getBindtapData
:
getBindtapData
,
wxacodeGet
:
wxacodeGet
,
getObjByListKeyValue
:
getObjByListKeyValue
getObjByListKeyValue
:
getObjByListKeyValue
,
getQueryByUrl
:
getQueryByUrl
,
}
...
...
Please
register
or
sign in
to post a comment