drawback.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <script setup lang="ts">
  2. import FPrice from "~/components/FPrice/FPrice.vue";
  3. import {UPLOAD_URL} from "~/utils/http";
  4. import GoodStatusPopup from "~/pages/refund/components/GoodStatusPopup.vue";
  5. import RefundReasonPopup from "~/pages/refund/components/RefundReasonPopup.vue";
  6. import {getToken} from "~/utils/auth";
  7. import {refundApply, takeOrder} from "~/apis/order.api";
  8. const headers = {
  9. "Content-Type": "multipart/form-data",
  10. 'X-Token': 'Bearer ' + getToken()
  11. }
  12. const state = reactive({
  13. showGoodStatusPopup: false,
  14. showReasonPopup: false,
  15. // detail: {}
  16. total_price: '0.00',
  17. orderId: '',
  18. from: '',
  19. })
  20. const userStore = useUserStore()
  21. const formData = reactive({
  22. ids: '',
  23. // 申请说明
  24. mark: '',
  25. num: '',
  26. // 联系电话
  27. phone: '',
  28. // 图片
  29. pics: [],
  30. // 原因
  31. refund_message: '',
  32. // 退款金额
  33. refund_price: '',
  34. type: '',
  35. // 1退款, 2退款退货
  36. refund_type: '',
  37. // 收货状态
  38. goods: ''
  39. })
  40. const defaultFileList = ref([])
  41. const radioVal = ref(false)
  42. function handleUploadSuccess({ data, option, fileItem }) {
  43. // console.log(data.data.path)
  44. if (data && data.data) {
  45. const resData = JSON.parse(data.data).data
  46. const path = resData.path
  47. formData.pics.push(path)
  48. }
  49. // if (data && data.path) {
  50. // formData.pics.push(data.path)
  51. // }
  52. //
  53. // console.log(fileItem)
  54. }
  55. onLoad(async (options) => {
  56. if (options && options.from !== '') {
  57. state.from = options.from
  58. }
  59. await userStore.getUserInfo()
  60. formData.refund_type = options.refund_type
  61. formData.ids = options.ids
  62. formData.refund_price = options.total_price
  63. formData.num = options.total_num
  64. formData.phone = userStore.userInfo.phone
  65. formData.type = options.type || 1
  66. state.orderId = options.orderId
  67. })
  68. function handleSubmit() {
  69. if(!formData.goods) {
  70. return uni.showToast({
  71. title: '请选择收货状态',
  72. icon: "none"
  73. })
  74. }
  75. if (!formData.refund_message) {
  76. return uni.showToast({
  77. title: '请选择退款原因',
  78. icon: "none"
  79. })
  80. }
  81. uni.showModal({
  82. content: '您确定继续退款吗?',
  83. confirmColor: '#FE0032',
  84. success: function (res) {
  85. if (res.confirm) {
  86. refundApply(state.orderId.toString(), formData).then(res => {
  87. // {"status":200,"message":"申请退款成功","data":{"refund_order_id":"671"}}
  88. uni.showToast({
  89. title: '申请退款成功',
  90. icon: 'none'
  91. })
  92. setTimeout(() => {
  93. uni.navigateTo({
  94. url: `/pages/refund/index?from=${state.from}`
  95. })
  96. }, 300)
  97. })
  98. }
  99. }
  100. })
  101. // if (state.orderId) {
  102. // }
  103. console.log(formData)
  104. }
  105. function handleChooseGoodStatus () {
  106. state.showGoodStatusPopup = true
  107. }
  108. function getGoodsStatus(radioVal) {
  109. if (radioVal == 1) {
  110. return formData.goods = '未收到货'
  111. }
  112. if (radioVal == 2) {
  113. return formData.goods = '已收到货'
  114. }
  115. }
  116. function onGoodStatusConfirm(val) {
  117. // console.log(val)
  118. // formData.goods = val
  119. getGoodsStatus(val)
  120. }
  121. function getRefundMessage(radioVal) {
  122. if (radioVal == 1) {
  123. return '订单信息拍错了'
  124. }
  125. if (radioVal == 2) {
  126. return '我不想要了'
  127. }
  128. if (radioVal == 3) {
  129. return '地址/电话信息填写错误'
  130. }
  131. if (radioVal == 4) {
  132. return '没用/少用优惠'
  133. }
  134. if (radioVal == 5) {
  135. return '发货速度不满意'
  136. }
  137. if (radioVal == 6) {
  138. return '缺货'
  139. }
  140. if (radioVal == 7) {
  141. return '拍多了'
  142. }
  143. }
  144. function onRefundReasonConfirm(val) {
  145. formData.refund_message = getRefundMessage(val)
  146. console.log(formData.refund_message)
  147. }
  148. </script>
  149. <template>
  150. <div>
  151. <nut-cell-group>
  152. <nut-cell :desc="formData.goods == '' ? '请选择' : `${formData.goods}`" is-link @click="handleChooseGoodStatus">
  153. <template #title>
  154. <div class="flex font-bold gap-1 items-center">
  155. <div>收货状态</div>
  156. <div class="text-primary">*</div>
  157. </div>
  158. </template>
  159. </nut-cell>
  160. <nut-cell :desc="formData.refund_message == '' ? '请选择' : `${formData.refund_message}`" is-link @click="state.showReasonPopup = true">
  161. <template #title>
  162. <div class="flex font-bold gap-1 items-center">
  163. <div>退款原因</div>
  164. <div class="text-primary">*</div>
  165. </div>
  166. </template>
  167. </nut-cell>
  168. <nut-cell >
  169. <div class="flex flex-col">
  170. <div class="flex font-bold gap-1 items-center">
  171. <div>退款金额</div>
  172. <div class="text-primary">*</div>
  173. </div>
  174. <FPrice :price="formData.refund_price" :ex-class="['font-bold text-xl']"></FPrice>
  175. <div class="text-gray-500 text-[12px]">
  176. 不可修改,最多¥{{ formData.refund_price }},含发货邮费¥{{state.total_price}}
  177. </div>
  178. </div>
  179. </nut-cell>
  180. </nut-cell-group>
  181. <div class="bg-white p-3">
  182. <div class="text-sm">
  183. 补充描述和凭证
  184. </div>
  185. <div class="flex flex-col my-2 gap-2 bg-gray-100">
  186. <textarea placeholder="补充描述,有助于商家更好的处理售后问题"
  187. class="p-2 text-xs rounded-lg"
  188. v-model="formData.mark"
  189. />
  190. <div class="flex p-2 text-gray">
  191. <div class="flex flex-col justify-center items-center text-xs gap-2">
  192. <nut-uploader :url="UPLOAD_URL"
  193. :headers="headers"
  194. :name="'field'"
  195. :timeout="1000*50"
  196. :data="{ filename: 'field'}"
  197. v-model:file-list="defaultFileList" maximum="3"
  198. @success="handleUploadSuccess"
  199. >
  200. </nut-uploader>
  201. </div>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="fixed bottom-0 pb-safe w-full">
  206. <div class="px-3 ">
  207. <nut-button
  208. @click="handleSubmit"
  209. type="primary" block>提交
  210. </nut-button>
  211. <!-- <FButton-->
  212. <!-- @click="handleSubmit"-->
  213. <!-- :exClass="['!bg-primary', 'rounded-full', 'text-white']"-->
  214. <!-- block-->
  215. <!-- >-->
  216. <!-- 提交-->
  217. <!-- </FButton>-->
  218. <!-- <div class="text-center text-white bg-red rounded-full text-sm p-2">-->
  219. <!-- </div>-->
  220. </div>
  221. </div>
  222. <GoodStatusPopup v-model:show="state.showGoodStatusPopup"
  223. @confirm="onGoodStatusConfirm"
  224. />
  225. <RefundReasonPopup v-model:show="state.showReasonPopup"
  226. @confirm="onRefundReasonConfirm"
  227. />
  228. </div>
  229. </template>
  230. <route lang="yaml">
  231. style:
  232. navigationBarTitleText: 售后订单
  233. </route>
  234. <style lang="scss">
  235. page {
  236. background: #f8f8f8;
  237. }
  238. .nut-radio-group {
  239. width: 100%;
  240. }
  241. //.nut-radio {
  242. // display: flex !important;
  243. // width: 100%;
  244. //}
  245. </style>