after.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <view class="one_1">
  5. <image v-if="info.source&&info.source.file.length>0" class="image"
  6. :src="info.source.file&&info.source.file.length>0?info.source.file[0].url:''">
  7. </image>
  8. <image v-else class="image" :src="config.logo_url&&config.logo_url.length>0?config.logo_url[0].url:''">
  9. </image>
  10. <text v-if="info.type=='0'">酒店民宿</text>
  11. <text v-else>景区门票</text>
  12. </view>
  13. <view class="one_2">
  14. <view class="left">
  15. <image v-if="info.source&&info.source.file.length>0" class="image"
  16. :src="info.source.file&&info.source.file.length>0?info.source.file[0].url:''">
  17. </image>
  18. <image v-else class="image"
  19. :src="config.logo_url&&config.logo_url.length>0?config.logo_url[0].url:''">
  20. </image>
  21. </view>
  22. <view class="right">
  23. <view class="right_1">
  24. <view class="left">
  25. <view class="name textOver">{{info.source_name||'暂无'}}</view>
  26. <view class="other">{{info.zhType||'暂无'}}</view>
  27. <view class="other">{{info.zhPerson||'暂无'}}</view>
  28. </view>
  29. <view class="right">
  30. <view class="other">
  31. ¥{{info.source.money||'0'}}
  32. </view>
  33. <view class="other">
  34. ×{{info.num||'0'}}
  35. </view>
  36. </view>
  37. </view>
  38. <view class="right_2">
  39. 合计:¥{{info.money||'0'}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="two">
  45. <uni-forms class="form" ref="form" :rules="rules" :modelValue="form" label-position="top" label-width='100'>
  46. <uni-forms-item label="退款理由(必填)" required name="reason">
  47. <uni-easyinput type="textarea" v-model="form.reason" placeholder="请输入退款理由" />
  48. </uni-forms-item>
  49. <uni-forms-item label="上传图片0/3(选填)" name="file">
  50. <upload class='upload' :list="form.file" name="file" :count="3" @uplSuc="uplSuc" @uplDel="uplDel">
  51. </upload>
  52. </uni-forms-item>
  53. </uni-forms>
  54. <button class="button" type="primary" @click="submit('form')">提交</button>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import moment from 'moment';
  60. import upload from '../../components/upload/index.vue';
  61. export default {
  62. components: {
  63. upload
  64. },
  65. data() {
  66. return {
  67. id: '',
  68. config: {
  69. logo_url: []
  70. },
  71. user: {},
  72. info: {
  73. source: {
  74. file: []
  75. }
  76. },
  77. form: {
  78. file: []
  79. },
  80. statusList: [],
  81. personList: [],
  82. typeList: [],
  83. // 校验规则
  84. rules: {
  85. reason: {
  86. rules: [{
  87. required: true,
  88. errorMessage: '请输入退款理由'
  89. }]
  90. },
  91. },
  92. }
  93. },
  94. onLoad: async function(e) {
  95. const that = this;
  96. that.$set(that, `id`, e && e.id || '');
  97. that.searchConfig();
  98. that.searchToken();
  99. await that.searchOther();
  100. that.search();
  101. },
  102. methods: {
  103. searchConfig() {
  104. const that = this;
  105. try {
  106. const res = uni.getStorageSync('config');
  107. if (res) that.$set(that, `config`, res);
  108. } catch (e) {
  109. uni.showToast({
  110. title: err.errmsg,
  111. icon: 'error',
  112. duration: 2000
  113. });
  114. }
  115. },
  116. searchToken() {
  117. const that = this;
  118. try {
  119. const res = uni.getStorageSync('token');
  120. if (res) that.$set(that, `user`, res);
  121. } catch (e) {
  122. uni.showToast({
  123. title: err.errmsg,
  124. icon: 'error',
  125. duration: 2000
  126. });
  127. }
  128. },
  129. async search() {
  130. const that = this;
  131. if (that.id) {
  132. const res = await that.$api(`/order/${that.id}`, 'GET', {})
  133. if (res.errcode == '0') {
  134. const status = that.statusList.find(i => i.value == res.data.status)
  135. if (status) res.data.zhStatus = status.label
  136. if (res.data && res.data.source && res.data.source.person) {
  137. const person = that.personList.find(i => i.value == res.data.source.person)
  138. if (person) res.data.zhPerson = person.label
  139. }
  140. if (res.data && res.data.source && res.data.source.type) {
  141. const type = that.typeList.find(i => i.value == res.data.source.type)
  142. if (type) res.data.zhType = type.label
  143. }
  144. that.$set(that, `info`, res.data)
  145. } else {
  146. uni.showToast({
  147. title: res.errmsg,
  148. });
  149. }
  150. }
  151. },
  152. // 图片上传
  153. uplSuc(e) {
  154. const that = this;
  155. that.$set(that.form, `${e.name}`, [...that.form[e.name], e.data]);
  156. },
  157. // 图片删除
  158. uplDel(e) {
  159. const that = this;
  160. let data = that.form[e.name];
  161. let arr = data.filter((i, index) => index != e.data.index);
  162. that.$set(that.form, `${e.name}`, arr)
  163. },
  164. submit(ref) {
  165. const that = this;
  166. that.$refs[ref].validate().then(async data => {
  167. data.user = that.user._id
  168. data.order = that.id
  169. data.type = that.info.type
  170. data.apply_time = moment().format('YYYY-MM-DD HH:mm:ss')
  171. const res = await that.$api(`/afterSale`, 'POST', data);
  172. if (res.errcode == '0') {
  173. const arr = await that.$api(`/order/${that.id}`, 'POST', {
  174. status: "5"
  175. })
  176. if (arr.errcode == '0') {
  177. uni.showToast({
  178. title: '售后申请成功',
  179. icon: 'none'
  180. })
  181. uni.navigateBack({
  182. delta: 1
  183. })
  184. } else {
  185. uni.showToast({
  186. title: res.errmsg,
  187. });
  188. }
  189. } else {
  190. uni.showToast({
  191. title: res.errmsg,
  192. icon: 'none'
  193. })
  194. }
  195. }).catch(err => {
  196. console.log('err', err);
  197. })
  198. },
  199. // 查询其他信息
  200. async searchOther() {
  201. const that = this;
  202. let res;
  203. // 查询类型
  204. res = await that.$api(`/dictData`, 'GET', {
  205. type: 'order_status',
  206. is_use: '0',
  207. })
  208. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  209. // 出游人群
  210. res = await that.$api(`/dictData`, 'GET', {
  211. type: 'ticket_person',
  212. is_use: '0',
  213. })
  214. if (res.errcode == '0') that.$set(that, `personList`, res.data);
  215. // 服务特色
  216. res = await that.$api(`/dictData`, 'GET', {
  217. type: 'ticket_type',
  218. is_use: '0',
  219. })
  220. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  221. },
  222. }
  223. }
  224. </script>
  225. <style lang="scss" scoped>
  226. .main {
  227. .one {
  228. background-color: var(--mainColor);
  229. border-radius: 5px;
  230. margin: 2vw 2vw 0 2vw;
  231. padding: 2vw;
  232. border: 1px solid #d5d5da;
  233. .one_1 {
  234. display: flex;
  235. align-items: center;
  236. .image {
  237. width: 8vw;
  238. height: 8vw;
  239. border-radius: 8vw;
  240. }
  241. text {
  242. padding: 0 0 0 2vw;
  243. }
  244. }
  245. .one_2 {
  246. display: flex;
  247. justify-content: space-between;
  248. margin: 2vw 0 0 0;
  249. padding: 0 2vw;
  250. .left {
  251. width: 20vw;
  252. .image {
  253. width: 20vw;
  254. height: 20vw;
  255. border-radius: 1vw;
  256. }
  257. }
  258. .right {
  259. width: 65vw;
  260. margin: 0 0 0 2vw;
  261. .right_1 {
  262. display: flex;
  263. justify-content: space-between;
  264. .left {
  265. width: 55vw;
  266. .name {
  267. font-size: var(--font14Size);
  268. }
  269. .other {
  270. padding: 2px 0 0 0;
  271. font-size: var(--font12Size);
  272. color: var(--f85Color);
  273. }
  274. }
  275. .right {
  276. width: 10vw;
  277. text-align: right;
  278. .other {
  279. padding: 2px 0 0 0;
  280. font-size: var(--font12Size);
  281. color: var(--f85Color);
  282. }
  283. }
  284. }
  285. .right_2 {
  286. text-align: right;
  287. font-size: var(--font12Size);
  288. }
  289. }
  290. }
  291. }
  292. .two {
  293. padding: 2vw;
  294. .form-item {
  295. display: flex;
  296. align-items: center;
  297. }
  298. .button {
  299. background-color: var(--f3CColor);
  300. }
  301. }
  302. }
  303. </style>