home.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="gotoTlevatorControl('/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. function showNotEnabled() {
  135. uni.showModal({
  136. showCancel: false,
  137. content: "该酒店未开通此功能"
  138. })
  139. }
  140. let showGuide = ref(false)
  141. let cShowMsg = ref('') // 展示的解释语
  142. let cWidth = ref('')
  143. let cHeight = ref('')
  144. let cLeft = ref('')
  145. let cRight = ref('')
  146. let cTop = ref('')
  147. let currentIndex = ref(0)
  148. //配置需要显示引导的view以及引导显示的msg
  149. let noticeArray = [{
  150. "showID": "changeHotel", // 对应的id
  151. "showMessage": "点击“切换” 选择您要入住的酒店", // 对应的解释文本
  152. "type": "bottom" // 解释框的气泡类型
  153. },
  154. {
  155. "showID": "checkin", // 对应的id
  156. "showMessage": "点击“入住”办理当前酒店入住流程", // 对应的解释文本
  157. "type": "bottom" // 解释框的气泡类型
  158. },
  159. {
  160. "showID": "extend",
  161. "showMessage": "点击“续住”办理当前房间续住流程",
  162. "type": "bottom"
  163. },
  164. {
  165. "showID": "checkout",
  166. "showMessage": "点击“退房”办理当前房间退房流程",
  167. "type": "bottom"
  168. },
  169. {
  170. "showID": "lift_qrcode",
  171. "showMessage": "如面部无法识别, 点击进入梯控二维码界面",
  172. "type": "bottom"
  173. },
  174. {
  175. "showID": "emergency_key",
  176. "showMessage": "如面部无法识别, 点击进入手机开门界面",
  177. "type": "bottom"
  178. },
  179. {
  180. "showID": "shop",
  181. "showMessage": "点击进入酒店小超市, 挑选心仪商品",
  182. "type": "bottom"
  183. }
  184. ]
  185. const instance = getCurrentInstance()
  186. function clickNext() {
  187. console.log('点击了下一个')
  188. currentIndex.value++;
  189. console.log('currentIndex.value', currentIndex.value)
  190. console.log('noticeArray.length', noticeArray.length)
  191. if (currentIndex.value >= noticeArray.length) {
  192. console.log('click next return')
  193. showGuide.value = false
  194. return
  195. }
  196. cShowMsg.value = noticeArray[currentIndex.value].showMessage;
  197. var idS = '#' + noticeArray[currentIndex.value].showID;
  198. console.log(idS)
  199. const query = uni.createSelectorQuery().in(instance);
  200. query.select(idS).boundingClientRect(data => {
  201. console.log("得到布局位置信息" + JSON.stringify(data));
  202. cWidth.value = data.width;
  203. cHeight.value = data.height;
  204. cLeft.value = data.left;
  205. cRight.value = data.right;
  206. cTop.value = data.top;
  207. }).exec();
  208. }
  209. const user = useUserStore()
  210. const appInfo = useAppInfoStore()
  211. onLoad(() => {
  212. //清空缓存订单信息
  213. useOrderStore().updateOrderInfo({})
  214. checkinInfoStore.clearCheckinInfo()
  215. if (!user.userInfo.openid) {
  216. uni.login({
  217. success: async (res) => {
  218. console.log('get openid', res)
  219. if (res.code) {
  220. //发起网络请求
  221. let getOpenidRes = await uni.request({
  222. url: '/user/weChatOpenid',
  223. method: 'POST',
  224. data: {
  225. code: res.code,
  226. appId: appInfo.appId
  227. }
  228. })
  229. if (getOpenidRes.data.success) {
  230. console.log("获取微信openId", getOpenidRes);
  231. user.updateUserInfo({
  232. ...user.userInfo,
  233. openid: getOpenidRes.data.data
  234. })
  235. }
  236. } else {
  237. console.log('登录失败!' + res.errMsg)
  238. }
  239. }
  240. })
  241. }
  242. if (uni.getStorageSync('showGuide') === '') {
  243. showGuide.value = true
  244. uni.setStorageSync('showGuide', 'false')
  245. nextTick(function() {
  246. if (currentIndex.value >= noticeArray.length) {
  247. showGuide.value = false;
  248. return;
  249. }
  250. // showGuide.value = true;
  251. cShowMsg.value = noticeArray[currentIndex.value].showMessage;
  252. var idS = '#' + noticeArray[currentIndex.value].showID;
  253. console.log(idS)
  254. //根据布局信息显示引导框位置
  255. const query = uni.createSelectorQuery().in(instance);
  256. query.select(idS).boundingClientRect(data => {
  257. console.log("得到布局位置信息" + JSON.stringify(data));
  258. cWidth.value = data.width;
  259. cHeight.value = data.height;
  260. cLeft.value = data.left;
  261. cRight.value = data.right;
  262. cTop.value = data.top;
  263. }).exec();
  264. });
  265. }
  266. })
  267. </script>
  268. <style lang="scss">
  269. page {
  270. background-color: #ffffff;
  271. }
  272. .hotel-name {
  273. margin: 20rpx 40rpx;
  274. display: flex;
  275. flex-direction: row;
  276. color: #ffffff;
  277. background-color: hsla(0, 100%, 0%, 0.5);
  278. padding: 20rpx 0;
  279. border-radius: 10rpx;
  280. transform: translateY(-80rpx);
  281. .hotel-name--fix {
  282. font-size: 20rpx;
  283. width: 100rpx;
  284. height: 100%;
  285. padding-right: 16rpx;
  286. display: flex;
  287. flex-direction: row;
  288. align-items: center;
  289. }
  290. .hotel-name--content {
  291. width: 100%;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. }
  296. }
  297. .business {
  298. display: flex;
  299. flex-direction: column;
  300. margin: 0 20rpx;
  301. border-radius: 10rpx;
  302. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  303. .business-row {
  304. display: flex;
  305. flex-direction: row;
  306. justify-content: space-around;
  307. margin: 0 60rpx 30rpx;
  308. // padding-top: 60rpx;
  309. .business-item {
  310. width: 30vw;
  311. display: flex;
  312. justify-content: center;
  313. flex-direction: column;
  314. align-items: center;
  315. image {
  316. width: 127rpx;
  317. height: 116rpx;
  318. }
  319. }
  320. }
  321. }
  322. .voucher {
  323. width: 90vw;
  324. margin: 20rpx auto;
  325. image {
  326. width: 100%;
  327. }
  328. }
  329. </style>