fill-logistics.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="fill-logistics-page">
  3. <!-- 表单区域 -->
  4. <view class="form-card">
  5. <u-form :model="form" ref="uForm" label-width="160">
  6. <u-form-item label="物流单号" prop="expressNumber">
  7. <u-input v-model="form.expressNumber" placeholder="请填写" />
  8. <u-icon slot="right" name="scan" size="40" color="#999" @click="scanCode"></u-icon>
  9. </u-form-item>
  10. <u-form-item label="物流公司" prop="expressName" right-icon="arrow-right">
  11. <u-input v-model="form.expressName" type="select" placeholder="请选择"
  12. @click="showExpressSelect = true" />
  13. </u-form-item>
  14. <u-form-item label="联系电话" prop="mobile" :border-bottom="false">
  15. <u-input v-model="form.mobile" type="number" placeholder="请填写" />
  16. </u-form-item>
  17. </u-form>
  18. </view>
  19. <!-- 补充描述和凭证 -->
  20. <view class="upload-card">
  21. <view class="card-title">补充描述和凭证</view>
  22. <view class="upload-box">
  23. <u-input v-model="desc" type="textarea" placeholder="有助于平台更好的处理售后问题" :maxlength="200" height="150"
  24. :clearable="false" class="textarea" />
  25. <view class="word-count">{{ desc.length }}/200</view>
  26. <view class="image-upload-wrapper">
  27. <CommonImageUpload v-model="form.urlList" :max-count="5" code="shopRefund" />
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 底部提交按钮 -->
  32. <view class="bottom-bar">
  33. <u-button type="success" shape="circle" :custom-style="submitBtnStyle" @click="submit">提交</u-button>
  34. </view>
  35. <!-- 物流公司选择器 -->
  36. <u-select v-model="showExpressSelect" :list="expressList" value-name="dictValue" label-name="dictLabel"
  37. @confirm="onExpressConfirm"></u-select>
  38. </view>
  39. </template>
  40. <script>
  41. import CommonImageUpload from '@/components/image-upload.vue';
  42. export default {
  43. components: {
  44. CommonImageUpload
  45. },
  46. data() {
  47. return {
  48. refundOrderId: '',
  49. desc: '', // 备注描述暂时不传接口,UI里有
  50. form: {
  51. refundOrderId: '',
  52. expressType: 3, // 3-自行寄回
  53. expressNumber: '',
  54. expressName: '',
  55. mobile: '',
  56. urlList: []
  57. },
  58. showExpressSelect: false,
  59. expressList: [],
  60. submitBtnStyle: {
  61. backgroundColor: '#38C148',
  62. color: '#fff',
  63. height: '80rpx',
  64. fontSize: '32rpx',
  65. width: '100%'
  66. },
  67. rules: {
  68. expressNumber: [{
  69. required: true,
  70. message: '请输入物流单号',
  71. trigger: ['blur', 'change']
  72. }],
  73. expressName: [{
  74. required: true,
  75. message: '请选择物流公司',
  76. trigger: ['blur', 'change']
  77. }],
  78. mobile: [{
  79. required: true,
  80. message: '请输入联系电话',
  81. trigger: ['blur', 'change']
  82. }, {
  83. validator: (rule, value, callback) => {
  84. return this.$u.test.mobile(value);
  85. },
  86. message: '手机号码不正确',
  87. trigger: ['blur', 'change']
  88. }]
  89. }
  90. };
  91. },
  92. onLoad(options) {
  93. if (options.refundOrderId) {
  94. this.refundOrderId = options.refundOrderId;
  95. this.form.refundOrderId = options.refundOrderId;
  96. }
  97. this.getExpressOptions();
  98. },
  99. onReady() {
  100. this.$refs.uForm.setRules(this.rules);
  101. },
  102. methods: {
  103. getExpressOptions() {
  104. uni.$u.http.get('/token/common/getDictOptions?type=shop_order_refund_express_name').then(res => {
  105. if (res.code === 200) {
  106. this.expressList = res.data || [];
  107. }
  108. });
  109. },
  110. onExpressConfirm(e) {
  111. this.form.expressName = e[0].label;
  112. },
  113. scanCode() {
  114. uni.scanCode({
  115. success: (res) => {
  116. this.form.expressNumber = res.result;
  117. }
  118. });
  119. },
  120. submit() {
  121. this.$refs.uForm.validate(valid => {
  122. if (valid) {
  123. uni.showLoading({ title: '提交中' });
  124. // 如果需要将 desc 拼接到某个字段,可以这里处理
  125. // 接口文档没写 desc 字段,暂时忽略或拼到别处。
  126. this.$u.api.refundFillExpressAjax(this.form).then(res => {
  127. uni.hideLoading();
  128. if (res.code == 200) {
  129. uni.showToast({
  130. title: '提交成功',
  131. icon: 'success'
  132. });
  133. setTimeout(() => {
  134. uni.navigateBack({ delta: 1 });
  135. }, 1500);
  136. } else {
  137. uni.showToast({
  138. title: res.msg || '提交失败',
  139. icon: 'none'
  140. });
  141. }
  142. }).catch(() => {
  143. uni.hideLoading();
  144. });
  145. }
  146. });
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .fill-logistics-page {
  153. min-height: 100vh;
  154. background-color: #F5F5F5;
  155. padding: 20rpx;
  156. padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
  157. .form-card {
  158. background-color: #fff;
  159. border-radius: 16rpx;
  160. padding: 0 30rpx;
  161. margin-bottom: 20rpx;
  162. }
  163. .upload-card {
  164. background-color: #fff;
  165. border-radius: 16rpx;
  166. padding: 30rpx;
  167. .card-title {
  168. font-size: 30rpx;
  169. font-weight: bold;
  170. color: #333;
  171. margin-bottom: 20rpx;
  172. }
  173. .upload-box {
  174. background-color: #F8F8F8;
  175. border-radius: 12rpx;
  176. padding: 20rpx;
  177. position: relative;
  178. .textarea {
  179. font-size: 28rpx;
  180. }
  181. .word-count {
  182. text-align: right;
  183. font-size: 24rpx;
  184. color: #999;
  185. margin-bottom: 20rpx;
  186. }
  187. .image-upload-wrapper {
  188. margin-top: 20rpx;
  189. }
  190. }
  191. }
  192. .bottom-bar {
  193. position: fixed;
  194. bottom: 0;
  195. left: 0;
  196. right: 0;
  197. background-color: #fff;
  198. padding: 20rpx 40rpx;
  199. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  200. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  201. z-index: 100;
  202. }
  203. }
  204. </style>