service.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1">
  6. <text>售后商品</text>
  7. </view>
  8. <view class="one_2">
  9. <view class="list" v-for="(item,index) in info.goods" :key="index">
  10. <view class="list_1">
  11. <image class="image"
  12. :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
  13. </image>
  14. </view>
  15. <view class="list_2">
  16. <view class="name">
  17. {{item.goods_name}}
  18. </view>
  19. <view class="other_1">
  20. <text>规格:</text>
  21. <text>{{item.name}}</text>
  22. </view>
  23. <view class="other_1">
  24. <text>金额:</text>
  25. <text class="money">¥{{info.type=='0'?item.sell_money:item.group_config.money}}</text>
  26. </view>
  27. <view class="other_1">
  28. <text>数量:</text>
  29. <text>×{{item.buy_num}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="two">
  36. <view class="two_1" v-if="status=='3'">
  37. <uni-forms ref="thrform" :rules="thrrules" :model="thrform" label-width="auto">
  38. <uni-forms-item label="售后商品" name="goods">
  39. <picker class="picker" mode="selector" :range="info.goods" @change="goodsChange"
  40. range-key="goods_name">
  41. <view>{{thrform.goods_name||'请选择退款商品'}}</view>
  42. </picker>
  43. </uni-forms-item>
  44. <uni-forms-item label="售后类型" name="type">
  45. <picker class="picker" mode="selector" :range="typeList" @change="typeChange"
  46. range-key="label">
  47. <view>{{thrform.type_name||'请选择售后类型'}}</view>
  48. </picker>
  49. </uni-forms-item>
  50. <uni-forms-item label="退款金额" name="money" v-if="thrform.type=='1'||thrform.type=='2'">
  51. <uni-easyinput type="digit" v-model="thrform.money" @input="toMoney"
  52. placeholder="请输入退款金额" />
  53. <view class="money">
  54. 最大退款金额不能超过 <text>{{moneyInfo.payTotal||0}}</text>,<text @tap="toAll">全部提现</text>
  55. </view>
  56. </uni-forms-item>
  57. <uni-forms-item label="申请理由" name="reason">
  58. <picker class="picker" mode="selector" :range="reasonList" @change="reasonChange"
  59. range-key="label">
  60. <view>{{thrform.reason_name||'请选择申请理由'}}</view>
  61. </picker>
  62. </uni-forms-item>
  63. <uni-forms-item label="售后描述" name="desc">
  64. <uni-easyinput type="textarea" v-model="thrform.desc" placeholder="请输入售后描述" />
  65. </uni-forms-item>
  66. <uni-forms-item label="附件" name="file">
  67. <upload :list="thrform.file" name="file" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
  68. </upload>
  69. </uni-forms-item>
  70. <view class="btn">
  71. <button type="primary" size="mini" @click="onSubmit('thrform')">提交保存</button>
  72. </view>
  73. </uni-forms>
  74. </view>
  75. <view class="two_2" v-else>
  76. <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
  77. <uni-forms-item label="申请描述" name="desc">
  78. <uni-easyinput type="textarea" autoHeight v-model="form.desc" placeholder="请输入申请描述" />
  79. </uni-forms-item>
  80. <view class="btn">
  81. <button type="default" size="mini" @click="onSubmit('form')">提交保存</button>
  82. </view>
  83. </uni-forms>
  84. </view>
  85. </view>
  86. </view>
  87. </mobile-frame>
  88. </template>
  89. <script>
  90. import upload from '@/components/upload/index.vue';
  91. export default {
  92. components: {
  93. upload
  94. },
  95. data() {
  96. return {
  97. id: '',
  98. status: '',
  99. // 用户信息
  100. user: {},
  101. // 信息详情
  102. info: {},
  103. // 仅退款
  104. form: {},
  105. rules: {
  106. desc: {
  107. rules: [{
  108. required: true,
  109. errorMessage: '请输入申请描述',
  110. }]
  111. },
  112. },
  113. // 已收到货
  114. thrform: {
  115. file: []
  116. },
  117. // 最大退款数
  118. moneyInfo: {},
  119. thrrules: {
  120. type: {
  121. rules: [{
  122. required: true,
  123. errorMessage: '请选择售后类型',
  124. }]
  125. },
  126. goods_id: {
  127. rules: [{
  128. required: true,
  129. errorMessage: '请选择退款商品',
  130. }]
  131. },
  132. reason: {
  133. rules: [{
  134. required: true,
  135. errorMessage: '请选择申请理由',
  136. }]
  137. },
  138. },
  139. // 售后类型
  140. typeList: [],
  141. // 申请理由
  142. reasonList: [],
  143. };
  144. },
  145. onLoad: async function(e) {
  146. const that = this;
  147. that.$set(that, `id`, e && e.id || '');
  148. that.$set(that, `status`, e && e.status || '');
  149. // 查询其他信息
  150. await that.searchOther();
  151. // 监听用户登录
  152. await that.watchLogin();
  153. },
  154. methods: {
  155. watchLogin() {
  156. const that = this;
  157. uni.getStorage({
  158. key: 'token',
  159. success: function(res) {
  160. let user = that.$jwt(res.data);
  161. if (user) {
  162. that.$set(that, `user`, user);
  163. that.search();
  164. }
  165. },
  166. fail: function() {
  167. uni.navigateTo({
  168. url: `/pages/login/index`
  169. })
  170. }
  171. })
  172. },
  173. async search() {
  174. const that = this;
  175. let id = that.id;
  176. let res = await that.$api(`/orderDetail/${id}`, 'GET')
  177. if (res.errcode == '0') {
  178. for (let val of res.data.goods) val.goods_name = val.goods.name;
  179. that.$set(that, `info`, res.data)
  180. } else {
  181. uni.showToast({
  182. title: res.errmsg,
  183. icon: 'none'
  184. })
  185. }
  186. },
  187. // 售后请求
  188. // 已收到货
  189. goodsChange(e) {
  190. const that = this;
  191. let data = that.info.goods[e.detail.value];
  192. if (data) that.$set(that.info, `goods`, [data])
  193. that.$set(that.thrform, `goods`, data._id);
  194. that.$set(that.thrform, `goods_name`, data.goods_name);
  195. },
  196. // 选择售后类型
  197. async typeChange(e) {
  198. const that = this;
  199. let thrform = that.thrform;
  200. let data = that.typeList[e.detail.value];
  201. if (data) {
  202. that.$set(that.thrform, `type`, data.value);
  203. that.$set(that.thrform, `type_name`, data.label);
  204. }
  205. if (data.value != '3') {
  206. if (thrform.goods) {
  207. const arr = await that.$api(`/afterSale/cgfr`, 'POST', {
  208. order_detail: that.id,
  209. goods_id: thrform.goods
  210. });
  211. if (arr.errcode == '0') {
  212. that.$set(that, `moneyInfo`, arr.data);
  213. } else {
  214. uni.showToast({
  215. title: arr.errmsg,
  216. icon: 'none',
  217. })
  218. }
  219. } else {
  220. uni.showToast({
  221. title: '缺少商品信息',
  222. icon: 'none'
  223. })
  224. }
  225. }
  226. },
  227. // 选择申请理由
  228. reasonChange(e) {
  229. const that = this;
  230. let data = that.reasonList[e.detail.value];
  231. if (data) {
  232. that.$set(that.thrform, `reason`, data.value);
  233. that.$set(that.thrform, `reason_name`, data.label);
  234. }
  235. },
  236. // 退款金额
  237. toMoney(value) {
  238. const that = this;
  239. let money = that.moneyInfo.payTotal;
  240. if (parseFloat(value) > parseFloat(money)) {
  241. uni.showToast({
  242. title: '输入金额不能超过实际支付金额',
  243. icon: 'none'
  244. })
  245. }
  246. },
  247. // 图片上传
  248. uplSuc(e) {
  249. const that = this;
  250. that.$set(that.thrform, `${e.name}`, [...that.thrform[e.name], e.data]);
  251. },
  252. // 图片删除
  253. uplDel(e) {
  254. const that = this;
  255. let data = that.thrform[e.name];
  256. let arr = data.filter((i, index) => index != e.data.index);
  257. that.$set(that.thrform, `${e.name}`, arr)
  258. },
  259. // 全部提现
  260. toAll() {
  261. const that = this;
  262. that.$set(that.thrform, `money`, that.moneyInfo.payTotal)
  263. },
  264. // 提交保存
  265. async onSubmit(ref) {
  266. const that = this;
  267. let status = that.status;
  268. that.$refs[ref].validate().then(async params => {
  269. if (status == '3') {
  270. that.Receip(params)
  271. } else {
  272. that.orderCancel(params)
  273. }
  274. })
  275. },
  276. // 已收到货
  277. async Receip(e) {
  278. const that = this;
  279. e.file = that.thrform.file;
  280. e.order_detail = that.id;
  281. let money = that.moneyInfo.payTotal;
  282. let res;
  283. if (e.type != '3') {
  284. if (e.money) {
  285. if (parseFloat(e.money) > parseFloat(money)) {
  286. uni.showToast({
  287. title: '输入金额不能超过实际支付金额',
  288. icon: 'none'
  289. })
  290. } else {
  291. res = await that.$api(`/afterSale`, 'POST', e)
  292. }
  293. } else {
  294. uni.showToast({
  295. title: `请输入退款金额`,
  296. icon: 'none',
  297. });
  298. }
  299. } else {
  300. res = await that.$api(`/afterSale`, 'POST', e)
  301. }
  302. if (res.errcode == '0') {
  303. uni.showToast({
  304. title: '申请售后完成',
  305. icon: 'none'
  306. })
  307. uni.navigateBack({
  308. detail: 1
  309. })
  310. } else {
  311. uni.showToast({
  312. title: res.errmsg,
  313. icon: 'none'
  314. })
  315. }
  316. },
  317. // 未收到货
  318. async orderCancel(e) {
  319. const that = this;
  320. e.order_detail = that.id;
  321. const res = await that.$api(`/afterSale/orderCancel`, 'POST', e);
  322. if (res.errcode == '0') {
  323. uni.showToast({
  324. title: `申请售后成功`,
  325. icon: 'success',
  326. });
  327. uni.navigateBack({
  328. detail: 1
  329. })
  330. } else {
  331. uni.showToast({
  332. title: res.errmsg,
  333. icon: 'none',
  334. })
  335. }
  336. },
  337. // 查询其他信息
  338. async searchOther() {
  339. const that = this;
  340. let res;
  341. res = await that.$api(`/dictData`, 'GET', {
  342. code: "afterSale_type"
  343. });
  344. if (res.errcode == '0') {
  345. let type = res.data.filter(i => i.value != '4' && i.value != '5')
  346. that.$set(that, `typeList`, type)
  347. }
  348. res = await that.$api(`/dictData`, 'GET', {
  349. code: "afterSale_reason"
  350. });
  351. if (res.errcode == '0') {
  352. that.$set(that, `reasonList`, res.data)
  353. }
  354. }
  355. }
  356. }
  357. </script>
  358. <style lang="scss">
  359. .main {
  360. display: flex;
  361. flex-direction: column;
  362. width: 100vw;
  363. height: 100vh;
  364. .one {
  365. margin: 2vw;
  366. border: 1px solid #f1f1f1;
  367. border-radius: 5px;
  368. padding: 2vw;
  369. .one_1 {
  370. margin: 0 0 2vw 0;
  371. text {
  372. font-size: 16px;
  373. font-weight: bold;
  374. }
  375. }
  376. .one_2 {
  377. .list {
  378. display: flex;
  379. background-color: #f1f1f1;
  380. padding: 2vw;
  381. margin: 0 0 2vw 0;
  382. border-radius: 5px;
  383. .list_1 {
  384. width: 22vw;
  385. height: 22vw;
  386. border-radius: 5px;
  387. .image {
  388. width: 100%;
  389. height: 100%;
  390. border-radius: 5px;
  391. }
  392. }
  393. .list_2 {
  394. width: 63vw;
  395. padding: 0 0 0 2vw;
  396. .name {
  397. font-size: 16px;
  398. font-weight: bold;
  399. margin: 0 0 0.5vw 0;
  400. }
  401. .other_1 {
  402. .money {
  403. color: #ff0000 !important;
  404. }
  405. text {
  406. font-size: 13px;
  407. color: #858585;
  408. }
  409. text:last-child {
  410. color: #000000;
  411. }
  412. }
  413. }
  414. }
  415. .list:last-child {
  416. margin: 0;
  417. }
  418. }
  419. }
  420. .two {
  421. margin: 2vw;
  422. border: 1px solid #ff0000;
  423. border-radius: 5px;
  424. padding: 2vw;
  425. .two_1 {
  426. .picker {
  427. border: 1px solid #3333;
  428. border-radius: 5px;
  429. padding: 2vw;
  430. }
  431. .money {
  432. margin: 1vw 0 0 0;
  433. text {
  434. color: #ff0000;
  435. }
  436. text:last-child {
  437. color: #6A5ACD;
  438. }
  439. }
  440. .btn {
  441. text-align: center;
  442. }
  443. }
  444. .two_2 {
  445. .btn {
  446. text-align: center;
  447. button {
  448. background-color: var(--f35BColor);
  449. color: #fff;
  450. }
  451. }
  452. }
  453. }
  454. }
  455. </style>