my.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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('/pages/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('/pages/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('/pages/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('/pages/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('/pages/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('/pages/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: `/pages/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. },
  265. complete() {
  266. uni.navigateTo({
  267. url
  268. });
  269. }
  270. });
  271. }
  272. },
  273. }
  274. }
  275. </script>
  276. <style lang="scss" scoped>
  277. .container {
  278. position: relative;
  279. min-height: 100vh;
  280. .title {
  281. z-index: 999;
  282. position: fixed;
  283. top: 0;
  284. left: 0;
  285. right: 0;
  286. font-size: 28rpx;
  287. color: #fff;
  288. text-align: center;
  289. }
  290. .header {
  291. position: relative;
  292. height: 480rpx;
  293. color: #fff;
  294. overflow: hidden;
  295. img {
  296. width: 100%;
  297. }
  298. .img {
  299. position: absolute;
  300. top: 190rpx;
  301. left: 32rpx;
  302. width: 140rpx;
  303. height: 140rpx;
  304. border-radius: 50%;
  305. }
  306. .name {
  307. position: absolute;
  308. top: 200rpx;
  309. left: 202rpx;
  310. font-size: 40rpx;
  311. font-weight: bold;
  312. }
  313. .number {
  314. position: absolute;
  315. top: 265rpx;
  316. left: 202rpx;
  317. font-size: 24rpx;
  318. opacity: 0.5;
  319. }
  320. .real {
  321. position: absolute;
  322. top: 285rpx;
  323. left: 202rpx;
  324. display: flex;
  325. align-items: center;
  326. box-sizing: border-box;
  327. padding-left: 13rpx;
  328. width: 179rpx;
  329. height: 42rpx;
  330. font-size: 24rpx;
  331. border-radius: 113rpx;
  332. background-color: rgba(255, 255, 255, 0.2);
  333. img {
  334. margin-right: 7rpx;
  335. width: 24rpx;
  336. height: 24rpx;
  337. }
  338. }
  339. .real2 {
  340. position: absolute;
  341. top: 285rpx;
  342. left: 202rpx;
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. box-sizing: border-box;
  347. padding-left: 13rpx;
  348. padding-bottom: 5rpx;
  349. width: 179rpx;
  350. height: 42rpx;
  351. font-size: 24rpx;
  352. border-radius: 113rpx;
  353. background-color: rgba(255, 255, 255, 0.2);
  354. img {
  355. margin-left: 12rpx;
  356. width: 24rpx;
  357. height: 24rpx;
  358. }
  359. }
  360. .login {
  361. position: absolute;
  362. top: 235rpx;
  363. left: 202rpx;
  364. font-size: 40rpx;
  365. font-weight: bold;
  366. }
  367. }
  368. .body {
  369. position: absolute;
  370. top: 360rpx;
  371. width: 100%;
  372. min-height: calc(100vh - 360rpx);
  373. border-radius: 20rpx 20rpx 0 0;
  374. background-color: #f7f7f7;
  375. .myOrder {
  376. padding: 0 30rpx;
  377. margin-bottom: 23rpx;
  378. height: 224rpx;
  379. border-radius: 20rpx;
  380. background-color: #fff;
  381. .myOrder_header {
  382. display: flex;
  383. align-items: flex-end;
  384. height: 64rpx;
  385. .header_img {
  386. width: 42rpx;
  387. height: 42rpx;
  388. }
  389. .header_title {
  390. display: flex;
  391. align-items: flex-end;
  392. height: 64rpx;
  393. font-size: 32rpx;
  394. font-weight: bold;
  395. }
  396. .header_more {
  397. display: flex;
  398. align-items: center;
  399. margin-left: auto;
  400. font-size: 24rpx;
  401. color: #b3b3b3;
  402. .more_img {
  403. margin-top: -5rpx;
  404. margin-left: 10rpx;
  405. width: 30rpx;
  406. height: 30rpx;
  407. }
  408. }
  409. }
  410. .myOrder_list {
  411. display: flex;
  412. justify-content: space-around;
  413. height: 160rpx;
  414. .list_box {
  415. display: flex;
  416. flex-direction: column;
  417. justify-content: center;
  418. align-items: center;
  419. width: 140rpx;
  420. .box_img {
  421. width: 50rpx;
  422. height: 50rpx;
  423. }
  424. .box_text {
  425. margin-top: 10rpx;
  426. color: #808080;
  427. font-size: 24rpx;
  428. }
  429. }
  430. }
  431. }
  432. .body_box {
  433. padding: 0 30rpx;
  434. margin-bottom: 23rpx;
  435. border-radius: 20rpx 20rpx 0 0;
  436. background-color: #fff;
  437. .box_title {
  438. display: flex;
  439. align-items: flex-end;
  440. height: 64rpx;
  441. font-size: 32rpx;
  442. font-weight: bold;
  443. }
  444. .box_list {
  445. display: grid;
  446. grid-template-columns: repeat(4, 1fr);
  447. grid-auto-rows: 160rpx;
  448. .item_box {
  449. display: flex;
  450. flex-direction: column;
  451. justify-content: center;
  452. align-items: center;
  453. .box_img {
  454. width: 50rpx;
  455. height: 50rpx;
  456. }
  457. .box_text {
  458. margin-top: 10rpx;
  459. color: #333333;
  460. font-size: 28rpx;
  461. }
  462. }
  463. }
  464. }
  465. }
  466. }
  467. </style>