service.vue 6.3 KB

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