service.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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=='0'||thrform.type=='1'">
  48. <uni-easyinput type="digit" v-model="thrform.money" @input="toMoney" placeholder="请输入退款金额" />
  49. <view>
  50. 最大退款金额不能超过{{moneyInfo.payTotal||0}}
  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="icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
  63. </uni-forms-item>
  64. <view class="btn">
  65. <button type="primary" size="mini" @click="onSubmit('form')">提交保存</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. thrrules: {},
  110. // 售后类型
  111. typeList: [],
  112. // 申请理由
  113. reasonList: [],
  114. };
  115. },
  116. onLoad: async function(e) {
  117. const that = this;
  118. that.$set(that, `id`, e && e.id || '636221e5e25ed78601dd4fbb');
  119. that.$set(that, `status`, e && e.status || '3');
  120. // 查询其他信息
  121. await that.searchOther();
  122. // 监听用户登录
  123. await that.watchLogin();
  124. },
  125. methods: {
  126. watchLogin() {
  127. const that = this;
  128. uni.getStorage({
  129. key: 'token',
  130. success: function(res) {
  131. let user = that.$jwt(res.data);
  132. if (user) {
  133. that.$set(that, `user`, user);
  134. that.search();
  135. }
  136. },
  137. fail: function() {
  138. uni.navigateTo({
  139. url: `/pages/login/index`
  140. })
  141. }
  142. })
  143. },
  144. async search() {
  145. const that = this;
  146. let id = that.id;
  147. console.log(id);
  148. let res = await that.$api(`/orderDetail/${id}`, 'GET')
  149. if (res.errcode == '0') {
  150. for (let val of res.data.goods) val.goods_name = val.goods.name;
  151. that.$set(that, `info`, res.data)
  152. } else {
  153. uni.showToast({
  154. title: res.errmsg,
  155. icon: 'none'
  156. })
  157. }
  158. },
  159. // 售后请求
  160. // 已收到货
  161. goodsChange(e) {
  162. const that = this;
  163. let data = that.info.goods[e.detail.value];
  164. if (data) that.$set(that.info, `goods`, [data])
  165. that.$set(that.thrform, `goods_name`, data.goods_name);
  166. },
  167. // 选择售后类型
  168. async typeChange(e) {
  169. const that = this;
  170. let data = that.typeList[e.detail.value];
  171. if (data) {
  172. that.$set(that.form, `type`, data.value);
  173. that.$set(that.form, `type_name`, data.label);
  174. }
  175. if (data.value != '2') {
  176. const arr = await that.$api(`/afterSale/cgfr`, 'POST', {
  177. order_detail: that.id,
  178. goods_id: that.info._id
  179. });
  180. if (arr.errcode == '0') {
  181. that.$set(that, `moneyInfo`, arr.data);
  182. } else {
  183. uni.showToast({
  184. title: arr.errmsg,
  185. icon: 'none',
  186. })
  187. }
  188. }
  189. },
  190. // 选择申请理由
  191. reasonChange(e) {
  192. const that = this;
  193. let data = that.reasonList[e.detail.value];
  194. if (data) {
  195. that.$set(that.thrform, `reason`, data.value);
  196. that.$set(that.thrform, `reason_name`, data.label);
  197. }
  198. },
  199. // 退款金额
  200. toMoney(value) {
  201. const that = this;
  202. let money = that.moneyInfo.payTotal;
  203. if (parseFloat(value) > parseFloat(money)) {
  204. uni.showToast({
  205. title: '输入金额不能超过实际支付金额',
  206. icon: 'none'
  207. })
  208. }
  209. },
  210. // 图片上传
  211. uplSuc(e) {
  212. const that = this;
  213. that.$set(that, `${e.name}`, [...that[e.name], e.data]);
  214. },
  215. // 图片删除
  216. uplDel(e) {
  217. const that = this;
  218. let data = that[e.name];
  219. let arr = data.filter((i, index) => index != e.data.index);
  220. that.$set(that, `${e.name}`, arr)
  221. },
  222. // 提交保存
  223. async onSubmit(ref) {
  224. const that = this;
  225. let status = that.status;
  226. let money = that.moneyInfo.payTotal;
  227. that.$refs[ref].validate().then(params => {
  228. if (status == '3') {
  229. if (parseFloat(params.money) > parseFloat(money)) {
  230. uni.showToast({
  231. title: '输入金额不能超过实际支付金额',
  232. icon: 'none'
  233. })
  234. } else {
  235. console.log(params);
  236. }
  237. } else {
  238. that.orderCancel(params)
  239. }
  240. })
  241. },
  242. // 未收到货
  243. async orderCancel(e) {
  244. const that = this;
  245. e.order_detail = that.id;
  246. const res = await that.$api(`/afterSale/orderCancel`, 'POST', e);
  247. if (res.errcode == '0') {
  248. uni.showToast({
  249. title: `申请售后成功`,
  250. icon: 'success',
  251. });
  252. uni.navigateBack({
  253. detail: 1
  254. })
  255. } else {
  256. uni.showToast({
  257. title: res.errmsg,
  258. icon: 'none',
  259. })
  260. }
  261. },
  262. // 查询其他信息
  263. async searchOther() {
  264. const that = this;
  265. let res;
  266. res = await that.$api(`/dictData`, 'GET', {
  267. code: "afterSale_type"
  268. });
  269. if (res.errcode == '0') {
  270. let type = res.data.filter(i => i.value != '4' && i.value != '5')
  271. that.$set(that, `typeList`, type)
  272. }
  273. res = await that.$api(`/dictData`, 'GET', {
  274. code: "afterSale_reason"
  275. });
  276. if (res.errcode == '0') {
  277. that.$set(that, `reasonList`, res.data)
  278. }
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .main {
  285. display: flex;
  286. flex-direction: column;
  287. width: 100vw;
  288. height: 100vh;
  289. .one {
  290. margin: 2vw;
  291. border: 1px solid #f1f1f1;
  292. border-radius: 5px;
  293. padding: 2vw;
  294. .one_1 {
  295. margin: 0 0 2vw 0;
  296. text {
  297. font-size: 16px;
  298. font-weight: bold;
  299. }
  300. }
  301. .one_2 {
  302. .list {
  303. display: flex;
  304. background-color: #f1f1f1;
  305. padding: 2vw;
  306. margin: 0 0 2vw 0;
  307. border-radius: 5px;
  308. .list_1 {
  309. width: 22vw;
  310. height: 22vw;
  311. border-radius: 5px;
  312. .image {
  313. width: 100%;
  314. height: 100%;
  315. border-radius: 5px;
  316. }
  317. }
  318. .list_2 {
  319. width: 63vw;
  320. padding: 0 0 0 2vw;
  321. .name {
  322. font-size: 16px;
  323. font-weight: bold;
  324. margin: 0 0 0.5vw 0;
  325. }
  326. .other_1 {
  327. text {
  328. font-size: 13px;
  329. color: #858585;
  330. }
  331. text:last-child {
  332. color: #000000;
  333. }
  334. }
  335. }
  336. }
  337. .list:last-child {
  338. margin: 0;
  339. }
  340. }
  341. }
  342. .two {
  343. margin: 2vw;
  344. border: 1px solid #ff0000;
  345. border-radius: 5px;
  346. padding: 2vw;
  347. .two_1 {
  348. .picker {
  349. border: 1px solid #3333;
  350. border-radius: 5px;
  351. padding: 2vw;
  352. }
  353. .btn {
  354. text-align: center;
  355. }
  356. }
  357. .two_2 {
  358. .btn {
  359. text-align: center;
  360. button {
  361. background-color: var(--f35BColor);
  362. color: #fff;
  363. }
  364. }
  365. }
  366. }
  367. }
  368. </style>