123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- order_status: '',
- evaluate_status: '',
- orderList: [],
- page: 1,
- size: 10,
- tabList: ['全部', '待付款', '待收货', '待评价'],
- tabIndex: 0,
- orderIds:[]
- // markers: [{
- // iconPath: "/static/images/rider.png",
- // id: 0,
- // latitude: 31.834082,
- // longitude: 117.232939,
- // width: 40,
- // height: 40,
- // callout: {
- // content: '距离你2.77km',
- // color: '#fe7200',
- // display: 'ALWAYS',
- // padding: 10,
- // borderRadius: 30
- // }
- // }]
- },
- toggleTab(e) {
- this.setData({
- tabIndex: e.currentTarget.dataset.index,
- orderList: [],
- page: 1,
- });
- this.switchOrderType(e.currentTarget.dataset.index);
- },
- swiperChange(e) {
- this.setData({
- tabIndex: e.detail.current
- });
- this.switchOrderType(e.detail.current);
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- if (options.tabIndex) {
- this.setData({
- tabIndex: options.tabIndex
- });
- }
- },
- getOrderList() {
- let that = this;
- util.request(api.OrderList,
- {
- order_status: that.data.order_status,
- evaluate_status: that.data.evaluate_status,
- page: that.data.page,
- size: that.data.size
- }).then(function (res) {
- if (res.errno === 0) {
- let orderList = res.data.data;
- that.setData({
- orderList: that.data.orderList.concat(orderList)
- });
- //获取待付款倒计时
- that.data.orderList.forEach((item, num) => {
- if (item.pay_status == 0 || item.pay_status == 1) {
- util.countdown(that, that.data.orderList, 'orderList', num)
- }
- })
- }
- });
- },
- payOrder(event) {
- wx.redirectTo({
- url: '/pages/pay/pay?orderIds=' + event.target.dataset.orderId
- + '&actualPrice=' + event.target.dataset.actualPrice
- })
- },
- againBuy(event) {
- let orderId = event.target.dataset.orderId;
- // let goodType = event.target.dataset.goodType;
- // if (goodType!= '00'){
- // wx.showModal({
- // title: '提示信息',
- // content: '非保税仓商品不允许再来一单,需门店扫描二维码进行购买',
- // showCancel: false
- // });
- // return;
- // }
- util.request(api.CartAddByOrder, {orderId: orderId}).then(function (res) {
- if (res.errno === 0) {
- wx.switchTab({
- url: '/pages/cart/cart',
- });
- } else if (res.errno === 0) {
- wx.showToast({
- title: res.errmsg,
- image: '/static/images/icon_error.png',
- duration: 2000
- });
- }
- });
- },
- switchOrderType(tabIndex) {
- let that = this;
- if (tabIndex == 0) {
- that.setData({
- order_status: '',
- evaluate_status: '',
- });
- } else if (tabIndex == 1) {
- that.setData({
- order_status: 0,
- evaluate_status: '',
- });
- } else if (tabIndex == 2) {
- that.setData({
- order_status: 300,
- evaluate_status: '',
- });
- } else if (tabIndex == 3) {
- that.setData({
- order_status: 301,
- evaluate_status: 0,
- });
- }
- that.getOrderList();
- },
- onReady: function () {
- // 页面渲染完成
- },
- onShow: function () {
- // 页面显示
- let that = this;
- that.switchOrderType(that.data.tabIndex);
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- },
- onReachBottom() {
- var that = this;
- that.setData({
- page: that.data.page + 1,
- });
- that.getOrderList();
- }
- })
|