oftenRoute.vue 2.0 KB

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