index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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}}
  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. // uni.navigateTo({
  95. // url: '/pagesMain/contractInfo?memberCardId=1&couponId=&studentId=2628'
  96. // });
  97. },
  98. onPullDownRefresh() {
  99. this.initialize()
  100. setTimeout(() => {
  101. uni.stopPullDownRefresh();
  102. }, 500)
  103. },
  104. methods: {
  105. // 获取初始化数据
  106. initialize() {
  107. NET.request(API.getIndexSwiperList, {}, 'POST').then(res => {
  108. this.swiperList = res.data
  109. }).catch(error => {
  110. this.$refs.uTips.show({
  111. title: error.message,
  112. type: 'warning',
  113. })
  114. })
  115. NET.request(API.getAddressInfo, uni.getStorageSync('locationData'), 'POST').then(res => {
  116. this.locationText = res.data.province + '-' + res.data.city + '-' + res.data.district
  117. }).catch(error => {
  118. this.$refs.uTips.show({
  119. title: error.message,
  120. type: 'warning',
  121. })
  122. })
  123. NET.request(API.getVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  124. this.venueList = res.data
  125. }).catch(error => {
  126. this.$refs.uTips.show({
  127. title: error.message,
  128. type: 'warning',
  129. })
  130. })
  131. NET.request(API.getVideoList, uni.getStorageSync('locationData'), 'POST').then(res => {
  132. this.videoList = res.data
  133. }).catch(error => {
  134. this.$refs.uTips.show({
  135. title: error.message,
  136. type: 'warning',
  137. })
  138. })
  139. },
  140. // 跳转场馆详情
  141. goToVenueDetail(item) {
  142. uni.navigateTo({
  143. url: '/pagesMember/venueDetail?id=' + item.id
  144. });
  145. },
  146. },
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. @import "@/static/css/themes.scss";
  151. .content {
  152. width: 100%;
  153. float: left;
  154. /deep/.u-navbar {
  155. .u-title {
  156. font-weight: bold;
  157. }
  158. }
  159. .section-title {
  160. width: 100%;
  161. height: 28px;
  162. display: flex;
  163. align-items: center;
  164. margin-top: 20px;
  165. padding: 0 15px;
  166. u-section {
  167. margin-left: 10px;
  168. flex: 1;
  169. }
  170. }
  171. .venue-box {
  172. width: 100vw;
  173. float: left;
  174. padding-left: 5px;
  175. overflow-x: auto;
  176. white-space: nowrap;
  177. /deep/.u-card--border:after {
  178. border-color: #cccccc;
  179. border-radius: 15px;
  180. }
  181. .venue-card {
  182. min-width: 70vw;
  183. display: inline-block;
  184. .venue-content {
  185. padding: 0px 25px 10px 15px;
  186. .venue-name {
  187. height: 20px;
  188. font-weight: bold;
  189. font-size: 15px;
  190. line-height: 20px;
  191. }
  192. .info-text {
  193. color: #999999;
  194. line-height: 18px;
  195. /deep/.u-icon {
  196. margin-right: 5px;
  197. font-size: 14px;
  198. }
  199. }
  200. }
  201. }
  202. }
  203. .video-box {
  204. width: 100vw;
  205. float: left;
  206. box-sizing: border-box;
  207. padding: 10px 7px 0px 7px;
  208. .video-card {
  209. width: calc(50% - 16px);
  210. margin: 0 8px 16px 8px;
  211. float: left;
  212. .video-col {
  213. width: 100%;
  214. height: 30vw;
  215. float: left;
  216. border-radius: 10px;
  217. overflow: hidden;
  218. video {
  219. width: 100%;
  220. height: 30vw;
  221. }
  222. }
  223. .video-name {
  224. width: 100%;
  225. float: left;
  226. text-align: center;
  227. line-height: 20px;
  228. font-size: 14px;
  229. margin-top: 5px;
  230. }
  231. }
  232. }
  233. }
  234. </style>