after.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view>
  3. <CustomToast ref="customToast" />
  4. <!-- 页面标题 -->
  5. <view class="flex-items region mar-t-10">
  6. <view>
  7. <image class=" mar-l-20 productImg" :src="order.images" mode="cover"></image>
  8. </view>
  9. <view class="mar-l-20 mar-r-20">
  10. <view class="font28 pad-b-10 ">
  11. {{order.productName}}
  12. </view>
  13. <view class="pad-tb-16 font-gray">
  14. <text>
  15. 规格: {{order.skuName}}
  16. </text>
  17. <text class="mar-l-20">
  18. x{{order.count}}
  19. </text>
  20. </view>
  21. <view class="mar-r-16">
  22. </view>
  23. </view>
  24. </view>
  25. <view class="region1">
  26. <uni-forms class="pad-16" ref="customForm" :rules="customRules" labelWidth="80px" :modelValue="after">
  27. <uni-forms-item label="申请类型" required name="type">
  28. <uni-data-select v-model="after.type" placeholder="请选择申请类型" :localdata="typeRange">
  29. </uni-data-select>
  30. </uni-forms-item>
  31. <uni-forms-item label="申请原因" required name="reason">
  32. <uni-data-select v-model="after.reason" placeholder="请选择申请原因" :localdata="reasonRange">
  33. </uni-data-select>
  34. </uni-forms-item>
  35. </uni-forms>
  36. </view>
  37. <view class="region pad-16">
  38. <view class="flex-items-between">
  39. <view>
  40. 退货数量(本次可申请{{order.count}}件)
  41. </view>
  42. <view>
  43. <uni-number-box v-model="after.count" :min="1" :max="order.count" />
  44. </view>
  45. </view>
  46. <view class="flex-items-between mar-t-20">
  47. <view>
  48. 退款金额
  49. </view>
  50. <view>
  51. <text class=" font-red font32 font-bold">
  52. ¥{{order.unitPrice*after.count}}
  53. </text>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 表单区域 -->
  58. <view class="form-container region">
  59. <!-- 申请说明 -->
  60. <view class="form-item">
  61. <view class="form-label">申请说明</view>
  62. <view class="textarea-container">
  63. <textarea style="width: 100%;" v-model="after.remark" placeholder="请详细描述申请说明(选填)"
  64. class="form-textarea" :maxlength="maxLength"></textarea>
  65. <view class="char-count">
  66. 您还可以输入{{ remainingChars }} 字
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 上传凭证 -->
  71. <view class="form-item">
  72. <view class="form-label">上传凭证(可选)</view>
  73. <view class="upload-container">
  74. <uni-file-picker @delete="delFile" v-model="imageValue" fileMediatype="image" mode="grid"
  75. @select="select" />
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 提交按钮 -->
  80. <button class="submit-button" @click="submitForm('customForm')">提交申请</button>
  81. </view>
  82. </template>
  83. <script>
  84. import CustomToast from '../../components/CustomToast.vue';
  85. import {
  86. UPLOAD_URL
  87. } from '../../common/config.js';
  88. import {
  89. orderDetail,
  90. submitOrderAfter
  91. } from '../../config/api.js';
  92. export default {
  93. components: {
  94. CustomToast,
  95. },
  96. data() {
  97. return {
  98. typeRange: [{
  99. value: 1,
  100. text: "退货退款"
  101. },
  102. {
  103. value: 2,
  104. text: "仅退款"
  105. },
  106. ],
  107. reasonRange: [{
  108. value: 1,
  109. text: "不喜欢,效果不好"
  110. },
  111. {
  112. value: 2,
  113. text: "不想要了"
  114. },
  115. {
  116. value: 3,
  117. text: "材质与商品描述不符"
  118. },
  119. {
  120. value: 4,
  121. text: "大小尺寸与商品描述不符"
  122. },
  123. {
  124. value: 5,
  125. text: "安装质量问题"
  126. },
  127. {
  128. value: 6,
  129. text: "做工瑕疵"
  130. },
  131. {
  132. value: 7,
  133. text: "颜色、款式、图案与描述不符"
  134. },
  135. {
  136. value: 8,
  137. text: "商品破损或污渍"
  138. },
  139. {
  140. value: 9,
  141. text: "其他原因"
  142. },
  143. ],
  144. after: {
  145. imgList: [],
  146. reason: '',
  147. remark: "",
  148. count: 1
  149. },
  150. customRules: {
  151. type: {
  152. rules: [{
  153. required: true,
  154. errorMessage: '请选择申请类型'
  155. }]
  156. },
  157. reason: {
  158. rules: [{
  159. required: true,
  160. errorMessage: '请选择申请原因'
  161. }]
  162. },
  163. },
  164. token: '',
  165. imageValue: [],
  166. fileList: [],
  167. orderNumber: '',
  168. reason: '',
  169. images: [],
  170. contactName: '',
  171. contactPhone: '',
  172. orderId: "",
  173. order: {},
  174. maxLength: 200, // 最大字数
  175. };
  176. },
  177. computed: {
  178. // 计算剩余字数
  179. remainingChars() {
  180. return this.maxLength - this.after.remark.length;
  181. }
  182. },
  183. onLoad(op) {
  184. this.orderId = op.id;
  185. this.getOrderDetail();
  186. this.token = uni.getStorageSync('access_token');
  187. },
  188. methods: {
  189. delFile(e) {
  190. this.after.imgList.splice(e.index, 1); // 删除对应 index 的附件
  191. },
  192. getOrderDetail() {
  193. orderDetail({
  194. id: this.orderId
  195. }).then((res) => {
  196. this.order = res.data;
  197. });
  198. },
  199. // 获取选择的文件
  200. async select(e) {
  201. let list = [].concat(e.tempFiles);
  202. for (let i = 0; i < list.length; i++) {
  203. const result = await this.uploadFilePromise(list[i].url);
  204. this.after.imgList.push(result.data.link);
  205. }
  206. },
  207. uploadFilePromise(url) {
  208. return new Promise((resolve, reject) => {
  209. uni.uploadFile({
  210. url: UPLOAD_URL,
  211. filePath: url,
  212. header: {
  213. "Blade-Auth": this.token
  214. },
  215. name: 'file',
  216. formData: {
  217. user: 'test'
  218. },
  219. success: (res) => {
  220. resolve(JSON.parse(res.data));
  221. }
  222. });
  223. });
  224. },
  225. // 提交表单
  226. submitForm(ref) {
  227. this.$refs[ref].validate().then(res => {
  228. this.after.images = this.after.imgList.join(',');
  229. this.after.orderId = this.orderId
  230. submitOrderAfter(this.after).then((res) => {
  231. if (res.code == 200) {
  232. this.$refs.customToast.showToast('申请提交成功');
  233. setTimeout(() => {
  234. uni.navigateBack({
  235. delta: 1
  236. })
  237. }, 1000)
  238. }
  239. })
  240. })
  241. }
  242. }
  243. }
  244. </script>
  245. <style scoped>
  246. .page-title {
  247. font-size: 36rpx;
  248. font-weight: bold;
  249. text-align: center;
  250. padding: 20rpx 0;
  251. color: #333;
  252. }
  253. .form-container {
  254. padding: 20rpx;
  255. }
  256. .form-item {
  257. margin-bottom: 20rpx;
  258. }
  259. .form-label {
  260. font-size: 28rpx;
  261. color: #666;
  262. margin-bottom: 10rpx;
  263. }
  264. .textarea-container {
  265. position: relative;
  266. }
  267. .form-textarea {
  268. border: 1px solid #ccc;
  269. border-radius: 5rpx;
  270. padding: 10rpx;
  271. font-size: 28rpx;
  272. height: 150rpx;
  273. resize: none;
  274. }
  275. .char-count {
  276. position: absolute;
  277. bottom: 10rpx;
  278. right: 10rpx;
  279. font-size: 24rpx;
  280. color: #999;
  281. }
  282. .upload-container {
  283. margin-top: 10rpx;
  284. }
  285. .submit-button {
  286. background-color: #F95B5B;
  287. color: #fff;
  288. font-size: 32rpx;
  289. padding: 5rpx;
  290. border-radius: 10rpx;
  291. margin-left: 30rpx;
  292. margin-right: 30rpx;
  293. text-align: center;
  294. margin-top: 30rpx;
  295. }
  296. </style>