my.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <view class="page">
  3. <view class="top">
  4. <NavigateBar title="个人中心"></NavigateBar>
  5. <view class="top--desc">
  6. <view class="top--desc__icon">
  7. <view class="top--desc__icon-outer">
  8. <view class="top--desc__icon-inner">
  9. <u-image :src="userPicPath" width="52rpx" height="52rpx"></u-image>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="top--desc__word">
  14. <view class="top--desc__word-name">
  15. <u-text size="20" :text="userInfo.name" mode="name" format="encrypt" color="#FFFFFF"></u-text>
  16. </view>
  17. <view class="top--desc__word-phone">
  18. <u-text size="16" :text="renderPhoneNumber(userInfo.phone)" mode="name"
  19. color="#FFFFFF"></u-text>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="middle">
  25. <view class="middle--item" v-for="(item, index) in itemList" :key="item.src">
  26. <view class="middle--item__content" @click="navigateTo(item.url)">
  27. <view class="middle--item__img">
  28. <u-image :src="item.src" :width="item.width" :height="item.height" mode="aspectFit"></u-image>
  29. </view>
  30. <view class="middle--item__word">{{ item.text }}</view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="bottom">
  35. <u-button text="退出登录" @click="logout" shape="circle" color="#9e97c3"></u-button>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. stringHasText
  42. } from '../../utils/commonUtils.js'
  43. import {
  44. mapState,
  45. mapMutations
  46. } from 'vuex'
  47. import NavigateBar from '../../components/navigateBar/navigate-bar.vue';
  48. export default {
  49. components: {
  50. NavigateBar
  51. },
  52. data() {
  53. return {
  54. userPicPath: '/static/user.png',
  55. itemList: [{
  56. src: "/static/my_order.png",
  57. text: "我的订单",
  58. url: '/pages/order/order',
  59. width: "50rpx",
  60. height: "60rpx"
  61. },
  62. {
  63. src: "/static/receipt.png",
  64. text: "预约开票",
  65. url: '',
  66. width: "58rpx",
  67. height: "55rpx"
  68. },
  69. {
  70. src: "/static/front_desk.png",
  71. text: "联系前台",
  72. url: '',
  73. width: "65rpx",
  74. height: "48rpx"
  75. },
  76. {
  77. src: "/static/user_info.png",
  78. text: "实名认证",
  79. url: '/subpkg/myAccount/myAccount',
  80. width: "73rpx",
  81. height: "48rpx"
  82. }
  83. ]
  84. };
  85. },
  86. computed: {
  87. ...mapState('m_user', ['userInfo', 'token']),
  88. listDebug() {
  89. return [{
  90. src: "/static/change_hotel.png",
  91. text: "选择酒店",
  92. url: '/subpkg/changeHotel/changeHotel'
  93. }]
  94. }
  95. },
  96. methods: {
  97. ...mapMutations('m_user', ['updateUserInfo', 'updateToken']),
  98. ...mapMutations('m_business', ['updateCurrentHotel', 'updateIdCardInfo']),
  99. navigateTo(url) {
  100. if (url !== '' && url !== null && url !== undefined) {
  101. if (url === '/pages/order/order') {
  102. uni.switchTab({
  103. url: url
  104. })
  105. } else {
  106. uni.navigateTo({
  107. url: url
  108. })
  109. }
  110. } else {
  111. uni.$showMsg('功能开发中,敬请期待')
  112. }
  113. },
  114. async logout() {
  115. console.log(this.token)
  116. let res = await uni.$http.post('/user/logout')
  117. console.log(res)
  118. this.updateUserInfo({
  119. name: ''
  120. })
  121. this.updateToken('')
  122. this.updateCurrentHotel({})
  123. this.updateIdCardInfo([])
  124. uni.redirectTo({
  125. url: '/pages/login/login'
  126. })
  127. },
  128. renderPhoneNumber(str) {
  129. if (!stringHasText(this.userInfo.phone)) return ""
  130. let strArray = str.split("")
  131. for (let i = 3; i < 7; i++) {
  132. strArray[i] = "*"
  133. }
  134. let string = strArray.join("")
  135. // console.log("string", string);
  136. return string
  137. }
  138. },
  139. onLoad() {
  140. if (!this.token) {
  141. uni.redirectTo({
  142. url: '/pages/login/login'
  143. })
  144. }
  145. },
  146. // #ifdef MP-WEIXIN
  147. onShareAppMessage(info) {
  148. return {
  149. title: '源享住',
  150. path: 'pages/login/login',
  151. imageUrl: "/static/logo.png"
  152. }
  153. }
  154. // #endif
  155. }
  156. </script>
  157. <style>
  158. .u-button__text {
  159. color: #FFFFFF;
  160. }
  161. page {
  162. width: 100%;
  163. height: 100%;
  164. background-color: #f4f4f4;
  165. }
  166. </style>
  167. <style lang="scss" scoped>
  168. .page {
  169. .top {
  170. width: 100%;
  171. height: 580rpx;
  172. background-image: url("/static/mine-top.png");
  173. background-size: cover;
  174. background-repeat: no-repeat;
  175. box-sizing: border-box;
  176. .top--desc {
  177. width: 100%;
  178. display: flex;
  179. flex-direction: row;
  180. align-items: center;
  181. padding: 100rpx 40rpx 0 40rpx;
  182. .top--desc__icon-outer {
  183. width: 130rpx;
  184. height: 130rpx;
  185. display: flex;
  186. align-items: center;
  187. justify-content: center;
  188. border-radius: 50%;
  189. background-color: #6c70a1;
  190. .top--desc__icon-inner {
  191. width: 110rpx;
  192. height: 110rpx;
  193. border-radius: 50%;
  194. background-color: #FFFFFF;
  195. display: flex;
  196. justify-content: center;
  197. align-items: center;
  198. }
  199. }
  200. .top--desc__word {
  201. padding-left: 20rpx;
  202. .top--desc__word-name {
  203. height: 50rpx;
  204. display: flex;
  205. align-items: center;
  206. }
  207. .top--desc__word-phone {
  208. height: 50rpx;
  209. display: flex;
  210. align-items: center;
  211. }
  212. }
  213. }
  214. }
  215. .middle {
  216. display: flex;
  217. flex-direction: row;
  218. background-color: #FFFFFF;
  219. margin: 0 20rpx;
  220. justify-content: space-between;
  221. padding: 30rpx;
  222. border-radius: 40rpx;
  223. transform: translateY(-110rpx);
  224. .middle--item__content {
  225. width: 140rpx;
  226. height: 120rpx;
  227. display: flex;
  228. flex-direction: column;
  229. align-items: center;
  230. justify-content: space-between;
  231. .middle--item__img {
  232. height: 60rpx;
  233. display: flex;
  234. align-items: center;
  235. justify-content: center;
  236. }
  237. }
  238. }
  239. .my-middle {
  240. margin-top: 40rpx;
  241. background-color: white;
  242. .info-item {
  243. display: flex;
  244. justify-content: space-between;
  245. height: 120rpx;
  246. line-height: 160rpx;
  247. border-bottom: 1px solid #F0EFF5;
  248. margin: 0 40rpx;
  249. .info-item-left {
  250. display: flex;
  251. align-items: center;
  252. .left-img {
  253. padding-right: 20rpx;
  254. display: flex;
  255. align-items: center;
  256. justify-content: center;
  257. }
  258. }
  259. .info-item-right {
  260. display: flex;
  261. align-items: center;
  262. color: #AFB2BA;
  263. }
  264. }
  265. }
  266. .bottom {
  267. margin: 20rpx;
  268. transform: translateY(100rpx);
  269. }
  270. }
  271. </style>