index.vue 10 KB

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