const util = require('../../utils/util.js'); const api = require('../../config/api.js'); const user = require('../../services/user.js'); import { Router } from '../../utils/router.js' let raw = [ { name: "FURLA", link: "gu6HmTLKp", type: "fushi", img: "hf4", belong: "", qrcode: "furla" }, { name: "Adidas", link: "wmgAlMV6w", type: "fushi", img: "hf1", belong: "", qrcode: "Adidas" }, { name: "Clarks", link: "TSC1mTgLg", type: "fushi", img: "hf11", belong: "", qrcode: "Clarks" }, { name: "润园四季", link: "8OBkdB5a8", type: "fushi", img: "hf13", belong: "", qrcode: "DAZZLE" }, { name: "FILA", link: "dP6EECGrI", type: "fushi", img: "hf2", belong: "", qrcode: "FILA" }, { name: "DAZZLE", link: "n1Pg6NjKW", type: "fushi", img: "hf3", belong: "", qrcode: "DAZZLE" }, { name: "LANCOME", link: "kklFfbwet", type: "liren", img: "hf5", belong: "", qrcode: "FILA" }, { name: "名表专柜", link: "qzInCQin1", type: "qita", img: "hf12", belong: "", qrcode: "FILA" }, { name: "MJstyle", link: "UK5iVJ2yu", type: "fushi", img: "hf7", belong: "", qrcode: "MJstyle" }, { name: "PANDORA", link: "teO9zu7cP", type: "fushi", img: "hf6", belong: "", qrcode: "FILA" }, { name: "NOME", link: "bTpjhkgSh", type: "fushi", img: "hf8", belong: "", qrcode: "NOME" }, { name: "探鱼", link: "lzNp1eYM3", type: "meishi", img: "hf9", belong: "", qrcode: "tanyu" }, { name: "LOHAS", link: "ZNTxtgnlJ", type: "qita", img: "hf14", belong: "", qrcode: "LOHAS" } ] //获取应用实例 const app = getApp() Router({ data: { raw, data: raw, showSearch: false, activeType:-1, header:[ { name:'全部', type:'all', id: -1 }, { name: '美食', id: 1, type: 'meishi' }, { name: '服饰', id: 2, type: 'fushi' }, { name: '丽人', id: 3, type: 'liren' }, { name: '其他', id: 0, type: 'qita' }, ], noRecord:'', hideMask: false, keyword:'', url:'https://www.4dkankan.com/eShopMobile.html?m=', totalPages: 1, currentPage: 1, size: 10, loading: false, brandList:[] }, onShareAppMessage: function () { return { title: '看店4DKanKan:宅家中,云逛街,轻松买', desc: '看店4DKanKan:宅家中,云逛街,轻松买', path: '/pages/index/index' } }, onPullDownRefresh(){ this.setData({ brandList: this.data.brandList.slice(0,10), currentPage: 1 }); this.getBrandList(1,false,true); }, onReachBottom() { if (!this.data.loading) { this.loadMore(); console.log('reach down') } }, loadMore: function () { if (this.data.currentPage { if (isSearch){ if (res.data.data.length <= 0) { this.setData({ noRecord: true }); } else { wx.pageScrollTo({ scrollTop: 0 }) this.setData({ brandList: res.data.data, currentPage: res.data.currentPage, totalPages: res.data.totalPages, loading: false, noRecord: false, showSearch: false }); } } else if(refresh){ this.setData({ brandList: res.data.data, currentPage: res.data.currentPage, totalPages: res.data.totalPages, loading: false }); } else { this.setData({ brandList: tempContent.concat(res.data.data), currentPage: res.data.currentPage, totalPages: res.data.totalPages, loading: false }); } }); }, inputChange: function (e) { let val = e.detail.value this.setData({ keyword:val, noRecord: false }) }, search:function(){ let {keyword} = this.data this.getBrandList(1, true) // if (this.brandList.length <= 0) { // this.setData({ // noRecord: true // }) // } // else { // this.setData({ // activeType: -1, // noRecord: false, // showSearch: false // }) // } }, inputFocus: function () { }, tapHeaderBar(e){ let { id } = e.currentTarget.dataset this.setData({ activeType: id, showSearch: false, keyword: '', brandList: [], currentPage: 1 }) this.getBrandList(1) }, tabShow(){ this.setData({ showSearch: true }) }, tabHide() { this.setData({ showSearch: false, noRecord:false, keyword:'' }) }, onLoad: function (options) { this.setData({ imgServer: util.imgServer }) this.getBrandList(1) }, onReady: function () { // 页面渲染完成 }, onShow: function () { if(typeof this.getTabBar === 'function' && this.getTabBar()){ this.getTabBar().setData({ selected:0 }) } // 页面显示 }, onHide: function () { // 页面隐藏 }, onUnload: function () { // 页面关闭 }, gotoWV: function (event){ let { id } = event.currentTarget.dataset wx.navigateTo({ url: `/pages/webview/index?id=${id}`, }) } })