123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- orderId: 0,
- orderInfo: {},
- orderGoods: [],
- handleOption: {},
- wuliu: {},
- currentStoreId: '',
- tabIndex: 0,
- refundInfo: {},
- createTime: '',
- refundTime:'',
- isRefundStatus: '',//true :申请中; false :已退款
- refundStatus:'',
- approvalRemark:'',
- orderSn: ''
- },
- onLoad: function (options) {
- // 页面初始化 options为页面跳转所带来的参数
- let that = this;
- that.setData({
- orderId: options.id,
- tabIndex: options.tabIndex,
- isRefundStatus: options.isRefundStatus,
- refundStatus: options.refundStatus,
- approvalRemark: options.approvalRemark
- });
- },
- copyBtn: function (e) {
- var self = this;
- wx.setClipboardData({
- data: this.data.orderSn,
- success: function (res) {
- wx.showToast({
- title: '复制成功',
- });
- }
- });
- },
- 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,
- orderSn: res.data.orderInfo.order_sn,
- orderGoods: res.data.orderGoods,
- handleOption: res.data.handleOption,
- wuliu: res.data.wuliu
- });
- if (that.data.orderInfo.order_status == 401 || that.data.orderInfo.order_status == 402) {
- that.setData({
- refundInfo: res.data.refundInfo,
- createTime: util.tsFormatTime(res.data.refundInfo.createTime, 'Y-M-D h:m:s'),
- refundTime: util.tsFormatTime(res.data.refundInfo.refundTime, 'Y-M-D h:m:s')
- });
- }
- 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?orderIds=' + that.data.orderId
- + '&actualPrice=' + that.data.orderInfo.actual_price + '&isMergePay=0'
- })
- },
- onReady: function () {
- // 页面渲染完成
- },
- onShow: function () {
- // 页面显示
- this.getOrderDetail();
- this.setData({
- currentStoreId: wx.getStorageSync('storeId')
- });
- },
- 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',
- });
- }
- })
- }
- });
- },
- refund(){
- let that = this;
- util.request(api.refund, {
- 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',
- });
- }
- })
- }else{
- wx.showModal({
- title: '',
- confirmColor: '#b4282d',
- content: res.errmsg,
- showCancel:false
- })
- }
- });
- }
- })
|