home.vue 11 KB

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