index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view :style="colorStyle">
  3. <form @submit="subRefund">
  4. <view class='apply-return'>
  5. <view class='goodsStyle acea-row row-between' v-for="(item,index) in refundCartInfo" :key="index">
  6. <view class='pictrue'>
  7. <image :src='item.productInfo.attrInfo?item.productInfo.attrInfo.image:item.productInfo.image'></image>
  8. </view>
  9. <view class='text acea-row row-between'>
  10. <view class='name line2'>{{item.productInfo.store_name}}</view>
  11. <view class='money'>
  12. <view>¥{{item.truePrice}}</view>
  13. <view class='num'>x{{item.cart_num}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class='list'>
  18. <view class='item acea-row row-between-wrapper'>
  19. <view>退货件数</view>
  20. <view class='num' v-if="refundCartInfo.length !== 1 || refund_total_num == 1">
  21. {{refund_total_num}}
  22. </view>
  23. <picker v-else class='num' @change="returnGoodsNum" :value="refund_num_index" :range="refundNumData">
  24. <view class="picker acea-row row-between-wrapper">
  25. <view class='reason'>{{refundNumData[refund_num_index]}}</view>
  26. <text class='iconfont icon-jiantou'></text>
  27. </view>
  28. </picker>
  29. <!-- <input type="number" v-model="refund_num" @input="inputNumber" v-else /> -->
  30. </view>
  31. <!-- <view class='item acea-row row-between-wrapper'>
  32. <view>退款金额</view>
  33. <view class='num' v-if="refundCartInfo.length !== 1">¥{{refund_pay_price.toFixed(2)}}</view>
  34. <view class='num' v-else>¥{{refund_Money.toFixed(2)}}
  35. </view>
  36. </view> -->
  37. <view class='item acea-row row-between-wrapper'
  38. v-if="status && status._type !== 1 && !productType">
  39. <view>退款类型</view>
  40. <picker class='num' @change="returnGoodsChange" :value="returnGoods" :range="returnGoodsData">
  41. <view class="picker acea-row row-between-wrapper">
  42. <view class='reason'>{{returnGoodsData[returnGoods]}}</view>
  43. <text class='iconfont icon-jiantou'></text>
  44. </view>
  45. </picker>
  46. </view>
  47. <view class='item acea-row row-between-wrapper'>
  48. <view>退款原因</view>
  49. <picker class='num' @change="bindPickerChange" :value="index" :range="RefundArray">
  50. <view class="picker acea-row row-between-wrapper">
  51. <view class='reason'>{{RefundArray[index]}}</view>
  52. <text class='iconfont icon-jiantou'></text>
  53. </view>
  54. </picker>
  55. </view>
  56. <view class='item textarea acea-row row-between'>
  57. <view>备注说明</view>
  58. <textarea placeholder='填写备注信息,100字以内' class='num' name="refund_reason_wap_explain"
  59. placeholder-class='填写备注信息,100字以内'></textarea>
  60. </view>
  61. <view class='item acea-row row-between'>
  62. <view class='title acea-row row-between-wrapper'>
  63. <view>上传凭证</view>
  64. <view class='tip'>( 最多可上传3张 )</view>
  65. </view>
  66. <view class='upload acea-row row-middle'>
  67. <view class='pictrue' v-for="(item,index) in refund_reason_wap_img" :key="index">
  68. <image :src='item'></image>
  69. <view class='iconfont icon-guanbi1 font-num' @tap='DelPic(index)'></view>
  70. </view>
  71. <view class='pictrue acea-row row-center-wrapper row-column' @tap='uploadpic'
  72. v-if="refund_reason_wap_img.length < 3">
  73. <text class='iconfont icon-icon25201'></text>
  74. <view>上传凭证</view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <button :disabled="buttonDisabled" class='returnBnt bg-color' form-type="submit">申请退款</button>
  80. </view>
  81. </form>
  82. <!-- #ifdef MP -->
  83. <!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
  84. <!-- #endif -->
  85. </view>
  86. </template>
  87. <script>
  88. import {
  89. ordeRefundReason,
  90. orderRefundVerify,
  91. getOrderDetail,
  92. returnGoodsSubmit,
  93. postRefundGoods
  94. } from '@/api/order.js';
  95. import {
  96. toLogin
  97. } from '@/libs/login.js';
  98. import {
  99. mapGetters
  100. } from "vuex";
  101. import colors from '@/mixins/color.js';
  102. export default {
  103. components: {},
  104. mixins: [colors],
  105. data() {
  106. return {
  107. id:0,
  108. cartIds:[],
  109. refund_reason_wap_img: [],
  110. status: {},
  111. RefundArray: [],
  112. refundCartInfo: [],
  113. returnGoodsData: ['仅退款', '退货并退款'],
  114. refund_total_num: 0,
  115. index: 0,
  116. returnGoods: 0,
  117. orderId: 0,
  118. refundNumData: [],
  119. refund_num_index: 0,
  120. productType:0,
  121. isShowAuth: false,
  122. buttonDisabled: false
  123. };
  124. },
  125. computed: mapGetters(['isLogin']),
  126. watch: {
  127. isLogin: {
  128. handler: function(newV, oldV) {
  129. if (newV) {
  130. this.refundGoodsInfo();
  131. this.getRefundReason();
  132. }
  133. },
  134. deep: true
  135. }
  136. },
  137. onLoad(options) {
  138. this.orderId = options.orderId;
  139. this.id = options.id;
  140. this.productType = parseInt(options.productType) || 0;
  141. if(options.cartIds){
  142. this.cartIds = JSON.parse(options.cartIds) || []
  143. }
  144. if (this.isLogin) {
  145. this.refundGoodsInfo();
  146. this.getRefundReason();
  147. } else {
  148. toLogin();
  149. }
  150. },
  151. onShow() {
  152. uni.removeStorageSync('form_type_cart');
  153. },
  154. methods: {
  155. onLoadFun(){
  156. this.refundGoodsInfo();
  157. this.getRefundReason();
  158. this.isShowAuth = false
  159. },
  160. // 授权关闭
  161. authColse: function(e) {
  162. this.isShowAuth = e
  163. },
  164. refundGoodsInfo(){
  165. postRefundGoods({id:this.id,cart_ids:this.cartIds}).then(res=>{
  166. let data = res.data;
  167. this.status = data._status;
  168. this.refundCartInfo = data.cartInfo;
  169. this.refundCartInfo.forEach(item=>{
  170. this.refund_total_num = this.$util.$h.Add(this.refund_total_num, item.cart_num)
  171. })
  172. this.refundNumData = Array(this.refund_total_num).fill(0).map((e, i) => i + 1)
  173. }).catch(err=>{
  174. return this.$util.Tips({
  175. title: err
  176. });
  177. })
  178. },
  179. /**
  180. * 获取退款理由
  181. */
  182. getRefundReason: function() {
  183. let that = this;
  184. ordeRefundReason().then(res => {
  185. that.$set(that, 'RefundArray', res.data);
  186. })
  187. },
  188. /**
  189. * 删除图片
  190. *
  191. */
  192. DelPic: function(e) {
  193. let index = e,
  194. that = this,
  195. pic = this.refund_reason_wap_img[index];
  196. that.refund_reason_wap_img.splice(index, 1);
  197. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  198. },
  199. /**
  200. * 上传文件
  201. *
  202. */
  203. uploadpic: function() {
  204. let that = this;
  205. this.$util.uploadImageOne('upload/image', function(res) {
  206. that.refund_reason_wap_img.push(res.data.url);
  207. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  208. });
  209. },
  210. /**
  211. * 申请退货
  212. */
  213. subRefund: function(e) {
  214. this.buttonDisabled = true;
  215. let that = this,
  216. value = e.detail.value;
  217. //收集form表单
  218. if (!value.refund_reason_wap_explain) {
  219. this.buttonDisabled = false;
  220. return this.$util.Tips({
  221. title: '请输入备注说明'
  222. });
  223. }
  224. let cartInfo = this.refundCartInfo;
  225. if(cartInfo.length === 1){
  226. this.cartIds = [
  227. {
  228. cart_id:cartInfo[0].id,
  229. cart_num: this.refund_num_index + 1
  230. }
  231. ]
  232. }
  233. returnGoodsSubmit(this.id, {
  234. text: that.RefundArray[that.index] || '',
  235. refund_reason_wap_explain: value.refund_reason_wap_explain,
  236. refund_reason_wap_img: that.refund_reason_wap_img.join(','),
  237. refund_type: this.returnGoods ? 2 : 1,
  238. uni: that.orderId,
  239. cart_ids: this.cartIds
  240. }).then(res => {
  241. this.buttonDisabled = false;
  242. return this.$util.Tips({
  243. title: '申请成功',
  244. icon: 'success'
  245. }, {
  246. tab: 5,
  247. url: '/pages/users/user_return_list/index?isT=1'
  248. });
  249. }).catch(err => {
  250. this.buttonDisabled = false;
  251. return this.$util.Tips({
  252. title: err
  253. });
  254. })
  255. },
  256. bindPickerChange(e) {
  257. this.$set(this, 'index', e.detail.value);
  258. },
  259. returnGoodsChange(e) {
  260. this.$set(this, 'returnGoods', e.detail.value);
  261. },
  262. returnGoodsNum(e) {
  263. this.$set(this, 'refund_num_index', Number(e.detail.value));
  264. }
  265. }
  266. }
  267. </script>
  268. <style scoped lang="scss">
  269. .apply-return .list {
  270. background-color: #fff;
  271. margin-top: 18rpx;
  272. }
  273. .apply-return .list .item {
  274. margin-left: 30rpx;
  275. padding-right: 30rpx;
  276. min-height: 90rpx;
  277. border-bottom: 1rpx solid #eee;
  278. font-size: 30rpx;
  279. color: #333;
  280. }
  281. .apply-return .list .item .num {
  282. color: #282828;
  283. width: 427rpx;
  284. text-align: right;
  285. }
  286. .apply-return .list .item .num .picker .reason {
  287. width: 385rpx;
  288. }
  289. .apply-return .list .item .num .picker .iconfont {
  290. color: #666;
  291. font-size: 30rpx;
  292. margin-top: 2rpx;
  293. }
  294. .apply-return .list .item.textarea {
  295. padding: 30rpx 30rpx 30rpx 0;
  296. }
  297. .apply-return .list .item textarea {
  298. height: 100rpx;
  299. font-size: 30rpx;
  300. }
  301. .apply-return .list .item .placeholder {
  302. color: #bbb;
  303. }
  304. .apply-return .list .item .title {
  305. height: 95rpx;
  306. width: 100%;
  307. }
  308. .apply-return .list .item .title .tip {
  309. font-size: 30rpx;
  310. color: #bbb;
  311. }
  312. .apply-return .list .item .upload {
  313. padding-bottom: 36rpx;
  314. }
  315. .apply-return .list .item .upload .pictrue {
  316. margin: 22rpx 23rpx 0 0;
  317. width: 156rpx;
  318. height: 156rpx;
  319. position: relative;
  320. font-size: 24rpx;
  321. color: #bbb;
  322. }
  323. .apply-return .list .item .upload .pictrue:nth-of-type(4n) {
  324. margin-right: 0;
  325. }
  326. .apply-return .list .item .upload .pictrue image {
  327. width: 100%;
  328. height: 100%;
  329. border-radius: 3rpx;
  330. }
  331. .apply-return .list .item .upload .pictrue .icon-guanbi1 {
  332. position: absolute;
  333. font-size: 45rpx;
  334. top: -10rpx;
  335. right: -10rpx;
  336. }
  337. .apply-return .list .item .upload .pictrue .icon-icon25201 {
  338. color: #bfbfbf;
  339. font-size: 50rpx;
  340. }
  341. .apply-return .list .item .upload .pictrue:nth-last-child(1) {
  342. border: 1rpx solid #ddd;
  343. box-sizing: border-box;
  344. }
  345. .apply-return .returnBnt {
  346. font-size: 32rpx;
  347. color: #fff;
  348. width: 690rpx;
  349. height: 86rpx;
  350. border-radius: 50rpx;
  351. text-align: center;
  352. line-height: 86rpx;
  353. margin: 43rpx auto;
  354. }
  355. .goodsStyle .text .name {
  356. align-self: flex-start;
  357. }
  358. .list /deep/ .uni-input-input {
  359. text-align: right;
  360. }
  361. </style>