Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wxapp
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
亲子游项目
wxapp
Commits
50ab9278
Commit
50ab9278
authored
Jul 04, 2022
by
张天炜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改文案
parent
debb239c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
198 additions
and
198 deletions
+198
-198
pages/search/list/list.js
+198
-198
No files found.
pages/search/list/list.js
View file @
50ab9278
...
...
@@ -3,203 +3,204 @@ import api from '../../../utils/Api.js'
import
Wx
from
'../../../utils/Wx.js'
import
Schedule
from
'../../../utils/Schedule.js'
const
{
$Toast
$Toast
}
=
require
(
'../../../iview/base/index'
);
Page
({
/**
* 页面的初始数据
*/
data
:
{
projects
:
[],
currentPage
:
1
,
loading
:
true
,
hasMore
:
true
,
is_transfer
:
0
,
title
:
''
,
tags
:
[],
catalog
:
'0'
,
filters
:
{
region_params
:
{},
order
:
'default'
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
let
_title
=
options
.
title
let
_tags
=
options
.
tags
let
_catalog
=
options
.
catalog
console
.
log
(
options
)
if
(
_tags
!=
null
&&
_tags
.
length
>
0
)
{
this
.
setData
({
tags
:
JSON
.
parse
(
_tags
)
})
}
if
(
_title
!=
null
&&
_title
.
length
>
0
)
{
this
.
setData
({
title
:
_title
})
}
if
(
_catalog
!=
null
&&
_catalog
.
length
>
0
)
{
this
.
setData
({
catalog
:
_catalog
})
if
(
_catalog
===
"undefined"
)
{
this
.
setData
({
is_transfer
:
1
});
}
}
// 页面title
let
_ptitle
=
options
.
ptitle
if
(
_ptitle
!=
null
&&
_ptitle
.
length
>
0
)
{
wx
.
setNavigationBarTitle
({
title
:
_ptitle
})
}
this
.
getListData
()
},
/**
* 加载
*/
getListData
:
function
(
callback
)
{
const
p
=
this
.
data
.
currentPage
const
is_transfer
=
this
.
data
.
is_transfer
let
params
=
{
p
:
p
,
is_transfer
:
is_transfer
}
if
(
this
.
data
.
tags
.
length
>
0
)
{
params
[
'tags'
]
=
JSON
.
stringify
(
this
.
data
.
tags
)
}
if
(
this
.
data
.
title
.
length
>
0
)
{
params
[
'title'
]
=
this
.
data
.
title
}
if
(
parseInt
(
this
.
data
.
catalog
)
>
0
)
{
params
[
'catalog_id'
]
=
this
.
data
.
catalog
}
// 地域和排序
params
[
'order'
]
=
this
.
data
.
filters
.
order
let
region_params
=
this
.
data
.
filters
.
region_params
let
arr
=
Object
.
getOwnPropertyNames
(
region_params
)
if
(
arr
.
length
>
0
)
{
params
[
region_params
[
'key'
]]
=
region_params
[
'value'
]
}
console
.
log
(
'params'
,
params
)
// 请求数据接口
api
.
search
.
index
(
params
).
then
(
res
=>
{
if
(
res
.
code
)
{
this
.
setData
({
hasMore
:
false
,
loading
:
false
,
currentPage
:
2
})
$Toast
({
content
:
res
.
msg
,
type
:
'error'
});
}
else
{
let
_projects
=
this
.
data
.
projects
this
.
setData
({
projects
:
_projects
.
concat
(
res
.
data
),
loading
:
false
,
hasMore
:
res
.
data
&&
res
.
data
.
length
>
0
?
true
:
false
,
currentPage
:
res
.
data
&&
res
.
data
.
length
>
0
?
p
:
(
p
-
1
)
})
typeof
callback
==
"function"
&&
callback
()
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
this
.
setData
({
projects
:
[],
loading
:
true
,
hasMore
:
true
,
currentPage
:
1
})
wx
.
showNavigationBarLoading
()
wx
.
showLoading
({
title
:
'加载中...'
,
})
new
Schedule
().
task
(
this
.
getListData
).
delay
(
800
).
task
(()
=>
{
wx
.
hideNavigationBarLoading
()
wx
.
stopPullDownRefresh
()
wx
.
hideLoading
()
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
let
that
=
this
if
(
that
.
data
.
loading
||
!
that
.
data
.
hasMore
)
{
return
;
}
else
{
let
page
=
that
.
data
.
currentPage
+
1
new
Schedule
().
task
(()
=>
{
that
.
setData
({
loading
:
true
,
currentPage
:
page
})
}).
delay
(
1000
).
task
(
that
.
getListData
)
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
},
/**
* 用户进行了筛选操作
*/
filterChange
:
function
(
event
)
{
let
_filters
=
event
.
detail
.
filters
this
.
setData
({
filters
:
_filters
})
wx
.
startPullDownRefresh
()
},
})
\ No newline at end of file
/**
* 页面的初始数据
*/
data
:
{
projects
:
[],
currentPage
:
1
,
loading
:
true
,
hasMore
:
true
,
is_transfer
:
0
,
title
:
''
,
tags
:
[],
catalog
:
'0'
,
filters
:
{
region_params
:
{},
order
:
'default'
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
let
_title
=
options
.
title
let
_tags
=
options
.
tags
let
_catalog
=
options
.
catalog
console
.
log
(
options
)
if
(
_tags
!=
null
&&
_tags
.
length
>
0
)
{
this
.
setData
({
tags
:
JSON
.
parse
(
_tags
)
})
}
if
(
_title
!=
null
&&
_title
.
length
>
0
)
{
this
.
setData
({
title
:
_title
})
}
if
(
_catalog
!=
null
&&
_catalog
.
length
>
0
)
{
this
.
setData
({
catalog
:
_catalog
})
if
(
_catalog
===
"undefined"
)
{
this
.
setData
({
is_transfer
:
1
});
}
}
// 页面title
let
_ptitle
=
options
.
ptitle
_ptitle
=
_ptitle
==
'水果零食'
?
'玩皮研学'
:
_ptitle
;
if
(
_ptitle
!=
null
&&
_ptitle
.
length
>
0
)
{
wx
.
setNavigationBarTitle
({
title
:
_ptitle
})
}
this
.
getListData
()
},
/**
* 加载
*/
getListData
:
function
(
callback
)
{
const
p
=
this
.
data
.
currentPage
const
is_transfer
=
this
.
data
.
is_transfer
let
params
=
{
p
:
p
,
is_transfer
:
is_transfer
}
if
(
this
.
data
.
tags
.
length
>
0
)
{
params
[
'tags'
]
=
JSON
.
stringify
(
this
.
data
.
tags
)
}
if
(
this
.
data
.
title
.
length
>
0
)
{
params
[
'title'
]
=
this
.
data
.
title
}
if
(
parseInt
(
this
.
data
.
catalog
)
>
0
)
{
params
[
'catalog_id'
]
=
this
.
data
.
catalog
}
// 地域和排序
params
[
'order'
]
=
this
.
data
.
filters
.
order
let
region_params
=
this
.
data
.
filters
.
region_params
let
arr
=
Object
.
getOwnPropertyNames
(
region_params
)
if
(
arr
.
length
>
0
)
{
params
[
region_params
[
'key'
]]
=
region_params
[
'value'
]
}
console
.
log
(
'params'
,
params
)
// 请求数据接口
api
.
search
.
index
(
params
).
then
(
res
=>
{
if
(
res
.
code
)
{
this
.
setData
({
hasMore
:
false
,
loading
:
false
,
currentPage
:
2
})
$Toast
({
content
:
res
.
msg
,
type
:
'error'
});
}
else
{
let
_projects
=
this
.
data
.
projects
this
.
setData
({
projects
:
_projects
.
concat
(
res
.
data
),
loading
:
false
,
hasMore
:
res
.
data
&&
res
.
data
.
length
>
0
?
true
:
false
,
currentPage
:
res
.
data
&&
res
.
data
.
length
>
0
?
p
:
(
p
-
1
)
})
typeof
callback
==
"function"
&&
callback
()
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
this
.
setData
({
projects
:
[],
loading
:
true
,
hasMore
:
true
,
currentPage
:
1
})
wx
.
showNavigationBarLoading
()
wx
.
showLoading
({
title
:
'加载中...'
,
})
new
Schedule
().
task
(
this
.
getListData
).
delay
(
800
).
task
(()
=>
{
wx
.
hideNavigationBarLoading
()
wx
.
stopPullDownRefresh
()
wx
.
hideLoading
()
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
let
that
=
this
if
(
that
.
data
.
loading
||
!
that
.
data
.
hasMore
)
{
return
;
}
else
{
let
page
=
that
.
data
.
currentPage
+
1
new
Schedule
().
task
(()
=>
{
that
.
setData
({
loading
:
true
,
currentPage
:
page
})
}).
delay
(
1000
).
task
(
that
.
getListData
)
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
},
/**
* 用户进行了筛选操作
*/
filterChange
:
function
(
event
)
{
let
_filters
=
event
.
detail
.
filters
this
.
setData
({
filters
:
_filters
})
wx
.
startPullDownRefresh
()
},
})
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