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
82c6c9ca
authored
2019-08-13 00:35:20 +0800
by
simon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
no message
1 parent
d784bd00
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
597 additions
and
73 deletions
src/app.js
src/app.json
src/component/order-submit-success-tips-comp/order-submit-success-tips-comp.js
src/pages/address-edit/address-edit.js
src/pages/address-edit/address-edit.wxml
src/pages/address-management/address-management.js
src/pages/address-management/address-management.scss
src/pages/address-management/address-management.wxml
src/pages/gift-detail/gift-detail.js
src/pages/gift-detail/gift-detail.scss
src/pages/gift-detail/gift-detail.wxml
src/pages/gift-shop/gift-shop.js
src/pages/gift-shop/gift-shop.scss
src/pages/gift-shop/gift-shop.wxml
src/pages/index/index.js
src/pages/vip-login/vip-login.js
src/utils/util.js
src/app.js
View file @
82c6c9c
...
...
@@ -25,6 +25,7 @@ App({
userInfo
:
null
,
wxcode
:
store
.
getItem
(
"wxcode"
),
tlMemberCode
:
""
,
giftInfo
:
null
,
// 来自 gift-shop
},
//重写分享方法
share
:
function
()
{
...
...
@@ -57,22 +58,13 @@ App({
})
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
post
({
url
:
this
.
api
.
index
,
url
:
this
.
api
.
member
,
data
:
{},
loading
:
true
,
}).
then
((
result
)
=>
{
this
.
globalData
.
indexInfo
=
result
;
this
.
globalData
.
userInfo
=
result
.
userInfo
;
if
(
result
.
isNeedAuth
==
1
&&
auth
==
true
)
{
//需要授权
this
.
router
.
push
({
path
:
"authorize"
})
reject
();
// resolve();
}
else
{
resolve
(
result
)
}
// this.globalData.userInfo = result.userInfo;
resolve
(
result
)
}).
catch
((
err
)
=>
{
reject
();
});
...
...
src/app.json
View file @
82c6c9c
{
"pages"
:
[
"pages/user-center/user-center"
,
"pages/gift-shop/gift-shop"
,
"pages/index/index"
,
"pages/user-center/user-center"
,
"pages/gift-detail/gift-detail"
,
"pages/scan-result/scan-result"
,
"pages/contact/contact"
,
"pages/contact-table/contact-table"
,
"pages/index/index"
,
"pages/authorize/authorize"
,
"pages/register/register"
,
"pages/integral-detail/integral-detail"
,
...
...
src/component/order-submit-success-tips-comp/order-submit-success-tips-comp.js
View file @
82c6c9c
...
...
@@ -18,6 +18,11 @@ Component({
innerButton
:
{
type
:
String
,
value
:
'确定'
,
},
// 兑换对象 通过item区分红包和实物奖显示不同文案
item
:
{
type
:
Object
,
value
:
{}
}
},
data
:
{
...
...
src/pages/address-edit/address-edit.js
View file @
82c6c9c
import
{
getBindtapData
,
getObjByListKeyValue
,
checkMobile
}
from
'../../utils/util'
;
let
app
=
getApp
();
Page
({
data
:
{
authorizeVisible
:
false
,
value
:
""
,
checked
:
true
,
checked
:
false
,
addressEditInfo
:
{
receiverCode
:
""
,
receiverName
:
""
,
receiverPhone
:
""
,
receiverAddress
:
""
,
defaultAddress
:
1
,
}
},
onShareAppMessage
()
{},
showAuth
()
{
...
...
@@ -11,11 +24,130 @@ Page({
authorizeVisible
:
true
})
},
onLoad
(
options
)
{},
onLoad
(
options
)
{
// this.setData({
// options: app.globalData.addressEditInfo
// })
this
.
initData
();
},
initData
()
{
let
addressEditInfo
=
app
.
globalData
.
addressEditInfo
;
this
.
setData
({
addressEditInfo
})
},
/**
* 显示提示
*/
showTips
(
tips
)
{
wx
.
showToast
({
title
:
tips
,
icon
:
"none"
})
},
/**
* 检查提交
*/
checkSubmit
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
addressEditInfo
=
this
.
data
.
addressEditInfo
;
if
(
!
addressEditInfo
.
receiverName
)
{
this
.
showTips
(
"请输入收货人姓名"
)
reject
();
}
else
if
(
!
addressEditInfo
.
receiverPhone
)
{
this
.
showTips
(
"请输入收货电话"
)
reject
();
}
else
if
(
!
checkMobile
(
addressEditInfo
.
receiverPhone
))
{
this
.
showTips
(
"请输入正确收货电话"
)
reject
();
}
else
if
(
!
addressEditInfo
.
receiverAddress
)
{
this
.
showTips
(
"请输入收货地址"
)
reject
();
}
else
{
resolve
()
}
});
},
/**
* 表单提交
* @param {*} evt
*/
onSubmitHandler
(
evt
)
{
this
.
checkSubmit
().
then
((
result
)
=>
{
let
{
addressEditInfo
,
checked
}
=
this
.
data
;
addressEditInfo
.
defaultAddress
=
checked
?
1
:
0
;
app
.
post
({
url
:
app
.
api
.
receiverSave
,
data
:
addressEditInfo
}).
then
((
result2
)
=>
{
wx
.
showModal
({
content
:
'操作成功'
,
showCancel
:
false
,
success
(
res
)
{
wx
.
navigateBack
({
delta
:
1
});
}
})
})
});
},
/**
* 删除表单
* @param {*} evt
*/
onDeleteHandler
(
evt
)
{
let
{
addressEditInfo
,
}
=
this
.
data
;
app
.
post
({
url
:
app
.
api
.
receiverDelete
,
data
:
{
receiverCode
:
addressEditInfo
.
receiverCode
}
}).
then
((
result
)
=>
{
wx
.
showModal
({
content
:
'删除成功'
,
showCancel
:
false
,
success
(
res
)
{
wx
.
navigateBack
({
delta
:
1
});
}
})
})
},
bindReceiverNameInput
(
e
)
{
this
.
setData
({
"addressEditInfo.receiverName"
:
e
.
detail
.
value
});
},
bindReceiverPhoneInput
(
e
)
{
this
.
setData
({
"addressEditInfo.receiverPhone"
:
e
.
detail
.
value
});
},
bindReceiverAddressInput
(
e
)
{
this
.
setData
({
"addressEditInfo.receiverAddress"
:
e
.
detail
.
value
});
},
onChange
(
event
)
{
let
checked
=
event
.
detail
this
.
setData
({
checked
:
event
.
detail
checked
:
event
.
detail
,
});
}
})
...
...
src/pages/address-edit/address-edit.wxml
View file @
82c6c9c
...
...
@@ -8,15 +8,15 @@
<view class="form">
<view class="form-item">
<view class="label">收货人姓名</view>
<input class="cont" placeholder="请输入" />
<input
value="{{addressEditInfo.receiverName}}" bindinput="bindReceiverNameInput"
class="cont" placeholder="请输入" />
</view>
<view class="form-item">
<view class="label">手机号码</view>
<input class="cont" placeholder="请输入" />
<input
value="{{addressEditInfo.receiverPhone}}" bindinput="bindReceiverPhoneInput"
class="cont" placeholder="请输入" />
</view>
<view class="form-item form-item-textarea">
<view class="label">收货地址</view>
<textarea class="cont" placeholder="请输入"></textarea>
<textarea
value="{{addressEditInfo.receiverAddress}}" bindinput="bindReceiverAddressInput"
class="cont" placeholder="请输入"></textarea>
</view>
</view>
<!-- 设置为默认地址 -->
...
...
@@ -26,12 +26,14 @@
</view>
<view class="bottom">
<view class="btn-wrap">
<view class="btn">保存</view>
<view class="btn btn-red">删除</view>
<view bindtap="onSubmitHandler" class="btn">保存</view>
<view wx:if="{{addressEditInfo.receiverCode}}" bindtap="onDeleteHandler" class="btn btn-red">
删除
</view>
</view>
</view>
</view>
</view>
<van-popup show="{{ authorizeVisible }}"
>
<van-popup show="{{ authorizeVisible }}">
<authorize-comp bind:evtcomp="evtcomp"></authorize-comp>
</van-popup>
...
...
src/pages/address-management/address-management.js
View file @
82c6c9c
import
{
getBindtapData
,
getObjByListKeyValue
}
from
'../../utils/util'
;
let
app
=
getApp
();
Page
({
data
:
{
authorizeVisible
:
false
,
receiverList
:
[],
// 收货地址
defaultReceiver
:
null
,
// 默认收货地址
},
onShareAppMessage
()
{},
showAuth
()
{
...
...
@@ -10,16 +17,76 @@ Page({
})
},
onLoad
(
options
)
{},
onShow
()
{
this
.
initData
();
},
initData
()
{
app
.
queryIndex
().
then
((
result
)
=>
{
this
.
queryReceiver
();
})
},
queryReceiver
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
app
.
post
({
url
:
app
.
api
.
receiver
,
data
:
{}
}).
then
((
result2
)
=>
{
let
defaultReceiver
=
getObjByListKeyValue
(
1
,
"defaultAddress"
,
result2
);
this
.
setData
({
indexInfo
:
app
.
globalData
.
indexInfo
,
receiverList
:
result2
,
defaultReceiver
:
defaultReceiver
})
resolve
();
})
});
},
// 编辑收货地址
onAddressEditHandler
()
{
onAddressEditHandler
(
evt
)
{
console
.
log
(
"edit"
);
let
curData
=
getBindtapData
(
evt
);
app
.
globalData
.
addressEditInfo
=
curData
;
app
.
router
.
push
({
path
:
"addressEdit"
})
},
// 添加收货地址
onAddressAddHandler
()
{
onAddressAddHandler
(
evt
)
{
app
.
globalData
.
addressEditInfo
=
null
;
app
.
router
.
push
({
path
:
"addressEdit"
})
},
/**
* 设置为默认地址
*/
onSetDefaultHandler
(
evt
)
{
let
_this
=
this
;
let
curData
=
getBindtapData
(
evt
);
wx
.
showModal
({
title
:
'提示'
,
content
:
'设置为默认地址?'
,
success
(
res
)
{
if
(
res
.
confirm
)
{
curData
.
defaultAddress
=
1
;
app
.
post
({
url
:
app
.
api
.
receiverSave
,
data
:
curData
}).
then
((
result
)
=>
{
_this
.
queryReceiver
().
then
((
result
)
=>
{
wx
.
showModal
({
content
:
'操作成功'
,
showCancel
:
false
,
success
(
res
)
{}
})
})
})
}
}
})
// app.globalData.addressEditInfo = curData;
// console.log("def:", curData);
}
})
...
...
src/pages/address-management/address-management.scss
View file @
82c6c9c
...
...
@@ -32,9 +32,21 @@ $contentWidth:690px;
// 表单
.form
{
position
:
relative
;
padding
:
30px
30px
;
@extend
.bb
;
.ebg
{
position
:
absolute
;
top
:
0
;
left
:
0
;
z-index
:
1
;
width
:
100%
;
height
:
100%
;
}
&
-tit
{
position
:
relative
;
margin-bottom
:
28px
;
display
:
flex
;
justify-content
:
space-between
;
...
...
@@ -48,9 +60,11 @@ $contentWidth:690px;
height
:
36px
;
.address
{
position
:
relative
;
font-size
:
32px
;
margin-right
:
20px
;
vertical-align
:
middle
;
}
.used
{
...
...
@@ -66,10 +80,12 @@ $contentWidth:690px;
.address-edit
{
color
:
#3680EB
;
font-size
:
28px
;
z-index
:
11
;
}
}
&
-item
{
position
:
relative
;
margin-bottom
:
20px
;
font-size
:
28px
;
display
:
flex
;
...
...
src/pages/address-management/address-management.wxml
View file @
82c6c9c
...
...
@@ -6,28 +6,32 @@
<view class="content">
<!-- 地址 item -->
<view class="manage-wrap">
<view class="cont-wrap form">
<view wx:for="{{receiverList}}" wx:key="{{index}}" class="cont-wrap form">
<view bindtap="onSetDefaultHandler" data-data="{{item}}" class="ebg"></view>
<view class="form-tit">
<view class="address-message">
<view class="address">地址一:默认地址</view>
<view class="used">当前使用</view>
<view class="address">
地址{{index+1}}
<block wx:if="{{item.defaultAddress == 1}}">:默认地址</block>
</view>
<view wx:if="{{item.defaultAddress == 1}}" class="used">当前使用</view>
</view>
<view bindtap="onAddressEditHandler" class="address-edit">编辑</view>
<view bindtap="onAddressEditHandler"
data-data="{{item}}"
class="address-edit">编辑</view>
</view>
<view class="form-item">
<view class="label">收货人</view>
<view class="cont">
郑亮亮
</view>
<view class="cont">
{{item.receiverName}}
</view>
</view>
<view class="form-item">
<view class="label">收货电话</view>
<view class="cont">
13800000000
</view>
<view class="cont">
{{item.receiverPhone}}
</view>
</view>
<view class="form-item">
<view class="label">收货地址</view>
<view class="cont">
深圳市龙岗区XXX路
</view>
<view class="cont">
{{item.receiverAddress}}
</view>
</view>
</view>
<view class="cont-wrap form">
<
!-- <
view class="cont-wrap form">
<view class="form-tit">
<view class="address-message">
<view class="address">地址一:默认地址</view>
...
...
@@ -47,13 +51,13 @@
<view class="label">收货地址</view>
<view class="cont">深圳市龙岗区XXX路</view>
</view>
</view>
</view>
-->
</view>
<!-- 添加地址 -->
<view bindtap="onAddressAddHandler" class="manage-add">+添加地址</view>
</view>
</view>
</view>
<van-popup show="{{ authorizeVisible }}"
>
<van-popup show="{{ authorizeVisible }}">
<authorize-comp bind:evtcomp="evtcomp"></authorize-comp>
</van-popup>
...
...
src/pages/gift-detail/gift-detail.js
View file @
82c6c9c
import
{
getBindtapData
,
getObjByListKeyValue
}
from
'../../utils/util'
;
let
app
=
getApp
();
Page
({
data
:
{
authorizeVisible
:
false
,
commonTipsCompVisible
:
true
,
commonTipsCompVisible
:
false
,
orderSubmitSuccessCompVisible
:
true
,
cid
:
"1"
,
// 1积分不足 2.账号未审核
innerTitle
:
""
,
innerText
:
""
,
innerButton
:
""
,
indexInfo
:
{},
item
:
{},
remark
:
""
,
receiverList
:
[],
// 收货地址
defaultReceiver
:
null
,
// 默认收货地址
},
onShareAppMessage
()
{},
showAuth
()
{
...
...
@@ -10,12 +25,112 @@ Page({
authorizeVisible
:
true
})
},
onLoad
(
options
)
{},
onLoad
(
options
)
{
},
onShow
()
{
this
.
initData
();
},
initData
()
{
app
.
queryIndex
().
then
((
result
)
=>
{
app
.
post
({
url
:
app
.
api
.
receiver
,
data
:
{}
}).
then
((
result2
)
=>
{
let
defaultReceiver
=
getObjByListKeyValue
(
1
,
"defaultAddress"
,
result2
);
this
.
setData
({
indexInfo
:
app
.
globalData
.
indexInfo
,
receiverList
:
result2
,
defaultReceiver
:
defaultReceiver
,
item
:
app
.
globalData
.
giftInfo
,
})
})
})
},
showTips
(
tips
)
{
wx
.
showToast
({
title
:
tips
,
icon
:
"none"
})
},
/**
* 检查提交
*/
checkSubmit
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
let
{
item
,
defaultReceiver
,
indexInfo
}
=
this
.
data
;
console
.
log
(
"indexInfo:"
,
indexInfo
);
console
.
log
(
"item:"
,
item
);
if
(
indexInfo
.
memberPoints
<
item
.
commodityPrice
)
{
// 积分不足
this
.
setData
({
commonTipsCompVisible
:
true
,
cid
:
"1"
,
innerTitle
:
"积分不足"
,
innerText
:
"使用推广、签到功能\n可获取更多积分!"
,
innerButton
:
"我知道了"
,
});
reject
();
return
;
}
else
if
(
indexInfo
.
auditStatus
!=
"authorization"
)
{
// 未验证
this
.
setData
({
commonTipsCompVisible
:
true
,
cid
:
"2"
,
innerTitle
:
"账号未审核"
,
innerText
:
"通过认证的用户才能兑换礼品哦,快去提交资"
,
innerButton
:
"马上去验证"
,
});
reject
();
return
;
}
else
if
(
!
defaultReceiver
&&
item
.
commodityType
==
"object"
)
{
// 实物奖品必须添加地址
this
.
showTips
(
"请先添加地址"
)
reject
();
return
;
}
else
{
resolve
();
}
});
},
/**
* 确认兑换 / 提交订单
*/
onSubmitHandler
()
{
onSubmitHandler
(
evt
)
{
let
_this
=
this
;
this
.
checkSubmit
().
then
((
result
)
=>
{
let
{
item
,
defaultReceiver
}
=
this
.
data
;
wx
.
showModal
({
title
:
'兑换确认'
,
content
:
`将花费
${
item
.
commodityPrice
}
兑换
${
commodityTitle
}
一份`
,
success
(
res
)
{
if
(
res
.
confirm
)
{
app
.
post
({
url
:
app
.
api
.
commodityExchange
,
data
:
{
commodityCode
:
item
.
commodityCode
,
receiverCode
:
defaultReceiver
.
receiverCode
,
remark
:
this
.
data
.
remark
}
}).
then
((
result
)
=>
{
})
}
}
})
})
},
/**
* 收获地址管理
...
...
@@ -25,11 +140,29 @@ Page({
path
:
"addressManagement"
})
},
/**
* 添加收货地址
* 同地址管理
*/
onAddressAddHandler
()
{
app
.
router
.
push
({
path
:
"addressManagement"
})
},
bindRemarkInput
(
e
)
{
this
.
setData
({
remark
:
e
.
detail
.
value
})
},
// 隐藏蒙层
hideMask
()
{
this
.
setData
({
authorizeVisible
:
false
,
commonTipsCompVisible
:
false
,
orderSubmitSuccessCompVisible
:
false
,
})
},
// 子组件事件
...
...
@@ -43,6 +176,23 @@ Page({
// 隐藏弹窗
case
"_evt_common_comp_button"
:
this
.
hideMask
();
switch
(
data
.
cid
)
{
// 积分不足
case
"1"
:
this
.
hideMask
();
break
;
// 未验证
case
"2"
:
app
.
router
.
push
({
path
:
"vipLogin"
})
break
;
default
:
break
;
}
break
;
default
:
...
...
src/pages/gift-detail/gift-detail.scss
View file @
82c6c9c
...
...
@@ -4,6 +4,8 @@
$contentWidth
:
690px
;
.page
{
padding-bottom
:
$pageBottom
;
.bgc
{
background
:
#F8F8F8
;
}
...
...
@@ -47,8 +49,14 @@ $contentWidth:690px;
.image-wrap
{
width
:
200px
;
height
:
200px
;
border
:
solid
1px
#f0f0f0
;
border-radius
:
8px
;
@extend
.fcc
;
.img
{}
.image
{
width
:
180px
;
height
:
180px
;
}
}
.cont
{
...
...
@@ -61,12 +69,14 @@ $contentWidth:690px;
align-content
:
center
;
.name
{
width
:
100%
;
font-size
:
36px
;
color
:
#333333
;
@include
ellipsis
(
2
);
}
.integral
{
width
:
100%
;
margin-top
:
16px
;
font-size
:
28px
;
color
:
#FF7900
;
...
...
@@ -85,6 +95,18 @@ $contentWidth:690px;
line-height
:
48px
;
}
// 添加地址
.manage-add
{
width
:
$contentWidth
;
margin
:
20px
auto
;
@extend
.bb
;
background
:
#fff
;
padding
:
38px
30px
;
font-size
:
32px
;
color
:
#3680EB
;
@extend
.shadow
;
}
// 表单
.form
{
padding
:
30px
30px
40px
;
...
...
src/pages/gift-detail/gift-detail.wxml
View file @
82c6c9c
...
...
@@ -7,50 +7,52 @@
<view class="product">
<view class="product-item">
<view class="image-wrap">
<
!-- <image /> --
>
<
image class="image" mode="aspectFit" src="{{item.commodityImages[0]}}" /
>
</view>
<view class="cont">
<view class="name">
某东购物卡200元某东购物卡200元
</view>
<view class="integral">消耗积分:
3000
分</view>
<view class="name">
{{item.commodityTitle || '-'}}
</view>
<view class="integral">消耗积分:
{{item.commodityPrice}}
分</view>
</view>
</view>
</view>
<
block wx:if="{{1<0}}"
>
<!-- 使用规则 (京东卡) --
>
<
view class="cont-wrap use-rule">
京东E卡可在京东商城
<span class="link">www.jd.com</span
>
上购买自营商品(“自营商品”指在商品详情页明确标识为自营的商品),用户可在订单结算时输入E卡密码并使用。
</view>
<
/block
>
<block wx:
else
>
<!-- 表单
提交 (实物)
-->
<view class="cont-wrap form">
<
!-- 使用规则 --
>
<view class="cont-wrap use-rule"
>
<
!-- 京东E卡可在京东商城
<span class="link">www.jd.com</span>
上购买自营商品(“自营商品”指在商品详情页明确标识为自营的商品),用户可在订单结算时输入E卡密码并使用。 --
>
{{item.commodityInfo}}
</view>
<
!-- 表单提交 (实物) --
>
<block wx:
if="{{item.commodityType == 'object'}}"
>
<!-- 表单 -->
<view
wx:if="{{defaultReceiver}}"
class="cont-wrap form">
<view class="form-tit">
<view class="address-message">收货信息</view>
<view bindtap="onAddressManagementHandler" class="address-edit">更改地址</view>
</view>
<view class="form-item">
<view class="label">收货人</view>
<view class="cont">
郑亮亮
</view>
<view class="cont">
{{defaultReceiver.receiverName}}
</view>
</view>
<view class="form-item">
<view class="label">收货电话</view>
<view class="cont">
13800000000
</view>
<view class="cont">
{{defaultReceiver.receiverPhone}}
</view>
</view>
<view class="form-item">
<view class="label">收货地址</view>
<view class="cont">
深圳市龙岗区XXX路
</view>
<view class="cont">
{{defaultReceiver.receiverAddress}}
</view>
</view>
<textarea placeholder="备注您的其他要求" class="form-remark"></textarea>
<textarea
value="{{remark}}" bindinput="bindRemarkInput"
placeholder="备注您的其他要求" class="form-remark"></textarea>
</view>
<!-- 添加地址按钮 -->
<view wx:else bindtap="onAddressAddHandler" class="manage-add">我的收货地址</view>
</block>
</view>
<view class="bottom">
<view class="submit-bar">
<view class="submit-bar-cont">
现有积分
<span class="integral">
350
</span>
<span class="integral">
{{indexInfo.memberPoints}}
</span>
分
</view>
<view bindtap="onSubmitHandler" class="submit-bar-btn">确认兑换</view>
...
...
@@ -58,9 +60,13 @@
</view>
</view>
</view>
<van-popup show="{{ authorizeVisible }}"
>
<van-popup show="{{ authorizeVisible }}">
<authorize-comp bind:evtcomp="evtcomp"></authorize-comp>
</van-popup>
<van-popup show="{{ commonTipsCompVisible }}">
<common-tips-comp bind:evtcomp="evtcomp" inner-title="积分不足" inner-text="使用推广、签到功能\n可获取更多积分!" inner-button="我知道了"></common-tips-comp>
<common-tips-comp bind:evtcomp="evtcomp" cid="{{cid}}" inner-title="{{innerTitle}}" inner-text="{{innerText}}" inner-button="{{innerButton}}"></common-tips-comp>
</van-popup>
<!-- 兑换成功提示 -->
<van-popup show="{{ orderSubmitSuccessCompVisible }}">
<order-submit-success-tips-comp bind:evtcomp="evtcomp" item="{{item}}"></order-submit-success-tips-comp>
</van-popup>
...
...
src/pages/gift-shop/gift-shop.js
View file @
82c6c9c
import
{
getBindtapData
}
from
'../../utils/util'
;
let
app
=
getApp
();
Page
({
data
:
{
authorizeVisible
:
false
,
orderSubmitSuccessTipsCompVisible
:
true
,
productList
:
[
""
,
""
,
""
]
orderSubmitSuccessTipsCompVisible
:
false
,
total
:
0
,
page
:
1
,
size
:
10
,
keyWords
:
""
,
orderSort
:
0
,
productList
:
[],
},
onShareAppMessage
()
{},
showAuth
()
{
...
...
@@ -11,15 +20,96 @@ Page({
authorizeVisible
:
true
})
},
onLoad
(
options
)
{},
onLoad
(
options
)
{
this
.
queryProduct
();
},
// 到达底部
onReachBottom
()
{
if
(
this
.
data
.
productList
.
length
<
this
.
data
.
total
)
{
this
.
setData
({
page
:
this
.
data
.
page
+
1
});
this
.
queryProduct
();
}
},
// 重置页面列表 点击搜索条件时需要
resetPage
()
{
this
.
setData
({
page
:
1
,
productList
:
[]
})
},
/**
* 请求产品
*/
queryProduct
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
app
.
post
({
sid
:
false
,
url
:
app
.
api
.
commodityList
,
data
:
{
page
:
this
.
data
.
page
,
size
:
this
.
data
.
size
,
orderSort
:
this
.
data
.
orderSort
,
key
:
this
.
data
.
keyWords
,
// min:0,
// max:0,
},
}).
then
((
result
)
=>
{
let
productList
=
result
.
list
;
console
.
log
(
"productList:"
,
productList
);
productList
=
this
.
data
.
productList
.
concat
(
productList
);
this
.
setData
({
productList
:
productList
,
total
:
result
.
total
})
resolve
();
})
});
},
/**
* 显示礼物详情
*/
onShowGiftDetailHandler
()
{
onShowGiftDetailHandler
(
evt
)
{
let
curData
=
getBindtapData
(
evt
);
app
.
globalData
.
giftInfo
=
curData
;
app
.
router
.
push
({
path
:
"giftDetail"
});
},
/**
* 更换排序
*/
onChangeFitterHandler
(
e
)
{
let
orderSort
=
this
.
data
.
orderSort
;
if
(
orderSort
==
0
)
{
orderSort
=
1
;
}
else
{
orderSort
=
0
;
}
this
.
setData
({
orderSort
})
this
.
queryProduct
();
},
/**
* 手动查找产品
*/
onSearchHandler
(
e
)
{
this
.
resetPage
();
this
.
queryProduct
();
},
bindKeyWordsInput
(
e
)
{
this
.
setData
({
keyWords
:
e
.
detail
.
value
})
this
.
onSearchHandler
();
},
// 隐藏蒙层
hideMask
()
{
this
.
setData
({
...
...
src/pages/gift-shop/gift-shop.scss
View file @
82c6c9c
...
...
@@ -93,14 +93,21 @@ $contentWidth:690px;
.image-wrap
{
width
:
200px
;
height
:
200px
;
.img
{}
border
:
solid
1px
#f0f0f0
;
border-radius
:
8px
;
@extend
.fcc
;
.image
{
width
:
180px
;
height
:
180px
;
}
}
.cont
{
position
:
relative
;
flex
:
1
;
@extend
.bb
;
padding
-left
:
20px
;
margin
-left
:
20px
;
.name
{
font-size
:
32px
;
...
...
src/pages/gift-shop/gift-shop.wxml
View file @
82c6c9c
...
...
@@ -5,12 +5,12 @@
<view class="top">
<div class="top-wrap">
<view class="search">
<input class="ipt" placeholder="输入关键字搜索" />
<input class="ipt"
value="{{keyWords}}" bindinput="bindKeyWordsInput"
placeholder="输入关键字搜索" />
<image class="icon" mode="aspectFit" src="../../image/icon/icon-search.png" />
</view>
<view class="filter">
<view class="filter"
bindtap="onChangeFitterHandler"
>
积分排序
<view wx:if="{{
1>
0}}" class="icon-wrap">
<view wx:if="{{
orderSort ==
0}}" class="icon-wrap">
<image class="icon up" src="../../image/icon/icon-filter-up-on.png" mode="widthFix" />
<image class="icon down" src="../../image/icon/icon-filter-down.png" mode="widthFix" />
</view>
...
...
@@ -26,12 +26,12 @@
<view class="product">
<view class="product-item" wx:for="{{productList}}" wx:key="{{index}}">
<view class="image-wrap">
<
!-- <image /> --
>
<
image class="image" mode="aspectFit" src="{{item.commodityImages[0]}}" /
>
</view>
<view class="cont">
<view class="name">
某东购物卡200元
</view>
<view class="desc">
可在xx超市使用,可够买xxx可在xx超市使用,可够买xxx可在xx超市使用,可够买xxx
</view>
<view class="integral">消耗积分:
3000
分</view>
<view class="name">
{{item.commodityTitle}}
</view>
<view class="desc">
{{item.commodityBrief}}
</view>
<view class="integral">消耗积分:
{{item.commodityPrice}}
分</view>
<view bindtap="onShowGiftDetailHandler" data-data="{{item}}" class="btn">查看</view>
</view>
</view>
...
...
src/pages/index/index.js
View file @
82c6c9c
...
...
@@ -100,6 +100,18 @@ Page({
success
(
res
)
{
// 扫码结果
let
result
=
res
.
result
;
console
.
log
(
"res:"
,
res
);
wx
.
showToast
({
title
:
"res:"
+
res
.
result
,
icon
:
"none"
})
},
fail
(
err
)
{
console
.
log
(
"err:"
,
err
);
wx
.
showToast
({
title
:
"err:"
+
res
.
result
,
icon
:
"none"
})
}
})
},
...
...
src/pages/vip-login/vip-login.js
View file @
82c6c9c
...
...
@@ -129,6 +129,7 @@ Page({
}
=
this
.
data
;
app
.
router
.
push
({
// openType:"redirect",
path
:
"vipVerify"
})
},
...
...
src/utils/util.js
View file @
82c6c9c
...
...
@@ -133,6 +133,22 @@ function getBindtapData(evt, key = "data") {
}
/**
* 从数组中获取 key未value的对象
* @param {*} value
* @param {*} key
* @param {*} list
*/
function
getObjByListKeyValue
(
value
,
key
,
list
)
{
let
result
=
null
;
list
.
forEach
(
element
=>
{
if
(
element
[
key
+
""
]
==
value
)
{
result
=
element
;
}
});
return
result
;
}
/**
* 获取小程序码
* path = "/pages/index/index?pa=1"
* @param {*} path
...
...
@@ -142,6 +158,7 @@ function wxacodeGet(path) {
}
/**
* @desc 函数防抖
* @param func 函数
...
...
@@ -215,4 +232,5 @@ module.exports = {
formatWeek
:
formatWeek
,
getBindtapData
:
getBindtapData
,
wxacodeGet
:
wxacodeGet
,
getObjByListKeyValue
:
getObjByListKeyValue
}
...
...
Please
register
or
sign in
to post a comment