index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <view class="hotel-book">
  3. <!-- 自定义导航栏 -->
  4. <u-navbar :leftText='title' fixed safeAreaInsetTop :placeholder='true' :bgColor="bgColor" @leftClick='back'>
  5. </u-navbar>
  6. <!-- 背景图 -->
  7. <view class="hotel-book-img">
  8. <uni-swiper-dot :mode="mode" :info="info" :current="current1" :dots-styles="dotsStyles">
  9. <swiper class="swiper-box" @change="change1" circular>
  10. <swiper-item v-for="(item ,index) in info" :key="index" v-if="resource_type == 1 ">
  11. <view class="swiper-item">
  12. <image style="width: 100%;height:564rpx;" :src="item.img" mode="aspectFill"></image>
  13. </view>
  14. </swiper-item>
  15. <swiper-item v-if="resource_type == 2 ">
  16. <view class="swiper-item">
  17. <video class="baner-video" id="myVideo" ref="myVideo" style="width: 100%; height: 564rpx;"
  18. :src="video_url" controls :enable-progress-gesture="false">
  19. </video>
  20. </view>
  21. </swiper-item>
  22. </swiper>
  23. </uni-swiper-dot>
  24. </view>
  25. <!-- 酒店介绍 -->
  26. <view class="hotel-content">
  27. <view class="hotel-content-top">
  28. <image style="width: 48rpx;height: 48rpx;" src="/static/icon/local01.png" mode=""></image>
  29. <view class="hotel-content-top-text">
  30. <text>{{hotelDetail.name}}</text>
  31. </view>
  32. </view>
  33. <view class="hotel-content-introduce">
  34. <view class="introduce-top">
  35. <text class="introduce-top-rule1"></text>
  36. <text style="margin: 0 8rpx;">酒店介绍</text>
  37. <text class="introduce-top-rule2"></text>
  38. </view>
  39. <view class="introduce-btn-text introduce-btn">
  40. <view v-html="hotelDetail.details"></view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="hotel-btn">
  45. <view class="hotel-btn-left">
  46. <view class="hotel-btn-left-text" @click="goIndex">
  47. <view style="width: 48rpx;height: 48rpx;display: flex;align-items: center;justify-content: center;">
  48. <image style="width: 40rpx;height: 42rpx;" src="/static/icon/home04.png" mode=""></image>
  49. </view>
  50. <text>首页</text>
  51. </view>
  52. <view class="hotel-btn-left-text" @click="goJoin">
  53. <view
  54. style="width: 48rpx;height: 48rpx; display: flex;align-items: center;justify-content: center; ">
  55. <image style="width: 52rpx;height: 46rpx;" src="/static/icon/vip02.png" mode=""></image>
  56. </view>
  57. <text>会员</text>
  58. </view>
  59. <view class="hotel-btn-left-text" @click="goLocaltion">
  60. <view style="width: 48rpx;height: 48rpx;display: flex;align-items: center;justify-content: center;">
  61. <image style=" width: 44rpx;height: 44rpx;" src="/static/icon/home03.png" mode=""></image>
  62. </view>
  63. <text>导航</text>
  64. </view>
  65. </view>
  66. <view class="hotel-btn-right" @click="goJump">
  67. <text>预订</text>
  68. </view>
  69. </view>
  70. <!-- 弹出层/核销码 -->
  71. <dialogPanel ref="dialogPanel"/>
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. data() {
  77. return {
  78. //轮播图
  79. info: [],
  80. //自定义导航栏
  81. bgColor: '#fff',
  82. title: '',
  83. //酒店id
  84. hotel_id: '',
  85. hotelDetail: '',
  86. jump_type: '',
  87. jump_config: '',
  88. resource_type: '',
  89. video_url: '',
  90. //指示点显示位置
  91. dotsStyles: {
  92. backgroundColor: 'rgba(255, 255, 255, .3)',
  93. border: '1px rgba(255, 255, 255, .3) solid',
  94. color: '#fff',
  95. selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
  96. selectedBorder: '1px rgba(255, 255, 255, 1) solid'
  97. },
  98. //指示点显示位置
  99. current1: 0,
  100. mode: 'dot',
  101. hotel:{},
  102. }
  103. },
  104. onReady: function(res) {
  105. this.videoContext = uni.createVideoContext('myVideo')
  106. },
  107. onLoad(params) {
  108. if(!this.$store.getters.userInfo){
  109. uni.redirectTo({
  110. url: '/pages/login/login'
  111. })
  112. }
  113. if (params?.hotel_id) {
  114. params.address = params.address == 'null' ? "" : params.address;
  115. this.hotel = params;
  116. this.hotel_id = params.hotel_id;
  117. this.getDetail()
  118. }
  119. },
  120. methods: {
  121. // 切换轮播图指示点
  122. change1(e) {
  123. this.current1 = e.detail.current;
  124. },
  125. //视频自动播放
  126. openVideoPlay() {
  127. this.videoContext.play()
  128. },
  129. //返回上一级
  130. back() {
  131. const pages = getCurrentPages();
  132. if (pages.length === 2) {
  133. uni.navigateBack({
  134. delta: 1
  135. });
  136. } else if (pages.length === 1) {
  137. uni.switchTab({
  138. url: '/pages/index/index',
  139. })
  140. } else {
  141. uni.navigateBack({
  142. delta: 1
  143. });
  144. }
  145. },
  146. //预约跳转
  147. goJump() {
  148. if(this.hotelDetail.reserve_jump_type == 3){
  149. this.$refs.dialogPanel.show(this.hotelDetail.reserve_jump_config);
  150. return
  151. }
  152. this.$utils.jump({
  153. jump_type: this.hotelDetail.reserve_jump_type,
  154. jump_config: this.hotelDetail.reserve_jump_config
  155. })
  156. },
  157. //获取酒店详情
  158. getDetail() {
  159. this.$api.hotel.getHotelDetail({
  160. hotel_id: this.hotel_id
  161. }).then(res => {
  162. this.hotelDetail = res.data
  163. this.title = res.data.name
  164. this.info = JSON.parse(res.data.img_urls).map(item => {
  165. return {
  166. img: item
  167. }
  168. })
  169. //跳转h5和小程序
  170. this.jump_type = res.data.jump_type,
  171. this.jump_config = res.data.jump_config
  172. //banner展示视频或者图片
  173. this.resource_type = res.data.resource_type
  174. this.video_url = res.data.video_url
  175. console.log(this.video_url, '--->this.video_url');
  176. //视频自动播放
  177. this.openVideoPlay()
  178. })
  179. },
  180. // 跳转其他小程序
  181. goJoin() {
  182. wx.navigateToMiniProgram({
  183. appId: 'wx255b58f0992b3c53', //appid
  184. path: 'newUIMain/enrollment/enrollment', //path
  185. extraData: { //参数
  186. foo: 'bar'
  187. },
  188. // envVersion: 'develop', //开发版develop 开发版 trial 体验版 release 正式版
  189. success(res) {
  190. console.log('成功')
  191. // 打开成功
  192. },
  193. fail(e) {
  194. console.log(e, '失败')
  195. }
  196. })
  197. },
  198. // 跳转首页
  199. goIndex() {
  200. uni.reLaunch({
  201. url: '/pages/index/index'
  202. })
  203. },
  204. goLocaltion(){
  205. console.log(this.hotel)
  206. uni.openLocation({
  207. type: "gcj02",
  208. latitude: parseFloat(this.hotel.latitude), // 纬度,浮点数,范围为90 ~ -90
  209. longitude: parseFloat(this.hotel.longitude), // 经度,浮点数,范围为180 ~ -180。
  210. scale: 12, // 地图缩放级别,整形值,范围从1~28。默认为最大
  211. name: this.hotel.name, // 位置名
  212. address: this.hotel.address, // 地址详情说明
  213. })
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. $pageColor:#F9F9F9;
  220. $bgColor:#FFFFFF;
  221. @mixin flexlayout {
  222. display: flex;
  223. align-items: center;
  224. justify-content: center;
  225. }
  226. .hotel-book {
  227. height: 100%;
  228. background: #fff;
  229. }
  230. .hotel-book-img {
  231. height: 564rpx;
  232. .swiper-box {
  233. height: 564rpx;
  234. }
  235. }
  236. .hotel-btn {
  237. padding: 0 30rpx;
  238. position: fixed;
  239. bottom: 0;
  240. width: 100%;
  241. height: 148rpx;
  242. background: #FFFFFF;
  243. box-shadow: 0px -2rpx 20rpx 0px rgba(0, 0, 0, 0.04);
  244. display: flex;
  245. align-items: center;
  246. justify-content: space-between;
  247. .hotel-btn-left {
  248. display: flex;
  249. align-items: center;
  250. justify-content: space-between;
  251. .hotel-btn-left-text {
  252. display: flex;
  253. flex-direction: column;
  254. align-items: center;
  255. justify-content: flex-start;
  256. font-weight: 500;
  257. color: #999999;
  258. font-size: 22rpx;
  259. margin-right: 48rpx;
  260. }
  261. }
  262. .hotel-btn-right {
  263. width: 396rpx;
  264. height: 92rpx;
  265. background: linear-gradient(270deg, #FF6200 0%, #FF9342 100%);
  266. border-radius: 12rpx;
  267. display: flex;
  268. align-items: center;
  269. justify-content: center;
  270. font-weight: bold;
  271. color: #FFFFFF;
  272. font-size: 30rpx;
  273. }
  274. }
  275. .hotel-content {
  276. width: 100%;
  277. padding: 40rpx 30rpx 100rpx;
  278. .hotel-content-top {
  279. height: 48rpx;
  280. display: flex;
  281. align-items: center;
  282. justify-content: flex-start;
  283. .hotel-content-top-text {
  284. margin-top: -2rpx;
  285. font-weight: bold;
  286. color: #333333;
  287. font-size: 32rpx;
  288. margin-left: 8rpx;
  289. }
  290. }
  291. .hotel-content-introduce {
  292. margin-top: 32rpx;
  293. padding: 48rpx 22rpx;
  294. background: #FFFFFF;
  295. border-radius: 4rpx;
  296. border: 2rpx solid #999999;
  297. margin-bottom: 100rpx;
  298. }
  299. }
  300. .introduce-top {
  301. height: 32rpx;
  302. display: flex;
  303. align-items: center;
  304. justify-content: center;
  305. font-size: 32rpx;
  306. font-weight: bold;
  307. letter-spacing: 2rpx;
  308. .introduce-top-rule1 {
  309. width: 56rpx;
  310. height: 4rpx;
  311. background: linear-gradient(90deg, #FFFFFF 0%, #D9A94D 100%);
  312. }
  313. .introduce-top-rule2 {
  314. width: 56rpx;
  315. height: 4rpx;
  316. background: linear-gradient(-90deg, #FFFFFF 0%, #D9A94D 100%);
  317. }
  318. }
  319. .introduce-btn-text {
  320. margin-top: 72rpx;
  321. font-size: 28rpx;
  322. color: #333;
  323. font-weight: bold;
  324. line-height: 56rpx;
  325. }
  326. .introduce-btn {
  327. margin-top: 72rpx;
  328. width: 100%;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. font-size: 30rpx;
  333. color: #101010;
  334. font-weight: bold;
  335. }
  336. </style>