service.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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') that.Receip(params)
  370. else that.orderCancel(params)
  371. } else {
  372. uni.showToast({
  373. title: '该商品时间超时不允许退款或退货',
  374. icon: 'none'
  375. })
  376. }
  377. } else {
  378. uni.showToast({
  379. title: arr.errmsg,
  380. icon: 'none'
  381. })
  382. }
  383. })
  384. },
  385. // 已收到货
  386. async Receip(e) {
  387. const that = this;
  388. e.file = that.thrform.file;
  389. let money = that.moneyInfo.payTotal;
  390. let res;
  391. if (e.type != '3') {
  392. if (e.money) {
  393. if (parseFloat(e.money) > parseFloat(money)) {
  394. uni.showToast({
  395. title: '输入金额不能超过实际支付金额',
  396. icon: 'none'
  397. })
  398. } else {
  399. if (that.status == '-3') {
  400. e.order = that.id;
  401. res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
  402. } else {
  403. e.order_detail = that.id;
  404. res = await that.$api(`/afterSale`, 'POST', e)
  405. }
  406. }
  407. } else {
  408. uni.showToast({
  409. title: `请输入退款金额`,
  410. icon: 'none',
  411. });
  412. }
  413. } else {
  414. if (that.status == '-3') {
  415. e.order = that.id;
  416. res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
  417. } else {
  418. e.order_detail = that.id;
  419. res = await that.$api(`/afterSale`, 'POST', e)
  420. }
  421. }
  422. if (res.errcode == '0') {
  423. uni.showToast({
  424. title: '申请售后完成',
  425. icon: 'none'
  426. })
  427. uni.navigateBack({
  428. detail: 1
  429. })
  430. } else {
  431. uni.showToast({
  432. title: res.errmsg,
  433. icon: 'none'
  434. })
  435. }
  436. },
  437. // 未收到货
  438. async orderCancel(e) {
  439. const that = this;
  440. let res;
  441. if (that.status == '-3') {
  442. e.order = that.id;
  443. res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
  444. } else {
  445. e.order_detail = that.id;
  446. res = await that.$api(`/afterSale`, 'POST', e)
  447. }
  448. if (res.errcode == '0') {
  449. uni.showToast({
  450. title: `申请售后成功`,
  451. icon: 'success',
  452. });
  453. uni.navigateBack({
  454. detail: 1
  455. })
  456. } else {
  457. uni.showToast({
  458. title: res.errmsg,
  459. icon: 'none',
  460. })
  461. }
  462. },
  463. // 查询其他信息
  464. async searchOther() {
  465. const that = this;
  466. let res;
  467. res = await that.$api(`/dictData`, 'GET', {
  468. code: "afterSale_type"
  469. });
  470. if (res.errcode == '0') {
  471. let type = res.data.filter(i => i.value != '4' && i.value != '5')
  472. that.$set(that, `typeList`, type)
  473. }
  474. res = await that.$api(`/dictData`, 'GET', {
  475. code: "afterSale_reason"
  476. });
  477. if (res.errcode == '0') that.$set(that, `reasonList`, res.data)
  478. }
  479. }
  480. }
  481. </script>
  482. <style lang="scss">
  483. .main {
  484. display: flex;
  485. flex-direction: column;
  486. width: 100vw;
  487. height: 100vh;
  488. .one {
  489. margin: 2vw;
  490. border: 1px solid #f1f1f1;
  491. border-radius: 5px;
  492. padding: 2vw;
  493. .one_1 {
  494. margin: 0 0 2vw 0;
  495. text {
  496. font-size: 16px;
  497. font-weight: bold;
  498. }
  499. }
  500. .one_2 {
  501. .list {
  502. display: flex;
  503. background-color: #f1f1f1;
  504. padding: 2vw;
  505. margin: 0 0 2vw 0;
  506. border-radius: 5px;
  507. .list_1 {
  508. width: 22vw;
  509. height: 22vw;
  510. border-radius: 5px;
  511. .image {
  512. width: 100%;
  513. height: 100%;
  514. border-radius: 5px;
  515. }
  516. }
  517. .list_2 {
  518. width: 63vw;
  519. padding: 0 0 0 2vw;
  520. .name {
  521. font-size: 16px;
  522. font-weight: bold;
  523. margin: 0 0 0.5vw 0;
  524. }
  525. .other_1 {
  526. .money {
  527. color: var(--fFB1Color) !important;
  528. }
  529. text {
  530. font-size: 13px;
  531. color: #858585;
  532. }
  533. text:last-child {
  534. color: #000000;
  535. }
  536. }
  537. }
  538. }
  539. .list:last-child {
  540. margin: 0;
  541. }
  542. .set_name {
  543. display: flex;
  544. padding: 2vw 0;
  545. .set {
  546. margin: 0 1vw 0 0;
  547. font-size: 12px;
  548. border-radius: 5px;
  549. padding: 0 1vw;
  550. color: #ffffff;
  551. background-color: #FF6347;
  552. border: 1px solid #FFA500;
  553. }
  554. }
  555. .set {
  556. display: flex;
  557. justify-content: space-between;
  558. margin: 0 0 2vw 0;
  559. padding: 2vw 0;
  560. .set_1 {
  561. font-size: var(--font16Size);
  562. color: var(--f85Color);
  563. }
  564. text {
  565. padding: 0 1vw 0 0;
  566. font-size: var(--font20Szie);
  567. }
  568. }
  569. }
  570. }
  571. .two {
  572. margin: 2vw;
  573. border: 1px solid #f1f1f1;
  574. border-radius: 5px;
  575. padding: 2vw;
  576. .two_1 {
  577. .picker {
  578. border: 1px solid #3333;
  579. border-radius: 5px;
  580. padding: 2vw;
  581. }
  582. .money {
  583. margin: 1vw 0 0 0;
  584. text {
  585. color: var(--fFB1Color);
  586. }
  587. text:last-child {
  588. color: #6A5ACD;
  589. }
  590. }
  591. .btn {
  592. text-align: center;
  593. }
  594. }
  595. .two_2 {
  596. .btn {
  597. text-align: center;
  598. button {
  599. background-color: var(--f35BColor);
  600. color: #fff;
  601. }
  602. }
  603. }
  604. }
  605. }
  606. </style>