123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- // pages/integral/exchange.js
- import Integralinfo from '../../api/integralinfo'
- import {getMobileCache, getPhoneNumberNew as getPhoneNumberSync} from '../../utils/user'
- import { parseTime } from '../../utils/util'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- tabStatus: 'a',
- cardList: [],
- row:{},
- listStatus:false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- // this.data.row = JSON.parse(options.obj)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getList()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- // 排序
- cardsSortRule(pre, next) {
- if (!pre.order_status && pre.order_status === next.order_status) {
- // 一级分类内部的二级排序:没过期时,激活时间倒序
- return next.order_status - pre.order_status // -1
- } else {
- // 最外层一级大类排序:没过期排在过期前面
- if (pre.order_status && !next.order_status) {
- return 1
- } else {
- return -1
- }
- }
- },
- getList() {
- Integralinfo.getOrderList({
- channelid: '',
- shopid: '',
- storeid: '',
- mobile: '13816922995'
- }).then(res => {
- const data = res.data
- data.forEach((v) => {
- let starttime = Math.round(new Date(v.starttime).getTime() / 1000)
- let endDate = Math.round(new Date(v.endtime).getTime() / 1000)
- let current = Math.round(new Date().getTime() / 1000)
- v.start = parseTime(starttime, '{y}-{m}-{d} {h}:{i}:{s}')
- v.end = parseTime(endDate, '{y}-{m}-{d} {h}:{i}:{s}')
- if (v.order_status === 0 && endDate < current) {
- v.order_status = 2
- }
- })
- data.sort(this.cardsSortRule)
- this.setData({
- cardList: data,
- listStatus: true
- })
-
- });
- },
- toInstructions(){
- wx.navigateTo({
- url: '../integral/instructions'
- })
- }
- })
|