12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- var util = require('../../utils/util.js');
- var api = require('../../config/api.js');
- Page({
- data: {
- navList: [],
- categoryList: [],
- currentCategory: {},
- scrollLeft: 0,
- scrollTop: 0,
- goodsCount: 0,
- scrollHeight: 0
- },
- onLoad: function(options) {
- this.getCatalog();
- },
- getCatalog: function() {
- //CatalogList
- let that = this;
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.CatalogList).then(function(res) {
- that.setData({
- navList: res.data.categoryList,
- currentCategory: res.data.currentCategory
- });
- wx.hideLoading();
- });
- },
- getCurrentCategory: function(id) {
- let that = this;
- util.request(api.CatalogCurrent + "/" + id)
- .then(function(res) {
- that.setData({
- currentCategory: res.data.currentCategory
- });
- });
- },
- onReady: function() {
- // 页面渲染完成
- },
- onShow: function() {
- // 页面显示
- },
- onHide: function() {
- // 页面隐藏
- },
- onUnload: function() {
- // 页面关闭
- },
- switchCate: function(event) {
- var that = this;
- var currentTarget = event.currentTarget;
- if (this.data.currentCategory.id == event.currentTarget.dataset.id) {
- return false;
- }
- this.getCurrentCategory(event.currentTarget.dataset.id);
- }
- })
|