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