123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- data: {
- orderId: 0,
- orderInfo: {},
- orderGoods: [],
- handleOption: {}
- },
- onLoad: function (options) {
- getApp().checkNetStatu();
- // 页面初始化 options为页面跳转所带来的参数
- this.setData({
- orderId: options.id
- });
- },
- gotoLogti: function(e){
- let {no,id} = e.currentTarget.dataset
- wx.navigateTo({
- url: '/pages/logistics/index?no=' + no + '&id=' + id
- })
- },
- gotoGoods(e) {
- let {id} = e.currentTarget.dataset
- wx.navigateTo({
- url: '/pages/goods/goods?id=' + id
- })
- },
- gotoBrand:function(e){
- // let {id} = e.currentTarget.dataset
- // wx.navigateTo({
- // url: '/pages/brandDetail/brandDetail?id=' + id
- // })
- },
- getOrderDetail() {
- let that = this;
- util.request(api.OrderDetail, {
- orderId: that.data.orderId
- }).then(function (res) {
- if (res.errno === 0) {
- that.setData({
- orderInfo: res.data.orderInfo,
- orderGoods: res.data.orderGoods,
- handleOption: res.data.handleOption
- });
- //that.payTimer();
- }
- });
- },
- payTimer() {
- let that = this;
- let orderInfo = that.data.orderInfo;
- setInterval(() => {
- orderInfo.add_time -= 1;
- that.setData({
- orderInfo: orderInfo,
- });
- }, 1000);
- },
- cancelOrder(){
- let that = this;
- let orderInfo = that.data.orderInfo;
- var order_status = orderInfo.order_status;
- var errorMessage = '';
- switch (order_status){
- case 300: {
- errorMessage = '订单已发货';
- break;
- }
- case 301:{
- errorMessage = '订单已收货';
- break;
- }
- case 101:{
- errorMessage = '订单已取消';
- break;
- }
- case 102: {
- errorMessage = '订单已删除';
- break;
- }
- case 401: {
- errorMessage = '订单已退款';
- break;
- }
- case 402: {
- errorMessage = '订单已退货';
- break;
- }
- }
-
- if (errorMessage != '') {
- util.showErrorToast(errorMessage);
- return false;
- }
-
- wx.showModal({
- title: '',
- content: '确定要取消此订单?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderCancel,{
- orderId: orderInfo.id
- }).then(function (res) {
- if (res.errno === 0) {
- wx.showModal({
- title:'提示',
- content: res.errmsg,
- showCancel:false,
- confirmText:'确定',
- success: function (res) {
- // util.redirect('/pages/ucenter/order/order');
- wx.navigateBack({
- url: 'pages/ucenter/order/order?id=-1',
- });
- }
- });
- }
- });
- }
- }
- });
- },
- payOrder() {
- let that = this;
- util.request(api.PayPrepayId, {
- orderId: that.data.orderId || 15
- }).then(function (res) {
- if (res.errno === 0) {
- const payParam = res.data;
- wx.requestPayment({
- 'timeStamp': payParam.timeStamp,
- 'nonceStr': payParam.nonceStr,
- 'package': payParam.package,
- 'signType': payParam.signType,
- 'paySign': payParam.paySign,
- 'success': function (res) {
- console.log(res);
- },
- 'fail': function (res) {
- console.log(res);
- }
- });
- }
- });
- },
- confirmOrder() {
- //确认收货
- let that = this;
- let orderInfo = that.data.orderInfo;
- var order_status = orderInfo.order_status;
- var errorMessage = '';
- switch (order_status) {
- // case 300: {
- // errorMessage = '订单已发货';
- // break;
- // }
- case 301: {
- errorMessage = '订单已收货';
- break;
- }
- case 101: {
- errorMessage = '订单已取消';
- break;
- }
- case 102: {
- errorMessage = '订单已删除';
- break;
- }
- case 401: {
- errorMessage = '订单已退款';
- break;
- }
- case 402: {
- errorMessage = '订单已退货';
- break;
- }
- }
- if (errorMessage != '') {
- util.showErrorToast(errorMessage);
- return false;
- }
- wx.showModal({
- title: '',
- content: '确定已经收到商品?',
- success: function (res) {
- if (res.confirm) {
- util.request(api.OrderConfirm, {
- orderId: orderInfo.id
- }).then(function (res) {
- if (res.errno === 0) {
- wx.showModal({
- title: '提示',
- content: res.data,
- showCancel: false,
- confirmText: '确定',
- success: function (res) {
- // util.redirect('/pages/ucenter/order/order');
- wx.navigateBack({
- url: 'pages/ucenter/order/order?id=-1',
- });
- }
- });
- }
- });
- }
- }
- });
- },
- onReady: function () {
- // 页面渲染完成
- },
- onShow: function () {
- this.getOrderDetail();
- // 页面显示
- },
- onHide: function () {
- // 页面隐藏
- },
- onUnload: function () {
- // 页面关闭
- }
- })
|