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