home.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <view class="title">
  3. <text>源享住</text>
  4. </view>
  5. <view class="adv-pic">
  6. <swiper :indicator-dots="true" :autoplay="true" :interval="8000" :duration="1000" :circular="true">
  7. <swiper-item v-for="(item,index) in advPicList" :key="index">
  8. <image :src="item.image" mode="aspectFit"></image>
  9. </swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="hotel-name">
  13. <view class="hotel-name--fix" :style="[fixStyle]"></view>
  14. <view class="hotel-name--content" :style="[hotelNameFontSize]">
  15. <text>{{ hotel.name }}</text>
  16. </view>
  17. <view class="hotel-name--fix" @click="gotoSelectHotel" id="changeHotel">
  18. <image src="/static/switch.svg" style="width: 30rpx; height: 30rpx;"></image>
  19. 切换
  20. </view>
  21. </view>
  22. <view class="business">
  23. <view class="business-row">
  24. <view class="business-item" id="checkin"
  25. @click="navigateTo('/subpkg_checkin/selectCheckinType/selectCheckinType')">
  26. <view>
  27. <image src="/static/checkin.png" width="127rpx" height="116rpx"></image>
  28. </view>
  29. <text>入住</text>
  30. </view>
  31. <view class="business-item" id="extend" @click="navigateTo('/subpkg/extend/extend?fromExtend=true')">
  32. <view>
  33. <image src="/static/extend.png" width="127rpx" height="116rpx"></image>
  34. </view>
  35. <text>续住</text>
  36. </view>
  37. <view class="business-item" id="checkout" @click="navigateTo('/subpkg/extend/extend?fromExtend=false')">
  38. <view>
  39. <image src="/static/checkout.png" width="127rpx" height="116rpx"></image>
  40. </view>
  41. <text>退房</text>
  42. </view>
  43. </view>
  44. <view class="business-row">
  45. <view class="business-item" id="lift_qrcode"
  46. @click="gotoTlevatorControl('/subpkg/elevatorControl/elevatorControl')">
  47. <view>
  48. <image src="/static/lift_qrcode.png" width="127rpx" height="116rpx"></image>
  49. </view>
  50. <text>梯控二维码</text>
  51. </view>
  52. <view class="business-item" id="emergency_key" @click="navigateTo('/subpkg/emergencyKey/emergencyKey')">
  53. <view>
  54. <image src="/static/emergency_key.png" width="127rpx" height="116rpx"></image>
  55. </view>
  56. <text>手机开门</text>
  57. </view>
  58. <view class="business-item" id="shop" @click="showNotEnabled">
  59. <view>
  60. <image src="/static/shop.png" width="127rpx" height="116rpx"></image>
  61. </view>
  62. <text>客房超市</text>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="voucher" @click="navigateTo('/subpkg/voucherDesc/voucherDesc')" v-if="false">
  67. <image :src="voucherImg" mode="aspectFit" width="671rpx" height="181rpx"></image>
  68. </view>
  69. <guide :show="showGuide" :width="cWidth" :height="cHeight" :left="cLeft" :right="cRight" :top="cTop"
  70. :showMessage='cShowMsg' :currentIndex="currentIndex" :noticeArray="noticeArray" @click="clickNext">
  71. </guide>
  72. </template>
  73. <script setup>
  74. import {
  75. computed,
  76. ref,
  77. nextTick,
  78. getCurrentInstance
  79. } from 'vue';
  80. import {
  81. IMG_BASE_URL
  82. } from '../../config';
  83. import {
  84. useHotelStore
  85. } from '@/store/hotelStore.js'
  86. import {
  87. useUserStore
  88. } from '../../store/userStore';
  89. import {
  90. useAppInfoStore
  91. } from '../../store/appInfoStore.js'
  92. import {
  93. onLoad
  94. } from '@dcloudio/uni-app'
  95. import guide from '@/components/guide/guide.vue'
  96. let advPicList = [{
  97. image: IMG_BASE_URL + "/home_adv1.png",
  98. title: ""
  99. },
  100. {
  101. image: IMG_BASE_URL + "/home_adv2.png",
  102. title: ""
  103. }
  104. ]
  105. let hotel = useHotelStore().hotel
  106. let fixStyle = computed(() => {
  107. let style = {}
  108. if (hotel.hasOwnProperty('name') && hotel.name.length <= 14) return style
  109. style.display = "none"
  110. return style
  111. })
  112. let hotelNameFontSize = computed(() => {
  113. let style = {}
  114. if (hotel.hasOwnProperty('name') && hotel.name.length <= 14) return style
  115. style.fontSize = "30rpx"
  116. return style
  117. })
  118. function navigateTo(url) {
  119. if (url) {
  120. if (url !== "/subpkg_checkin/selectCheckinType/selectCheckinType") {
  121. if (!user.userInfo.idNumber) {
  122. uni.showModal({
  123. title: '身份信息未完善',
  124. content: '请至个人中心实名认证处完善个人信息',
  125. showCancel: false,
  126. success() {
  127. uni.switchTab({
  128. url: '/pages/my/my'
  129. })
  130. }
  131. })
  132. return
  133. }
  134. }
  135. uni.navigateTo({
  136. url: url,
  137. });
  138. }
  139. }
  140. function showNotEnabled() {
  141. uni.showModal({
  142. showCancel: false,
  143. content: "该酒店未开通此功能"
  144. })
  145. }
  146. function gotoSelectHotel() {
  147. uni.redirectTo({
  148. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  149. })
  150. }
  151. let voucherImg = IMG_BASE_URL + '/voucher.png'
  152. let showGuide = ref(false)
  153. let cShowMsg = ref('') // 展示的解释语
  154. let cWidth = ref('')
  155. let cHeight = ref('')
  156. let cLeft = ref('')
  157. let cRight = ref('')
  158. let cTop = ref('')
  159. let currentIndex = ref(0)
  160. //配置需要显示引导的view以及引导显示的msg
  161. let noticeArray = [{
  162. "showID": "changeHotel", // 对应的id
  163. "showMessage": "点击“切换” 选择您要入住的酒店", // 对应的解释文本
  164. "type": "bottom" // 解释框的气泡类型
  165. },
  166. {
  167. "showID": "checkin", // 对应的id
  168. "showMessage": "点击“入住”办理当前酒店入住流程", // 对应的解释文本
  169. "type": "bottom" // 解释框的气泡类型
  170. },
  171. {
  172. "showID": "extend",
  173. "showMessage": "点击“续住”办理当前房间续住流程",
  174. "type": "bottom"
  175. },
  176. {
  177. "showID": "checkout",
  178. "showMessage": "点击“退房”办理当前房间退房流程",
  179. "type": "bottom"
  180. },
  181. {
  182. "showID": "lift_qrcode",
  183. "showMessage": "如面部无法识别, 点击进入梯控二维码界面",
  184. "type": "bottom"
  185. },
  186. {
  187. "showID": "emergency_key",
  188. "showMessage": "如面部无法识别, 点击进入手机开门界面",
  189. "type": "bottom"
  190. },
  191. {
  192. "showID": "shop",
  193. "showMessage": "点击进入酒店小超市, 挑选心仪商品",
  194. "type": "bottom"
  195. }
  196. ]
  197. const instance = getCurrentInstance()
  198. function clickNext() {
  199. console.log('点击了下一个')
  200. currentIndex.value++;
  201. console.log('currentIndex.value', currentIndex.value)
  202. console.log('noticeArray.length', noticeArray.length)
  203. if (currentIndex.value >= noticeArray.length) {
  204. console.log('click next return')
  205. showGuide.value = false
  206. return
  207. }
  208. cShowMsg.value = noticeArray[currentIndex.value].showMessage;
  209. var idS = '#' + noticeArray[currentIndex.value].showID;
  210. console.log(idS)
  211. const query = uni.createSelectorQuery().in(instance);
  212. query.select(idS).boundingClientRect(data => {
  213. console.log("得到布局位置信息" + JSON.stringify(data));
  214. cWidth.value = data.width;
  215. cHeight.value = data.height;
  216. cLeft.value = data.left;
  217. cRight.value = data.right;
  218. cTop.value = data.top;
  219. }).exec();
  220. }
  221. const user = useUserStore()
  222. const appInfo = useAppInfoStore()
  223. onLoad(() => {
  224. if (!user.userInfo.openid) {
  225. uni.login({
  226. success: async (res) => {
  227. console.log('get openid', res)
  228. if (res.code) {
  229. //发起网络请求
  230. let getOpenidRes = await uni.request({
  231. url: '/user/weChatOpenid',
  232. method: 'POST',
  233. data: {
  234. code: res.code,
  235. appId: appInfo.appId
  236. }
  237. })
  238. if (getOpenidRes.data.success) {
  239. console.log("获取微信openId", getOpenidRes);
  240. user.updateUserInfo({
  241. ...user.userInfo,
  242. openid: getOpenidRes.data.data
  243. })
  244. }
  245. } else {
  246. console.log('登录失败!' + res.errMsg)
  247. }
  248. }
  249. })
  250. }
  251. if (uni.getStorageSync('showGuide') === '') {
  252. showGuide.value = true
  253. uni.setStorageSync('showGuide', 'false')
  254. nextTick(function() {
  255. if (currentIndex.value >= noticeArray.length) {
  256. showGuide.value = false;
  257. return;
  258. }
  259. // showGuide.value = true;
  260. cShowMsg.value = noticeArray[currentIndex.value].showMessage;
  261. var idS = '#' + noticeArray[currentIndex.value].showID;
  262. console.log(idS)
  263. //根据布局信息显示引导框位置
  264. const query = uni.createSelectorQuery().in(instance);
  265. query.select(idS).boundingClientRect(data => {
  266. console.log("得到布局位置信息" + JSON.stringify(data));
  267. cWidth.value = data.width;
  268. cHeight.value = data.height;
  269. cLeft.value = data.left;
  270. cRight.value = data.right;
  271. cTop.value = data.top;
  272. }).exec();
  273. });
  274. }
  275. })
  276. </script>
  277. <style lang="scss">
  278. page {
  279. background-color: #ffffff;
  280. }
  281. .title {
  282. z-index: 999;
  283. display: block;
  284. position: fixed;
  285. top: 80rpx;
  286. left: 30rpx;
  287. right: 30rpx;
  288. color: #ffffff;
  289. text-align: center;
  290. font-size: 40rpx;
  291. }
  292. .adv-pic {
  293. height: 540rpx;
  294. swiper {
  295. height: 540rpx;
  296. swiper-item {
  297. image {
  298. width: 100vw;
  299. height: 540rpx;
  300. }
  301. }
  302. }
  303. }
  304. .hotel-name {
  305. margin: 20rpx 40rpx;
  306. display: flex;
  307. flex-direction: row;
  308. color: #ffffff;
  309. background-color: hsla(0, 100%, 0%, 0.5);
  310. padding: 20rpx 0;
  311. border-radius: 10rpx;
  312. transform: translateY(-80rpx);
  313. .hotel-name--fix {
  314. font-size: 20rpx;
  315. width: 100rpx;
  316. height: 100%;
  317. padding-right: 16rpx;
  318. display: flex;
  319. flex-direction: row;
  320. align-items: center;
  321. }
  322. .hotel-name--content {
  323. width: 100%;
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. }
  328. }
  329. .business {
  330. display: flex;
  331. flex-direction: column;
  332. margin: 0 20rpx;
  333. border-radius: 10rpx;
  334. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  335. .business-row {
  336. display: flex;
  337. flex-direction: row;
  338. justify-content: space-around;
  339. margin: 0 60rpx 30rpx;
  340. // padding-top: 60rpx;
  341. .business-item {
  342. width: 30vw;
  343. display: flex;
  344. justify-content: center;
  345. flex-direction: column;
  346. align-items: center;
  347. image {
  348. width: 127rpx;
  349. height: 116rpx;
  350. }
  351. }
  352. }
  353. }
  354. .voucher {
  355. width: 90vw;
  356. margin: 20rpx auto;
  357. image {
  358. width: 100%;
  359. }
  360. }
  361. </style>