confirm.vue 9.6 KB

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