home.vue 8.9 KB

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