my.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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" />
  11. <img class="img" v-else src="../../static/my/portrait.png" />
  12. <!-- 姓名区域 -->
  13. <view class="name" v-if="flag">{{ userInfo.user_name }}</view>
  14. <!-- 用户id区域 -->
  15. <view class="number" v-if="flag">ID:{{ userInfo.id }}</view>
  16. <view class="login" v-if="!flag" @click="goPageLogin">去登录</view>
  17. </view>
  18. <!-- 内容区域 -->
  19. <view class="body">
  20. <!-- 我的订单区域 -->
  21. <view class="myOrder">
  22. <view class="myOrder_header">
  23. <img class="header_img" src="../../static/my/myorder5.png" />
  24. <view class="header_title">我的订单</view>
  25. <view class="header_more" @click="handleShowTest">
  26. 全部订单
  27. <img class="more_img" src="../../static/my/right.png" />
  28. </view>
  29. </view>
  30. <view class="myOrder_list">
  31. <view class="list_box" @click="handleShowTest">
  32. <img class="box_img" src="../../static/my/myorder.png" />
  33. <view class="box_text">待付款</view>
  34. </view>
  35. <view class="list_box" @click="handleShowTest">
  36. <img class="box_img" src="../../static/my/myorder2.png" />
  37. <view class="box_text">待发货</view>
  38. </view>
  39. <view class="list_box" @click="handleShowTest">
  40. <img class="box_img" src="../../static/my/myorder3.png" />
  41. <view class="box_text">待收货</view>
  42. </view>
  43. <view class="list_box" @click="handleShowTest">
  44. <img class="box_img" src="../../static/my/myorder4.png" />
  45. <view class="box_text">待评价</view>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- 常用工具区域 -->
  50. <view class="body_box">
  51. <view class="box_title">常用工具</view>
  52. <view class="box_list">
  53. <view class="item_box" @click="handleShowTest">
  54. <img class="box_img" src="../../static/my/shopcar.png" />
  55. <view class="box_text">购物车</view>
  56. </view>
  57. <view class="item_box" @click="handleShowTest">
  58. <img class="box_img" src="../../static/my/address.png" />
  59. <view class="box_text">收货地址</view>
  60. </view>
  61. <view class="item_box" @click="handleGoPageHome">
  62. <img class="box_img" src="../../static/my/center.png" />
  63. <view class="box_text">个人主页</view>
  64. </view>
  65. <view class="item_box" @click="handleGoPage('/pages/set/set')">
  66. <img class="box_img" src="../../static/my/set.png" />
  67. <view class="box_text">设置</view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 民宿管理区域 -->
  72. <view class="body_box">
  73. <view class="box_title">民宿管理</view>
  74. <view class="box_list">
  75. <view class="item_box" @click="handleGoPage('/pages/orderManage/orderManage')">
  76. <img class="box_img" src="../../static/my/order.png" />
  77. <view class="box_text">订单管理</view>
  78. </view>
  79. <view class="item_box" @click="handleGoPage('/pages/myEvaluate/myEvaluate')">
  80. <img class="box_img" src="../../static/my/evaluate.png" />
  81. <view class="box_text">我的评价</view>
  82. </view>
  83. <view class="item_box" @click="handleGoPage('/pages/myComplaint/myComplaint')">
  84. <img class="box_img" src="../../static/my/complaint.png" />
  85. <view class="box_text">投诉进度</view>
  86. </view>
  87. <view class="item_box" @click="handleGoPage('/pages/collect/collect')">
  88. <img class="box_img" src="../../static/my/collect.png" />
  89. <view class="box_text">收藏/住过</view>
  90. </view>
  91. <view class="item_box" @click="handleGoPage('/pages/myCoupon/myCoupon')">
  92. <img class="box_img" src="../../static/my/coupon.png" />
  93. <view class="box_text">我的卡券</view>
  94. </view>
  95. <view class="item_box" @click="handleGoPage('/pages/common/common')">
  96. <img class="box_img" src="../../static/my/people.png" />
  97. <view class="box_text">常用旅客</view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import { showTest } from '@/util/commonFunction.js'
  106. export default {
  107. data() {
  108. return {
  109. // 是否登录标识
  110. flag: false,
  111. // 用户信息
  112. userInfo: {},
  113. // 状态栏高度
  114. statusBarH: 0,
  115. // 胶囊按钮栏高度
  116. customBarH: 0,
  117. // 顶部页面标题栏显示隐藏控制
  118. headerType: false
  119. }
  120. },
  121. created() {
  122. // 获取系统信息
  123. uni.getSystemInfo({
  124. success: (e) => {
  125. // 获取状态栏高度
  126. this.statusBarH = e.statusBarHeight + 10
  127. // // 获取菜单按钮栏高度
  128. let custom = uni.getMenuButtonBoundingClientRect()
  129. this.customBarH = custom.height + 10
  130. }
  131. })
  132. },
  133. onPageScroll(e) {
  134. if (e.scrollTop > 50) {
  135. this.headerType = true
  136. } else {
  137. this.headerType = false
  138. }
  139. },
  140. onLoad() {
  141. uni.$on('changeFlag', this.changeFlag)
  142. },
  143. onShow() {
  144. let openid = uni.getStorageSync('openid')
  145. if (openid) {
  146. this.flag = true
  147. this.userInfo = uni.getStorageSync('userInfo')
  148. } else {
  149. this.flag = false
  150. }
  151. },
  152. methods: {
  153. // 跳转页面回调
  154. handleGoPage(url) {
  155. if (this.isLogin()) {
  156. uni.navigateTo({
  157. url
  158. })
  159. }
  160. },
  161. changeFlag(e) {
  162. // console.log(e)
  163. this.flag = e.data
  164. this.userInfo = uni.getStorageSync('userInfo')
  165. },
  166. // 去登录文字回调
  167. goPageLogin() {
  168. uni.navigateTo({
  169. url: '/pages/login/login'
  170. })
  171. },
  172. isLogin() {
  173. if (this.flag) {
  174. return true
  175. } else {
  176. uni.showToast({
  177. title: '请先登录',
  178. icon: 'none',
  179. mask: true
  180. })
  181. setTimeout(() => {
  182. uni.navigateTo({
  183. url: '/pages/login/login'
  184. })
  185. }, 1500)
  186. }
  187. },
  188. handleGoPageHome() {
  189. let userId = uni.getStorageSync('userInfo').id
  190. uni.navigateTo({
  191. url: `/pages/myHome/myHome?userId=${userId}`
  192. })
  193. },
  194. handleShowTest() {
  195. showTest()
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .container {
  202. position: relative;
  203. min-height: 100vh;
  204. .title {
  205. z-index: 999;
  206. position: fixed;
  207. top: 0;
  208. left: 0;
  209. right: 0;
  210. font-size: 28rpx;
  211. color: #fff;
  212. text-align: center;
  213. }
  214. .header {
  215. position: relative;
  216. height: 480rpx;
  217. color: #fff;
  218. overflow: hidden;
  219. img {
  220. width: 100%;
  221. }
  222. .img {
  223. position: absolute;
  224. top: 190rpx;
  225. left: 32rpx;
  226. width: 140rpx;
  227. height: 140rpx;
  228. border-radius: 50%;
  229. }
  230. .name {
  231. position: absolute;
  232. top: 200rpx;
  233. left: 202rpx;
  234. font-size: 40rpx;
  235. font-weight: bold;
  236. }
  237. .number {
  238. position: absolute;
  239. top: 265rpx;
  240. left: 202rpx;
  241. font-size: 24rpx;
  242. opacity: 0.5;
  243. }
  244. .real {
  245. position: absolute;
  246. top: 285rpx;
  247. left: 202rpx;
  248. display: flex;
  249. align-items: center;
  250. box-sizing: border-box;
  251. padding-left: 13rpx;
  252. width: 179rpx;
  253. height: 42rpx;
  254. font-size: 24rpx;
  255. border-radius: 113rpx;
  256. background-color: rgba(255, 255, 255, 0.2);
  257. img {
  258. margin-right: 7rpx;
  259. width: 24rpx;
  260. height: 24rpx;
  261. }
  262. }
  263. .real2 {
  264. position: absolute;
  265. top: 285rpx;
  266. left: 202rpx;
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. box-sizing: border-box;
  271. padding-left: 13rpx;
  272. padding-bottom: 5rpx;
  273. width: 179rpx;
  274. height: 42rpx;
  275. font-size: 24rpx;
  276. border-radius: 113rpx;
  277. background-color: rgba(255, 255, 255, 0.2);
  278. img {
  279. margin-left: 12rpx;
  280. width: 24rpx;
  281. height: 24rpx;
  282. }
  283. }
  284. .login {
  285. position: absolute;
  286. top: 235rpx;
  287. left: 202rpx;
  288. font-size: 40rpx;
  289. font-weight: bold;
  290. }
  291. }
  292. .body {
  293. position: absolute;
  294. top: 360rpx;
  295. width: 100%;
  296. min-height: calc(100vh - 360rpx);
  297. border-radius: 20rpx 20rpx 0 0;
  298. background-color: #f7f7f7;
  299. .myOrder {
  300. padding: 0 30rpx;
  301. margin-bottom: 23rpx;
  302. height: 224rpx;
  303. border-radius: 20rpx;
  304. background-color: #fff;
  305. .myOrder_header {
  306. display: flex;
  307. align-items: flex-end;
  308. height: 64rpx;
  309. .header_img {
  310. width: 42rpx;
  311. height: 42rpx;
  312. }
  313. .header_title {
  314. margin-left: 11rpx;
  315. font-size: 28rpx;
  316. font-weight: bold;
  317. }
  318. .header_more {
  319. display: flex;
  320. align-items: center;
  321. margin-left: auto;
  322. font-size: 24rpx;
  323. color: #b3b3b3;
  324. .more_img {
  325. margin-top: -5rpx;
  326. margin-left: 10rpx;
  327. width: 30rpx;
  328. height: 30rpx;
  329. }
  330. }
  331. }
  332. .myOrder_list {
  333. display: flex;
  334. justify-content: space-around;
  335. height: 160rpx;
  336. .list_box {
  337. display: flex;
  338. flex-direction: column;
  339. justify-content: center;
  340. align-items: center;
  341. width: 140rpx;
  342. .box_img {
  343. width: 50rpx;
  344. height: 50rpx;
  345. }
  346. .box_text {
  347. margin-top: 10rpx;
  348. color: #808080;
  349. font-size: 24rpx;
  350. }
  351. }
  352. }
  353. }
  354. .body_box {
  355. padding: 0 30rpx;
  356. margin-bottom: 23rpx;
  357. border-radius: 20rpx 20rpx 0 0;
  358. background-color: #fff;
  359. .box_title {
  360. display: flex;
  361. align-items: flex-end;
  362. height: 64rpx;
  363. font-size: 32rpx;
  364. font-weight: bold;
  365. }
  366. .box_list {
  367. display: grid;
  368. grid-template-columns: repeat(4, 1fr);
  369. grid-auto-rows: 160rpx;
  370. .item_box {
  371. display: flex;
  372. flex-direction: column;
  373. justify-content: center;
  374. align-items: center;
  375. .box_img {
  376. width: 50rpx;
  377. height: 50rpx;
  378. }
  379. .box_text {
  380. margin-top: 10rpx;
  381. color: #333333;
  382. font-size: 28rpx;
  383. }
  384. }
  385. }
  386. }
  387. }
  388. }
  389. </style>