service.vue 11 KB

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