my.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="page-container">
  3. <view class="my-top">
  4. <view class="icon-container">
  5. <u-image :src="userPicPath" width="46rpx" height="52rpx"></u-image>
  6. </view>
  7. <!-- <text class="my-top-text">尊敬的{{userInfo.name[0]+"**"}}</text> -->
  8. <u-text size="20" :text="userInfo.name" mode="name" format="encrypt" color="#FFFFFF"></u-text>
  9. </view>
  10. <view class="my-middle" v-for="area in list">
  11. <view class="info-item" v-for="item in area" @click="navigateTo(item.url)">
  12. <view class="info-item-left">
  13. <view class="left-img">
  14. <u-image :src="item.src" width="45rpx" height="45rpx" mode="aspectFit"></u-image>
  15. </view>
  16. <view class="tip">
  17. <text class="">{{item.text}}</text>
  18. </view>
  19. </view>
  20. <view class="info-item-right">
  21. <u-image :src="arrowPicPath" width="12rpx" height="20rpx"></u-image>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="my-middle" v-if="userInfo.selectHotel">
  26. <view class="info-item" v-for="item in listDebug" @click="navigateTo(item.url)">
  27. <view class="info-item-left">
  28. <view class="left-img">
  29. <u-image :src="item.src" width="45rpx" height="45rpx" mode="aspectFit"></u-image>
  30. </view>
  31. <view class="tip">
  32. <text class="">{{item.text}}</text>
  33. </view>
  34. </view>
  35. <view class="info-item-right">
  36. <u-image :src="arrowPicPath" width="12rpx" height="20rpx"></u-image>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="my-bottom">
  41. <u-button class="my-bottom-btn" text="退出登录" size="large" @click="logout"></u-button>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. mapState,
  48. mapMutations
  49. } from 'vuex'
  50. export default {
  51. data() {
  52. return {
  53. userPicPath: '/static/user.png',
  54. arrowPicPath: '/static/arrow.png',
  55. list: [
  56. [{
  57. src: "/static/user_info.png",
  58. text: "实名认证",
  59. url: '/subpkg/myAccount/myAccount'
  60. }, {
  61. src: "/static/my_order.png",
  62. text: "我的订单",
  63. url: '/pages/order/order'
  64. }],
  65. [{
  66. src: "/static/receipt.png",
  67. text: "预约开票",
  68. url: ''
  69. }, {
  70. src: "/static/front_desk.png",
  71. text: "联系前台",
  72. url: ''
  73. }]
  74. ]
  75. };
  76. },
  77. computed: {
  78. ...mapState('m_user', ['userInfo', 'token']),
  79. listDebug() {
  80. return [{
  81. src: "/static/change_hotel.png",
  82. text: "选择酒店",
  83. url: '/subpkg/changeHotel/changeHotel'
  84. }]
  85. }
  86. },
  87. methods: {
  88. ...mapMutations('m_user', ['updateUserInfo', 'updateToken']),
  89. navigateTo(url) {
  90. if (url !== '' && url !== null && url !== undefined) {
  91. if (url === '/pages/order/order') {
  92. uni.switchTab({
  93. url: url
  94. })
  95. } else {
  96. uni.navigateTo({
  97. url: url
  98. })
  99. }
  100. } else {
  101. uni.$showMsg('功能开发中,敬请期待')
  102. }
  103. },
  104. async logout() {
  105. console.log(this.token)
  106. let res = await uni.$http.post('/logout')
  107. console.log(res)
  108. uni.navigateTo({
  109. url: '/pages/login/login'
  110. })
  111. this.updateUserInfo({})
  112. this.updateToken('')
  113. }
  114. },
  115. onLoad() {
  116. if (!this.token) {
  117. uni.navigateTo({
  118. url: '/pages/login/login'
  119. })
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .page-container {
  126. background-color: #F0EFF5;
  127. height: 1110rpx;
  128. .my-top {
  129. height: 200rpx;
  130. background-color: #7096F6;
  131. display: flex;
  132. align-items: center;
  133. .icon-container {
  134. width: 100rpx;
  135. height: 100rpx;
  136. margin: 40rpx 50rpx;
  137. background-color: white;
  138. border-radius: 50rpx;
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. }
  143. .text-container {
  144. display: flex;
  145. justify-content: start;
  146. }
  147. .my-top-text {
  148. color: white;
  149. }
  150. }
  151. .my-middle {
  152. margin-top: 40rpx;
  153. background-color: white;
  154. .info-item {
  155. display: flex;
  156. justify-content: space-between;
  157. height: 120rpx;
  158. line-height: 160rpx;
  159. border-bottom: 1px solid #F0EFF5;
  160. margin: 0 40rpx;
  161. .info-item-left {
  162. display: flex;
  163. align-items: center;
  164. .left-img {
  165. padding-right: 20rpx;
  166. display: flex;
  167. align-items: center;
  168. justify-content: center;
  169. }
  170. }
  171. .info-item-right {
  172. display: flex;
  173. align-items: center;
  174. color: #AFB2BA;
  175. }
  176. }
  177. }
  178. .my-bottom {
  179. bottom: 80rpx;
  180. left: 80rpx;
  181. right: 80rpx;
  182. position: fixed;
  183. }
  184. }
  185. .u-button__text {
  186. color: #789EF6;
  187. }
  188. </style>