service.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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>
  43. </view>
  44. <view class="two_2" v-else>
  45. <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
  46. <uni-forms-item label="申请描述" name="desc">
  47. <uni-easyinput type="textarea" autoHeight v-model="form.desc" placeholder="请输入申请描述" />
  48. </uni-forms-item>
  49. <view class="btn">
  50. <button type="default" size="mini" @click="onSubmit('form')">提交保存</button>
  51. </view>
  52. </uni-forms>
  53. </view>
  54. </view>
  55. </view>
  56. </mobile-frame>
  57. </template>
  58. <script>
  59. export default {
  60. components: {},
  61. data() {
  62. return {
  63. id: '',
  64. status: '',
  65. // 用户信息
  66. user: {},
  67. // 信息详情
  68. info: {},
  69. // 仅退款
  70. form: {},
  71. rules: {
  72. desc: {
  73. rules: [{
  74. required: true,
  75. errorMessage: '请输入申请描述',
  76. }]
  77. },
  78. },
  79. // 已收到货
  80. thrform: {},
  81. thrrules: {}
  82. };
  83. },
  84. onLoad: async function(e) {
  85. const that = this;
  86. that.$set(that, `id`, e && e.id || '6361ceb683473c0322151aa8');
  87. that.$set(that, `status`, e && e.status || '3');
  88. console.log(e);
  89. that.watchLogin();
  90. },
  91. methods: {
  92. watchLogin() {
  93. const that = this;
  94. uni.getStorage({
  95. key: 'token',
  96. success: function(res) {
  97. let user = that.$jwt(res.data);
  98. if (user) {
  99. that.$set(that, `user`, user);
  100. that.search();
  101. }
  102. }
  103. })
  104. },
  105. async search() {
  106. const that = this;
  107. let id = that.id;
  108. let res = await that.$api(`/orderDetail/${id}`, 'GET')
  109. if (res.errcode == '0') {
  110. for (let val of res.data.goods) val.goods_name = val.goods.name;
  111. that.$set(that, `info`, res.data)
  112. } else {
  113. uni.showToast({
  114. title: res.errmsg,
  115. icon: 'none'
  116. })
  117. }
  118. },
  119. // 售后请求
  120. // 已收到货
  121. goodsChange(e) {
  122. const that = this;
  123. let data = that.info.goods[e.detail.value];
  124. console.log(data);
  125. },
  126. // 提交保存
  127. async onSubmit(ref) {
  128. const that = this;
  129. let status = that.status;
  130. that.$refs[ref].validate().then(params => {
  131. if (status == '3') {
  132. console.log('1');
  133. } else {
  134. that.orderCancel(params)
  135. }
  136. })
  137. },
  138. // 未收到货
  139. async orderCancel(e) {
  140. const that = this;
  141. e.order_detail = that.id;
  142. const res = await that.$api(`/afterSale/orderCancel`, 'POST', e);
  143. if (res.errcode == '0') {
  144. uni.showToast({
  145. title: `申请售后成功`,
  146. icon: 'success',
  147. });
  148. uni.navigateBack({
  149. detail: 1
  150. })
  151. } else {
  152. uni.showToast({
  153. title: res.errmsg,
  154. icon: 'none',
  155. })
  156. }
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="scss">
  162. .main {
  163. display: flex;
  164. flex-direction: column;
  165. width: 100vw;
  166. height: 100vh;
  167. .one {
  168. margin: 2vw;
  169. border: 1px solid #f1f1f1;
  170. border-radius: 5px;
  171. padding: 2vw;
  172. .one_1 {
  173. margin: 0 0 2vw 0;
  174. text {
  175. font-size: 16px;
  176. font-weight: bold;
  177. }
  178. }
  179. .one_2 {
  180. .list {
  181. display: flex;
  182. background-color: #f1f1f1;
  183. padding: 2vw;
  184. margin: 0 0 2vw 0;
  185. border-radius: 5px;
  186. .list_1 {
  187. width: 22vw;
  188. height: 22vw;
  189. border-radius: 5px;
  190. .image {
  191. width: 100%;
  192. height: 100%;
  193. border-radius: 5px;
  194. }
  195. }
  196. .list_2 {
  197. width: 63vw;
  198. padding: 0 0 0 2vw;
  199. .name {
  200. font-size: 16px;
  201. font-weight: bold;
  202. margin: 0 0 0.5vw 0;
  203. }
  204. .other_1 {
  205. text {
  206. font-size: 13px;
  207. color: #858585;
  208. }
  209. text:last-child {
  210. color: #000000;
  211. }
  212. }
  213. }
  214. }
  215. .list:last-child {
  216. margin: 0;
  217. }
  218. }
  219. }
  220. .two {
  221. margin: 2vw;
  222. border: 1px solid #ff0000;
  223. border-radius: 5px;
  224. padding: 2vw;
  225. .two_1 {}
  226. .two_2 {
  227. .btn {
  228. text-align: center;
  229. button {
  230. background-color: var(--f35BColor);
  231. color: #fff;
  232. }
  233. }
  234. }
  235. }
  236. }
  237. </style>