home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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="navigateTo('/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" v-if="false">
  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. appId: ''
  144. };
  145. },
  146. computed: {
  147. ...mapState("m_user", ["userInfo"]),
  148. ...mapState("m_business", ["currentHotel"]),
  149. fixStyle() {
  150. let style = {}
  151. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  152. style.display = "none"
  153. return style
  154. },
  155. hotelNameFontSize() {
  156. let style = {}
  157. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  158. style.fontSize = "30rpx"
  159. return style
  160. }
  161. },
  162. methods: {
  163. ...mapMutations('m_user', ['updateUserInfo']),
  164. navigateTo(url) {
  165. if (url !== "" && url !== null && url !== undefined) {
  166. if (url !== "/subpkg_checkin/selectCheckinType/selectCheckinType") {
  167. if (!this.userInfo.idNumber) {
  168. uni.showModal({
  169. title: '身份信息未完善',
  170. content: '请至个人中心实名认证处完善个人信息',
  171. showCancel: false,
  172. success() {
  173. uni.switchTab({
  174. url: '/pages/my/my'
  175. })
  176. }
  177. })
  178. return
  179. }
  180. }
  181. uni.navigateTo({
  182. url: url,
  183. });
  184. }
  185. },
  186. gotoSelectHotel() {
  187. uni.redirectTo({
  188. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  189. })
  190. },
  191. clicktoNext() {
  192. console.log('点击了下一个')
  193. if (this.currentIndex >= this.noticeArray.length) {
  194. this.showGuide = false;
  195. uni.setStorageSync('showGuide', false)
  196. return;
  197. }
  198. this.noticeArray[this.currentIndex].zindex = 0;
  199. this.cShowMsg = '';
  200. this.currentIndex++;
  201. if (this.currentIndex >= this.noticeArray.length) {
  202. this.showGuide = false;
  203. return;
  204. }
  205. this.cShowMsg = this.noticeArray[this.currentIndex].showMessage;
  206. var idS = '#' + this.noticeArray[this.currentIndex].showID;
  207. console.log(idS)
  208. const query = uni.createSelectorQuery().in(this);
  209. query.select(idS).boundingClientRect(data => {
  210. console.log("得到布局位置信息" + JSON.stringify(data));
  211. this.cWidth = data.width;
  212. this.cHeight = data.height;
  213. this.cLeft = data.left;
  214. this.cRight = data.right;
  215. this.cTop = data.top;
  216. }).exec();
  217. },
  218. },
  219. onShow() {
  220. //进入页面时 currentHotel 为空时 跳转选择酒店
  221. if (JSON.stringify(this.currentHotel) === '{}') {
  222. uni.redirectTo({
  223. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  224. })
  225. }
  226. },
  227. async onLoad() {
  228. const {miniProgram: {appId}} = uni.getAccountInfoSync();
  229. this.appId = appId
  230. // console.log(__wxConfig)
  231. //获取openid
  232. if (!this.userInfo.openid) {
  233. // #ifdef MP-WEIXIN
  234. wx.login({
  235. success: (res) => {
  236. if (res.code) {
  237. //发起网络请求
  238. uni.$http.post('/user/weChatOpenid', {
  239. code: res.code,
  240. appId: this.appId
  241. }).then((res) => {
  242. this.userInfo.openid = res.data.data
  243. this.updateUserInfo(this.userInfo)
  244. })
  245. } else {
  246. console.log('登录失败!' + res.errMsg)
  247. }
  248. }
  249. })
  250. // #endif
  251. // #ifdef MP-ALIPAY
  252. my.getAuthCode({
  253. scopes: 'auth_user',
  254. success: res => {
  255. const authCode = res.authCode;
  256. // console.log("authCode",authCode);
  257. //发起网络请求
  258. uni.$http.post('/user/aliOpenid', {
  259. code: authCode,
  260. appId: '2021004131662268'
  261. }).then((res) => {
  262. this.userInfo.openid = res.data.data
  263. console.log("获取支付宝端的openid", res.data.data);
  264. this.updateUserInfo(this.userInfo)
  265. })
  266. },
  267. fail: err => {
  268. console.log('my.getAuthCode 调用失败', err)
  269. }
  270. });
  271. // #endif
  272. }
  273. //显示引导
  274. // uni.setStorageSync('showGuide', true)
  275. let showGuide = uni.getStorageSync('showGuide')
  276. console.log(typeof showGuide)
  277. console.log(showGuide)
  278. console.log(showGuide === '')
  279. if (showGuide === '') {
  280. this.showGuide = true
  281. uni.setStorageSync('showGuide', 'false')
  282. let _this = this;
  283. this.$nextTick(function() {
  284. if (_this.currentIndex >= _this.noticeArray.length) {
  285. _this.showGuide = false;
  286. return;
  287. }
  288. _this.showGuide = true;
  289. _this.cShowMsg = _this.noticeArray[_this.currentIndex].showMessage;
  290. var idS = '#' + _this.noticeArray[_this.currentIndex].showID;
  291. console.log(idS)
  292. //根据布局信息显示引导框位置
  293. const query = uni.createSelectorQuery().in(_this);
  294. query.select(idS).boundingClientRect(data => {
  295. console.log("得到布局位置信息" + JSON.stringify(data));
  296. _this.cWidth = data.width;
  297. _this.cHeight = data.height;
  298. _this.cLeft = data.left;
  299. this.cRight = data.right;
  300. _this.cTop = data.top;
  301. }).exec();
  302. });
  303. }
  304. },
  305. // #ifdef MP-WEIXIN
  306. onShareAppMessage(info) {
  307. return {
  308. title: '源享住',
  309. path: 'pages/login/login',
  310. imageUrl: "/static/logo.png"
  311. }
  312. },
  313. onShareTimeline(info) {}
  314. // #endif
  315. };
  316. </script>
  317. <style lang="scss" scoped>
  318. .container {
  319. height: 100%;
  320. width: 100%;
  321. display: flex;
  322. flex-direction: column;
  323. .top {
  324. width: 100%;
  325. height: 130rpx;
  326. position: fixed;
  327. top: 0;
  328. left: 0;
  329. right: 0;
  330. z-index: 99;
  331. }
  332. .adv-pic {
  333. width: 100%;
  334. height: 540rpx;
  335. }
  336. .hotel-name {
  337. margin: 0 40rpx 10rpx;
  338. display: flex;
  339. flex-direction: row;
  340. color: #FFFFFF;
  341. background-color: hsla(0, 100%, 0%, 0.5);
  342. padding: 20rpx 0;
  343. border-radius: 10rpx;
  344. transform: translateY(-60rpx);
  345. .hotel-name--fix {
  346. font-size: 20rpx;
  347. width: 100rpx;
  348. padding-right: 16rpx;
  349. display: flex;
  350. flex-direction: row;
  351. align-items: center;
  352. }
  353. .hotel-name--content {
  354. width: 100%;
  355. display: flex;
  356. align-items: center;
  357. justify-content: center;
  358. }
  359. }
  360. .bottom {
  361. display: flex;
  362. flex-direction: column;
  363. margin: 0 20rpx;
  364. border-radius: 10rpx;
  365. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  366. .bottom--row {
  367. display: flex;
  368. flex-direction: row;
  369. justify-content: space-around;
  370. margin: 0 60rpx 30rpx;
  371. padding-top: 60rpx;
  372. .bottom--row-item {
  373. width: 30vw;
  374. display: flex;
  375. justify-content: center;
  376. flex-direction: column;
  377. align-items: center;
  378. }
  379. }
  380. }
  381. }
  382. </style>