service.vue 6.9 KB

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