|
@@ -1,4 +1,5 @@
|
|
|
const getHeight = require("../../utils/getRheRemainingHeight");
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -9,53 +10,120 @@ Page({
|
|
|
searchContent: "", //搜索内容
|
|
|
mainActiveIndex: 0, //分类选择器打开分类的下标
|
|
|
activeId: null, //分类选择器选择id
|
|
|
- items: [{
|
|
|
- text: '所有城市',
|
|
|
- children: [{
|
|
|
- text: '温州',
|
|
|
- id: '温州',
|
|
|
- },
|
|
|
- {
|
|
|
- text: '杭州',
|
|
|
- id: '杭州',
|
|
|
- },
|
|
|
- ],
|
|
|
- }, {
|
|
|
- text: '可选城市',
|
|
|
- children: [{
|
|
|
- text: '嘉兴',
|
|
|
- id: '嘉兴',
|
|
|
- },
|
|
|
- {
|
|
|
- text: '台州',
|
|
|
- id: '台州',
|
|
|
- },
|
|
|
- ],
|
|
|
- }, ]
|
|
|
+ activeName: null,
|
|
|
+ items: [], //分类列表
|
|
|
+ total: 0,
|
|
|
+ sort: [],
|
|
|
+ content: {
|
|
|
+ pageNumber: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ pageTotal: 1,
|
|
|
+ where: {
|
|
|
+ condition: ""
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad(options) {},
|
|
|
- onClickNav({
|
|
|
- detail = {}
|
|
|
+ onLoad(options) {
|
|
|
+ this.selectMenu();
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 查询列表 */
|
|
|
+ getList(init = false) {
|
|
|
+ if (init.detail != undefined) init = init.detail;
|
|
|
+ if (init) this.setData({
|
|
|
+ ['content.pageNumber']: 1
|
|
|
+ })
|
|
|
+ if (this.data.content.pageNumber > this.data.content.pageTotal) return;
|
|
|
+ let content = this.data.content;
|
|
|
+ if (this.data.activeId) content.where.sat_sharematerial_classid = this.data.activeId;
|
|
|
+ if (this.data.sort[0]) content.sort = this.data.sort;
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "saletool.sharematerial.sharematerial",
|
|
|
+ "method": "selectList",
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log("列表", res)
|
|
|
+ this.selectComponent('#ListBox').RefreshToComplete();
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data),
|
|
|
+ ['content.pageNumber']: res.pageNumber + 1,
|
|
|
+ ['content.pageTotal']: res.pageTotal,
|
|
|
+ total: res.total,
|
|
|
+ sort: res.sort
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 清除搜索输入 */
|
|
|
+ searchClear() {
|
|
|
+ this.setData({
|
|
|
+ ['content.where.condition']: ""
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ /* 搜索框输入 */
|
|
|
+ searchInput({
|
|
|
+ detail
|
|
|
}) {
|
|
|
this.setData({
|
|
|
- mainActiveIndex: detail.index || 0,
|
|
|
+ ['content.where.condition']: detail.trim()
|
|
|
+ })
|
|
|
+ this.getList(true)
|
|
|
+ },
|
|
|
+ /* 开关切换 */
|
|
|
+ changeSwitch({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ sort: detail
|
|
|
+ })
|
|
|
+ this.getList(true);
|
|
|
+ },
|
|
|
+ /* 查询分类 */
|
|
|
+ selectMenu(index = 0, res) {
|
|
|
+ if (index == 5) return wx.showToast({
|
|
|
+ title: res.data,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ _Http.basic({
|
|
|
+ "classname": "saletool.sharematerial.sharematerial",
|
|
|
+ "method": "select",
|
|
|
+ "content": {
|
|
|
+ "parentid": 0
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg != '成功') return this.selectMenu(index + 1, res);
|
|
|
+ let str = JSON.stringify(res.data).replace(/classname/g, 'text').replace(/sat_sharematerial_classid/g, 'id');
|
|
|
+ this.setData({
|
|
|
+ items: JSON.parse(str)
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
+ /* 切换分类 */
|
|
|
onClickItem({
|
|
|
detail = {}
|
|
|
}) {
|
|
|
- const activeId = this.data.activeId === detail.id ? null : detail.id;
|
|
|
- console.log(activeId)
|
|
|
this.setData({
|
|
|
- activeId
|
|
|
+ activeId: this.data.activeId === detail.id ? null : detail.id,
|
|
|
+ activeName: this.data.activeName === detail.text ? null : detail.text
|
|
|
+ });
|
|
|
+ this.getList(true);
|
|
|
+ },
|
|
|
+ onClickNav({
|
|
|
+ detail = {}
|
|
|
+ }) {
|
|
|
+ this.setData({
|
|
|
+ mainActiveIndex: detail.index || 0,
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|