index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // pages/apply-return/index.js
  2. import { ordeRefundReason, orderRefundVerify, getOrderDetail} from '../../api/order.js';
  3. import util from '../../utils/util.js';
  4. const app=getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. parameter: {
  11. 'navbar': '1',
  12. 'return': '1',
  13. 'title': '申请退货',
  14. 'color': false
  15. },
  16. refund_reason_wap_img:[],
  17. orderInfo:{},
  18. RefundArray: [],
  19. index: 0,
  20. orderId:0,
  21. },
  22. /**
  23. * 授权回调
  24. *
  25. */
  26. onLoadFun:function(){
  27. this.getOrderInfo();
  28. this.getRefundReason();
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. if (!options.orderId) return app.Tips({title:'缺少订单id,无法退款'},{tab:3,url:1});
  35. this.setData({orderId:options.orderId});
  36. },
  37. /**
  38. * 获取订单详情
  39. *
  40. */
  41. getOrderInfo:function(){
  42. var that=this;
  43. getOrderDetail(that.data.orderId).then(res=>{
  44. that.setData({ orderInfo: res.data });
  45. });
  46. },
  47. /**
  48. * 获取退款理由
  49. */
  50. getRefundReason:function(){
  51. var that=this;
  52. ordeRefundReason().then(res=>{
  53. that.setData({ RefundArray: res.data });
  54. })
  55. },
  56. /**
  57. * 删除图片
  58. *
  59. */
  60. DelPic:function(e){
  61. var index = e.target.dataset.index, that = this, pic = this.data.refund_reason_wap_img[index];
  62. that.data.refund_reason_wap_img.splice(index, 1);
  63. that.setData({ refund_reason_wap_img: that.data.refund_reason_wap_img });
  64. },
  65. /**
  66. * 上传文件
  67. *
  68. */
  69. uploadpic:function(){
  70. var that=this;
  71. util.uploadImageOne('upload/image',function(res){
  72. that.data.refund_reason_wap_img.push(res.data.url);
  73. that.setData({ refund_reason_wap_img: that.data.refund_reason_wap_img});
  74. });
  75. },
  76. /**
  77. * 申请退货
  78. */
  79. subRefund:function(e){
  80. var that = this, value = e.detail.value;
  81. //收集form表单
  82. // if (!value.refund_reason_wap_explain) return app.Tips({title:'请输入退款原因'});
  83. orderRefundVerify({
  84. text: that.data.RefundArray[that.data.index] || '',
  85. refund_reason_wap_explain: value.refund_reason_wap_explain,
  86. refund_reason_wap_img: that.data.refund_reason_wap_img.join(','),
  87. uni: that.data.orderId
  88. }).then(res=>{
  89. return app.Tips({ title: '申请成功', icon: 'success' }, { tab: 5, url: '/pages/user_return_list/index?isT=1' });
  90. }).catch(err=>{
  91. return app.Tips({ title: err });
  92. })
  93. },
  94. bindPickerChange: function (e) {
  95. this.setData({index: e.detail.value});
  96. },
  97. })