service.vue 11 KB

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