service.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="list" v-if="info._id">
  6. <view class="list_1">
  7. <text>退款商品</text>
  8. </view>
  9. <view class="list_2">
  10. <view class="l">
  11. <image class="image"
  12. :src="info.goods.file&&info.goods.file.length>0?info.goods.file[0].url:''" mode="">
  13. </image>
  14. </view>
  15. <view class="c">
  16. <view class="name">
  17. {{info.goods.name}}
  18. </view>
  19. <view class="specs">
  20. {{info.name}}
  21. </view>
  22. </view>
  23. <view class="r">
  24. <view v-if="type=='0'" class="price">
  25. ¥{{info.sell_money}}
  26. </view>
  27. <view v-else class="price">
  28. ¥{{info.group_config.money}}
  29. </view>
  30. <view class="num">
  31. ×{{info.buy_num}}
  32. </view>
  33. <view class="money" v-if="moneyInfo.payTotal">
  34. <view class="">商品总价:{{moneyInfo.goodsTotal}}</view>
  35. <view class="">优惠减免:{{moneyInfo.discountTotal}}</view>
  36. <view class="">运费总价:{{moneyInfo.freightTotal}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="two">
  43. <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
  44. <uni-forms-item label="退款商品" name="goods_id">
  45. <picker class="picker" mode="selector" :range="goodsList" @change="goodsChange"
  46. range-key="name">
  47. <view>{{form.goods_name||'请选择退款商品'}}</view>
  48. </picker>
  49. </uni-forms-item>
  50. <uni-forms-item label="售后类型" name="type" v-if="info._id">
  51. <picker class="picker" mode="selector" :range="typeList" @change="typeChange" range-key="label">
  52. <view>{{form.type_name||'请选择售后类型'}}</view>
  53. </picker>
  54. </uni-forms-item>
  55. <uni-forms-item label="退款金额" name="money" v-if="form.type=='0'||form.type=='1'">
  56. <uni-easyinput type="digit" v-model="form.money" @input="toMoney" placeholder="请输入退款金额" />
  57. <view>
  58. 最大退款金额不能超过{{moneyInfo.payTotal||'暂无'}}
  59. </view>
  60. </uni-forms-item>
  61. <uni-forms-item label="申请理由" name="reason">
  62. <picker class="picker" mode="selector" :range="reasonList" @change="reasonChange"
  63. range-key="label">
  64. <view>{{form.reason_name||'请选择申请理由'}}</view>
  65. </picker>
  66. </uni-forms-item>
  67. <uni-forms-item label="申请售后描述" name="desc">
  68. <uni-easyinput type="textarea" v-model="form.desc" placeholder="请输入申请售后描述" />
  69. </uni-forms-item>
  70. <uni-forms-item label="附件" name="icon">
  71. <upload :list="icon" name="icon" :count="1" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
  72. </uni-forms-item>
  73. <view class="btn">
  74. <button v-if="money_num=='0'" type="primary" size="mini" @click="onSubmit('form')">提交保存</button>
  75. </view>
  76. </uni-forms>
  77. </view>
  78. </view>
  79. </mobile-frame>
  80. </template>
  81. <script>
  82. import upload from '@/components/upload/index.vue';
  83. export default {
  84. components: {
  85. upload
  86. },
  87. data() {
  88. return {
  89. id: '',
  90. // 订单类型
  91. type:'',
  92. user: {},
  93. // 商品详情
  94. info: {},
  95. form: {},
  96. moneyInfo: {},
  97. // 退货商品
  98. goodsList: [],
  99. icon: [],
  100. rules: {
  101. type: {
  102. rules: [{
  103. required: true,
  104. errorMessage: '请选择售后类型',
  105. }]
  106. },
  107. goods_id: {
  108. rules: [{
  109. required: true,
  110. errorMessage: '请选择退款商品',
  111. }]
  112. },
  113. reason: {
  114. rules: [{
  115. required: true,
  116. errorMessage: '请选择申请理由',
  117. }]
  118. },
  119. },
  120. // 售后类型
  121. typeList: [],
  122. // 申请理由
  123. reasonList: [],
  124. money_num: '0'
  125. };
  126. },
  127. onLoad: async function(e) {
  128. const that = this;
  129. that.$set(that, `id`, e && e.id || '');
  130. // 查询其他信息
  131. await that.searchOther();
  132. // 监听用户登录
  133. await that.watchLogin();
  134. },
  135. methods: {
  136. // 退款金额
  137. toMoney(value) {
  138. const that = this;
  139. let money = that.moneyInfo.payTotal;
  140. if (parseFloat(value) > parseFloat(money)) {
  141. uni.showToast({
  142. title: '输入金额不能超过实际支付金额',
  143. icon: 'none'
  144. })
  145. that.$set(that, `money_num`, '1');
  146. } else {
  147. that.$set(that, `money_num`, '0');
  148. }
  149. },
  150. // 选择售后类型
  151. async typeChange(e) {
  152. const that = this;
  153. let data = that.typeList[e.detail.value];
  154. if (data) {
  155. that.$set(that.form, `type`, data.value);
  156. that.$set(that.form, `type_name`, data.label);
  157. }
  158. if (data.value != '2') {
  159. const arr = await that.$api(`/afterSale/cgfr`, 'POST', {
  160. order_detail: that.id,
  161. goods_id: that.info._id
  162. });
  163. if (arr.errcode == '0') {
  164. that.$set(that, `moneyInfo`, arr.data);
  165. } else {
  166. uni.showToast({
  167. title: arr.errmsg,
  168. icon: 'none',
  169. })
  170. }
  171. }
  172. },
  173. // 退款商品
  174. goodsChange(e) {
  175. const that = this;
  176. let data = that.goodsList[e.detail.value];
  177. if (data) {
  178. that.$set(that, `info`, data);
  179. that.$set(that.form, `goods_id`, data._id);
  180. that.$set(that.form, `goods_name`, data.name);
  181. }
  182. },
  183. // 选择申请理由
  184. reasonChange(e) {
  185. const that = this;
  186. let data = that.reasonList[e.detail.value];
  187. if (data) {
  188. that.$set(that.form, `reason`, data.value);
  189. that.$set(that.form, `reason_name`, data.label);
  190. }
  191. },
  192. // 图片上传
  193. uplSuc(e) {
  194. const that = this;
  195. that.$set(that, `${e.name}`, [...that[e.name], e.data]);
  196. },
  197. // 图片删除
  198. uplDel(e) {
  199. const that = this;
  200. let data = that[e.name];
  201. let arr = data.filter((i, index) => index != e.data.index);
  202. that.$set(that, `${e.name}`, arr)
  203. },
  204. // 提交保存
  205. async onSubmit(ref) {
  206. const that = this;
  207. that.$refs[ref].validate().then(async params => {
  208. if (params.type != '2') {
  209. if (params.money) {
  210. params.file = that.icon;
  211. params.order_detail = that.id;
  212. const arr = await that.$api(`/afterSale`, 'POST', params);
  213. if (arr.errcode == '0') {
  214. uni.showToast({
  215. title: `申请售后成功`,
  216. icon: 'success',
  217. });
  218. uni.navigateBack({
  219. detail: 1
  220. })
  221. } else {
  222. uni.showToast({
  223. title: arr.errmsg,
  224. icon: 'none',
  225. })
  226. }
  227. } else {
  228. uni.showToast({
  229. title: `请输入退款金额`,
  230. icon: 'none',
  231. });
  232. }
  233. } else {
  234. params.file = that.icon;
  235. params.order_detail = that.id;
  236. const arr = await that.$api(`/afterSale`, 'POST', params);
  237. if (arr.errcode == '0') {
  238. uni.showToast({
  239. title: `申请售后成功`,
  240. icon: 'success',
  241. });
  242. uni.navigateBack({
  243. detail: 1
  244. })
  245. } else {
  246. uni.showToast({
  247. title: arr.errmsg,
  248. icon: 'none',
  249. })
  250. }
  251. }
  252. })
  253. },
  254. // 查询其他信息
  255. async searchOther() {
  256. const that = this;
  257. let res;
  258. res = await that.$api(`/dictData`, 'GET', {
  259. code: "afterSale_type"
  260. });
  261. if (res.errcode == '0') {
  262. that.$set(that, `typeList`, res.data)
  263. }
  264. res = await that.$api(`/dictData`, 'GET', {
  265. code: "afterSale_reason"
  266. });
  267. if (res.errcode == '0') {
  268. that.$set(that, `reasonList`, res.data)
  269. }
  270. },
  271. // 监听用户是否登录
  272. watchLogin() {
  273. const that = this;
  274. uni.getStorage({
  275. key: 'token',
  276. success: async function(res) {
  277. let user = that.$jwt(res.data);
  278. if (user) {
  279. that.$set(that, `user`, user);
  280. if (that.id) {
  281. let arr = await that.$api(`/orderDetail/${that.id}`, 'GET')
  282. if (arr.errcode == '0') {
  283. that.$set(that, `goodsList`, arr.data.goods)
  284. that.$set(that, `type`, arr.data.type)
  285. }
  286. }
  287. }
  288. },
  289. fail: function(err) {
  290. uni.reLaunch({
  291. url: '/pages/login/index'
  292. })
  293. }
  294. })
  295. },
  296. }
  297. }
  298. </script>
  299. <style lang="scss">
  300. .main {
  301. .one {
  302. .list {
  303. margin: 2vw;
  304. padding: 2vw;
  305. border-radius: 2vw;
  306. border: 1px solid #3333;
  307. .list_1 {
  308. margin: 0 0 1vw 0;
  309. display: flex;
  310. flex-direction: row;
  311. justify-content: space-between;
  312. font-size: var(--font14Size);
  313. font-weight: bold;
  314. }
  315. .list_2 {
  316. margin: 0 0 1vw 0;
  317. display: flex;
  318. .l {
  319. width: 20vw;
  320. .image {
  321. width: 100%;
  322. height: 20vw;
  323. border-radius: 5px;
  324. }
  325. }
  326. .c {
  327. width: 50vw;
  328. padding: 0 2vw;
  329. .specs{
  330. color: var(--f85Color);
  331. font-size: var(--font12Size);
  332. }
  333. }
  334. .r {
  335. width: 25vw;
  336. text-align: right;
  337. .money {
  338. color: var(--f85Color);
  339. font-size: var(--font12Size);
  340. }
  341. }
  342. }
  343. .other {
  344. margin: 0 0 2vw 0;
  345. text-align: right;
  346. text {
  347. font-size: 14px;
  348. padding: 0 0 0 2vw;
  349. }
  350. }
  351. .btn {
  352. text-align: right;
  353. margin: 2vw 0 0 0;
  354. border-top: 1px solid #f1fff1;
  355. button {
  356. margin: 2vw 0 0 2vw;
  357. }
  358. }
  359. }
  360. }
  361. .two {
  362. padding: 2vw;
  363. .picker {
  364. border: 1px solid #3333;
  365. border-radius: 5px;
  366. padding: 2vw;
  367. }
  368. .btn {
  369. text-align: center;
  370. button {
  371. width: 30%;
  372. font-size: 14px;
  373. background-color: var(--f35BColor);
  374. }
  375. }
  376. }
  377. }
  378. .uni-forms-item {
  379. margin-bottom: 6vw !important;
  380. display: flex;
  381. flex-direction: row;
  382. }
  383. </style>