service.vue 7.1 KB

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