my.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <view class="container">
  3. <!-- 页面标题 -->
  4. <view class="title" :style="{ height: customBarH * 2 + 'rpx', top: statusBarH * 2 + 'rpx' }" v-if="!headerType">我的</view>
  5. <view class="title" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx', backgroundColor: '#fff', color: '#000' }" v-else>我的</view>
  6. <!-- 顶部用户信息区域 -->
  7. <view class="header">
  8. <img src="https://chtech.ncjti.edu.cn/hotelReservation/image/18.png" />
  9. <!-- 头像区域 -->
  10. <img class="img" mode="aspectFill" v-if="flag" :src="userInfo.headPhoto" @click="handleGoPageHome" />
  11. <img class="img" v-else src="../../static/my/portrait.png" @click="handleGoPageHome" />
  12. <!-- 姓名区域 -->
  13. <view class="name" v-if="flag" @click="handleGoPageHome">{{ userInfo.user_name }}</view>
  14. <!-- 用户id区域 -->
  15. <view class="number" v-if="flag" @click="handleGoPageHome">ID:{{ userInfo.id }}</view>
  16. <!-- 是否实名认证区域 -->
  17. <!-- <view class="real" v-if="userInfo.card_number">
  18. <img src="../../static/my/true.png" />
  19. 已实名认证
  20. </view>
  21. <view class="real2" v-if="flag" v-else>
  22. 去认证
  23. <img src="../../static/my/right2.png" />
  24. </view> -->
  25. <view class="login" v-if="!flag" @click="goPageLogin">去登录</view>
  26. </view>
  27. <!-- 内容区域 -->
  28. <view class="body">
  29. <!-- 订单管理区域 -->
  30. <view class="body_item" @click="handleGoPage('/pages/orderManage/orderManage')">
  31. <img class="img" src="../../static/my/order.png" />
  32. 订单管理
  33. <img class="img_icon" src="../../static/my/right3.png" />
  34. </view>
  35. <!-- 我的评价区域 -->
  36. <view class="body_item" @click="handleGoPage('/pages/myEvaluate/myEvaluate')">
  37. <img class="img" src="../../static/my/evaluate.png" />
  38. 我的评价
  39. <img class="img_icon" src="../../static/my/right3.png" />
  40. </view>
  41. <!-- 收藏/住过区域 -->
  42. <view class="body_item" @click="handleGoPage('/pages/collect/collect')">
  43. <img class="img" src="../../static/my/collect.png" />
  44. 收藏/住过
  45. <img class="img_icon" src="../../static/my/right3.png" />
  46. </view>
  47. <!-- 我的卡券区域 -->
  48. <view class="body_item" @click="handleGoPage('/pages/myCoupon/myCoupon')">
  49. <img class="img" src="../../static/my/coupon.png" />
  50. 我的卡券
  51. <img class="img_icon" src="../../static/my/right3.png" />
  52. </view>
  53. <!-- 投诉进度区域 -->
  54. <view class="body_item" @click="handleGoPage('/pages/myComplaint/myComplaint')">
  55. <img class="img" src="../../static/my/complaint.png" />
  56. 投诉进度
  57. <img class="img_icon" src="../../static/my/right3.png" />
  58. </view>
  59. <!-- 常用旅客区域 -->
  60. <view class="body_item" @click="handleGoPage('/pages/common/common')">
  61. <img class="img2" src="../../static/my/people.png" />
  62. 常用旅客
  63. <img class="img_icon" src="../../static/my/right3.png" />
  64. </view>
  65. <!-- 设置区域 -->
  66. <view class="body_item" @click="handleGoPage('/pages/set/set')">
  67. <img class="img3" src="../../static/my/set.png" />
  68. 设置
  69. <img class="img_icon" src="../../static/my/right3.png" />
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. data() {
  77. return {
  78. // 是否登录标识
  79. flag: false,
  80. // 用户信息
  81. userInfo: {},
  82. // 状态栏高度
  83. statusBarH: 0,
  84. // 胶囊按钮栏高度
  85. customBarH: 0,
  86. // 顶部页面标题栏显示隐藏控制
  87. headerType: false
  88. }
  89. },
  90. created() {
  91. // 获取系统信息
  92. uni.getSystemInfo({
  93. success: (e) => {
  94. // 获取状态栏高度
  95. this.statusBarH = e.statusBarHeight + 10
  96. // // 获取菜单按钮栏高度
  97. let custom = uni.getMenuButtonBoundingClientRect()
  98. this.customBarH = custom.height + 10
  99. }
  100. })
  101. },
  102. onPageScroll(e) {
  103. if (e.scrollTop > 50) {
  104. this.headerType = true
  105. } else {
  106. this.headerType = false
  107. }
  108. },
  109. onLoad() {
  110. uni.$on('changeFlag', this.changeFlag)
  111. },
  112. onShow() {
  113. let openid = uni.getStorageSync('openid')
  114. if (openid) {
  115. this.flag = true
  116. this.userInfo = uni.getStorageSync('userInfo')
  117. } else {
  118. this.flag = false
  119. }
  120. },
  121. methods: {
  122. // 跳转页面回调
  123. handleGoPage(url) {
  124. if (this.isLogin()) {
  125. uni.navigateTo({
  126. url
  127. })
  128. }
  129. },
  130. changeFlag(e) {
  131. // console.log(e)
  132. this.flag = e.data
  133. this.userInfo = uni.getStorageSync('userInfo')
  134. },
  135. // 去登录文字回调
  136. goPageLogin() {
  137. uni.navigateTo({
  138. url: '/pages/login/login'
  139. })
  140. },
  141. isLogin() {
  142. if (this.flag) {
  143. return true
  144. } else {
  145. uni.showToast({
  146. title: '请先登录',
  147. icon: 'none',
  148. mask: true
  149. })
  150. setTimeout(() => {
  151. uni.navigateTo({
  152. url: '/pages/login/login'
  153. })
  154. }, 1500)
  155. }
  156. },
  157. handleGoPageHome() {
  158. let userId = uni.getStorageSync('userInfo').id
  159. uni.navigateTo({
  160. url: `/pages/myHome/myHome?userId=${userId}`
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .container {
  168. position: relative;
  169. min-height: 100vh;
  170. .title {
  171. z-index: 999;
  172. position: fixed;
  173. top: 0;
  174. left: 0;
  175. right: 0;
  176. font-size: 28rpx;
  177. color: #fff;
  178. text-align: center;
  179. }
  180. .header {
  181. position: relative;
  182. height: 480rpx;
  183. color: #fff;
  184. overflow: hidden;
  185. img {
  186. width: 100%;
  187. }
  188. .img {
  189. position: absolute;
  190. top: 190rpx;
  191. left: 32rpx;
  192. width: 140rpx;
  193. height: 140rpx;
  194. border-radius: 50%;
  195. }
  196. .name {
  197. position: absolute;
  198. top: 200rpx;
  199. left: 202rpx;
  200. font-size: 40rpx;
  201. font-weight: bold;
  202. }
  203. .number {
  204. position: absolute;
  205. top: 265rpx;
  206. left: 202rpx;
  207. font-size: 24rpx;
  208. opacity: 0.5;
  209. }
  210. .real {
  211. position: absolute;
  212. top: 285rpx;
  213. left: 202rpx;
  214. display: flex;
  215. align-items: center;
  216. box-sizing: border-box;
  217. padding-left: 13rpx;
  218. width: 179rpx;
  219. height: 42rpx;
  220. font-size: 24rpx;
  221. border-radius: 113rpx;
  222. background-color: rgba(255, 255, 255, 0.2);
  223. img {
  224. margin-right: 7rpx;
  225. width: 24rpx;
  226. height: 24rpx;
  227. }
  228. }
  229. .real2 {
  230. position: absolute;
  231. top: 285rpx;
  232. left: 202rpx;
  233. display: flex;
  234. justify-content: center;
  235. align-items: center;
  236. box-sizing: border-box;
  237. padding-left: 13rpx;
  238. padding-bottom: 5rpx;
  239. width: 179rpx;
  240. height: 42rpx;
  241. font-size: 24rpx;
  242. border-radius: 113rpx;
  243. background-color: rgba(255, 255, 255, 0.2);
  244. img {
  245. margin-left: 12rpx;
  246. width: 24rpx;
  247. height: 24rpx;
  248. }
  249. }
  250. .login {
  251. position: absolute;
  252. top: 235rpx;
  253. left: 202rpx;
  254. font-size: 40rpx;
  255. font-weight: bold;
  256. }
  257. }
  258. .body {
  259. position: absolute;
  260. top: 360rpx;
  261. box-sizing: border-box;
  262. padding: 0 30rpx;
  263. width: 100%;
  264. min-height: calc(100vh - 360rpx);
  265. border-radius: 20rpx 20rpx 0 0;
  266. background-color: #fff;
  267. .body_item {
  268. display: flex;
  269. align-items: center;
  270. height: 121rpx;
  271. font-size: 28rpx;
  272. border-bottom: 1rpx solid #e6e6e6;
  273. .img {
  274. margin-right: 17rpx;
  275. width: 53rpx;
  276. height: 53rpx;
  277. }
  278. .img2 {
  279. margin-right: 22rpx;
  280. width: 42rpx;
  281. height: 42rpx;
  282. }
  283. .img3 {
  284. margin-right: 18rpx;
  285. width: 50rpx;
  286. height: 50rpx;
  287. }
  288. .img_icon {
  289. margin-left: auto;
  290. width: 49rpx;
  291. height: 49rpx;
  292. }
  293. }
  294. }
  295. }
  296. </style>