my.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="title">
  3. <text>个人中心</text>
  4. </view>
  5. <view class="top">
  6. <view class="user-info">
  7. <view class="avatar-outer">
  8. <view class="avatar-inner">
  9. <image src="@/static/user.png"></image>
  10. </view>
  11. </view>
  12. <view class="user-info-text">
  13. <text>{{encryptedName}}</text>
  14. <text>{{encryptedPhone}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="business">
  19. <view class="business-item" v-for="(item,index) in businessItemList" :key="index">
  20. <image :src="item.src" @click="handleBusiness(item.name)"></image>
  21. <text>{{item.text}}</text>
  22. </view>
  23. </view>
  24. <view class="logout-button">
  25. <button @click="logout">退出登录</button>
  26. </view>
  27. </template>
  28. <script setup>
  29. import {
  30. computed
  31. } from 'vue';
  32. import {
  33. useUserStore
  34. } from '../../store/userStore';
  35. import {
  36. useHotelStore
  37. } from '@/store/hotelStore'
  38. const user = useUserStore()
  39. let encryptedName = computed(() => {
  40. let name = user.userInfo.name.slice()
  41. let res
  42. if (name.length == 2) {
  43. res = name[0] + '*'
  44. } else {
  45. res = name[0] + '*' + name[name.length - 1]
  46. }
  47. return res
  48. })
  49. let encryptedPhone = computed(() => {
  50. let phone = user.userInfo.phone
  51. let res
  52. if (user.userInfo.phone) {
  53. res = phone.slice(0, 3) + '****' + phone.slice(7)
  54. } else {
  55. res = ''
  56. }
  57. return res
  58. })
  59. let businessItemList = [{
  60. src: "/static/my_order.png",
  61. text: "我的订单",
  62. name: 'order',
  63. },
  64. {
  65. src: "/static/receipt.png",
  66. text: "预约开票",
  67. name: 'receipt',
  68. },
  69. {
  70. src: "/static/front_desk.png",
  71. text: "联系前台",
  72. name: 'front_desk',
  73. },
  74. {
  75. src: "/static/user_info.png",
  76. text: "实名认证",
  77. name: 'myAccount',
  78. }
  79. ]
  80. let hotel = useHotelStore().hotel
  81. function handleBusiness(name) {
  82. if (name === 'order') {
  83. uni.switchTab({
  84. url: '/pages/order/order'
  85. })
  86. } else if (name === 'receipt') {
  87. uni.showToast({
  88. icon: 'none',
  89. title: '该酒店不支持该服务,请至前台办理'
  90. })
  91. } else if (name === 'front_desk') {
  92. uni.showModal({
  93. title: "联系前台",
  94. content: `将要拨打前台电话:${hotel.phone}`,
  95. success: (res) => {
  96. if (res.confirm) {
  97. uni.makePhoneCall({
  98. phoneNumber: hotel.phone,
  99. });
  100. }
  101. },
  102. });
  103. } else if (name === 'myAccount') {
  104. uni.navigateTo({
  105. url: '/subpkg/myAccount/myAccount'
  106. })
  107. }
  108. }
  109. function logout() {
  110. uni.request({
  111. url: '/user/logout',
  112. method: 'POST'
  113. })
  114. user.updateToken('')
  115. user.updateUserInfo({})
  116. uni.redirectTo({
  117. url: '/pages/login/login'
  118. })
  119. }
  120. </script>
  121. <style lang="scss">
  122. .title {
  123. z-index: 999;
  124. display: block;
  125. position: fixed;
  126. top: 80rpx;
  127. left: 30rpx;
  128. right: 30rpx;
  129. color: #ffffff;
  130. text-align: center;
  131. font-size: 40rpx;
  132. }
  133. .top {
  134. width: 100%;
  135. height: 40vh;
  136. background-image: url("/static/mine-top.png");
  137. background-size: cover;
  138. background-repeat: no-repeat;
  139. box-sizing: border-box;
  140. .user-info {
  141. width: 100%;
  142. display: flex;
  143. flex-direction: row;
  144. align-items: center;
  145. padding: 200rpx 40rpx 0 40rpx;
  146. overflow: hidden;
  147. .avatar-outer {
  148. width: 130rpx;
  149. height: 130rpx;
  150. display: flex;
  151. align-items: center;
  152. justify-content: center;
  153. border-radius: 50%;
  154. background-color: #6c70a1;
  155. .avatar-inner {
  156. width: 110rpx;
  157. height: 110rpx;
  158. border-radius: 50%;
  159. background-color: #FFFFFF;
  160. display: flex;
  161. justify-content: center;
  162. align-items: center;
  163. image {
  164. width: 52rpx;
  165. height: 52rpx;
  166. }
  167. }
  168. }
  169. .user-info-text {
  170. padding-left: 20rpx;
  171. display: flex;
  172. flex-direction: column;
  173. text {
  174. margin: 5rpx;
  175. color: #ffffff;
  176. font-size: 32rpx;
  177. }
  178. }
  179. }
  180. }
  181. .business {
  182. display: flex;
  183. flex-direction: row;
  184. background-color: #FFFFFF;
  185. margin: 0 20rpx;
  186. justify-content: space-between;
  187. padding: 30rpx;
  188. border-radius: 40rpx;
  189. transform: translateY(-110rpx);
  190. .business-item {
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: center;
  194. align-items: center;
  195. image {
  196. width: 60rpx;
  197. height: 60rpx;
  198. }
  199. }
  200. }
  201. .logout-button {
  202. padding-top: 36vh;
  203. margin: 20rpx;
  204. button {
  205. color: #ffffff;
  206. background-color: #a09cc4;
  207. border-radius: 800rpx;
  208. }
  209. }
  210. </style>