oftenRoute.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="center">
  3. <view class="">
  4. <view class="" v-for="(item,index) in routeData">
  5. {{item.sendCity ? item.sendCity: item.sendProvince}} {{item.sendArea}} ----> {{item.unloadCity ? item.unloadCity: item.unloadProvince}} {{item.unloadArea}}
  6. <view class="" @click="addRoute(item)">修改</view>
  7. <view class="" @click="del(item.id)">删除</view>
  8. </view>
  9. </view>
  10. <view class="">
  11. <u-button type="primary" @click="addRoute(1)">创建常用路线</u-button>
  12. </view>
  13. <u-toast ref="uToast"></u-toast>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. routeData: []
  21. }
  22. },
  23. onShow() {},
  24. onLoad() {
  25. this.getList()
  26. },
  27. methods: {
  28. del(ids) {
  29. this.$request.baseRequest('post', '/commonRoute/api/delete', {
  30. id: ids
  31. }).then(res => {
  32. if (res.code == 200) {
  33. this.$refs.uToast.show({
  34. type: 'success',
  35. message: "删除成功!",
  36. })
  37. this.getList()
  38. }
  39. })
  40. .catch(res => {
  41. uni.$u.toast(res.message);
  42. });
  43. },
  44. getList() {
  45. this.$request.baseRequest('get', '/commonRoute/select', {
  46. commonId: uni.getStorageSync("firstAuthentication").id,
  47. pageSize: 10,
  48. currentPage: 1
  49. }).then(res => {
  50. if (res.code == 200) {
  51. this.routeData = res.data.records
  52. }
  53. })
  54. .catch(res => {
  55. uni.$u.toast(res.message);
  56. });
  57. },
  58. addRoute(item) {
  59. if(item == 1 && this.routeData.length == 50){
  60. this.$refs.uToast.show({
  61. type: 'success',
  62. message: "最多可创建50条常用路线!",
  63. })
  64. }else{
  65. uni.$u.route("pages/mine/often/addRoute", {
  66. id: item.id
  67. })
  68. }
  69. },
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. </style>