my-pathList.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. isNewUser: false // 是否新用户
  49. },
  50. emits: ['onPathClick', 'onNewUserPathClick'],
  51. data() {
  52. return {
  53. navPoint: {},
  54. alertDialog: {
  55. content: "",
  56. data: null
  57. }
  58. };
  59. },
  60. computed: {
  61. pathListLen() {
  62. return Object.keys(this.pathList).length;
  63. }
  64. },
  65. mounted() {
  66. },
  67. methods: {
  68. onPathImgClick(item, type = '') {
  69. // console.log("onPathImgClick");
  70. //item.type 1: 比赛路线 2: 导航到指定地点
  71. if (item.type == 1) {
  72. this.dealPathClick(item);
  73. } else if (item.type == 2) {
  74. this.dealNavClick(item);
  75. } else if (item.type >= 3) {
  76. if (type == 'path') {
  77. this.dealPathClick(item);
  78. } else if (type == 'nav') {
  79. this.dealNavClick(item);
  80. }
  81. }
  82. },
  83. dealPathClick(item) {
  84. // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
  85. if (this.mcState == 1) {
  86. if (this.selectedPath > 0 && this.selectedPath != item.path.ocaId) {
  87. this.alertDialog.content = "该路线与您之前选择的不一致,确定要更换路线吗?"
  88. this.alertDialog.data = item;
  89. this.$refs.alertDialog.open();
  90. } else {
  91. this.startGame(item);
  92. }
  93. } else if (this.mcState == 0) {
  94. uni.showToast({
  95. title: '比赛尚未开始',
  96. icon: 'none',
  97. duration: 3000
  98. });
  99. } else if (this.mcState == 2) {
  100. uni.showToast({
  101. title: '比赛已结束',
  102. icon: 'none',
  103. duration: 3000
  104. });
  105. }
  106. },
  107. dealNavClick(item) {
  108. this.navPoint = item.point;
  109. // this.$refs.mypopupmap.popupOpen();
  110. const url =
  111. `action://to_map_app?title=${this.navPoint.name}&latitude=${this.navPoint.latitude}&longitude=${this.navPoint.longitude}`;
  112. tools.appAction(url);
  113. },
  114. dialogConfirm() {
  115. const item = this.alertDialog.data;
  116. this.startGame(item);
  117. },
  118. dialogClose() {
  119. },
  120. startGame(item) {
  121. if (this.isNewUser) {
  122. this.$emit('onNewUserPathClick', item);
  123. } else {
  124. this.to_detail(item);
  125. }
  126. },
  127. to_detail(item) {
  128. const url = `action://to_detail/?id=${item.path.ocaId}&matchType=${item.path.mcType}`;
  129. tools.appAction(url);
  130. this.$emit('onPathClick', item);
  131. },
  132. }
  133. }
  134. </script>
  135. <style scoped>
  136. .pathimg {
  137. width: 127px;
  138. height: 115px;
  139. }
  140. .pathimg2 {
  141. width: 106px;
  142. height: 80px;
  143. }
  144. .pathimg3 {
  145. width: 141px;
  146. height: 141px;
  147. }
  148. .pathName {
  149. font-weight: 500;
  150. color: #383838;
  151. font-size: 16px;
  152. line-height: 36px;
  153. font-family: Source Han Sans CN;
  154. }
  155. .navimg {
  156. width: 30px;
  157. height: 30px;
  158. }
  159. .navimg2 {
  160. width: 44px;
  161. height: 65px;
  162. margin-top: 20px;
  163. }
  164. .navtext {
  165. font-weight: 500;
  166. /* color: #aaaaaa; */
  167. color: #CE0202;
  168. font-size: 10px;
  169. font-family: Source Han Sans CN;
  170. white-space: nowrap;
  171. }
  172. .main-path {
  173. width: 90%;
  174. margin-top: 10px;
  175. margin-bottom: 10px;
  176. flex-wrap: wrap;
  177. /* justify-content: flex-start; */
  178. /* justify-content: space-evenly; */
  179. }
  180. .path-nav {
  181. width: 50%;
  182. justify-content: center;
  183. }
  184. .line {
  185. width: 100%;
  186. height: 0px;
  187. margin: 20px 5% 0 5%;
  188. border: 1px dashed;
  189. border-color: #c6c6c6;
  190. }
  191. </style>