home.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  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: true, //引导是否显示
  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. return;
  195. }
  196. this.noticeArray[this.currentIndex].zindex = 0;
  197. this.cShowMsg = '';
  198. this.currentIndex++;
  199. if (this.currentIndex >= this.noticeArray.length) {
  200. this.showGuide = false;
  201. return;
  202. }
  203. this.cShowMsg = this.noticeArray[this.currentIndex].showMessage;
  204. var idS = '#' + this.noticeArray[this.currentIndex].showID;
  205. console.log(idS)
  206. const query = uni.createSelectorQuery().in(this);
  207. query.select(idS).boundingClientRect(data => {
  208. console.log("得到布局位置信息" + JSON.stringify(data));
  209. this.cWidth = data.width;
  210. this.cHeight = data.height;
  211. this.cLeft = data.left;
  212. this.cRight = data.right;
  213. this.cTop = data.top;
  214. }).exec();
  215. },
  216. },
  217. onShow() {
  218. //进入页面时 currentHotel 为空时 跳转选择酒店
  219. if (JSON.stringify(this.currentHotel) === '{}') {
  220. uni.redirectTo({
  221. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  222. })
  223. }
  224. },
  225. async onLoad() {
  226. // console.log(__wxConfig)
  227. //获取openid
  228. if (!this.userInfo.openid) {
  229. // #ifdef MP-WEIXIN
  230. wx.login({
  231. success: (res) => {
  232. if (res.code) {
  233. //发起网络请求
  234. uni.$http.post('/user/weChatOpenid', {
  235. code: res.code
  236. }).then((res) => {
  237. this.userInfo.openid = res.data.data
  238. this.updateUserInfo(this.userInfo)
  239. })
  240. } else {
  241. console.log('登录失败!' + res.errMsg)
  242. }
  243. }
  244. })
  245. // #endif
  246. // #ifdef MP-ALIPAY
  247. my.getAuthCode({
  248. scopes: 'auth_user',
  249. success: res => {
  250. const authCode = res.authCode;
  251. // console.log("authCode",authCode);
  252. //发起网络请求
  253. uni.$http.post('/user/aliOpenid', {
  254. code: authCode,
  255. appId: '2021004131662268'
  256. }).then((res) => {
  257. this.userInfo.openid = res.data.data
  258. console.log("获取支付宝端的openid", res.data.data);
  259. this.updateUserInfo(this.userInfo)
  260. })
  261. },
  262. fail: err => {
  263. console.log('my.getAuthCode 调用失败', err)
  264. }
  265. });
  266. // #endif
  267. }
  268. let _this = this;
  269. this.$nextTick(function() {
  270. if (_this.currentIndex >= _this.noticeArray.length) {
  271. _this.showGuide = false;
  272. return;
  273. }
  274. _this.showGuide = true;
  275. _this.cShowMsg = _this.noticeArray[_this.currentIndex].showMessage;
  276. var idS = '#' + _this.noticeArray[_this.currentIndex].showID;
  277. console.log(idS)
  278. //根据布局信息显示引导框位置
  279. const query = uni.createSelectorQuery().in(_this);
  280. query.select(idS).boundingClientRect(data => {
  281. console.log("得到布局位置信息" + JSON.stringify(data));
  282. _this.cWidth = data.width;
  283. _this.cHeight = data.height;
  284. _this.cLeft = data.left;
  285. this.cRight = data.right;
  286. _this.cTop = data.top;
  287. }).exec();
  288. });
  289. },
  290. // #ifdef MP-WEIXIN
  291. onShareAppMessage(info) {
  292. return {
  293. title: '源享住',
  294. path: 'pages/login/login',
  295. imageUrl: "/static/logo.png"
  296. }
  297. },
  298. onShareTimeline(info) {}
  299. // #endif
  300. };
  301. </script>
  302. <style lang="scss" scoped>
  303. .container {
  304. height: 100%;
  305. width: 100%;
  306. display: flex;
  307. flex-direction: column;
  308. .top {
  309. width: 100%;
  310. height: 130rpx;
  311. position: fixed;
  312. top: 0;
  313. left: 0;
  314. right: 0;
  315. z-index: 99;
  316. }
  317. .adv-pic {
  318. width: 100%;
  319. height: 540rpx;
  320. }
  321. .hotel-name {
  322. margin: 0 40rpx 10rpx;
  323. display: flex;
  324. flex-direction: row;
  325. color: #FFFFFF;
  326. background-color: hsla(0, 100%, 0%, 0.5);
  327. padding: 20rpx 0;
  328. border-radius: 10rpx;
  329. transform: translateY(-60rpx);
  330. .hotel-name--fix {
  331. font-size: 20rpx;
  332. width: 100rpx;
  333. padding-right: 16rpx;
  334. display: flex;
  335. flex-direction: row;
  336. align-items: center;
  337. }
  338. .hotel-name--content {
  339. width: 100%;
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. }
  344. }
  345. .bottom {
  346. display: flex;
  347. flex-direction: column;
  348. margin: 0 20rpx;
  349. border-radius: 10rpx;
  350. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  351. .bottom--row {
  352. display: flex;
  353. flex-direction: row;
  354. justify-content: space-between;
  355. margin: 0 60rpx 30rpx;
  356. padding-top: 60rpx;
  357. .bottom--row-item__content {
  358. display: flex;
  359. flex-direction: column;
  360. align-items: center;
  361. justify-content: space-between;
  362. height: 170rpx;
  363. width: 170rpx;
  364. .bottom--row-item__img {
  365. height: 120rpx;
  366. display: flex;
  367. align-items: center;
  368. justify-content: center;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. </style>