index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view>
  3. <view v-if="orderList.length > 0">
  4. <view class='refund'>
  5. <view>
  6. <view class='list'>
  7. <view class='item acea-row row-between-wrapper'>
  8. <view v-for="goods in orderList" :key="goods.cart_id" class='picTxt acea-row'>
  9. <view v-if="goods.refund_num > 0" class="checkbox" @click.stop="goodsCheck(goods)">
  10. <text v-if="goods.check" class="iconfont icon-xuanzhong1"></text>
  11. <text v-else class="iconfont icon-weixuanzhong"></text>
  12. </view>
  13. <view v-else class="checkbox">
  14. <text class="iconfont icon-weixuanzhong disabled"></text>
  15. </view>
  16. <view class='pictrue'>
  17. <image :src='goods.cart_info.product.image'></image>
  18. </view>
  19. <view class='text'>
  20. <view class='line1 name'>{{goods.cart_info.product.store_name}}</view>
  21. <view class="attr line1">{{ goods.cart_info.productAttr.sku }}</view>
  22. <view class="refund_bom acea-row row-between">
  23. <view class='money acea-row row-middle'>
  24. <text>¥{{goods.cart_info.productAttr.price}}</text>
  25. <text class="callate_text">x{{goods.product_num}}</text>
  26. </view>
  27. <view class='carnum acea-row row-center-wrapper'>
  28. <view class="reduce" :class="(goods.numSub || goods.refund_num == 1) ? 'on' : ''" @click.stop='subCart(goods)'>-</view>
  29. <view class='num'>{{goods.refund_num}}</view>
  30. <view class="plus" :class="(goods.max_count == goods.refund_num || goods.numAdd) ? 'on' : ''" @click.stop='addCart(goods)'>+</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="form-box">
  38. <view class="form-item item-txt">
  39. <text class="label">退款金额</text>
  40. <input style="text-align: right;" class="p-color" type="text" placeholder="请输入金额" placeholder-class="holder-color" v-model="rerundPrice" @blur="checkMaxPrice">
  41. </view>
  42. <view class="form-item item-txt">
  43. <text class="label">退款原因</text>
  44. <view class="picker">
  45. <picker @change="bindPickerChange" :value="qsIndex" :range="qsArray">
  46. <view class="picker-box">
  47. {{qsArray[qsIndex]}}
  48. <text class="iconfont icon-jiantou"></text>
  49. </view>
  50. </picker>
  51. </view>
  52. </view>
  53. <view class="form-item item-txtarea">
  54. <text class="label">备注说明</text>
  55. <view class="txtarea"><textarea v-model="con" placeholder-class="holder-color" placeholder="请填写备注信息,100字以内" /></view>
  56. </view>
  57. </view>
  58. </view>
  59. <button class="btn-box" @click="confirmRefund" :disabled="disabled" :class="{'disabled' : disabled}">确认退款</button>
  60. </view>
  61. </view>
  62. <view v-else>
  63. <emptyPage title="暂无订单信息~"></emptyPage>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. // +----------------------------------------------------------------------
  69. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  70. // +----------------------------------------------------------------------
  71. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  72. // +----------------------------------------------------------------------
  73. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  74. // +----------------------------------------------------------------------
  75. // | Author: CRMEB Team <admin@crmeb.com>
  76. // +----------------------------------------------------------------------
  77. import {
  78. getRefundOrderApi, confirmRefundApi, computeRefundPrice
  79. } from '@/api/admin.js';
  80. import { refundMessage } from '@/api/order.js';
  81. import { getProductHot } from '@/api/store.js';
  82. import { mapGetters } from "vuex";
  83. import emptyPage from '@/components/emptyPage.vue'
  84. const app = getApp();
  85. export default {
  86. components: {
  87. emptyPage
  88. },
  89. data() {
  90. return {
  91. loading: false, //是否加载中
  92. loadend: false, //是否加载完毕
  93. loadTitle: '加载更多', //提示语
  94. orderList: [],
  95. order_id: "",
  96. mer_id: '',
  97. isAllSelect: true, //全选
  98. selectValue: [], //选中的数据
  99. maxRefundPrice: 0.00,
  100. rerundPrice: "",
  101. con: "",
  102. qsArray:[],
  103. qsIndex:0,
  104. disabled: false,
  105. };
  106. },
  107. computed: mapGetters(['isLogin']),
  108. onReady(){},
  109. mounted: function() {},
  110. onLoad: function(options) {
  111. let that = this;
  112. that.order_id = options.order_id
  113. that.mer_id = options.mer_id
  114. Promise.all([this.refundMessage()])
  115. },
  116. onShow: function() {
  117. if (this.isLogin == true) {
  118. this.getOrderData();
  119. }else{
  120. setTimeout(() =>{
  121. toLogin()
  122. }, 300);
  123. }
  124. },
  125. methods: {
  126. getOrderData(){
  127. let that = this
  128. getRefundOrderApi(that.mer_id,that.order_id)
  129. .then(res => {
  130. that.orderList = res.data.product
  131. that.maxRefundPrice = Number(res.data.postage_price) + Number(res.data.total_refund_price)
  132. that.rerundPrice = that.maxRefundPrice.toFixed(2);
  133. that.orderList.forEach((item) => {
  134. item.max_count = item.refund_num
  135. this.$set(item, "check", true);
  136. })
  137. }).catch(res => {
  138. that.$util.Tips({
  139. title: res
  140. });
  141. })
  142. },
  143. // 退款理由
  144. refundMessage(){
  145. refundMessage().then(res=>{
  146. this.qsArray = res.data
  147. })
  148. },
  149. checkMaxPrice(){
  150. if(this.rerundPrice > this.maxRefundPrice){
  151. this.rerundPrice = this.maxRefundPrice.toFixed(2)
  152. }
  153. },
  154. // 下拉选中
  155. bindPickerChange(e){
  156. this.qsIndex = e.target.value
  157. },
  158. // 商品递减
  159. subCart(goods) {
  160. if (goods.refund_num <= 1) {
  161. goods.refund_num = 1;
  162. goods.numSub = true;
  163. } else {
  164. goods.refund_num--
  165. goods.numAdd = false;
  166. this.getRefundPrice()
  167. }
  168. },
  169. // 商品增加
  170. addCart(goods) {
  171. if(goods.max_count <= goods.refund_num){
  172. goods.refund_num = goods.max_count
  173. goods.numAdd = true;
  174. }else{
  175. goods.refund_num++
  176. goods.numSub = false;
  177. this.getRefundPrice()
  178. }
  179. },
  180. confirmRefund() {
  181. let that = this;
  182. let refundData = that.getSelectedProduct();
  183. let arr = Object.keys(refundData);
  184. if(arr.length == 0){
  185. return that.$util.Tips({
  186. title: '请选择商品'
  187. });
  188. }
  189. if(that.maxRefundPrice == undefined){
  190. return that.$util.Tips({
  191. title: '请输入退款金额'
  192. });
  193. }
  194. let data = {
  195. refund_message: that.qsArray[that.qsIndex],
  196. refund_price: that.rerundPrice,
  197. mer_mark: that.con,
  198. refund: refundData,
  199. order_id: that.order_id
  200. }
  201. that.disabled = true
  202. uni.showLoading({
  203. title: "退款中"
  204. })
  205. confirmRefundApi(that.mer_id, data)
  206. .then(res => {
  207. that.$util.Tips({
  208. title: res.message
  209. });
  210. that.disabled = false
  211. setTimeout(()=>{
  212. uni.navigateTo({
  213. url:`/pages/admin/refundDetail/index?id=${res.data.refund_order_id}&mer_id=${that.mer_id}`
  214. })
  215. },500)
  216. })
  217. .catch(err => {
  218. return that.$util.Tips({
  219. title: err
  220. }, {
  221. tab: 3,
  222. url: 1
  223. });
  224. });
  225. },
  226. // 获取选中的商品
  227. getSelectedProduct(){
  228. let arr = {}
  229. this.orderList.forEach((item) => {
  230. if(item.check){
  231. arr[item.order_product_id] = item.refund_num
  232. }
  233. })
  234. return arr
  235. },
  236. // 商品选中
  237. goodsCheck(goods) {
  238. goods.check = !goods.check
  239. this.getRefundPrice()
  240. },
  241. // 计算退款金额
  242. getRefundPrice(){
  243. let that = this;
  244. let refundData = that.getSelectedProduct();
  245. computeRefundPrice(that.mer_id,{refund: refundData,order_id: that.order_id})
  246. .then(res => {
  247. that.rerundPrice = res.data.totalRefundPrice
  248. }).catch(res => {
  249. that.$util.Tips({
  250. title: res
  251. });
  252. })
  253. },
  254. },
  255. onReachBottom() {
  256. },
  257. // 滚动监听
  258. onPageScroll(e) {
  259. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  260. uni.$emit('scroll');
  261. }
  262. }
  263. </script>
  264. <style scoped lang="scss">
  265. page {
  266. background: #F5F5F5;
  267. }
  268. .refund {
  269. .list{
  270. background: #fff;
  271. }
  272. .item{
  273. padding: 20rpx;
  274. }
  275. .picTxt {
  276. width: 100%;
  277. position: relative;
  278. align-items: center;
  279. margin-bottom: 30rpx;
  280. .checkbox {
  281. width: 60rpx;
  282. .iconfont {
  283. font-size: 40rpx;
  284. color: #CCCCCC;
  285. border-radius: 100%;
  286. &.disabled{
  287. background: #f3f3f3;
  288. }
  289. }
  290. .icon-xuanzhong1 {
  291. color: #2291F8;
  292. }
  293. }
  294. .pictrue {
  295. width: 130rpx;
  296. height: 130rpx;
  297. image {
  298. width: 100%;
  299. height: 100%;
  300. border-radius: 16rpx;
  301. }
  302. }
  303. .text {
  304. width: 490rpx;
  305. margin-left: 20rpx;
  306. font-size: 28rpx;
  307. color: #282828;
  308. }
  309. .attr {
  310. font-size: 24rpx;
  311. color: #999999;
  312. margin-top: 17rpx;
  313. }
  314. .text .money {
  315. font-size: 26rpx;
  316. color: #282828;
  317. }
  318. .refund_bom{
  319. margin-top: 20rpx;
  320. align-items: center;
  321. .callate_text{
  322. margin-left: 12rpx;
  323. }
  324. }
  325. .carnum {
  326. height: 47rpx;
  327. }
  328. .carnum view {
  329. border: 1px solid #a4a4a4;
  330. min-width: 66rpx;
  331. text-align: center;
  332. height: 100%;
  333. line-height: 46rpx;
  334. font-size: 28rpx;
  335. color: #a4a4a4;
  336. }
  337. .reduce {
  338. border-right: 0;
  339. border-radius: 3rpx 0 0 3rpx;
  340. &.on{
  341. border-color: #e3e3e3;
  342. color: #dedede;
  343. }
  344. }
  345. .plus {
  346. border-left: 0;
  347. border-radius: 0 3rpx 3rpx 0;
  348. &.on{
  349. border-color: #e3e3e3;
  350. color: #dedede;
  351. }
  352. }
  353. .carnum .num {
  354. color: #282828;
  355. }
  356. }
  357. .form-box{
  358. padding-left: 30rpx;
  359. margin-top: 18rpx;
  360. background-color: #fff;
  361. .form-item{
  362. display: flex;
  363. justify-content: space-between;
  364. border-bottom: 1px solid #f5f5f5;
  365. font-size: 30rpx;
  366. }
  367. .item-txt{
  368. align-items: center;
  369. width: 100%;
  370. padding:30rpx 30rpx 30rpx 0;
  371. }
  372. .item-txtarea{
  373. padding:30rpx 30rpx 30rpx 0;
  374. textarea{
  375. display: block;
  376. width: 400rpx;
  377. height: 100rpx;
  378. font-size: 30rpx;
  379. text-align: right;
  380. }
  381. }
  382. .icon-jiantou{
  383. margin-left: 10rpx;
  384. font-size: 28rpx;
  385. color: #BBBBBB;
  386. }
  387. .holder-color{
  388. color: #CCCCCC;
  389. }
  390. }
  391. .btn-box{
  392. width:690rpx;
  393. height:86rpx;
  394. margin: 100rpx auto 0;
  395. line-height: 86rpx;
  396. text-align: center;
  397. color: #fff;
  398. background: #2291F8 ;
  399. border-radius:43rpx;
  400. font-size: 32rpx;
  401. &.disabled{
  402. background: #bbb;
  403. pointer-events: none;
  404. }
  405. }
  406. .btn-box[disabled]{
  407. pointer-events: none;
  408. background: #bbb;
  409. }
  410. }
  411. </style>