service.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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 || '636221e5e25ed78601dd4fbb');
  87. that.$set(that, `status`, e && e.status || '3');
  88. that.watchLogin();
  89. },
  90. methods: {
  91. watchLogin() {
  92. const that = this;
  93. uni.getStorage({
  94. key: 'token',
  95. success: function(res) {
  96. let user = that.$jwt(res.data);
  97. if (user) {
  98. that.$set(that, `user`, user);
  99. that.search();
  100. }
  101. }
  102. })
  103. },
  104. async search() {
  105. const that = this;
  106. let id = that.id;
  107. console.log(id);
  108. let res = await that.$api(`/orderDetail/${id}`, 'GET')
  109. if (res.errcode == '0') {
  110. console.log(res.data);
  111. for (let val of res.data.goods) val.goods_name = val.goods.name;
  112. that.$set(that, `info`, res.data)
  113. } else {
  114. uni.showToast({
  115. title: res.errmsg,
  116. icon: 'none'
  117. })
  118. }
  119. },
  120. // 售后请求
  121. // 已收到货
  122. goodsChange(e) {
  123. const that = this;
  124. let data = that.info.goods[e.detail.value];
  125. console.log(data);
  126. },
  127. // 提交保存
  128. async onSubmit(ref) {
  129. const that = this;
  130. let status = that.status;
  131. that.$refs[ref].validate().then(params => {
  132. if (status == '3') {
  133. console.log('1');
  134. } else {
  135. that.orderCancel(params)
  136. }
  137. })
  138. },
  139. // 未收到货
  140. async orderCancel(e) {
  141. const that = this;
  142. e.order_detail = that.id;
  143. const res = await that.$api(`/afterSale/orderCancel`, 'POST', e);
  144. if (res.errcode == '0') {
  145. uni.showToast({
  146. title: `申请售后成功`,
  147. icon: 'success',
  148. });
  149. uni.navigateBack({
  150. detail: 1
  151. })
  152. } else {
  153. uni.showToast({
  154. title: res.errmsg,
  155. icon: 'none',
  156. })
  157. }
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss">
  163. .main {
  164. display: flex;
  165. flex-direction: column;
  166. width: 100vw;
  167. height: 100vh;
  168. .one {
  169. margin: 2vw;
  170. border: 1px solid #f1f1f1;
  171. border-radius: 5px;
  172. padding: 2vw;
  173. .one_1 {
  174. margin: 0 0 2vw 0;
  175. text {
  176. font-size: 16px;
  177. font-weight: bold;
  178. }
  179. }
  180. .one_2 {
  181. .list {
  182. display: flex;
  183. background-color: #f1f1f1;
  184. padding: 2vw;
  185. margin: 0 0 2vw 0;
  186. border-radius: 5px;
  187. .list_1 {
  188. width: 22vw;
  189. height: 22vw;
  190. border-radius: 5px;
  191. .image {
  192. width: 100%;
  193. height: 100%;
  194. border-radius: 5px;
  195. }
  196. }
  197. .list_2 {
  198. width: 63vw;
  199. padding: 0 0 0 2vw;
  200. .name {
  201. font-size: 16px;
  202. font-weight: bold;
  203. margin: 0 0 0.5vw 0;
  204. }
  205. .other_1 {
  206. text {
  207. font-size: 13px;
  208. color: #858585;
  209. }
  210. text:last-child {
  211. color: #000000;
  212. }
  213. }
  214. }
  215. }
  216. .list:last-child {
  217. margin: 0;
  218. }
  219. }
  220. }
  221. .two {
  222. margin: 2vw;
  223. border: 1px solid #ff0000;
  224. border-radius: 5px;
  225. padding: 2vw;
  226. .two_1 {}
  227. .two_2 {
  228. .btn {
  229. text-align: center;
  230. button {
  231. background-color: var(--f35BColor);
  232. color: #fff;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </style>