my-pathList.vue 4.9 KB

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