123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- 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<this.data.totalPages) {
- console.log(this.data.currentPage + 1)
- this.getBrandList(this.data.currentPage + 1);
- } else {
- return;
- }
- },
- getBrandList(page,isSearch=false,refresh=false){
-
- this.setData({
- loading: true
- })
- let tempContent = this.data.brandList ?
- this.data.brandList :
- [];
- let { activeType, size, keyword,} = this.data
-
- util.request(api.IndexList, { type: activeType, page, name:keyword, size })
- .then(res=> {
- 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}`,
- })
- }
- })
|