/*
 * 手太欠
 * 企获客商城
 */

const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        logisticsPop: false,       //物流弹出框状态
        orderData   : '',           //商品详情
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad (options) {
        this.orderData(options.orderId)
    },

    /**
     * 订单详情
     */
    orderData(orderId){
        wx.$api.order.orders(orderId).then(res=>{
            console.log(res)
            this.setData({
                orderData: res
            })
        })
    },

    /**
     * 物流弹出
     */
    logisticsShow() {
        this.setData({
            logisticsPop: !this.data.logisticsPop
        })
    },

    /**
     * 物流隐藏
     */
    logisticsHide() {
        this.setData({
            logisticsPop: !this.data.logisticsPop
        })
    },

    /**
     * 返回订单
     */
    orderRun() {
        wx.navigateBack({
            delta: 1,
        })
    },

    /**
     * 订单支付
     */
    orderPay(e){
        let orderId = e.currentTarget.dataset.orderid
        wx.navigateTo({
            url: '/pages/mall/mall_pay/mall_pay?orderid=' + orderId,
        })

    },

    /**
     * 取消订单
     */
    orderDelete(e) {
        let orderId = e.currentTarget.dataset.orderid
        wx.$api.order.cancel(orderId).then(res=>{
            wx.redirectTo({
                url: '/pages/mall/mall_order/mall_order',
            })
        })
    },

    /**
     * 签收订单
     */
    orderSign(e) {
        let orderId = e.currentTarget.dataset.orderid
        wx.$api.order.sign(orderId).then(res=>{
            wx.redirectTo({
                url: '/pages/mall/mall_order/mall_order',
            })
        })
    },
})