my-pathList.vue 5.4 KB

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