index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // components/returnOrderNo/index.js
  2. const util = require("../../utils/util.js");
  3. Component({
  4. properties: {
  5. show:{
  6. type: Boolean,
  7. observer: function (newVal){
  8. this.setData({show: newVal});
  9. }
  10. },
  11. orderId:{
  12. type: String,
  13. observer: function (newVal){
  14. this.setData({orderId: newVal});
  15. }
  16. },
  17. refundExpressCompany:{
  18. type: String,
  19. observer: function (newVal){
  20. // this.setData({refundExpressCompany: newVal});
  21. this.getExpressIndex(newVal)
  22. }
  23. },
  24. refundExpressNum:{
  25. type: String,
  26. observer: function (newVal){
  27. if (newVal) {
  28. this.setData({refundExpressNum: newVal});
  29. }
  30. }
  31. },
  32. },
  33. data: {
  34. show:false,
  35. orderId:'',
  36. expressList:['圆通快递', '申通快递', '韵达快递', '中通快递', '顺丰快递', '天天快递', '宅急送', '中国邮政', '百世快递', '京东快递', '德邦快递'],
  37. expressIndex:-1
  38. },
  39. methods: {
  40. // 获取快递公司索引
  41. getExpressIndex(str){
  42. if (str) {
  43. this.data.expressList.forEach((el,i) => {
  44. if (str==el) {
  45. this.setData({expressIndex:i})
  46. }
  47. });
  48. }
  49. },
  50. cancel(){
  51. this.triggerEvent('close')
  52. },
  53. bindPickerChange(e){
  54. this.setData({expressIndex:e.detail.value})
  55. },
  56. submit(e){
  57. let data=e.detail.value;
  58. if (util.isEmpty(data.refundExpressCompany)) {
  59. util.showTips('请选择快递公司。');
  60. return false;
  61. }
  62. if (util.isEmpty(data.refundExpressNum)) {
  63. util.showTips('请填写快递单号。');
  64. return false;
  65. }
  66. data.orderid=this.data.orderId;
  67. this.triggerEvent('sub',data)
  68. }
  69. }
  70. })