aftersale.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <view class="container">
  3. <view class="order-goods">
  4. <view class="h">退款商品</view>
  5. <view class="goods">
  6. <view class="item" v-for="(item, index) in orderGoods" :key="index">
  7. <view class="img">
  8. <image :src="item.picUrl"></image>
  9. </view>
  10. <view class="info">
  11. <view class="t">
  12. <text class="name">{{ item.goodsName }}</text>
  13. <text class="number">x{{ item.number }}</text>
  14. </view>
  15. <view class="attr">{{ item.specifications }}</view>
  16. <view class="price">¥{{ item.price }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <van-cell-group title="订单明细">
  22. <van-cell title="商品总价" :value="' ¥' + orderInfo.goodsPrice + '元'" />
  23. <!-- <van-cell title=" 运费" value=" ¥{{orderInfo.freightPrice}}元" /> -->
  24. <van-cell title=" 优惠" :value="'-¥' + orderInfo.couponPrice + '元'" />
  25. <van-cell title="订单实付" :value="' ¥' + orderInfo.actualPrice + '元'" />
  26. </van-cell-group>
  27. <van-cell-group title="操作">
  28. <van-field :value="aftersale.typeDesc" label="退款类型" readonly="readonly" placeholder="请选择" input-align="right" required clickable @tap.native="showTypePicker" />
  29. <van-field :value="aftersale.reason" label="退款原因" placeholder="请输入" @change="onReasonChange" input-align="right" required clearable />
  30. <van-field label="退款说明" :value="aftersale.comment" placeholder="请输入" type="textarea" input-align="right" autosize />
  31. <van-cell title="退款金额" :value="'¥' + aftersale.amount + '元'" label="不可修改,即订单实付- 运费" required />
  32. <van-cell title="上传凭证" label="最多上传三张">
  33. <van-uploader :file-list="fileList" @after-read="afterRead" @delete="deleteImage" :max-count="3" preview-size="50px" />
  34. </van-cell>
  35. </van-cell-group>
  36. <van-button type="danger" @click="submit" block>申请售后</van-button>
  37. <van-popup :show="showPicker" position="bottom">
  38. <van-picker show-toolbar :columns="columns" @cancel="onCancel" @confirm="onConfirm" />
  39. </van-popup>
  40. </view>
  41. </template>
  42. <script>
  43. var util = require('../../../utils/util.js');
  44. var api = require('../../../config/api.js');
  45. export default {
  46. data() {
  47. return {
  48. orderId: 0,
  49. orderInfo: {
  50. goodsPrice: '',
  51. couponPrice: '',
  52. actualPrice: ''
  53. },
  54. orderGoods: [],
  55. aftersale: {
  56. pictures: [],
  57. orderId: '',
  58. amount: '',
  59. comment: '',
  60. reason: '',
  61. type: '',
  62. typeDesc: ''
  63. },
  64. //columns: ['未上门','服务质量问题','其他'],
  65. columns: ['不想要\不喜欢', '7天无理由退款', '搬家/出差', '重复购买', '地址超服务范围', '地址约错', '约不到想要的服务时间', '活动/优惠未享受', '服务质量问题'],
  66. contentLength: 0,
  67. refundTypes: [],
  68. //退款原因
  69. fileList: [],
  70. showPicker: false
  71. };
  72. },
  73. onLoad: function (options) {
  74. // 页面初始化 options为页面跳转所带来的参数
  75. this.setData({
  76. orderId: options.id
  77. });
  78. this.getOrderDetail();
  79. this.getRefudnType();
  80. },
  81. onReady: function () {
  82. // 页面渲染完成
  83. },
  84. onShow: function () {
  85. // 页面显示
  86. },
  87. onHide: function () {
  88. // 页面隐藏
  89. },
  90. onUnload: function () {
  91. // 页面关闭
  92. },
  93. methods: {
  94. getRefudnType() {
  95. let that = this;
  96. util.request(api.AftersaleRefundType).then(function (res) {
  97. if (res.errno === 0) {
  98. that.setData({
  99. refundTypes: res.data,
  100. columns: res.data.map((obj) => obj.name)
  101. });
  102. console.info(that.refundTypes);
  103. }
  104. });
  105. },
  106. getOrderDetail: function () {
  107. uni.showLoading({
  108. title: '加载中'
  109. });
  110. setTimeout(function () {
  111. uni.hideLoading();
  112. }, 2000);
  113. let that = this;
  114. util.request(api.OrderDetail, {
  115. orderId: that.orderId
  116. }).then(function (res) {
  117. if (res.errno === 0) {
  118. console.log(res.data);
  119. that.setData({
  120. orderInfo: res.data.orderInfo,
  121. orderGoods: res.data.orderGoods,
  122. 'aftersale.orderId': that.orderId,
  123. 'aftersale.amount': res.data.orderInfo.actualPrice - res.data.orderInfo.freightPrice
  124. });
  125. }
  126. uni.hideLoading();
  127. });
  128. },
  129. deleteImage(event) {
  130. const { fileList = [] } = this;
  131. fileList.splice(event.detail.index, 1);
  132. this.setData({
  133. fileList: fileList
  134. });
  135. let urls = [];
  136. fileList.forEach(function (e) {
  137. urls.push(e.url);
  138. });
  139. this.setData({
  140. 'aftersale.pictures': urls
  141. });
  142. },
  143. afterRead(event) {
  144. const { file } = event.detail;
  145. let that = this;
  146. const uploadTask = uni.uploadFile({
  147. url: api.StorageUpload,
  148. filePath: file.path,
  149. name: 'file',
  150. success: function (res) {
  151. var _res = JSON.parse(res.data);
  152. if (_res.errno === 0) {
  153. var url = _res.data.url;
  154. that.aftersale.pictures.push(url);
  155. const { fileList = [] } = that;
  156. fileList.push({
  157. ...file,
  158. url: url
  159. });
  160. that.setData({
  161. fileList: fileList
  162. });
  163. }
  164. },
  165. fail: function (e) {
  166. uni.showModal({
  167. title: '错误',
  168. content: '上传失败',
  169. showCancel: false
  170. });
  171. }
  172. });
  173. },
  174. previewImage: function (e) {
  175. uni.previewImage({
  176. current: e.currentTarget.id,
  177. // 当前显示图片的http链接
  178. urls: this.files // 需要预览的图片http链接列表
  179. });
  180. },
  181. contentInput: function (e) {
  182. this.setData({
  183. contentLength: e.detail.cursor,
  184. 'aftersale.comment': e.detail.value
  185. });
  186. },
  187. onReasonChange: function (e) {
  188. this.setData({
  189. 'aftersale.reason': e.detail
  190. });
  191. },
  192. showTypePicker: function () {
  193. this.setData({
  194. showPicker: true
  195. });
  196. },
  197. onCancel: function () {
  198. this.setData({
  199. showPicker: false
  200. });
  201. },
  202. onConfirm: function (event) {
  203. let name = event.detail.value;
  204. let typeId = 0;
  205. let vals = this.refundTypes.filter((item) => item.name == event.detail.value);
  206. typeId = vals[0].id;
  207. this.setData({
  208. //'aftersale.type': event.detail.index,
  209. //'aftersale.typeDesc': event.detail.value,
  210. 'aftersale.type': typeId,
  211. 'aftersale.typeDesc': name,
  212. showPicker: false
  213. });
  214. },
  215. submit: function () {
  216. let that = this;
  217. if (that.aftersale.type == undefined) {
  218. util.showErrorToast('请选择退款类型');
  219. return false;
  220. }
  221. console.log(that.aftersale.reason);
  222. if (!that.aftersale.reason) {
  223. util.showErrorToast('请输入退款原因');
  224. return false;
  225. }
  226. uni.showLoading({
  227. title: '提交中...',
  228. mask: true,
  229. success: function () {}
  230. });
  231. util.request(api.AftersaleSubmit, that.aftersale, 'POST').then(function (res) {
  232. uni.hideLoading();
  233. if (res.errno === 0) {
  234. uni.showToast({
  235. title: '申请售后成功',
  236. icon: 'success',
  237. duration: 2000,
  238. complete: function () {
  239. uni.redirectTo({
  240. url: '/pages/ucenter/aftersaleList/aftersaleList'
  241. });
  242. }
  243. });
  244. } else {
  245. // util.showErrorToast(res.errmsg);
  246. uni.showToast({
  247. title: res.errmsg,
  248. icon: 'none'
  249. });
  250. }
  251. });
  252. }
  253. }
  254. };
  255. </script>
  256. <style>
  257. page {
  258. height: 100%;
  259. width: 100%;
  260. background: #f4f4f4;
  261. }
  262. .order-goods {
  263. margin-top: 20rpx;
  264. background: #fff;
  265. }
  266. .order-goods .h {
  267. height: 93.75rpx;
  268. line-height: 93.75rpx;
  269. margin-left: 31.25rpx;
  270. border-bottom: 1px solid #f4f4f4;
  271. padding-right: 31.25rpx;
  272. }
  273. .order-goods .h .label {
  274. float: left;
  275. font-size: 30rpx;
  276. color: #333;
  277. }
  278. .order-goods .h .status {
  279. float: right;
  280. font-size: 30rpx;
  281. color: #b4282d;
  282. }
  283. .order-goods .item {
  284. display: flex;
  285. align-items: center;
  286. height: 192rpx;
  287. margin-left: 31.25rpx;
  288. padding-right: 31.25rpx;
  289. border-bottom: 1px solid #f4f4f4;
  290. }
  291. .order-goods .item:last-child {
  292. border-bottom: none;
  293. }
  294. .order-goods .item .img {
  295. height: 145.83rpx;
  296. width: 145.83rpx;
  297. background: #f4f4f4;
  298. }
  299. .order-goods .item .img image {
  300. height: 145.83rpx;
  301. width: 145.83rpx;
  302. }
  303. .order-goods .item .info {
  304. flex: 1;
  305. height: 145.83rpx;
  306. margin-left: 20rpx;
  307. }
  308. .order-goods .item .t {
  309. margin-top: 8rpx;
  310. height: 33rpx;
  311. line-height: 33rpx;
  312. margin-bottom: 10.5rpx;
  313. }
  314. .order-goods .item .t .name {
  315. display: block;
  316. float: left;
  317. height: 33rpx;
  318. line-height: 33rpx;
  319. color: #333;
  320. font-size: 30rpx;
  321. }
  322. .order-goods .item .t .number {
  323. display: block;
  324. float: right;
  325. height: 33rpx;
  326. text-align: right;
  327. line-height: 33rpx;
  328. color: #333;
  329. font-size: 30rpx;
  330. }
  331. .order-goods .item .attr {
  332. height: 29rpx;
  333. line-height: 29rpx;
  334. color: #666;
  335. margin-bottom: 25rpx;
  336. font-size: 25rpx;
  337. }
  338. .order-goods .item .price {
  339. display: block;
  340. float: left;
  341. height: 30rpx;
  342. line-height: 30rpx;
  343. color: #333;
  344. font-size: 30rpx;
  345. }
  346. </style>