my.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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', 'updateIdCardInfo']),
  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. this.updateUserInfo({name:''})
  117. this.updateToken('')
  118. this.updateCurrentHotel({})
  119. this.updateIdCardInfo([])
  120. uni.redirectTo({
  121. url: '/pages/login/login'
  122. })
  123. },
  124. renderPhoneNumber(str) {
  125. if(!stringHasText(this.userInfo.phone)) return ""
  126. let strArray = str.split("")
  127. for(let i = 3; i < 7; i++) {
  128. strArray[i] = "*"
  129. }
  130. let string = strArray.join("")
  131. // console.log("string", string);
  132. return string
  133. }
  134. },
  135. onLoad() {
  136. if (!this.token) {
  137. uni.redirectTo({
  138. url: '/pages/login/login'
  139. })
  140. }
  141. },
  142. // #ifdef MP-WEIXIN
  143. onShareAppMessage(info) {
  144. return {
  145. title: '源享住',
  146. path: 'pages/login/login',
  147. imageUrl: "/static/logo.png"
  148. }
  149. }
  150. // #endif
  151. }
  152. </script>
  153. <style>
  154. .u-button__text {
  155. color: #FFFFFF;
  156. }
  157. page {
  158. width: 100%;
  159. height: 100%;
  160. background-color: #f4f4f4;
  161. }
  162. </style>
  163. <style lang="scss" scoped>
  164. .page {
  165. .top {
  166. width: 100%;
  167. height: 580rpx;
  168. background-image: url("/static/mine-top.png");
  169. background-size: cover;
  170. background-repeat: no-repeat;
  171. box-sizing: border-box;
  172. .top--desc {
  173. width: 100%;
  174. display: flex;
  175. flex-direction: row;
  176. align-items: center;
  177. padding: 100rpx 40rpx 0 40rpx;
  178. .top--desc__icon-outer {
  179. width: 130rpx;
  180. height: 130rpx;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. border-radius: 50%;
  185. background-color: #6c70a1;
  186. .top--desc__icon-inner {
  187. width: 110rpx;
  188. height: 110rpx;
  189. border-radius: 50%;
  190. background-color: #FFFFFF;
  191. display: flex;
  192. justify-content: center;
  193. align-items: center;
  194. }
  195. }
  196. .top--desc__word {
  197. padding-left: 20rpx;
  198. .top--desc__word-name {
  199. height: 50rpx;
  200. display: flex;
  201. align-items: center;
  202. }
  203. .top--desc__word-phone {
  204. height: 50rpx;
  205. display: flex;
  206. align-items: center;
  207. }
  208. }
  209. }
  210. }
  211. .middle {
  212. display: flex;
  213. flex-direction: row;
  214. background-color: #FFFFFF;
  215. margin: 0 20rpx;
  216. justify-content: space-between;
  217. padding: 30rpx;
  218. border-radius: 40rpx;
  219. transform: translateY(-110rpx);
  220. .middle--item__content {
  221. width: 140rpx;
  222. height: 120rpx;
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: space-between;
  227. .middle--item__img {
  228. height: 60rpx;
  229. display: flex;
  230. align-items: center;
  231. justify-content: center;
  232. }
  233. }
  234. }
  235. .my-middle {
  236. margin-top: 40rpx;
  237. background-color: white;
  238. .info-item {
  239. display: flex;
  240. justify-content: space-between;
  241. height: 120rpx;
  242. line-height: 160rpx;
  243. border-bottom: 1px solid #F0EFF5;
  244. margin: 0 40rpx;
  245. .info-item-left {
  246. display: flex;
  247. align-items: center;
  248. .left-img {
  249. padding-right: 20rpx;
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. }
  254. }
  255. .info-item-right {
  256. display: flex;
  257. align-items: center;
  258. color: #AFB2BA;
  259. }
  260. }
  261. }
  262. .bottom {
  263. margin: 20rpx;
  264. transform: translateY(100rpx);
  265. }
  266. }
  267. </style>