my.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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, item.text)">
  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. ...mapState("m_business", ["currentHotel"]),
  89. },
  90. methods: {
  91. ...mapMutations('m_user', ['updateUserInfo', 'updateToken']),
  92. ...mapMutations('m_business', ['updateCurrentHotel', 'updateIdCardInfo']),
  93. navigateTo(url, text) {
  94. if (url !== '' && url !== null && url !== undefined) {
  95. if (url === '/pages/order/order') {
  96. uni.switchTab({
  97. url: url
  98. })
  99. } else {
  100. uni.navigateTo({
  101. url: url
  102. })
  103. }
  104. } else {
  105. if (text === "预约开票") {
  106. uni.$showMsg('该酒店不支持该服务,请至前台办理')
  107. } else if (text === "联系前台") {
  108. uni.showModal({
  109. title: "联系前台",
  110. content: `将要拨打前台电话:${this.currentHotel.phone}`,
  111. success: (res) => {
  112. if (res.confirm) {
  113. uni.makePhoneCall({
  114. phoneNumber: this.currentHotel.phone,
  115. });
  116. }
  117. },
  118. });
  119. }
  120. }
  121. },
  122. async logout() {
  123. console.log(this.token)
  124. let res = await uni.$http.post('/user/logout')
  125. console.log(res)
  126. this.updateUserInfo({
  127. name: ''
  128. })
  129. this.updateToken('')
  130. this.updateCurrentHotel({})
  131. this.updateIdCardInfo([])
  132. uni.redirectTo({
  133. url: '/pages/login/login'
  134. })
  135. },
  136. renderPhoneNumber(str) {
  137. if (!stringHasText(this.userInfo.phone)) return ""
  138. let strArray = str.split("")
  139. for (let i = 3; i < 7; i++) {
  140. strArray[i] = "*"
  141. }
  142. let string = strArray.join("")
  143. // console.log("string", string);
  144. return string
  145. }
  146. },
  147. onLoad() {
  148. if (!this.token) {
  149. uni.redirectTo({
  150. url: '/pages/login/login'
  151. })
  152. }
  153. },
  154. // #ifdef MP-WEIXIN
  155. onShareAppMessage(info) {
  156. return {
  157. title: '源享住',
  158. path: 'pages/login/login',
  159. imageUrl: "/static/logo.png"
  160. }
  161. }
  162. // #endif
  163. }
  164. </script>
  165. <style>
  166. .u-button__text {
  167. color: #FFFFFF;
  168. }
  169. page {
  170. width: 100%;
  171. height: 100%;
  172. background-color: #f4f4f4;
  173. }
  174. </style>
  175. <style lang="scss" scoped>
  176. .page {
  177. .top {
  178. width: 100%;
  179. height: 580rpx;
  180. background-image: url("/static/mine-top.png");
  181. background-size: cover;
  182. background-repeat: no-repeat;
  183. box-sizing: border-box;
  184. .top--desc {
  185. width: 100%;
  186. display: flex;
  187. flex-direction: row;
  188. align-items: center;
  189. padding: 100rpx 40rpx 0 40rpx;
  190. .top--desc__icon-outer {
  191. width: 130rpx;
  192. height: 130rpx;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. border-radius: 50%;
  197. background-color: #6c70a1;
  198. .top--desc__icon-inner {
  199. width: 110rpx;
  200. height: 110rpx;
  201. border-radius: 50%;
  202. background-color: #FFFFFF;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. }
  207. }
  208. .top--desc__word {
  209. padding-left: 20rpx;
  210. .top--desc__word-name {
  211. height: 50rpx;
  212. display: flex;
  213. align-items: center;
  214. }
  215. .top--desc__word-phone {
  216. height: 50rpx;
  217. display: flex;
  218. align-items: center;
  219. }
  220. }
  221. }
  222. }
  223. .middle {
  224. display: flex;
  225. flex-direction: row;
  226. background-color: #FFFFFF;
  227. margin: 0 20rpx;
  228. justify-content: space-between;
  229. padding: 30rpx;
  230. border-radius: 40rpx;
  231. transform: translateY(-110rpx);
  232. .middle--item__content {
  233. width: 140rpx;
  234. height: 120rpx;
  235. display: flex;
  236. flex-direction: column;
  237. align-items: center;
  238. justify-content: space-between;
  239. .middle--item__img {
  240. height: 60rpx;
  241. display: flex;
  242. align-items: center;
  243. justify-content: center;
  244. }
  245. }
  246. }
  247. .my-middle {
  248. margin-top: 40rpx;
  249. background-color: white;
  250. .info-item {
  251. display: flex;
  252. justify-content: space-between;
  253. height: 120rpx;
  254. line-height: 160rpx;
  255. border-bottom: 1px solid #F0EFF5;
  256. margin: 0 40rpx;
  257. .info-item-left {
  258. display: flex;
  259. align-items: center;
  260. .left-img {
  261. padding-right: 20rpx;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. }
  266. }
  267. .info-item-right {
  268. display: flex;
  269. align-items: center;
  270. color: #AFB2BA;
  271. }
  272. }
  273. }
  274. .bottom {
  275. margin: 20rpx;
  276. transform: translateY(100rpx);
  277. }
  278. }
  279. </style>