123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- orderId: 0,
- orderInfo: {},
- orderGoods: [],
- handleOption: {},
- wuliu: {}
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- this.setData({
- orderId: options.id
- });
- },
- getOrderDetail() {
- let that = this;
- util.request(api.OrderDetail, {
- orderId: that.data.orderId
- }).then(function (res) {
- if (res.errno === 0) {
- console.log(res.data);
- that.setData({
- orderInfo: res.data.orderInfo,
- orderGoods: res.data.orderGoods,
- handleOption: res.data.handleOption,
- wuliu: res.data.wuliu
- });
- if (that.data.orderInfo.order_status == 0) {
- wx.setNavigationBarTitle({ title: "待支付" });
- }
- //待付款倒计时
- if (that.data.orderInfo.pay_status == 0||that.data.orderInfo.pay_status == 1){
- util.countdown(that, res.data.orderInfo, 'orderInfo', null)
- }
- }
- });
- },
- payOrder() {
- let that = this;
- wx.redirectTo({
- url: '/pages/pay/pay?orderId=' + that.data.orderId
- + '&actualPrice=' + that.data.orderInfo.actual_price
- })
- },
- onReady: function () {
- // 页面渲染完成
- },
- onShow: function () {
- // 页面显示
- this.getOrderDetail();
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- },
- postComment() {
- let that = this;
- wx.navigateTo({
- url: '/pages/commentPost/commentPost?typeId=0'+ '&orderId='+that.data.orderId,
- })
- },
- lookComment() {
- let that = this;
- wx.navigateTo({
- url: '/pages/comment/comment?typeId=0' + '&orderId=' + that.data.orderId,
- })
- },
- cancelOrder() {
- let that = this;
- util.request(api.OrderCancel, {
- orderId: that.data.orderId
- }).then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '取消成功',
- duration: 1500,
- success: function () {
- setTimeout(function () {
- wx.navigateBack({
- delta: 1
- });
- },1500);
- }
- })
- }else {
- wx.showToast({
- title: res.errmsg,
- duration: 1500
- })
- }
- });
- },
- confirmOrder() {
- let that = this;
- util.request(api.OrderConfirm, {
- orderId: that.data.orderId
- }).then(function (res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '订单完成',
- duration: 2000,
- complete: function () {
- wx.redirectTo({
- url: '/pages/ucenter/order/order',
- });
- }
- })
- }
- });
- }
- })
|