my.vue 6.0 KB

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