my.vue 11 KB

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