index.vue 9.3 KB

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