index.vue 9.1 KB

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