home.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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">
  16. <img src="/static/switch.svg" style="width: 30rpx; height: 30rpx;">
  17. 切换
  18. </view>
  19. </view>
  20. <view class="bottom">
  21. <view class="botton--row" v-for="(row, rowIndex) in bottomList" :key="rowIndex">
  22. <view class="botton--row-item" v-for="(item, itemIndex) in row" :key="itemIndex">
  23. <view class="botton--row-item__content" @click="navigateTo(item.url)">
  24. <view class="botton--row-item__img">
  25. <u-image :src="item.src" :width="item.width" :height="item.height"></u-image>
  26. </view>
  27. <view class="botton--row-item__word">{{ item.text }}</view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapState,
  37. mapMutations
  38. } from "vuex";
  39. import {
  40. IMG_BASE_URL
  41. } from "../../config.js"
  42. import NavigateBar from '../../components/navigateBar/navigate-bar.vue';
  43. export default {
  44. components: {
  45. NavigateBar
  46. },
  47. data() {
  48. return {
  49. topSrc: IMG_BASE_URL + "/home_top.png",
  50. bottomList: [
  51. [{
  52. src: "/static/checkin.png",
  53. text: "入住",
  54. url: "/subpkg_checkin/selectCheckinType/selectCheckinType",
  55. width: "118rpx",
  56. height: "108rpx"
  57. },
  58. {
  59. src: "/static/extand.png",
  60. text: "续住",
  61. url: "/subpkg/extend/extend?fromExtend=true",
  62. width: "105rpx",
  63. height: "103rpx"
  64. },
  65. {
  66. src: "/static/checkout.png",
  67. text: "退房",
  68. url: "/subpkg/extend/extend?fromExtend=false",
  69. width: "113rpx",
  70. height: "105rpx"
  71. },
  72. ],
  73. [{
  74. src: "/static/lift_qrcode.png",
  75. text: "梯控二维码",
  76. url: "/subpkg/elevatorControl/elevatorControl",
  77. width: "105rpx",
  78. height: "93rpx"
  79. },
  80. {
  81. src: "/static/emergency_key.png",
  82. text: "手机开门",
  83. url: "/subpkg/emergencyKey/emergencyKey",
  84. width: "78rpx",
  85. height: "95rpx"
  86. }
  87. ]
  88. ],
  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. };
  99. },
  100. computed: {
  101. ...mapState("m_user", ["userInfo"]),
  102. ...mapState("m_business", ["currentHotel"]),
  103. fixStyle() {
  104. let style = {}
  105. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  106. style.display = "none"
  107. return style
  108. },
  109. hotelNameFontSize() {
  110. let style = {}
  111. if (this.currentHotel.hasOwnProperty('name') && this.currentHotel.name.length <= 14) return style
  112. style.fontSize = "30rpx"
  113. return style
  114. }
  115. },
  116. methods: {
  117. ...mapMutations('m_user', ['updateUserInfo']),
  118. navigateTo(url) {
  119. if (url !== "" && url !== null && url !== undefined) {
  120. if (url !== "/subpkg_checkin/selectCheckinType/selectCheckinType") {
  121. if (!this.userInfo.idNumber) {
  122. uni.showModal({
  123. title: '身份信息未完善',
  124. content: '请至个人中心实名认证处完善个人信息',
  125. showCancel: false,
  126. success() {
  127. uni.switchTab({
  128. url: '/pages/my/my'
  129. })
  130. }
  131. })
  132. return
  133. }
  134. }
  135. uni.navigateTo({
  136. url: url,
  137. });
  138. }
  139. },
  140. gotoSelectHotel() {
  141. uni.redirectTo({
  142. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  143. })
  144. }
  145. },
  146. onShow() {
  147. //进入页面时 currentHotel 为空时 跳转选择酒店
  148. if (JSON.stringify(this.currentHotel) === '{}') {
  149. uni.redirectTo({
  150. url: '/subpkg/chooseHotel/chooseHotel?source=home'
  151. })
  152. }
  153. },
  154. async onLoad() {
  155. console.log(__wxConfig)
  156. //获取openid
  157. if (!this.userInfo.openid) {
  158. // #ifdef MP-WEIXIN
  159. wx.login({
  160. success: (res) => {
  161. if (res.code) {
  162. //发起网络请求
  163. uni.$http.post('/user/weChatOpenid', {
  164. code: res.code
  165. }).then((res) => {
  166. this.userInfo.openid = res.data.data
  167. this.updateUserInfo(this.userInfo)
  168. })
  169. } else {
  170. console.log('登录失败!' + res.errMsg)
  171. }
  172. }
  173. })
  174. // #endif
  175. // #ifdef MP-ALIPAY
  176. my.getAuthCode({
  177. scopes: 'auth_user',
  178. success: res => {
  179. const authCode = res.authCode;
  180. // console.log("authCode",authCode);
  181. //发起网络请求
  182. uni.$http.post('/userInfo/aliOpenid', {
  183. code: authCode,
  184. appId: '2021004131662268'
  185. }).then((res) => {
  186. this.userInfo.openid = res.data.data
  187. console.log("获取支付宝端的openid", res.data.data);
  188. this.updateUserInfo(this.userInfo)
  189. })
  190. },
  191. fail: err => {
  192. console.log('my.getAuthCode 调用失败', err)
  193. }
  194. });
  195. // #endif
  196. }
  197. },
  198. // #ifdef MP-WEIXIN
  199. onShareAppMessage(info) {
  200. return {
  201. title: '源享住',
  202. path: 'pages/login/login',
  203. imageUrl: "/static/logo.png"
  204. }
  205. },
  206. onShareTimeline(info) {}
  207. // #endif
  208. };
  209. </script>
  210. <style lang="scss" scoped>
  211. .container {
  212. height: 100%;
  213. width: 100%;
  214. display: flex;
  215. flex-direction: column;
  216. .top {
  217. width: 100%;
  218. height: 130rpx;
  219. position: fixed;
  220. top: 0;
  221. left: 0;
  222. right: 0;
  223. z-index: 99;
  224. }
  225. .adv-pic {
  226. width: 100%;
  227. height: 540rpx;
  228. }
  229. .hotel-name {
  230. margin: 0 40rpx 10rpx;
  231. display: flex;
  232. flex-direction: row;
  233. color: #FFFFFF;
  234. background-color: hsla(0, 100%, 0%, 0.5);
  235. padding: 20rpx 0;
  236. border-radius: 10rpx;
  237. transform: translateY(-60rpx);
  238. .hotel-name--fix {
  239. font-size: 20rpx;
  240. width: 100rpx;
  241. padding-right: 16rpx;
  242. display: flex;
  243. flex-direction: row;
  244. align-items: center;
  245. }
  246. .hotel-name--content {
  247. width: 100%;
  248. display: flex;
  249. align-items: center;
  250. justify-content: center;
  251. }
  252. }
  253. .bottom {
  254. display: flex;
  255. flex-direction: column;
  256. margin: 0 20rpx;
  257. border-radius: 10rpx;
  258. box-shadow: 1px 1px #eaeaf5, -1px 2px #eaeaf5;
  259. .botton--row:first-child {
  260. display: flex;
  261. flex-direction: row;
  262. justify-content: space-between;
  263. margin: 0 60rpx 30rpx;
  264. padding-top: 60rpx;
  265. .botton--row-item__content {
  266. display: flex;
  267. flex-direction: column;
  268. align-items: center;
  269. justify-content: space-between;
  270. height: 170rpx;
  271. width: 170rpx;
  272. .botton--row-item__img {
  273. height: 120rpx;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. }
  278. }
  279. }
  280. .botton--row:last-child {
  281. display: flex;
  282. flex-direction: row;
  283. justify-content: space-between;
  284. margin: 0 180rpx;
  285. padding-bottom: 80rpx;
  286. .botton--row-item__content {
  287. display: flex;
  288. flex-direction: column;
  289. align-items: center;
  290. justify-content: space-between;
  291. height: 170rpx;
  292. width: 170rpx;
  293. .botton--row-item__img {
  294. height: 120rpx;
  295. display: flex;
  296. align-items: center;
  297. justify-content: center;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. </style>