noService.vue 9.3 KB

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