apply-reason.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!-- 售后申请 -->
  2. <template>
  3. <view class="slot">
  4. <view class="form">
  5. <u-form :model="form" ref="form" label-width="140rpx">
  6. <u-form-item label="退款原因">
  7. <u-input v-model="form.reason" type="select" placeholder="请选择" @click="openReasonPopup" />
  8. </u-form-item>
  9. <u-form-item label="退款说明">
  10. <u-input v-model="form.desc" placeholder="选填" />
  11. </u-form-item>
  12. <u-form-item label="退款金额" :border-bottom="false">
  13. <u-input type="digit" v-model="form.user_refundFee" placeholder="-" />
  14. </u-form-item>
  15. </u-form>
  16. </view>
  17. <view class="btn">
  18. <u-button type="primary" shape="circle" @click="submit"><text>提交</text></u-button>
  19. </view>
  20. <!-- 原因选择框 -->
  21. <SelectReason ref="SelectReason" title="退款原因" :ops="reasonOps" @change="changeReason"></SelectReason>
  22. </view>
  23. </template>
  24. <script>
  25. var _self;
  26. import SelectReason from '@/components/select-reason.vue';
  27. export default {
  28. name: 'apply-reason',
  29. components: {
  30. SelectReason
  31. },
  32. props: {
  33. totalPrice:{
  34. type:String|Number,
  35. default:0
  36. },
  37. },
  38. data() {
  39. return {
  40. // 表单
  41. form: {
  42. reasonId: null,
  43. reason: '',
  44. desc: '',
  45. user_refundFee:null,
  46. },
  47. refundFeeMax:null,
  48. // 原因
  49. currentReasonIndex: null,
  50. reasonOps: [{
  51. label: '不喜欢/不想要',
  52. value: '1'
  53. },
  54. {
  55. label: '实物与描述不符合',
  56. value: '2'
  57. },
  58. {
  59. label: '卖家发错商品',
  60. value: '3'
  61. },
  62. {
  63. label: '与卖家协商一致',
  64. value: '4'
  65. },
  66. {
  67. label: '其他',
  68. value: '-1'
  69. }
  70. ]
  71. };
  72. },
  73. watch: {
  74. // 监听关键字,如果有输入关键字,则打开待选词列表
  75. totalPrice:{
  76. handler(newVal) {
  77. console.log(newVal);
  78. this.refundFeeMax = newVal;
  79. this.form.user_refundFee = newVal;
  80. },
  81. deep:true,
  82. immediate:true,
  83. }
  84. },
  85. onLoad() {
  86. _self = this;
  87. },
  88. methods: {
  89. // 计算金额,
  90. // 打开原因选择框
  91. openReasonPopup() {
  92. this.$refs.SelectReason.open(this.currentReasonIndex);
  93. },
  94. // 选择原因回调
  95. changeReason(index) {
  96. console.log(index);
  97. this.currentReasonIndex = index;
  98. this.form.reasonId = this.reasonOps[index].value;
  99. this.form.reason = this.reasonOps[index].label;
  100. },
  101. // 提交
  102. submit() {
  103. if (!this.form.reasonId) {
  104. this.$u.toast('请选择退款原因');
  105. return;
  106. }
  107. // if(this.refundFeeMax&&this.refundFeeMax<this.form.user_refundFee){
  108. // this.$u.toast("退款金额不能超出选中商品总价值")
  109. // return;
  110. // }
  111. let reason = this.form.reason;
  112. console.log(this.form.desc);
  113. if(this.form.desc){
  114. reason+=`(${this.form.desc})`
  115. }
  116. this.$emit('done',{
  117. reason: reason,
  118. user_refundFee: this.form.user_refundFee || 0
  119. })
  120. }
  121. }
  122. };
  123. </script>
  124. <style lang="scss" scoped>
  125. .form {
  126. background-color: $app-theme-bg-color;
  127. border-radius: 16rpx;
  128. box-shadow: $app-theme-shadow;
  129. padding: 0 30rpx;
  130. }
  131. .btn {
  132. padding: 60rpx 0rpx;
  133. }
  134. </style>