Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高淑倩
7-Eleven
Commits
d5e089f8
Commit
d5e089f8
authored
Sep 19, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
点击分类
parent
af4a7549
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
91 deletions
+90
-91
tabSort.js
src/component/tabSort/tabSort.js
+43
-78
tabSort.wxml
src/component/tabSort/tabSort.wxml
+34
-11
tabSort.wxss
src/component/tabSort/tabSort.wxss
+12
-0
currentLinkRouter.js
src/utils/currentLinkRouter.js
+1
-2
No files found.
src/component/tabSort/tabSort.js
View file @
d5e089f8
...
...
@@ -2,6 +2,7 @@
var
app
=
getApp
()
const
wxService
=
require
(
'../../utils/wxService'
)
const
utils
=
require
(
'../../utils/util'
)
const
utilLink
=
require
(
'../../utils/currentLinkRouter'
)
const
envInfo
=
require
(
'../../config/index'
).
envInfo
Component
({
...
...
@@ -19,7 +20,47 @@ Component({
}
},
attached
()
{
const
{
categoryType
}
=
this
.
data
let
currentTab
=
categoryType
.
categorys
currentTab
.
forEach
(
item
=>
{
// 存在 row 处理数据 8 商品 9 分类
let
newRow
=
null
if
(
item
.
link
)
{
if
(
item
.
link
.
type
==
2
)
{
// 父组件 更新
const
urls
=
getCurrentPages
()
const
currentPath
=
urls
[
0
]
const
pageId
=
item
.
link
.
url
item
.
link
.
newPath
=
`/
${
currentPath
.
route
}
`
}
return
}
else
if
(
item
.
row
)
{
newRow
=
JSON
.
parse
(
item
.
row
)
if
(
newRow
.
type
==
8
)
{
newRow
.
newPath
=
'/pages/productDetail/productDetail'
}
else
if
(
newRow
.
type
==
9
)
{
newRow
.
newPath
=
'/subPackage/page/pages/categoryPro/categoryPro'
}
item
.
row
=
newRow
}
})
// 当前匹配路径是否需要授权 true 需要 false 不需要
currentTab
.
forEach
(
item
=>
{
let
checkUrl
=
''
if
(
item
.
link
)
{
checkUrl
=
item
.
link
.
newPath
?
item
.
link
.
newPath
:
item
.
link
.
url
}
else
if
(
item
.
row
)
{
checkUrl
=
item
.
row
.
newPath
?
item
.
row
.
newPath
:
item
.
row
.
url
}
wxService
.
NoLoginPage
(
checkUrl
).
then
(
res
=>
{
if
(
checkUrl
)
item
.
needAuth
=
res
.
needAuth
this
.
setData
({
categoryList
:
currentTab
},()
=>
{
console
.
log
(
'categoryList'
,
this
.
data
.
categoryList
)
})
})
})
},
/**
* 组件的初始数据
...
...
@@ -28,6 +69,7 @@ Component({
// currentTab: 0,
currentTab
:
99
,
isAuthorization
:
false
,
// false 不显示 true 显示
categoryList
:[]
},
/*组件所在页面的生命周期 */
pageLifetimes
:
{
...
...
@@ -62,84 +104,7 @@ Component({
},
// 设置tab active
switchNav
(
event
)
{
const
ev
=
event
.
currentTarget
.
dataset
;
let
cur
=
ev
.
current
let
curItemType
=
ev
.
item
const
userInfo
=
wx
.
getStorageSync
(
'_baseUserInfo'
)
const
{
currentTab
}
=
this
.
data
// 切换 active
if
(
currentTab
==
cur
)
{
return
false
}
else
{
this
.
setData
({
currentTab
:
cur
})
}
// link row
if
(
curItemType
.
link
)
{
let
currentClickType
=
app
.
globalData
.
commonFunc
.
getLink
(
curItemType
.
link
.
type
,
curItemType
)
if
(
curItemType
.
link
.
type
==
1
)
{
// 触发父组件更新页面 外部小程序
this
.
setData
({
isAuthorization
:
false
})
return
false
}
else
if
(
!
userInfo
)
{
this
.
setData
({
isAuthorization
:
true
})
return
false
}
else
if
(
userInfo
&&
userInfo
.
member
&&
!
userInfo
.
member
.
mobile
)
{
wxService
.
openCard
()
return
false
}
if
(
curItemType
.
link
.
type
==
2
)
{
// 触发父组件更新页面
wxService
.
nextTick
(()
=>
{
this
.
triggerEvent
(
'updatePage'
,
{
pageId
:
currentClickType
.
url
})
})
}
else
if
(
curItemType
.
link
.
type
==
3
)
{
// 预览
wx
.
previewImage
({
current
:
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
imageUrl
}
`
,
// 当前显示图片的http链接
urls
:
[
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
link
.
url
}
`
]
// 需要预览的图片http链接列表
})
}
else
if
(
curItemType
.
link
.
type
==
4
)
{
wxService
.
router
(
`
${
currentClickType
}
`
)
}
else
if
(
curItemType
.
link
.
type
==
5
)
{
if
(
currentClickType
==
1
)
{
wxService
.
openCard
()
}
else
if
(
currentClickType
==
2
)
{
wxService
.
openCard
()
}
}
else
if
(
curItemType
.
link
.
type
==
6
)
{
wxService
.
router
(
`/
${
currentClickType
}
`
)
}
else
if
(
curItemType
.
link
.
type
==
7
)
{
// 集点详情
wxService
.
router
(
`
${
currentClickType
}
`
)
}
}
else
if
(
curItemType
.
row
)
{
let
rowObj
=
JSON
.
parse
(
curItemType
.
row
)
let
currentClickRow
=
app
.
globalData
.
commonFunc
.
getLinkRow
(
rowObj
.
type
,
rowObj
)
if
(
rowObj
.
type
==
1
)
{
}
else
if
(
rowObj
.
type
==
2
)
{
}
else
if
(
rowObj
.
type
==
3
)
{
}
else
if
(
rowObj
.
type
==
4
)
{
}
else
if
(
rowObj
.
type
==
5
)
{
}
else
if
(
rowObj
.
type
==
6
)
{
}
else
if
(
rowObj
.
type
==
7
)
{
}
else
if
(
rowObj
.
type
==
8
)
{
// 商品
wxService
.
router
(
`/pages/productDetail/productDetail?id=
${
currentClickRow
}
`
)
}
else
if
(
rowObj
.
type
==
9
)
{
// 分类
wxService
.
router
(
`/subPackage/page/pages/categoryPro/categoryPro?
${
currentClickRow
}
`
)
}
}
utilLink
.
currentLinkRouter
(
event
,
this
)
},
switchTab
(
event
)
{
var
cur
=
event
.
detail
.
current
...
...
src/component/tabSort/tabSort.wxml
View file @
d5e089f8
<!--component/tabSort/tabSort.wxml-->
<view class="tab-sort" wx:if="{{category
Type.categorys
}}">
<view class="tab-sort" wx:if="{{category
List
}}">
<scroll-view scroll-x class="scroll-view_H" scroll-with-animation="{{true}}">
<block
wx:for="{{category
Type.categorys
}}"
wx:for="{{category
List
}}"
wx:for-index="idx"
wx:for-item="navItem"
wx:key="idx"
>
<view
class="scroll-view-item {{currentTab == idx ?'active':''}}"
style="width:{{navItemWidth}}%"
data-current="{{idx}}"
data-redirectId="{{navItem.redirectId}}"
data-item="{{navItem}}"
bindtap="switchNav"
>
<view>{{navItem.title}}</view>
<view wx:if="{{navItem.needAuth}}" class="scroll-view-item {{currentTab == idx ?'active':''}}" style="width:{{navItemWidth}}%">
<view wx:if="{{!currentHasUserInfo}}" class="scroll-view-item {{currentTab == idx ?'active':''}}" style="width: {{navItemWidth}}%;height: 80rpx;display: flex;">
<button
bindgetuserinfo="_getUserInfo"
data-jflag="false"
open-type='getUserInfo'
class="scroll-view-item {{currentTab == idx ?'active':''}}"
hover-class="btn-hover"
>
{{navItem.title}}
</button>
</view>
<view wx:else class="scroll-view-item {{currentTab == idx ?'active':''}}" style="width:{{navItemWidth}}%">
<view
data-current="{{idx}}"
data-redirectId="{{navItem.redirectId}}"
data-item="{{navItem}}"
bindtap="switchNav"
>{{navItem.title}}
</view>
</view>
</view>
<view wx:else class="scroll-view-item {{currentTab == idx ?'active':''}}" style="width:{{navItemWidth}}%">
<view
data-current="{{idx}}"
data-redirectId="{{navItem.redirectId}}"
data-item="{{navItem}}"
bindtap="switchNav"
>{{navItem.title}}
</view>
</view>
</block>
</scroll-view>
<!-- showQrcode 2 购物车 1 会员码 0 隐藏 -->
...
...
src/component/tabSort/tabSort.wxss
View file @
d5e089f8
...
...
@@ -40,3 +40,14 @@
display: flex;
align-items: center;
}
button {
background-color: transparent;
border-radius:0;
padding: 0;
}
button::after{
border:none;
}
.button-hover, .button-active{
background-color:transparent;
}
\ No newline at end of file
src/utils/currentLinkRouter.js
View file @
d5e089f8
...
...
@@ -38,8 +38,7 @@ function currentLinkRouter(event, _this) {
wxService
.
router
(
`
${
currentClickType
}
`
)
}
}
else
if
(
curItemType
.
row
)
{
// let rowObj = JSON.parse(curItemType.row)
let
rowObj
=
curItemType
.
row
let
rowObj
=
typeof
(
curItemType
.
row
)
==
"string"
?
JSON
.
parse
(
curItemType
.
row
)
:
curItemType
.
row
let
currentClickRow
=
app
.
globalData
.
commonFunc
.
getLinkRow
(
rowObj
.
type
,
rowObj
)
if
(
rowObj
.
type
==
1
)
{
}
...
...
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