my-pathList.vue 4.0 KB

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