service.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one" v-if="status!='-3'">
  5. <view class="one_1">
  6. <text>售后商品</text>
  7. </view>
  8. <view class="one_2">
  9. <view v-for="(item,index) in info.goods" :key="index">
  10. <view class="set_name" v-if="item.is_set=='0'">
  11. <text class="set">套装</text> {{item.name}}
  12. </view>
  13. <view class="list" v-if="item.is_set=='0'" v-for="(tag,indexx) in item.goods" :key="indexx">
  14. <view class="list_1">
  15. <image class="image"
  16. :src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:''" mode="">
  17. </image>
  18. </view>
  19. <view class="list_2">
  20. <view class="name">
  21. {{tag.goods_name}}
  22. </view>
  23. <view class="other_1">
  24. <text>规格:</text>
  25. <text>{{tag.spec_name}}</text>
  26. </view>
  27. <view class="other_1">
  28. <text>数量:</text>
  29. <text>×{{tag.set_num}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="set" v-if="item.is_set=='0'">
  34. <view class="set_1">套装价:¥{{item.sell_money}}</view>
  35. <view class="set_2">数量:×{{item.buy_num}}</view>
  36. </view>
  37. <view class="list" v-else>
  38. <view class="list_1">
  39. <image class="image"
  40. :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
  41. </image>
  42. </view>
  43. <view class="list_2">
  44. <view class="name">
  45. {{item.goods_name}}
  46. </view>
  47. <view class="other_1">
  48. <text>规格:</text>
  49. <text>{{item.name}}</text>
  50. </view>
  51. <view class="other_1">
  52. <text>金额:</text>
  53. <text
  54. class="money">¥{{info.type=='0'?item.price||item.sell_money:item.group_config.money}}</text>
  55. </view>
  56. <view class="other_1">
  57. <text>数量:</text>
  58. <text>×{{item.buy_num}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="two">
  66. <view class="two_1" v-if="status=='3'||status=='-3'">
  67. <uni-forms ref="thrform" :rules="thrrules" :model="thrform" label-width="auto">
  68. <uni-forms-item label="售后商品" name="goods"
  69. v-if="status!='-3'&&goodsList.length>0&&!thrform.set_id">
  70. <picker class="picker" mode="selector" :range="goodsList" @change="goodsChange"
  71. range-key="goods_name">
  72. <view>{{thrform.goods_name||'请选择退款商品'}}</view>
  73. </picker>
  74. </uni-forms-item>
  75. <uni-forms-item label="售后套装" name="set_id"
  76. v-if="status!='-3'&&!thrform.goods_name&&setList.length>0">
  77. <picker class="picker" mode="selector" :range="setList" @change="setChange"
  78. range-key="name">
  79. <view>{{thrform.set_name||'请选择退款套装'}}</view>
  80. </picker>
  81. </uni-forms-item>
  82. <uni-forms-item label="售后套装商品" name="goods" v-if="status!='-3'&&thrform.set_name">
  83. <picker class="picker" mode="selector" :range="setgoodsList" @change="setgoodsChange"
  84. range-key="goods_name">
  85. <view>{{thrform.goods_name||'请选择退款套装商品'}}</view>
  86. </picker>
  87. </uni-forms-item>
  88. <uni-forms-item label="售后类型" name="type">
  89. <picker class="picker" mode="selector" :range="typeList" @change="typeChange"
  90. range-key="label">
  91. <view>{{thrform.type_name||'请选择售后类型'}}</view>
  92. </picker>
  93. </uni-forms-item>
  94. <uni-forms-item label="退款金额" name="money" v-if="thrform.type=='1'||thrform.type=='2'">
  95. <uni-easyinput type="digit" v-model="thrform.money" @input="toMoney"
  96. placeholder="请输入退款金额" />
  97. <view class="money">
  98. 最大退款金额不能超过 <text>{{moneyInfo.payTotal||0}}</text>,<text @tap="toAll">全部退款</text>
  99. </view>
  100. </uni-forms-item>
  101. <uni-forms-item label="申请理由" name="reason">
  102. <picker class="picker" mode="selector" :range="reasonList" @change="reasonChange"
  103. range-key="label">
  104. <view>{{thrform.reason_name||'请选择申请理由'}}</view>
  105. </picker>
  106. </uni-forms-item>
  107. <uni-forms-item label="售后描述" name="desc">
  108. <uni-easyinput type="textarea" v-model="thrform.desc" placeholder="请输入售后描述" />
  109. </uni-forms-item>
  110. <uni-forms-item label="附件" name="file">
  111. <upload :list="thrform.file" name="file" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
  112. </upload>
  113. </uni-forms-item>
  114. <view class="btn">
  115. <button type="primary" size="mini" @click="onSubmit('thrform')">提交保存</button>
  116. </view>
  117. </uni-forms>
  118. </view>
  119. <view class="two_2" v-else>
  120. <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
  121. <uni-forms-item label="申请描述" name="desc">
  122. <uni-easyinput type="textarea" autoHeight v-model="form.desc" placeholder="请输入申请描述" />
  123. </uni-forms-item>
  124. <view class="btn">
  125. <button type="default" size="mini" @click="onSubmit('form')">提交保存</button>
  126. </view>
  127. </uni-forms>
  128. </view>
  129. </view>
  130. </view>
  131. </mobile-frame>
  132. </template>
  133. <script>
  134. import upload from '@/components/upload/index.vue';
  135. export default {
  136. components: {
  137. upload
  138. },
  139. data() {
  140. return {
  141. id: '',
  142. status: '',
  143. // 用户信息
  144. user: {},
  145. // 信息详情
  146. info: {},
  147. // 仅退款
  148. form: {},
  149. rules: {
  150. desc: {
  151. rules: [{
  152. required: true,
  153. errorMessage: '请输入申请描述',
  154. }]
  155. },
  156. },
  157. // 已收到货
  158. thrform: {
  159. file: []
  160. },
  161. // 最大退款数
  162. moneyInfo: {},
  163. thrrules: {
  164. type: {
  165. rules: [{
  166. required: true,
  167. errorMessage: '请选择售后类型',
  168. }]
  169. },
  170. goods: {
  171. rules: [{
  172. required: true,
  173. errorMessage: '请选择退款商品',
  174. }]
  175. },
  176. reason: {
  177. rules: [{
  178. required: true,
  179. errorMessage: '请选择申请理由',
  180. }]
  181. },
  182. },
  183. // 售后类型
  184. typeList: [],
  185. // 申请理由
  186. reasonList: [],
  187. // 正常商品
  188. goodsList: [],
  189. // 套装
  190. setList: [],
  191. // 套装商品
  192. setgoodsList: [],
  193. };
  194. },
  195. onLoad: async function(e) {
  196. const that = this;
  197. that.$set(that, `id`, e && e.id || '');
  198. that.$set(that, `status`, e && e.status || '');
  199. // 查询其他信息
  200. await that.searchOther();
  201. // 监听用户登录
  202. await that.watchLogin();
  203. },
  204. methods: {
  205. watchLogin() {
  206. const that = this;
  207. uni.getStorage({
  208. key: 'token',
  209. success: function(res) {
  210. let user = that.$jwt(res.data);
  211. if (user) {
  212. that.$set(that, `user`, user);
  213. that.search();
  214. }
  215. },
  216. fail: function() {
  217. uni.navigateTo({
  218. url: `/pages/login/index`
  219. })
  220. }
  221. })
  222. },
  223. async search() {
  224. const that = this;
  225. let res;
  226. if (that.status != '-3') {
  227. res = await that.$api(`/orderDetail/${that.id}`, 'GET')
  228. if (res.errcode == '0') {
  229. for (let val of res.data.goods) val.goods_name = val.goods.name;
  230. that.$set(that, `info`, res.data)
  231. let goodsList = res.data.goods.filter(i => i.is_set != '0')
  232. that.$set(that, `goodsList`, goodsList)
  233. let setList = res.data.goods.filter(i => i.is_set == '0')
  234. that.$set(that, `setList`, setList)
  235. } else {
  236. uni.showToast({
  237. title: res.errmsg,
  238. icon: 'none'
  239. })
  240. }
  241. } else {
  242. res = await that.$api(`/groupOrder/userView/${that.id}`, 'GET', {}, 'group')
  243. if (res.errcode == '0') {
  244. that.$set(that.thrform, `goods`, res.data.goods._id);
  245. that.$set(that, `info`, res.data)
  246. } else {
  247. uni.showToast({
  248. title: res.errmsg,
  249. icon: 'none'
  250. })
  251. }
  252. }
  253. },
  254. // 售后请求
  255. // 已收到货
  256. goodsChange(e) {
  257. const that = this;
  258. let data = that.goodsList[e.detail.value];
  259. if (data) that.$set(that.info, `goods`, [data])
  260. that.$set(that.thrform, `goods`, data._id);
  261. that.$set(that.thrform, `goods_name`, data.goods_name);
  262. },
  263. // 套装
  264. setChange(e) {
  265. const that = this;
  266. let data = that.setList[e.detail.value];
  267. if (data) {
  268. that.$set(that, `setgoodsList`, data.goods)
  269. that.$set(that.info, `goods`, [data])
  270. }
  271. that.$set(that.thrform, `set_id`, data._id);
  272. that.$set(that.thrform, `set_name`, data.name);
  273. },
  274. // 套装商品
  275. setgoodsChange(e) {
  276. const that = this;
  277. let data = that.setgoodsList[e.detail.value];
  278. that.$set(that.thrform, `goods`, data.spec._id);
  279. that.$set(that.thrform, `goods_name`, data.goods_name);
  280. },
  281. // 选择售后类型
  282. async typeChange(e) {
  283. const that = this;
  284. let thrform = that.thrform;
  285. let data = that.typeList[e.detail.value];
  286. if (data) {
  287. that.$set(that.thrform, `type`, data.value);
  288. that.$set(that.thrform, `type_name`, data.label);
  289. }
  290. if (that.status != '-3') {
  291. if (data.value != '3') {
  292. if (thrform.goods) {
  293. let obj = {
  294. order_detail: that.id,
  295. }
  296. if (thrform.set_id) obj.goods_id = thrform.set_id;
  297. else obj.goods_id = thrform.goods;
  298. const arr = await that.$api(`/afterSale/cgfr`, 'POST', obj);
  299. if (arr.errcode == '0') {
  300. that.$set(that, `moneyInfo`, arr.data);
  301. } else {
  302. uni.showToast({
  303. title: arr.errmsg,
  304. icon: 'none',
  305. })
  306. }
  307. } else {
  308. uni.showToast({
  309. title: '缺少商品信息',
  310. icon: 'none'
  311. })
  312. }
  313. }
  314. } else {
  315. that.$set(that.moneyInfo, `payTotal`, that.info.pay);
  316. }
  317. },
  318. // 选择申请理由
  319. reasonChange(e) {
  320. const that = this;
  321. let data = that.reasonList[e.detail.value];
  322. if (data) {
  323. that.$set(that.thrform, `reason`, data.value);
  324. that.$set(that.thrform, `reason_name`, data.label);
  325. }
  326. },
  327. // 退款金额
  328. toMoney(value) {
  329. const that = this;
  330. let money = that.moneyInfo.payTotal;
  331. if (parseFloat(value) > parseFloat(money)) {
  332. uni.showToast({
  333. title: '输入金额不能超过实际支付金额',
  334. icon: 'none'
  335. })
  336. }
  337. },
  338. // 图片上传
  339. uplSuc(e) {
  340. const that = this;
  341. that.$set(that.thrform, `${e.name}`, [...that.thrform[e.name], e.data]);
  342. },
  343. // 图片删除
  344. uplDel(e) {
  345. const that = this;
  346. let data = that.thrform[e.name];
  347. let arr = data.filter((i, index) => index != e.data.index);
  348. that.$set(that.thrform, `${e.name}`, arr)
  349. },
  350. // 全部提现
  351. toAll() {
  352. const that = this;
  353. that.$set(that.thrform, `money`, that.moneyInfo.payTotal)
  354. },
  355. // 提交保存
  356. async onSubmit(ref) {
  357. const that = this;
  358. let status = that.status;
  359. that.$refs[ref].validate().then(async params => {
  360. // 判断是否团长提现完成 如果提现成功不能退款 过了规定日期
  361. if (that.thrform.set_id) params.set_id = that.thrform.set_id;
  362. let arr;
  363. if (that.status != '-3') arr = await that.$api(`/afterSale/canRefund/${that.id}`,
  364. 'GET');
  365. else arr = await that.$api(`/groupAfterSale/canRefund/${that.id}`,
  366. 'GET', {}, 'group');
  367. if (arr.errcode == '0') {
  368. if (arr.data == true) {
  369. if (status == '3') {
  370. that.Receip(params)
  371. } else {
  372. that.orderCancel(params)
  373. console.log(params);
  374. }
  375. } else {
  376. uni.showToast({
  377. title: '该商品时间超时不允许退款或退货',
  378. icon: 'none'
  379. })
  380. }
  381. } else {
  382. uni.showToast({
  383. title: arr.errmsg,
  384. icon: 'none'
  385. })
  386. }
  387. })
  388. },
  389. // 已收到货
  390. async Receip(e) {
  391. const that = this;
  392. e.file = that.thrform.file;
  393. let money = that.moneyInfo.payTotal;
  394. let res;
  395. if (e.type != '3') {
  396. if (e.money) {
  397. if (parseFloat(e.money) > parseFloat(money)) {
  398. uni.showToast({
  399. title: '输入金额不能超过实际支付金额',
  400. icon: 'none'
  401. })
  402. } else {
  403. if (that.status == '-3') {
  404. e.order = that.id;
  405. res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
  406. } else {
  407. e.order_detail = that.id;
  408. res = await that.$api(`/afterSale`, 'POST', e)
  409. }
  410. }
  411. } else {
  412. uni.showToast({
  413. title: `请输入退款金额`,
  414. icon: 'none',
  415. });
  416. }
  417. } else {
  418. if (that.status == '-3') {
  419. e.order = that.id;
  420. res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
  421. } else {
  422. e.order_detail = that.id;
  423. res = await that.$api(`/afterSale`, 'POST', e)
  424. }
  425. }
  426. if (res.errcode == '0') {
  427. uni.showToast({
  428. title: '申请售后完成',
  429. icon: 'none'
  430. })
  431. uni.navigateBack({
  432. detail: 1
  433. })
  434. } else {
  435. uni.showToast({
  436. title: res.errmsg,
  437. icon: 'none'
  438. })
  439. }
  440. },
  441. // 未收到货
  442. async orderCancel(e) {
  443. const that = this;
  444. let res;
  445. if (that.status == '-3') {
  446. e.order = that.id;
  447. res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
  448. } else {
  449. e.order_detail = that.id;
  450. res = await that.$api(`/afterSale`, 'POST', e)
  451. }
  452. if (res.errcode == '0') {
  453. uni.showToast({
  454. title: `申请售后成功`,
  455. icon: 'success',
  456. });
  457. uni.navigateBack({
  458. detail: 1
  459. })
  460. } else {
  461. uni.showToast({
  462. title: res.errmsg,
  463. icon: 'none',
  464. })
  465. }
  466. },
  467. // 查询其他信息
  468. async searchOther() {
  469. const that = this;
  470. let res;
  471. res = await that.$api(`/dictData`, 'GET', {
  472. code: "afterSale_type"
  473. });
  474. if (res.errcode == '0') {
  475. let type = res.data.filter(i => i.value != '4' && i.value != '5')
  476. that.$set(that, `typeList`, type)
  477. }
  478. res = await that.$api(`/dictData`, 'GET', {
  479. code: "afterSale_reason"
  480. });
  481. if (res.errcode == '0') that.$set(that, `reasonList`, res.data)
  482. }
  483. }
  484. }
  485. </script>
  486. <style lang="scss">
  487. .main {
  488. display: flex;
  489. flex-direction: column;
  490. width: 100vw;
  491. height: 100vh;
  492. .one {
  493. margin: 2vw;
  494. border: 1px solid #f1f1f1;
  495. border-radius: 5px;
  496. padding: 2vw;
  497. .one_1 {
  498. margin: 0 0 2vw 0;
  499. text {
  500. font-size: 16px;
  501. font-weight: bold;
  502. }
  503. }
  504. .one_2 {
  505. .list {
  506. display: flex;
  507. background-color: #f1f1f1;
  508. padding: 2vw;
  509. margin: 0 0 2vw 0;
  510. border-radius: 5px;
  511. .list_1 {
  512. width: 22vw;
  513. height: 22vw;
  514. border-radius: 5px;
  515. .image {
  516. width: 100%;
  517. height: 100%;
  518. border-radius: 5px;
  519. }
  520. }
  521. .list_2 {
  522. width: 63vw;
  523. padding: 0 0 0 2vw;
  524. .name {
  525. font-size: 16px;
  526. font-weight: bold;
  527. margin: 0 0 0.5vw 0;
  528. }
  529. .other_1 {
  530. .money {
  531. color: #ff0000 !important;
  532. }
  533. text {
  534. font-size: 13px;
  535. color: #858585;
  536. }
  537. text:last-child {
  538. color: #000000;
  539. }
  540. }
  541. }
  542. }
  543. .list:last-child {
  544. margin: 0;
  545. }
  546. .set_name {
  547. display: flex;
  548. padding: 2vw 0;
  549. .set {
  550. margin: 0 1vw 0 0;
  551. font-size: 12px;
  552. border-radius: 5px;
  553. padding: 0 1vw;
  554. color: #ffffff;
  555. background-color: #FF6347;
  556. border: 1px solid #FFA500;
  557. }
  558. }
  559. .set {
  560. display: flex;
  561. justify-content: space-between;
  562. margin: 0 0 2vw 0;
  563. padding: 2vw 0;
  564. .set_1 {
  565. font-size: var(--font16Size);
  566. color: var(--f85Color);
  567. }
  568. text {
  569. padding: 0 1vw 0 0;
  570. font-size: var(--font20Szie);
  571. }
  572. }
  573. }
  574. }
  575. .two {
  576. margin: 2vw;
  577. border: 1px solid #f1f1f1;
  578. border-radius: 5px;
  579. padding: 2vw;
  580. .two_1 {
  581. .picker {
  582. border: 1px solid #3333;
  583. border-radius: 5px;
  584. padding: 2vw;
  585. }
  586. .money {
  587. margin: 1vw 0 0 0;
  588. text {
  589. color: #ff0000;
  590. }
  591. text:last-child {
  592. color: #6A5ACD;
  593. }
  594. }
  595. .btn {
  596. text-align: center;
  597. }
  598. }
  599. .two_2 {
  600. .btn {
  601. text-align: center;
  602. button {
  603. background-color: var(--f35BColor);
  604. color: #fff;
  605. }
  606. }
  607. }
  608. }
  609. }
  610. </style>