confirm.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="refund-wrapper" :style="viewColor">
  3. <view class="item" v-for="(item,index) in productData.product" :key="index">
  4. <view class="img-box">
  5. <image :src="item.cart_info.productAttr.image || item.cart_info.product.image"></image>
  6. </view>
  7. <view class="info">
  8. <view class="name line1"><text v-if="order_status == 2" class="event_name event_bg">预售</text>{{item.cart_info.product.store_name}}</view>
  9. <view class='attr line1' v-if="item.cart_info.productAttr.sku">{{item.cart_info.productAttr.sku}}</view>
  10. <view class="money acea-row row-middle">
  11. <view class="price">¥{{ order_status == 3 ? item.cart_info.productAssistAttr.assist_price : order_status == 4 ? item.cart_info.activeSku.active_price : item.cart_info.productAttr.price}} ×{{item.refund_num}}</view>
  12. <image v-if="item.cart_info.productAttr.show_svip_price" class="svip-img" :src="`${domain}/static/images/svip.png`"></image>
  13. </view>
  14. </view>
  15. </view>
  16. <view class="form-box">
  17. <view class="form-item item-txt" v-if="type==1">
  18. <text class="label">商品件数</text>
  19. <view class="picker">
  20. <picker @change="bindNumChange" :value="numIndex" :range="numArray" :disabled="order_status == 2">
  21. <view class="picker-box">
  22. {{numArray[numIndex] || 0}}
  23. <text v-if="order_status != 2" class="iconfont icon-jiantou"></text>
  24. </view>
  25. </picker>
  26. </view>
  27. </view>
  28. <view class="form-item item-txt">
  29. <text class="label">{{ status == 0 ? '退款金(含运费)' : '退款金(不含运费)' }}</text>
  30. <input style="text-align: right;" :class="{disabled:type == 2}" :disabled="type == 2" class="p-color" type="text" placeholder="请输入金额" v-model="rerundPrice" @blur="checkMaxPrice">
  31. </view>
  32. <view class="form-item item-txt">
  33. <text class="label">退款原因</text>
  34. <view class="picker">
  35. <picker @change="bindPickerChange" :value="qsIndex" :range="qsArray">
  36. <view class="picker-box">
  37. {{qsArray[qsIndex]}}
  38. <text class="iconfont icon-jiantou"></text>
  39. </view>
  40. </picker>
  41. </view>
  42. </view>
  43. <view class="form-item item-txtarea">
  44. <text class="label">备注说明</text>
  45. <view class="txtarea"><textarea v-model="con" value="" placeholder="填写备注信息,100字以内" /></view>
  46. </view>
  47. </view>
  48. <view class="upload-box">
  49. <view class="title">
  50. <view class="txt">上传凭证</view>
  51. <view class="des">( 最多可上传9张 )</view>
  52. </view>
  53. <view class="upload-img">
  54. <view class="img-item" v-for="(item,index) in uploadImg" :key="index">
  55. <image :src="item" mode=""></image>
  56. <view class="iconfont icon-guanbi1" @click="deleteImg(index)"></view>
  57. </view>
  58. <view v-if="uploadImg.length < 9" class="add-img" @click="uploadpic">
  59. <text class="iconfont icon-icon25201"></text>
  60. <text class="txt">上传凭证</text>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="btn-box" @click="bindComfirm">申请退款</view>
  65. <alertBox :msg="msg" v-if="isShowBox" @bindClose="bindClose"></alertBox>
  66. </view>
  67. </template>
  68. <script>
  69. // +----------------------------------------------------------------------
  70. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  71. // +----------------------------------------------------------------------
  72. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  73. // +----------------------------------------------------------------------
  74. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  75. // +----------------------------------------------------------------------
  76. // | Author: CRMEB Team <admin@crmeb.com>
  77. // +----------------------------------------------------------------------
  78. import { refundProduct,refundApply,refundMessage } from '@/api/order.js'
  79. import alertBox from '@/components/alert/index.vue'
  80. import { mapGetters } from "vuex";
  81. import { HTTP_REQUEST_URL } from '@/config/app';
  82. export default{
  83. components:{
  84. alertBox
  85. },
  86. computed: mapGetters(['viewColor']),
  87. data(){
  88. return {
  89. domain: HTTP_REQUEST_URL,
  90. order_id:0,
  91. isShowBox:false,
  92. // 图片上传
  93. uploadImg:[],
  94. // 选择问题
  95. qsArray:[],
  96. // 问题index
  97. qsIndex:0,
  98. // 选择个数
  99. numArray:[],
  100. //个数index
  101. numIndex:0,
  102. //商品id
  103. ids:'',
  104. // 退款方式:1:退款 2:退款退货
  105. refund_type:'',
  106. //退款类型 1:单个 2:批量
  107. type:'',
  108. productData:{},
  109. con:'',
  110. refund_price:'',
  111. postage_price: '',
  112. maxRefundPrice: '',
  113. rerundPrice: '',
  114. // 单价
  115. unitPrice:0,
  116. msg:'',
  117. refund_order_id:'',//退款id
  118. status: '',
  119. order_status: false,
  120. }
  121. },
  122. onLoad(optios) {
  123. this.ids = optios.ids
  124. this.refund_type = optios.refund_type
  125. this.type = optios.type,
  126. this.order_id = optios.order_id
  127. Promise.all([this.refundProduct(),this.refundMessage()])
  128. },
  129. methods:{
  130. checkMaxPrice(){
  131. if(this.rerundPrice > this.maxRefundPrice){
  132. this.rerundPrice = this.maxRefundPrice.toFixed(2)
  133. }
  134. },
  135. // 限制退款金额
  136. limitAamount(){
  137. if(parseFloat(this.rerundPrice) > parseFloat(this.maxRefundPrice)){
  138. uni.showToast({
  139. title:'退款金额不能大于支付金额',
  140. icon:'none'
  141. })
  142. this.validate = false;
  143. }
  144. },
  145. // 退款理由
  146. refundMessage(){
  147. refundMessage().then(res=>{
  148. this.qsArray = res.data
  149. })
  150. },
  151. // 退款商品
  152. refundProduct(){
  153. refundProduct(this.order_id,{ids:this.ids, type: this.type}).then(({data})=>{
  154. this.productData = data
  155. this.refund_price = data.total_refund_price
  156. this.postage_price = data.postage_price
  157. this.maxRefundPrice = Number(data.postage_price) + Number(data.total_refund_price)
  158. this.rerundPrice = this.maxRefundPrice.toFixed(2);
  159. this.status = data.status;
  160. this.order_status = data.activity_type;
  161. this.unitPostage = this.postage_price > 0 ? this.$util.$h.Div(this.postage_price, data.product[0].refund_num).toFixed(2) : 0;
  162. if(this.type == 1){
  163. this.unitPrice = this.$util.$h.Div(data.total_refund_price,data.product[0].refund_num)
  164. for (let i=1;i<=data.product[0].refund_num;i++){
  165. this.numArray.unshift(i)
  166. }
  167. this.refund_price = this.$util.$h.Mul(this.unitPrice, this.numArray[0])
  168. }
  169. }).catch((err) => {
  170. return this.$util.Tips({
  171. title: err
  172. }, {
  173. tab: 3,
  174. url: 1
  175. });
  176. });
  177. },
  178. // 下拉选中
  179. bindPickerChange(e){
  180. this.qsIndex = e.target.value
  181. },
  182. bindNumChange(e){
  183. this.numIndex = e.target.value
  184. this.refund_price = this.numArray[e.target.value] === this.productData.product[0].refund_num ? this.productData.total_refund_price : this.$util.$h.Mul(this.unitPrice, this.numArray[e.target.value])
  185. this.maxRefundPrice = this.refund_price + (this.postage_price > 0 ? (this.numArray[e.target.value] === this.productData.product[0].refund_num
  186. ? this.postage_price
  187. : this.$util.$h.Mul(this.numArray[e.target.value], this.unitPostage)):0);
  188. this.rerundPrice = this.maxRefundPrice.toFixed(2);
  189. },
  190. // 删除图片
  191. deleteImg(index){
  192. this.uploadImg.splice(index,1)
  193. },
  194. /**
  195. * 上传文件
  196. */
  197. uploadpic: function () {
  198. if(this.uploadImg.length <9){
  199. let that = this;
  200. that.$util.uploadImageOne('upload/image', function (res) {
  201. that.uploadImg.push(res.data.path);
  202. that.$set(that,'uploadImg',that.uploadImg);
  203. });
  204. }else{
  205. uni.showToast({
  206. title:'最多可上传9张',
  207. icon:'none'
  208. })
  209. }
  210. },
  211. // 提交
  212. async bindComfirm(){
  213. try {
  214. const data = await refundApply(this.order_id,{
  215. type:this.type,
  216. refund_type:this.refund_type,
  217. num:this.type == 1?this.numArray[this.numIndex]:'',
  218. ids:this.ids,
  219. refund_message:this.qsArray[this.qsIndex],
  220. mark:this.con,
  221. refund_price:this.rerundPrice,
  222. pics:this.uploadImg
  223. })
  224. this.msg = data.message
  225. this.refund_order_id = data.data.refund_order_id
  226. this.isShowBox = true
  227. }catch(err){
  228. uni.showToast({
  229. title:err,
  230. icon:'none'
  231. })
  232. }
  233. },
  234. // 弹窗关闭
  235. bindClose(){
  236. this.isShowBox = false
  237. uni.redirectTo({
  238. url:'/pages/users/refund/detail?id='+this.refund_order_id
  239. })
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .refund-wrapper{
  246. .item{
  247. position: relative;
  248. display: flex;
  249. padding: 25rpx 30rpx;
  250. background-color: #fff;
  251. &:after{
  252. content: ' ';
  253. position: absolute;
  254. right: 0;
  255. bottom: 0;
  256. width: 657rpx;
  257. height: 1px;
  258. background: #F0F0F0;
  259. }
  260. .img-box{
  261. width: 130rpx;
  262. height: 130rpx;
  263. image{
  264. width: 130rpx;
  265. height: 130rpx;
  266. border-radius:16rpx;
  267. }
  268. }
  269. .info{
  270. display: flex;
  271. flex-direction: column;
  272. width: 440rpx;
  273. margin-left: 26rpx;
  274. .tips{
  275. color: #868686;
  276. font-size: 20rpx;
  277. }
  278. .money{
  279. margin-top: 10rpx;
  280. }
  281. .price{
  282. font-size: 26rpx;
  283. }
  284. .attr{
  285. font-size: 20rpx;
  286. color: #868686;
  287. margin-top: 3px;
  288. }
  289. .svip-img{
  290. width: 65rpx;
  291. height: 28rpx;
  292. margin: 4rpx 0 0 4rpx;
  293. }
  294. }
  295. .check-box{
  296. display: flex;
  297. align-items: center;
  298. justify-content: center;
  299. flex: 1;
  300. .iconfont{
  301. font-size: 40rpx;
  302. color: #CCCCCC;
  303. }
  304. .icon-xuanzhong1{
  305. color: $theme-color;
  306. }
  307. }
  308. }
  309. .form-box{
  310. padding-left: 30rpx;
  311. margin-top: 18rpx;
  312. background-color: #fff;
  313. .form-item{
  314. display: flex;
  315. justify-content: space-between;
  316. border-bottom: 1px solid #f0f0f0;
  317. font-size: 30rpx;
  318. }
  319. .item-txt{
  320. align-items: center;
  321. width: 100%;
  322. padding:30rpx 30rpx 30rpx 0;
  323. }
  324. .item-txtarea{
  325. padding:30rpx 30rpx 30rpx 0;
  326. textarea{
  327. display: block;
  328. width: 400rpx;
  329. height: 100rpx;
  330. font-size: 30rpx;
  331. text-align: right;
  332. }
  333. }
  334. .icon-jiantou{
  335. margin-left: 10rpx;
  336. font-size: 28rpx;
  337. color: #BBBBBB;
  338. }
  339. }
  340. .upload-box{
  341. padding: 30rpx;
  342. background-color: #fff;
  343. .title{
  344. display: flex;
  345. align-items: center;
  346. justify-content: space-between;
  347. font-size: 30rpx;
  348. .des{
  349. color: #BBBBBB;
  350. }
  351. }
  352. .upload-img{
  353. display: flex;
  354. flex-wrap: wrap;
  355. margin-top: 20rpx;
  356. .img-item{
  357. position: relative;
  358. width: 156rpx;
  359. height: 156rpx;
  360. margin-right: 23rpx;
  361. margin-top: 20rpx;
  362. &:nth-child(4n){
  363. margin-right: 0;
  364. }
  365. image{
  366. width: 156rpx;
  367. height: 156rpx;
  368. border-radius: 8rpx;
  369. }
  370. .iconfont{
  371. position: absolute;
  372. right: -15rpx;
  373. top: -20rpx;
  374. font-size: 40rpx;
  375. color: $theme-color;
  376. }
  377. }
  378. .add-img{
  379. display: flex;
  380. flex-direction: column;
  381. align-items: center;
  382. justify-content: center;
  383. width: 156rpx;
  384. height: 156rpx;
  385. margin-top: 20rpx;
  386. border: 1px solid #DDDDDD;
  387. border-radius: 3rpx;
  388. color: #BBBBBB;
  389. font-size: 24rpx;
  390. .iconfont{
  391. margin-bottom: 10rpx;
  392. font-size: 50rpx;
  393. }
  394. }
  395. }
  396. }
  397. .btn-box{
  398. width:690rpx;
  399. height:86rpx;
  400. margin: 70rpx auto;
  401. line-height: 86rpx;
  402. text-align: center;
  403. color: #fff;
  404. background: var(--view-theme);
  405. border-radius:43rpx;
  406. font-size: 32rpx;
  407. }
  408. }
  409. .p-color {
  410. color: var(--view-priceColor);
  411. }
  412. .p-color.disabled{
  413. color:#999;
  414. }
  415. .event_bg{
  416. background: #FF7F00;
  417. }
  418. .event_name{
  419. display: inline-block;
  420. margin-right: 9rpx;
  421. color: #fff;
  422. font-size: 20rpx;
  423. padding: 0 8rpx;
  424. line-height: 30rpx;
  425. text-align: center;
  426. border-radius: 6rpx;
  427. }
  428. </style>