123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- excludeAxb:'',//订单不包含安心包,才可以退款
- orderId: 0,
- orderInfo: {},
- orderGoods: [],
- expressInfo: {},
- flag: false,
- handleOption: {},
- orderType:0//如果是1表示从引荐人的订单列表过来的,需要隐藏操作按钮
- },
- onLoad: function(options) {
- // 页面初始化 options为页面跳转所带来的参数
- this.setData({
- orderId: options.id,
- orderType:options.orderType
- });
- this.getOrderDetail();
- },
- onPullDownRefresh() {
- wx.showNavigationBarLoading() //在标题栏中显示加载
- this.getOrderDetail();
- wx.hideNavigationBarLoading() //完成停止加载
- wx.stopPullDownRefresh() //停止下拉刷新
- },
- expandDetail: function() {
- let that = this;
- this.setData({
- flag: !that.data.flag
- })
- },
- getOrderDetail: function() {
- wx.showLoading({
- title: '加载中',
- });
- setTimeout(function() {
- wx.hideLoading()
- }, 2000);
- 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.orderInfo.handleOption,
- expressInfo: res.data.expressInfo
- });
- }
- let excludeAxb=(res.data.orderGoods).every((item)=>{return item.goodsSn!='1036016'});
- that.setData({
- excludeAxb:excludeAxb
- })
- wx.hideLoading();
- });
- },
- // “去付款”按钮点击效果
- payOrder: function() {
- let that = this;
- util.request(api.OrderPrepay, {
- orderId: that.data.orderId
- }, 'POST').then(function(res) {
- if (res.errno === 0) {
- const payParam = res.data;
- console.log("支付过程开始");
- wx.requestPayment({
- 'timeStamp': payParam.timeStamp,
- 'nonceStr': payParam.nonceStr,
- 'package': payParam.packageValue,
- 'signType': payParam.signType,
- 'paySign': payParam.paySign,
- 'success': function(res) {
- console.log("支付过程成功");
- util.redirect('/pages/ucenter/order/order');
- },
- 'fail': function(res) {
- console.log("支付过程失败");
- util.showErrorToast('支付失败');
- },
- 'complete': function(res) {
- console.log("支付过程结束")
- }
- });
- }
- });
- },
- // “取消订单”点击效果
- cancelOrder: function() {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function(res) {
- if (res.confirm) {
- util.request(api.OrderCancel, {
- orderId: orderInfo.id
- }, 'POST').then(function(res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '取消订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “取消订单并退款”点击效果
- refundOrder: function() {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function(res) {
- if (res.confirm) {
- util.request(api.OrderRefund, {
- orderId: orderInfo.id
- }, 'POST').then(function(res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '取消订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “删除”点击效果
- deleteOrder: function() {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确定要删除此订单?',
- success: function(res) {
- if (res.confirm) {
- util.request(api.OrderDelete, {
- orderId: orderInfo.id
- }, 'POST').then(function(res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '删除订单成功'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “待上门”点击效果
- confirmOrder: function() {
- let that = this;
- let orderInfo = that.data.orderInfo;
- wx.showModal({
- title: '',
- content: '确认上门服务?',
- success: function(res) {
- if (res.confirm) {
- util.request(api.OrderConfirm, {
- orderId: orderInfo.id
- }, 'POST').then(function(res) {
- if (res.errno === 0) {
- wx.showToast({
- title: '确认上门成功!'
- });
- util.redirect('/pages/ucenter/order/order');
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- }
- }
- });
- },
- // “申请售后”点击效果
- aftersaleOrder: function () {
- if(this.data.orderInfo.aftersaleStatus === 0){
- util.redirect('/pages/ucenter/aftersale/aftersale?id=' + this.data.orderId );
- }
- else{
- util.redirect('/pages/ucenter/aftersaleDetail/aftersaleDetail?id=' + this.data.orderId);
- }
- },
- viewService(){
- wx.navigateTo({
- url: '../serviceDetail/serviceDetail?orderId=' + this.data.orderId
- })
- },
- onReady: function() {
- // 页面渲染完成
- },
- onShow: function() {
- // 页面显示
- },
- onHide: function() {
- // 页面隐藏
- },
- onUnload: function() {
- // 页面关闭
- }
- })
|