index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view class="content">
  3. <u-navbar back-icon-size="0" :back-text="locationText" title="星火纵横" :title-color="mainColor" title-bold></u-navbar>
  4. <u-swiper :list="swiperList" mode="rect" effect3d border-radius="30" name="url" style="margin-bottom: 10px;"></u-swiper>
  5. <view class="section-title">
  6. <u-image width="20px" height="10px" :src="sectionIcon"></u-image>
  7. <u-section title="附近场馆" font-size="32" :right="false" :show-line="false"></u-section>
  8. </view>
  9. <view class="venue-box">
  10. <u-card :head-border-bottom="false" :show-foot="false" title-size="32" padding="0" margin="10px" v-for="(item, index) in venueList"
  11. :key="index" class="venue-card" @click="goToVenueDetail(item)">
  12. <view class="venue-content" slot="head" style="padding-top: 10px;">
  13. <view class="venue-name">{{item.name}}</view>
  14. </view>
  15. <view class="venue-content" slot="body">
  16. <view class="info-text">
  17. <u-icon name="car"></u-icon>
  18. 距您{{item.distance}}km
  19. </view>
  20. <view class="info-text">
  21. <u-icon name="map"></u-icon>
  22. {{item.address}}
  23. </view>
  24. </view>
  25. </u-card>
  26. </view>
  27. <view class="section-title">
  28. <u-image width="20px" height="10px" :src="sectionIcon"></u-image>
  29. <u-section title="精彩瞬间" font-size="32" :right="false" :show-line="false"></u-section>
  30. </view>
  31. <view class="video-box">
  32. <view v-for="(item, index) in videoList" :key="index" class="video-card">
  33. <view class="video-col">
  34. <video :src="item.url" object-fit="cover" controls></video>
  35. </view>
  36. <!-- <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px"></u-image> -->
  37. <view class="video-name">{{item.title}}</view>
  38. </view>
  39. </view>
  40. <u-top-tips ref="uTips"></u-top-tips>
  41. </view>
  42. </template>
  43. <script>
  44. import {
  45. mapGetters
  46. } from 'vuex'
  47. const NET = require('@/utils/request')
  48. const API = require('@/config/api')
  49. export default {
  50. computed: {
  51. ...mapGetters([
  52. 'mainColor',
  53. ])
  54. },
  55. data() {
  56. return {
  57. sectionIcon: API.getServerImg + 'biaoti.png',
  58. longitude: '',
  59. latitude: '',
  60. locationText: '',
  61. swiperList: [],
  62. venueList: [],
  63. videoList: []
  64. }
  65. },
  66. onLoad(options) {
  67. if (options.shareParams) {
  68. uni.setStorageSync({
  69. key: 'shareParams',
  70. data: options.shareParams
  71. })
  72. }
  73. uni.getLocation({
  74. type: 'wgs84',
  75. geocode: true,
  76. success: (res) => {
  77. uni.setStorage({
  78. key: 'locationData',
  79. data: {
  80. longitude: res.longitude,
  81. latitude: res.latitude,
  82. }
  83. })
  84. this.initialize()
  85. }
  86. });
  87. },
  88. onShow() {
  89. if (!uni.getStorageSync('token')) {
  90. uni.navigateTo({
  91. url: '/pages/login/index'
  92. });
  93. }
  94. },
  95. onPullDownRefresh() {
  96. this.initialize()
  97. setTimeout(() => {
  98. uni.stopPullDownRefresh();
  99. }, 500)
  100. },
  101. methods: {
  102. // 获取初始化数据
  103. initialize() {
  104. NET.request(API.getIndexSwiperList, {}, 'POST').then(res => {
  105. this.swiperList = res.data
  106. }).catch(error => {
  107. this.$refs.uTips.show({
  108. title: error.message,
  109. type: 'warning',
  110. })
  111. })
  112. NET.request(API.getAddressInfo, uni.getStorageSync('locationData'), 'POST').then(res => {
  113. this.locationText = res.data.province + '-' + res.data.city + '-' + res.data.district
  114. }).catch(error => {
  115. this.$refs.uTips.show({
  116. title: error.message,
  117. type: 'warning',
  118. })
  119. })
  120. NET.request(API.getVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  121. this.venueList = res.data
  122. }).catch(error => {
  123. this.$refs.uTips.show({
  124. title: error.message,
  125. type: 'warning',
  126. })
  127. })
  128. NET.request(API.getVideoList, uni.getStorageSync('locationData'), 'POST').then(res => {
  129. this.videoList = res.data
  130. }).catch(error => {
  131. this.$refs.uTips.show({
  132. title: error.message,
  133. type: 'warning',
  134. })
  135. })
  136. },
  137. // 跳转场馆详情
  138. goToVenueDetail(item) {
  139. uni.navigateTo({
  140. url: '/pagesMember/venueDetail?id=' + item.id
  141. });
  142. },
  143. },
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. @import "@/static/css/themes.scss";
  148. .content {
  149. width: 100%;
  150. float: left;
  151. /deep/.u-navbar {
  152. .u-title {
  153. font-weight: bold;
  154. }
  155. }
  156. .section-title {
  157. width: 100%;
  158. height: 28px;
  159. display: flex;
  160. align-items: center;
  161. margin-top: 20px;
  162. padding: 0 15px;
  163. u-section {
  164. margin-left: 10px;
  165. flex: 1;
  166. }
  167. }
  168. .venue-box {
  169. width: 100vw;
  170. float: left;
  171. padding-left: 5px;
  172. overflow-x: auto;
  173. white-space: nowrap;
  174. /deep/.u-card--border:after {
  175. border-color: #cccccc;
  176. border-radius: 15px;
  177. }
  178. .venue-card {
  179. min-width: 70vw;
  180. display: inline-block;
  181. .venue-content {
  182. padding: 0px 25px 10px 15px;
  183. .venue-name {
  184. height: 20px;
  185. font-weight: bold;
  186. font-size: 15px;
  187. line-height: 20px;
  188. }
  189. .info-text {
  190. color: #999999;
  191. line-height: 18px;
  192. /deep/.u-icon {
  193. margin-right: 5px;
  194. font-size: 14px;
  195. }
  196. }
  197. }
  198. }
  199. }
  200. .video-box {
  201. width: 100vw;
  202. float: left;
  203. box-sizing: border-box;
  204. padding: 10px 7px 0px 7px;
  205. .video-card {
  206. width: calc(50% - 16px);
  207. margin: 0 8px 16px 8px;
  208. float: left;
  209. .video-col {
  210. width: 100%;
  211. height: 30vw;
  212. float: left;
  213. border-radius: 10px;
  214. overflow: hidden;
  215. video {
  216. width: 100%;
  217. height: 30vw;
  218. }
  219. }
  220. .video-name {
  221. width: 100%;
  222. float: left;
  223. text-align: center;
  224. line-height: 20px;
  225. font-size: 14px;
  226. margin-top: 5px;
  227. }
  228. }
  229. }
  230. }
  231. </style>