index.vue 8.7 KB

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