order-refund.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view>
  3. <!-- 商品区 -->
  4. <view class="padding margin-lr margin-tb-sm bg-main border-radius">
  5. <view class="goods-area" v-for="(item, index) in order_detail" :key="index">
  6. <view class="dflex">
  7. <view class="img">
  8. <image :src="item.goodsMasterImg"></image>
  9. </view>
  10. <view class="margin-left-sm">
  11. <text class="clamp-2">{{ item.goodsName }}</text>
  12. <view class="ft-dark fs-xs padding-top-xs">
  13. <text class="margin-right">× {{ item.goodsCount }}</text>
  14. {{ item.goods_sku_name || '&nbsp;&nbsp;' }}
  15. </view>
  16. <view class="margin-top-sm">
  17. <text class="price">{{ item.goodsTotalAmt }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 退款区 -->
  24. <view class="padding-lr-xs padding-bottom-sm">
  25. <use-list-title title="货物状态" type="round" color="#333" :tip="goods_state" iconfont=" "
  26. @goto="openActionSheet(1)"></use-list-title>
  27. </view>
  28. <view class="padding-lr-xs">
  29. <use-list-title title="退款原因" type="round" color="#333" :tip="reason" iconfont=" "
  30. @goto="openActionSheet(2)"></use-list-title>
  31. </view>
  32. <view class="refund-area padding margin-lr margin-tb-sm bg-main border-radius">
  33. <view class="dflex-b">
  34. <text class="item margin-right-sm">退款金额:</text>
  35. <text class="price">{{refund_money}}</text>
  36. </view>
  37. </view>
  38. <!-- 上传凭证 -->
  39. <view class="padding margin-lr margin-tb-sm bg-main border-radius">
  40. <!-- 退款说明 -->
  41. <textarea v-model="desc" class="ft-black w-full margin-0 padding-0 fs-sm"
  42. placeholder="请填写退款说明(选填)"></textarea>
  43. <!-- 上传图片 -->
  44. <!-- <use-upload class="pos-r" @upload="refundImgs"></use-upload> -->
  45. </view>
  46. <!-- 提交操作 -->
  47. <view class="padding w-full margin-top">
  48. <view class="dflex-b">
  49. <view class="tac padding-tb-sm flex1 bg-base-tuikuan" @click="submit">提交申请</view>
  50. </view>
  51. </view>
  52. <!-- 操作菜单 -->
  53. <use-action-sheet v-model="actionSheetShow" :list="actionSheetList" :tips="actionSheetTips"
  54. @click="actionSheetClick" @close="actionSheetClose"></use-action-sheet>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. orderinfo,
  60. refund
  61. } from '../../../utils/api_order.js'
  62. import useListTitle from '../../../components/use-list-title/use-list-title.vue'
  63. import useUpload from '../../../components/use-upload/use-upload.vue'
  64. import useActionSheet from '../../../components/use-action-sheet/use-action-sheet.vue'
  65. export default {
  66. components:{
  67. useListTitle,
  68. useUpload,
  69. useActionSheet
  70. },
  71. data() {
  72. return {
  73. issubmit: false,
  74. goods_state: '请选择',
  75. reason: '请选择',
  76. desc: '', // 退款说明
  77. // 订单ID
  78. order_id: '',
  79. // 退款金额
  80. refund_money: 0,
  81. // 商品数据
  82. order_detail: [],
  83. // 订单数据
  84. order_data: {},
  85. postData: {
  86. order_id: '',
  87. goods_state: '',
  88. reason: '',
  89. desc: '',
  90. imgs: [],
  91. refund_money: 0,
  92. },
  93. actionSheetShow: false,
  94. actionSheetList: [],
  95. actionSheetTips: {
  96. // text: "退出登录 | 切换账号",
  97. // color: "#9a9a9a",
  98. // size: 24
  99. },
  100. };
  101. },
  102. onUnload() {
  103. uni.$emit('__event_order', 'refresh');
  104. },
  105. onLoad(option) {
  106. this.order_id = option.order_id;
  107. if (!this.order_id) {
  108. this.$api.msg('订单编号不存在');
  109. }
  110. this.loadData();
  111. },
  112. methods: {
  113. loadData() {
  114. let _this = this;
  115. // 订单详情
  116. var data=_this.order_id
  117. orderinfo(data).then((res) => {
  118. if(res.success){
  119. _this.order_data = res.data;
  120. _this.order_detail = res.data.orderDetails;
  121. // 退款金额为实付款金额
  122. _this.refund_money = _this.order_data.orderActualPrice;
  123. return
  124. }
  125. _this.$api.msg(res.msg);
  126. })
  127. },
  128. refundImgs(options) {
  129. let imgs = [];
  130. options.forEach((_) => {
  131. imgs.push(_.url);
  132. });
  133. if (imgs.length > 0) this.postData.imgs = imgs;
  134. console.log('refundImgs', this.postData.imgs);
  135. },
  136. submit() {
  137. if (!this.postData.goods_state) {
  138. this.$api.msg('请选择货物状态');
  139. return;
  140. }
  141. if (!this.postData.reason) {
  142. this.$api.msg('请选择退款原因');
  143. return;
  144. }
  145. if (this.issubmit) return;
  146. this.issubmit = true;
  147. this.postData.order_id = this.order_id;
  148. this.postData.refund_money = this.refund_money;
  149. this.postData.desc = this.desc;
  150. let _this = this;
  151. uni.showModal({
  152. title: '提示',
  153. content: '申请退款',
  154. success: function(res) {
  155. if (res.confirm) {
  156. //只有代发货状态才能申请退款
  157. var data=_this.postData.order_id
  158. refund(data).then((res) => {
  159. if(res.success){
  160. _this.$api.msg('提交成功');
  161. _this.issubmit = false;
  162. uni.navigateBack({});
  163. return
  164. }
  165. _this.$api.msg(res.msg);
  166. _this.issubmit = false;
  167. })
  168. } else if (res.cancel) {
  169. console.log('用户点击取消');
  170. }
  171. }
  172. });
  173. },
  174. // 打开操作菜单
  175. openActionSheet(idx) {
  176. console.log('ppp',idx)
  177. let type = '';
  178. let actionSheetList = [];
  179. switch (idx) {
  180. case 1:
  181. type = "货物状态";
  182. this.actionSheetTips.text = "请选择" + type;
  183. actionSheetList = [
  184. // {
  185. // text: "已收到货",
  186. // color: "#333",
  187. // type: type
  188. // },
  189. {
  190. text: "未收到货",
  191. color: "#333",
  192. type: type
  193. }, ];
  194. break;
  195. case 2:
  196. type = "退款原因";
  197. this.actionSheetTips.text = "请选择" + type;
  198. actionSheetList = [{
  199. text: "未发货不要了",
  200. color: "#333",
  201. type: type
  202. }, {
  203. text: "拍错了,重新下单",
  204. color: "#333",
  205. type: type
  206. }, {
  207. text: "换一家,质量不好",
  208. color: "#333",
  209. type: type
  210. }, {
  211. text: "其他",
  212. color: "#333",
  213. type: type
  214. }, ];
  215. break;
  216. }
  217. this.actionSheetShow = true;
  218. this.actionSheetList = actionSheetList;
  219. },
  220. // 关闭操作菜单
  221. actionSheetClose() {
  222. this.actionSheetShow = false;
  223. console.log(this.actionSheetShow);
  224. },
  225. // 点击操作菜单
  226. actionSheetClick(index) {
  227. let item = this.actionSheetList[index];
  228. switch (item.type) {
  229. case '货物状态':
  230. this.goods_state = item.text;
  231. this.postData.goods_state = item.text;
  232. break;
  233. case '退款原因':
  234. this.reason = item.text;
  235. this.postData.reason = item.text;
  236. break;
  237. }
  238. },
  239. }
  240. };
  241. </script>
  242. <style lang="scss">
  243. page {
  244. background: $page-color-base;
  245. }
  246. @import url('/packageShang/components/iconfont/iconfont.css');
  247. @import url('/packageShang/common/common.scss');
  248. /* 商品区 */
  249. .goods-area {
  250. &:last-child {
  251. margin-bottom: 0;
  252. }
  253. image {
  254. width: 180rpx;
  255. height: 180rpx;
  256. }
  257. }
  258. /* 退款区 */
  259. .refund-area {
  260. line-height: 60rpx;
  261. .desc {
  262. line-height: 60rpx;
  263. }
  264. }
  265. </style>