index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="content">
  3. <!-- 导航栏 -->
  4. <u-navbar :is-back="false">
  5. <view class="slot-wrap">
  6. <view @click="show = true">{{ locationText }}</view>
  7. <!-- <u-select v-model="show" mode="mutil-column-auto" :list="list" @confirm="confirm"></u-select> -->
  8. <u-picker mode="region" v-model="show" @confirm="handleChoosePlaceClick"></u-picker>
  9. </view>
  10. </u-navbar>
  11. <!-- 轮播图 -->
  12. <u-swiper :list="swiperList" mode="rect" height="300" effect3d border-radius="30" name="url" style="margin-bottom: 10px;"></u-swiper>
  13. <!-- <view class="section-title">
  14. <u-image width="20px" height="10px" :src="sectionIcon"></u-image>
  15. <u-section title="会员开通" font-size="32" :right="false" :show-line="false"></u-section>
  16. </view>
  17. <view class="menber-box">
  18. <view class="menber-col" v-for="(item, index) in menberList" :key="index" @click="goToPay(item)">
  19. <view class="menber-label">{{item.typeValue}}</view>
  20. <u-button type="warning" shape="circle" :ripple="true" :custom-style="{...handleCustomStyle, float: 'left', marginLeft: ''}" size="mini" @click="goToPay(item)">点击开通</u-button>
  21. <view class="menber-icon iconfont iconzu4931"></view>
  22. </view>
  23. </view> -->
  24. <!-- 会员开通 -->
  25. <view class="section-title">
  26. <u-image width="20px" height="10px" :src="sectionIcon"></u-image>
  27. <u-section title="会员开通" font-size="32" :show-line="false" @click="handleMoreClick"></u-section>
  28. </view>
  29. <view class="venue-box">
  30. <u-card :head-border-bottom="false" :foot-border-top="false" title-size="32" padding="0" margin="10px" v-for="(item, index) in venueList"
  31. :key="index" class="venue-card" @click="goToVenueDetail(item)">
  32. <view class="venue-content" slot="head" style="padding-top: 10px;">
  33. <view class="venue-name">{{item.name}}</view>
  34. </view>
  35. <view class="venue-content" slot="body">
  36. <view class="info-text" v-if="item.distance">
  37. <u-icon name="car"></u-icon>
  38. 距您{{item.distance}}
  39. </view>
  40. <view class="info-text">
  41. <u-icon name="map"></u-icon>
  42. {{item.address}}
  43. </view>
  44. </view>
  45. <view class="venue-content" slot="foot" style="text-align: right;">
  46. <u-button type="warning" shape="circle" :ripple="true" :custom-style="handleCustomStyle" size="mini" @click="goToVenueDetail(item)">预约</u-button>
  47. </view>
  48. </u-card>
  49. </view>
  50. <!-- 精彩瞬间 -->
  51. <view class="section-title">
  52. <u-image width="20px" height="10px" :src="sectionIcon"></u-image>
  53. <u-section title="精彩瞬间" font-size="32" :right="false" :show-line="false"></u-section>
  54. </view>
  55. <view class="video-box">
  56. <view v-for="(item, index) in videoList" :key="index" class="video-card">
  57. <view class="video-col">
  58. <video :src="item.url" object-fit="cover" controls :id="'video' + index"></video>
  59. </view>
  60. <!-- <u-image :src="item.url" mode="aspectFill" height="30vw" border-radius="10px"></u-image> -->
  61. <view class="video-name">{{item.title}}</view>
  62. </view>
  63. </view>
  64. <u-top-tips ref="uTips"></u-top-tips>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. mapGetters
  70. } from 'vuex'
  71. const NET = require('@/utils/request')
  72. const API = require('@/config/api')
  73. export default {
  74. computed: {
  75. ...mapGetters([
  76. 'mainColor',
  77. 'handleCustomStyle',
  78. ])
  79. },
  80. data() {
  81. return {
  82. show: false,
  83. sectionIcon: API.getServerImg + 'biaoti.png',
  84. longitude: '',
  85. latitude: '',
  86. locationText: '',
  87. swiperList: [],
  88. venueList: [],
  89. videoList: []
  90. }
  91. },
  92. onLoad(options) {
  93. if (options.shareParams) {
  94. // 分享获取参数
  95. const shareParams = decodeURIComponent(options.shareParams)
  96. const shareId = shareParams.split(':')[0]
  97. const shareType = shareParams.split(':')[1]
  98. NET.request(API.getQrcodeInfo, {shareId,shareType}, 'POST').then(res => {
  99. if(res.status == 50000) {
  100. this.$refs.uTips.show({
  101. title: res.message,
  102. type: 'warning',
  103. })
  104. }
  105. })
  106. // console.log(options.shareParams)
  107. // wx.setStorage({//存储到本地
  108. // key:"shareParams",
  109. // data:options.shareParams
  110. // })
  111. }
  112. // setTimeout(()=>{
  113. // let videoContext = uni.createVideoContext('video1')
  114. // videoContext.play()
  115. // console.log(12)
  116. // },6000)
  117. uni.getLocation({
  118. type: 'wgs84',
  119. geocode: true,
  120. success: (res) => {
  121. uni.setStorage({
  122. key: 'locationData',
  123. data: {
  124. longitude: res.longitude,
  125. latitude: res.latitude,
  126. }
  127. })
  128. this.initialize()
  129. }
  130. });
  131. },
  132. onShow() {
  133. // if (!uni.getStorageSync('token')) {
  134. // uni.navigateTo({
  135. // url: '/pages/login/index'
  136. // });
  137. // }
  138. },
  139. onPullDownRefresh() {
  140. this.initialize()
  141. setTimeout(() => {
  142. uni.stopPullDownRefresh();
  143. }, 500)
  144. },
  145. methods: {
  146. // 选择省市区
  147. handleChoosePlaceClick(e) {
  148. console.log(e);
  149. this.locationText = e.province.label + '-' + e.city.label + '-' + e.area.label
  150. const provinceCode = e.province.value + '0000'
  151. const cityCode = e.city.value + '00'
  152. const district = e.area.value
  153. NET.request(API.getCodeVenueList, { provinceCode, cityCode, district }, 'POST').then(res => {
  154. const venueData = res.data.map( item => {
  155. return {
  156. id: item.venueId,
  157. name: item.name,
  158. address: item.detailedAddress
  159. }
  160. })
  161. this.venueList = venueData.length <= 4 ? venueData : venueData.slice(0,4)
  162. })
  163. },
  164. // 获取初始化数据
  165. initialize() {
  166. // 轮播图
  167. NET.request(API.getIndexSwiperList, {}, 'POST').then(res => {
  168. this.swiperList = res.data
  169. }).catch(error => {
  170. this.$refs.uTips.show({
  171. title: error.message,
  172. type: 'warning',
  173. })
  174. })
  175. // 省-市-区
  176. NET.request(API.getAddressInfo, uni.getStorageSync('locationData'), 'POST').then(res => {
  177. this.locationText = res.data.province + '-' + res.data.city + '-' + res.data.district
  178. }).catch(error => {
  179. this.$refs.uTips.show({
  180. title: error.message,
  181. type: 'warning',
  182. })
  183. })
  184. // 附件场馆
  185. NET.request(API.getVenueList, uni.getStorageSync('locationData'), 'POST').then(res => {
  186. const venueData = res.data
  187. this.venueList = venueData.length <= 4 ? venueData : venueData.slice(0,4)
  188. }).catch(error => {
  189. this.$refs.uTips.show({
  190. title: error.message,
  191. type: 'warning',
  192. })
  193. })
  194. // 精彩瞬间
  195. NET.request(API.getVideoList, uni.getStorageSync('locationData'), 'POST').then(res => {
  196. const videoData = res.data
  197. // 取4个精彩瞬间
  198. this.videoList = videoData.length <= 4 ? videoData : videoData.slice(0,4)
  199. }).catch(error => {
  200. this.$refs.uTips.show({
  201. title: error.message,
  202. type: 'warning',
  203. })
  204. })
  205. },
  206. // 更多场馆
  207. handleMoreClick() {
  208. uni.navigateTo({
  209. url: '/pagesMember/venueMore'
  210. });
  211. },
  212. // 跳转开通支付
  213. // goToPay(site) {
  214. // uni.navigateTo({
  215. // url: '/pagesMain/openMember?memberCardType=' + site.type + '&typeValue=' + site.typeValue
  216. // });
  217. // },
  218. // 跳转场馆详情
  219. goToVenueDetail(item) {
  220. uni.navigateTo({
  221. url: '/pagesMember/venueDetail?id=' + item.id
  222. });
  223. },
  224. },
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. @import "@/static/css/themes.scss";
  229. .content {
  230. width: 100%;
  231. float: left;
  232. // /deep/.u-navbar {
  233. // .u-title {
  234. // font-weight: bold;
  235. // }
  236. // }
  237. .slot-wrap {
  238. display: flex;
  239. align-items: center;
  240. /* 如果您想让slot内容占满整个导航栏的宽度 */
  241. flex: 1;
  242. /* 如果您想让slot内容与导航栏左右有空隙 */
  243. padding: 0 30rpx;
  244. }
  245. .section-title {
  246. width: 100%;
  247. height: 28px;
  248. display: flex;
  249. align-items: center;
  250. margin-top: 20px;
  251. padding: 0 15px;
  252. u-section {
  253. margin-left: 10px;
  254. flex: 1;
  255. }
  256. }
  257. .menber-box {
  258. width: 100vw;
  259. float: left;
  260. padding-left: 5px;
  261. overflow-x: auto;
  262. white-space: nowrap;
  263. .menber-col {
  264. width: 70vw;
  265. margin: 10px 15px;
  266. padding: 15px 20px;
  267. display: inline-block;
  268. background-color: #FFFFFF;
  269. border-radius: 15px;
  270. box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
  271. position: relative;
  272. overflow: hidden;
  273. .menber-label {
  274. width: 100%;
  275. margin-bottom: 10px;
  276. float: left;
  277. font-size: 14px;
  278. font-weight: bold;
  279. line-height: 20px;
  280. }
  281. .menber-num {
  282. width: 100%;
  283. float: left;
  284. font-size: 26px;
  285. line-height: 28px;
  286. color: $mainColor;
  287. }
  288. .menber-icon {
  289. font-size: 80px;
  290. color: $mainColor;
  291. position: absolute;
  292. right: -15px;
  293. bottom: -15x;
  294. opacity: 0.5;
  295. }
  296. }
  297. }
  298. .venue-box {
  299. width: 100vw;
  300. float: left;
  301. padding-left: 5px;
  302. overflow-x: auto;
  303. white-space: nowrap;
  304. /deep/.u-card--border:after {
  305. border-color: #cccccc;
  306. border-radius: 15px;
  307. }
  308. .venue-card {
  309. min-width: 70vw;
  310. display: inline-block;
  311. .venue-content {
  312. padding: 0px 15px 10px 15px;
  313. .venue-name {
  314. height: 20px;
  315. font-weight: bold;
  316. font-size: 15px;
  317. line-height: 20px;
  318. }
  319. .info-text {
  320. max-width: 60vw;
  321. overflow: hidden;
  322. white-space: nowrap;
  323. text-overflow: ellipsis;
  324. color: #999999;
  325. line-height: 18px;
  326. /deep/.u-icon {
  327. margin-right: 5px;
  328. font-size: 14px;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. .video-box {
  335. width: 100vw;
  336. float: left;
  337. box-sizing: border-box;
  338. padding: 10px 7px 0px 7px;
  339. .video-card {
  340. width: calc(50% - 16px);
  341. margin: 0 8px 16px 8px;
  342. float: left;
  343. .video-col {
  344. width: 100%;
  345. height: 30vw;
  346. float: left;
  347. border-radius: 10px;
  348. overflow: hidden;
  349. video {
  350. width: 100%;
  351. height: 30vw;
  352. }
  353. }
  354. .video-name {
  355. width: 100%;
  356. float: left;
  357. text-align: center;
  358. line-height: 20px;
  359. font-size: 14px;
  360. margin-top: 5px;
  361. }
  362. }
  363. }
  364. }
  365. </style>