123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- let app = getApp();
- import recordSource from '../../utils/recordSource';
- const getReq = require('./../../config.js').getReq;
- Page({
- data: {
- tabs: [],
- prop_special: [],
- surplus_special: [],
- special_datas: {},
- summery: [],
- isScroll: false,
- isSendProp: false,
- firstLoad: true,
- fromSource: ''
- },
- onShow: function () {
- if (!this.data.firstLoad) {
- app.setFromSource(this.data.fromSource)
- if (app.globalData.backLogin) {
- app.globalData.backLogin = false;
- this.getDatas(0)
- }
- }
- // if (app.globalData.backLogin && !this.data.firstLoad) {
- // app.globalData.backLogin = false;
- // this.getDatas(0)
- // }
- },
- onLoad: function () {
- this.getDatas(0)
- },
- getDatas(special_id) {
- let fromSource = recordSource(app, 'act=special&op=index&special_id=0&page=10&curpage=1&client_type=mini')
- wx.showLoading({
- title: '加载中'
- });
- let self = this;
- getReq({
- act: 'special',
- op: 'index',
- special_id,
- page: 10,
- curpage: 1,
- from: fromSource
- }, function (res) {
- if (res.code == 200) {
- let prop_special = res.datas.special_list;
- let sent_down_special = prop_special.splice(0, 8);
- self.setData({
- surplus_special: prop_special,
- prop_special: sent_down_special,
- special_datas: res.datas,
- summery: res.datas.summary,
- firstLoad: false,
- fromSource: app.globalData.fromSource
- });
- }
- setTimeout(function () {
- wx.hideLoading()
- }, 1000)
- })
- },
- req_tabs() {
- let self = this
- getReq({
- act: 'index',
- op: 'tabs'
- }, function (res) {
- if (res.code == 200) {
- self.getDatas(res.datas.tabs[0].special_id);
- // console.log(res.datas.tabs[0].special_id);
- // self.getDatas(1364);
- self.setData({
- tabs: res.datas.tabs
- });
- }
- })
- },
- onMyEvent: function (e) {
- this.setData({
- prop_special: [],
- surplus_special: [],
- special_datas: {},
- summery: []
- });
- this.getDatas(e.detail.item.special_id)
- },
- onPageScroll(e) {
- clearTimeout(this.showTop);
- this.showTop = setTimeout(() => {
- let scrollTop = e.scrollTop;
- if (scrollTop >= 300) {
- this.setData({
- isScroll: true
- })
- }
- else {
- this.setData({
- isScroll: false
- })
- }
- }, 100);
- },
- backTop() {
- wx.pageScrollTo({
- scrollTop: 0,
- duration: 300
- })
- },
- onShareAppMessage: function () {
- return {
- title: "熊猫美妆小程序",
- path: "/pages/index/index"
- }
- },
- onReachBottom: function () {
- if (this.data.isSendProp) {
- return;
- }
- let surplus_special_num = this.data.surplus_special.length;
- if (surplus_special_num > 0) {
- // wx.showLoading({
- // title: '加载中'
- // });
- this.setData({
- isSendProp: true
- });
- this.data.isSendProp = true;
- let prop_special = this.data.surplus_special;
- let sent_down_special = prop_special.splice(0, 8);
- this.setData({
- surplus_special: prop_special,
- prop_special: this.data.prop_special.concat(sent_down_special)
- })
- this.setData({
- isSendProp: false
- });
- // wx.hideLoading();
- }
- }
- })
|