123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- var app = getApp();
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- campMinus: {},
- page: 1,
- size: 4,
- referrer: 0,
- storeId: '',
- campMinusId: '',
- merchSn: '',
- openCampAttr: false,
- storeName: '',
- isShare: '',
- categoryFilter: false,
- filterCategory: [],
- goodsList: [],
- categoryId: 0,
- currentSortType: 'desc',
- currentSortOrder: 'a.create_time',
- goodsCount: 0,
- },
- onLoad: function(options) {
- let that = this;
- // options.scene = '6&8&满4件减1&1';
- if (options.scene) {
- var scene = decodeURIComponent(options.scene);
- console.log("scene is ", scene);
- var scanArray = scene.split('&');
- var id = scanArray[0];
- var storeId = scanArray[1];
- var campName = scanArray[2];
- var isShare = scanArray[3];
- // console.log(campName);
- // console.log(storeId);
- this.setData({
- campMinusId: id,
- storeId: storeId,
- campName: campName,
- isShare: isShare
- });
- if(campName){
- wx.setNavigationBarTitle({
- title: campName
- })
- }
- } else {
- if (options.campName) {
- wx.setNavigationBarTitle({
- title: options.campName
- })
- }
- if (options.campMinusId) {
- that.setData({
- campMinusId: options.campMinusId
- });
- }
- if (options.storeId) {
- that.setData({
- storeId: options.storeId
- });
- }
- if (options.isShare) {
- that.setData({
- isShare: options.isShare
- });
- }
- }
- },
- onReady: function() {
- let that = this;
- that.getCampminusDetail();
- that.getGoodsList();
- },
- getCampminusDetail() {
- var that = this;
- util.request(api.CampminusDetail, {
- campMinusId: that.data.campMinusId,
- storeId: that.data.storeId
- })
- .then(function (res) {
- if (res.errno === 0) {
- if (res.data) {
- that.setData({
- campMinus: res.data,
- storeName: res.data.storeName
- });
- util.countdown(that, that.data.campMinus, 'campMinus', null);
- // console.log(that.data.campMinus.dateformat.day)
- // console.log(that.data.campMinus.dateformat.hr)
- // console.log(that.data.campMinus.dateformat.min)
- // console.log(that.data.campMinus.dateformat)
- // console.log(that.data.campMinus.dateformat.sec)
- }
- }
- });
- },
- getGoodsList() {
- wx.showLoading({
- title: '加载中...',
- });
- var that = this;
- util.request(api.StoreCampMinusGoodsList, { campMinusId: that.data.campMinusId, page: that.data.page, size: that.data.size, order: that.data.currentSortOrder, sort: that.data.currentSortType, categoryId: that.data.categoryId, storeId: that.data.storeId })
- .then(function (res) {
- if (res.errno === 0) {
- console.log(res.data.goodsList);
- let goodsList = that.data.goodsList.concat(res.data.goodsList);
- that.setData({
- goodsList: goodsList,
- goodsCount: res.data.goodsCount,
- filterCategory: res.data.filterCategory
- });
- wx.hideLoading();
- if (that.data.categoryId > 0) {
- let filterCategory = that.data.filterCategory;
- filterCategory.forEach(function (val, index, arr) {
- if (val.id == that.data.categoryId) {
- val.checked = true;
- filterCategory[index] = val;
- that.setData({ filterCategory: filterCategory });
- } else {
- val.checked = false;
- }
- }, that);
- }
- }
- });
- },
- openSortFilter: function (event) {
- let currentId = event.currentTarget.id;
- switch (currentId) {
- case 'categoryFilter':
- this.setData({
- 'categoryFilter': !this.data.categoryFilter,
- 'currentSortType': 'category',
- 'currentSortOrder': 'asc'
- });
- break;
- case 'priceSort':
- let tmpSortOrder = 'asc';
- if (this.data.currentSortOrder == 'asc') {
- tmpSortOrder = 'desc';
- }
- this.setData({
- 'currentSortType': 'price',
- 'currentSortOrder': tmpSortOrder,
- 'categoryFilter': false,
- goodsList: [],
- page: 1
- });
- this.getGoodsList();
- break;
- default:
- //综合排序
- this.setData({
- 'currentSortType': 'default',
- 'currentSortOrder': 'desc',
- 'categoryFilter': false,
- goodsList: [],
- page: 1
- });
- this.getGoodsList();
- }
- },
- selectCategory: function (event) {
- let that = this;
- let currentIndex = event.target.dataset.categoryIndex;
- this.setData({
- categoryFilter: false,
- categoryId: this.data.filterCategory[currentIndex].id,
- goodsList: []
- });
- that.getGoodsList();
- },
- /**
- * 去逛逛
- */
- toIndexPage: function() {
- wx.switchTab({
- url: "/pages/index/index"
- });
- },
- selectCampMinus(e) {
- let goodsBizType = e.currentTarget.dataset.goodsType;
- let that = this;
- // wx.navigateTo({
- // url: '/pages/shopping/coupon/coupon',
- // })
- that.setData({
- openCampAttr: !that.data.openCampAttr
- })
- if (that.data.openCampAttr) {
- // that.getTicketDiscountList(goodsBizType);
- }
- },
- hideSwitchCampPop: function() {
- this.setData({
- openCampAttr: false
- })
- },
- onReachBottom() {
- var that = this;
- if (!that.data.goodsList) {
- wx.showLoading({
- title: '加载中...',
- })
- }
- that.setData({
- page: that.data.page + 1,
- });
- that.getGoodsList();
- }
- })
|