my-pathList.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="main-path uni-row" :style="style ? style : 'justify-content: space-evenly;'" v-for="num of pathListLen" :key="'row-' + num">
  3. <template v-for="(item, index) in pathList['row'+ num]" :key="'row-' + num + '-' + index">
  4. <view v-if="item.type == 1 || item.type == 2">
  5. <image mode="aspectFit" class="pathimg" :src="item.img" @click="onPathImgClick(item)">
  6. </image>
  7. </view>
  8. <view v-if="item.type == 3" class="path-nav uni-row uni-aie">
  9. <image mode="aspectFit" class="pathimg2" :src="item.pathImg" @click="onPathImgClick(item, 'path')">
  10. </image>
  11. <view class="uni-column">
  12. <image mode="aspectFit" class="navimg" :src="item.navImg" @click="onPathImgClick(item, 'nav')"></image>
  13. <text class="navtext">(导航)</text>
  14. </view>
  15. </view>
  16. </template>
  17. <view v-if="showLine && num < pathListLen" class="line"></view>
  18. </view>
  19. </template>
  20. <script>
  21. import tools from '/common/tools';
  22. export default {
  23. name:"my-pathList",
  24. props: {
  25. pathList: {},
  26. mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  27. showLine: false ,// 是否显示线条
  28. style: ""
  29. },
  30. data() {
  31. return {
  32. navPoint: {},
  33. };
  34. },
  35. computed: {
  36. pathListLen() {
  37. return Object.keys(this.pathList).length;
  38. }
  39. },
  40. methods: {
  41. onPathImgClick(item, type='') {
  42. //item.type 1: 比赛路线 2: 导航到指定地点
  43. if (item.type == 1) {
  44. this.dealPathClick(item);
  45. } else if (item.type == 2) {
  46. this.dealNavClick(item);
  47. } else if (item.type == 3) {
  48. if (type == 'path') {
  49. this.dealPathClick(item);
  50. } else if (type == 'nav') {
  51. this.dealNavClick(item);
  52. }
  53. }
  54. },
  55. dealPathClick(item) {
  56. // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  57. if (this.mcState == 1) {
  58. const url = `action://to_detail/?id=${item.path.ocaId}&matchType=${item.path.mcType}`;
  59. // window.location.href = url;
  60. tools.appAction(url);
  61. } else if (this.mcState == 0) {
  62. uni.showToast({
  63. title: '比赛尚未开始',
  64. icon: 'none',
  65. duration: 3000
  66. });
  67. } else if (this.mcState == 2) {
  68. uni.showToast({
  69. title: '比赛已结束',
  70. icon: 'none',
  71. duration: 3000
  72. });
  73. }
  74. },
  75. dealNavClick(item) {
  76. this.navPoint = item.point;
  77. // this.$refs.mypopupmap.popupOpen();
  78. const url =
  79. `action://to_map_app?title=${this.navPoint.name}&latitude=${this.navPoint.latitude}&longitude=${this.navPoint.longitude}`;
  80. // window.location.href = url;
  81. tools.appAction(url);
  82. }
  83. }
  84. }
  85. </script>
  86. <style scoped>
  87. .pathimg {
  88. width: 127px;
  89. height: 115px;
  90. }
  91. .pathimg2 {
  92. width: 106px;
  93. height: 80px;
  94. }
  95. .navimg {
  96. width: 25px;
  97. height: 25px;
  98. }
  99. .navtext {
  100. font-weight: 500;
  101. color: #aaaaaa;
  102. font-size: 10px;
  103. font-family: Source Han Sans CN;
  104. }
  105. .main-path {
  106. width: 90%;
  107. margin-top: 10px;
  108. margin-bottom: 10px;
  109. flex-wrap: wrap;
  110. /* justify-content: flex-start; */
  111. /* justify-content: space-evenly; */
  112. }
  113. .path-nav {
  114. width: 50%;
  115. justify-content: center;
  116. }
  117. .line {
  118. width: 100%;
  119. height: 0px;
  120. margin: 20px 5% 0 5%;
  121. border: 1px dashed;
  122. border-color: #c6c6c6;
  123. }
  124. </style>