index.vue 9.7 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 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. };
  123. },
  124. computed: mapGetters(['isLogin']),
  125. watch: {
  126. isLogin: {
  127. handler: function(newV, oldV) {
  128. if (newV) {
  129. //#ifndef MP
  130. this.refundGoodsInfo();
  131. this.getRefundReason();
  132. //#endif
  133. }
  134. },
  135. deep: true
  136. }
  137. },
  138. onLoad(options) {
  139. this.orderId = options.orderId;
  140. this.id = options.id;
  141. this.productType = parseInt(options.productType) || 0;
  142. if(options.cartIds){
  143. this.cartIds = JSON.parse(options.cartIds) || []
  144. }
  145. if (this.isLogin) {
  146. this.refundGoodsInfo();
  147. this.getRefundReason();
  148. } else {
  149. //#ifndef MP
  150. toLogin();
  151. //#endif
  152. //#ifdef MP
  153. this.isShowAuth = true;
  154. //#endif
  155. }
  156. },
  157. onShow() {
  158. uni.removeStorageSync('form_type_cart');
  159. },
  160. methods: {
  161. onLoadFun(){
  162. this.refundGoodsInfo();
  163. this.getRefundReason();
  164. this.isShowAuth = false
  165. },
  166. // 授权关闭
  167. authColse: function(e) {
  168. this.isShowAuth = e
  169. },
  170. refundGoodsInfo(){
  171. postRefundGoods({id:this.id,cart_ids:this.cartIds}).then(res=>{
  172. let data = res.data;
  173. this.status = data._status;
  174. this.refundCartInfo = data.cartInfo;
  175. this.refundCartInfo.forEach(item=>{
  176. this.refund_total_num = this.$util.$h.Add(this.refund_total_num, item.cart_num)
  177. })
  178. this.refundNumData = Array(this.refund_total_num).fill(0).map((e, i) => i + 1)
  179. }).catch(err=>{
  180. return this.$util.Tips({
  181. title: err
  182. });
  183. })
  184. },
  185. /**
  186. * 获取退款理由
  187. */
  188. getRefundReason: function() {
  189. let that = this;
  190. ordeRefundReason().then(res => {
  191. that.$set(that, 'RefundArray', res.data);
  192. })
  193. },
  194. /**
  195. * 删除图片
  196. *
  197. */
  198. DelPic: function(e) {
  199. let index = e,
  200. that = this,
  201. pic = this.refund_reason_wap_img[index];
  202. that.refund_reason_wap_img.splice(index, 1);
  203. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  204. },
  205. /**
  206. * 上传文件
  207. *
  208. */
  209. uploadpic: function() {
  210. let that = this;
  211. this.$util.uploadImageOne('upload/image', function(res) {
  212. that.refund_reason_wap_img.push(res.data.url);
  213. that.$set(that, 'refund_reason_wap_img', that.refund_reason_wap_img);
  214. });
  215. },
  216. /**
  217. * 申请退货
  218. */
  219. subRefund: function(e) {
  220. let that = this,
  221. value = e.detail.value;
  222. //收集form表单
  223. if (!value.refund_reason_wap_explain) return this.$util.Tips({
  224. title: '请输入备注说明'
  225. });
  226. let cartInfo = this.refundCartInfo;
  227. if(cartInfo.length === 1){
  228. this.cartIds = [
  229. {
  230. cart_id:cartInfo[0].id,
  231. cart_num: this.refund_num_index + 1
  232. }
  233. ]
  234. }
  235. returnGoodsSubmit(this.id, {
  236. text: that.RefundArray[that.index] || '',
  237. refund_reason_wap_explain: value.refund_reason_wap_explain,
  238. refund_reason_wap_img: that.refund_reason_wap_img.join(','),
  239. refund_type: this.returnGoods ? 2 : 1,
  240. uni: that.orderId,
  241. cart_ids: this.cartIds
  242. }).then(res => {
  243. return this.$util.Tips({
  244. title: '申请成功',
  245. icon: 'success'
  246. }, {
  247. tab: 5,
  248. url: '/pages/users/user_return_list/index?isT=1'
  249. });
  250. }).catch(err => {
  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>