service.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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>¥{{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_id">
  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=='0'||thrform.type=='1'">
  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="icon">
  67. <upload :list="icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
  68. </uni-forms-item>
  69. <view class="btn">
  70. <button type="primary" size="mini" @click="onSubmit('form')">提交保存</button>
  71. </view>
  72. </uni-forms>
  73. </view>
  74. <view class="two_2" v-else>
  75. <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
  76. <uni-forms-item label="申请描述" name="desc">
  77. <uni-easyinput type="textarea" autoHeight v-model="form.desc" placeholder="请输入申请描述" />
  78. </uni-forms-item>
  79. <view class="btn">
  80. <button type="default" size="mini" @click="onSubmit('form')">提交保存</button>
  81. </view>
  82. </uni-forms>
  83. </view>
  84. </view>
  85. </view>
  86. </mobile-frame>
  87. </template>
  88. <script>
  89. import upload from '@/components/upload/index.vue';
  90. export default {
  91. components: {
  92. upload
  93. },
  94. data() {
  95. return {
  96. id: '',
  97. status: '',
  98. // 用户信息
  99. user: {},
  100. // 信息详情
  101. info: {},
  102. // 仅退款
  103. form: {},
  104. rules: {
  105. desc: {
  106. rules: [{
  107. required: true,
  108. errorMessage: '请输入申请描述',
  109. }]
  110. },
  111. },
  112. // 已收到货
  113. thrform: {},
  114. // 附件
  115. icon: [],
  116. // 最大退款数
  117. moneyInfo: {},
  118. thrrules: {
  119. type: {
  120. rules: [{
  121. required: true,
  122. errorMessage: '请选择售后类型',
  123. }]
  124. },
  125. goods_id: {
  126. rules: [{
  127. required: true,
  128. errorMessage: '请选择退款商品',
  129. }]
  130. },
  131. reason: {
  132. rules: [{
  133. required: true,
  134. errorMessage: '请选择申请理由',
  135. }]
  136. },
  137. },
  138. // 售后类型
  139. typeList: [],
  140. // 申请理由
  141. reasonList: [],
  142. };
  143. },
  144. onLoad: async function(e) {
  145. const that = this;
  146. that.$set(that, `id`, e && e.id || '636221e5e25ed78601dd4fbb');
  147. that.$set(that, `status`, e && e.status || '3');
  148. // 查询其他信息
  149. await that.searchOther();
  150. // 监听用户登录
  151. await that.watchLogin();
  152. },
  153. methods: {
  154. watchLogin() {
  155. const that = this;
  156. uni.getStorage({
  157. key: 'token',
  158. success: function(res) {
  159. let user = that.$jwt(res.data);
  160. if (user) {
  161. that.$set(that, `user`, user);
  162. that.search();
  163. }
  164. },
  165. fail: function() {
  166. uni.navigateTo({
  167. url: `/pages/login/index`
  168. })
  169. }
  170. })
  171. },
  172. async search() {
  173. const that = this;
  174. let id = that.id;
  175. console.log(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_id`, 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 != '2') {
  206. if (thrform.goods_id) {
  207. const arr = await that.$api(`/afterSale/cgfr`, 'POST', {
  208. order_detail: that.id,
  209. goods_id: thrform.goods_id
  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, `${e.name}`, [...that[e.name], e.data]);
  251. },
  252. // 图片删除
  253. uplDel(e) {
  254. const that = this;
  255. let data = that[e.name];
  256. let arr = data.filter((i, index) => index != e.data.index);
  257. that.$set(that, `${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. let money = that.moneyInfo.payTotal;
  269. that.$refs[ref].validate().then(params => {
  270. if (status == '3') {
  271. if (params.type != '2')
  272. if (params.money) {
  273. if (parseFloat(params.money) > parseFloat(money)) {
  274. uni.showToast({
  275. title: '输入金额不能超过实际支付金额',
  276. icon: 'none'
  277. })
  278. } else {
  279. params.file = that.icon;
  280. params.order_detail = that.id;
  281. console.log(params);
  282. }
  283. } else {
  284. uni.showToast({
  285. title: `请输入退款金额`,
  286. icon: 'none',
  287. });
  288. }
  289. } else {
  290. that.orderCancel(params)
  291. }
  292. })
  293. },
  294. // 未收到货
  295. async orderCancel(e) {
  296. const that = this;
  297. e.order_detail = that.id;
  298. const res = await that.$api(`/afterSale/orderCancel`, 'POST', e);
  299. if (res.errcode == '0') {
  300. uni.showToast({
  301. title: `申请售后成功`,
  302. icon: 'success',
  303. });
  304. uni.navigateBack({
  305. detail: 1
  306. })
  307. } else {
  308. uni.showToast({
  309. title: res.errmsg,
  310. icon: 'none',
  311. })
  312. }
  313. },
  314. // 查询其他信息
  315. async searchOther() {
  316. const that = this;
  317. let res;
  318. res = await that.$api(`/dictData`, 'GET', {
  319. code: "afterSale_type"
  320. });
  321. if (res.errcode == '0') {
  322. let type = res.data.filter(i => i.value != '4' && i.value != '5')
  323. that.$set(that, `typeList`, type)
  324. }
  325. res = await that.$api(`/dictData`, 'GET', {
  326. code: "afterSale_reason"
  327. });
  328. if (res.errcode == '0') {
  329. that.$set(that, `reasonList`, res.data)
  330. }
  331. }
  332. }
  333. }
  334. </script>
  335. <style lang="scss">
  336. .main {
  337. display: flex;
  338. flex-direction: column;
  339. width: 100vw;
  340. height: 100vh;
  341. .one {
  342. margin: 2vw;
  343. border: 1px solid #f1f1f1;
  344. border-radius: 5px;
  345. padding: 2vw;
  346. .one_1 {
  347. margin: 0 0 2vw 0;
  348. text {
  349. font-size: 16px;
  350. font-weight: bold;
  351. }
  352. }
  353. .one_2 {
  354. .list {
  355. display: flex;
  356. background-color: #f1f1f1;
  357. padding: 2vw;
  358. margin: 0 0 2vw 0;
  359. border-radius: 5px;
  360. .list_1 {
  361. width: 22vw;
  362. height: 22vw;
  363. border-radius: 5px;
  364. .image {
  365. width: 100%;
  366. height: 100%;
  367. border-radius: 5px;
  368. }
  369. }
  370. .list_2 {
  371. width: 63vw;
  372. padding: 0 0 0 2vw;
  373. .name {
  374. font-size: 16px;
  375. font-weight: bold;
  376. margin: 0 0 0.5vw 0;
  377. }
  378. .other_1 {
  379. text {
  380. font-size: 13px;
  381. color: #858585;
  382. }
  383. text:last-child {
  384. color: #000000;
  385. }
  386. }
  387. }
  388. }
  389. .list:last-child {
  390. margin: 0;
  391. }
  392. }
  393. }
  394. .two {
  395. margin: 2vw;
  396. border: 1px solid #ff0000;
  397. border-radius: 5px;
  398. padding: 2vw;
  399. .two_1 {
  400. .picker {
  401. border: 1px solid #3333;
  402. border-radius: 5px;
  403. padding: 2vw;
  404. }
  405. .money {
  406. margin: 1vw 0 0 0;
  407. text {
  408. color: #ff0000;
  409. }
  410. text:last-child {
  411. color: #6A5ACD;
  412. }
  413. }
  414. .btn {
  415. text-align: center;
  416. }
  417. }
  418. .two_2 {
  419. .btn {
  420. text-align: center;
  421. button {
  422. background-color: var(--f35BColor);
  423. color: #fff;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. </style>