my.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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" v-if="showFab">
  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" v-if="showFab">
  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. showFab: true
  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. this.getShow()
  145. let openid = uni.getStorageSync('openid')
  146. if (openid) {
  147. this.flag = true
  148. this.userInfo = uni.getStorageSync('userInfo')
  149. } else {
  150. this.flag = false
  151. }
  152. },
  153. methods: {
  154. async getShow() {
  155. const res = await this.$myRequest({
  156. url: '/mhotel/admintrueStr.action'
  157. })
  158. // console.log(res)
  159. if (res.code == 200) {
  160. res.data == 0 ? (this.showFab = true) : (this.showFab = false)
  161. }
  162. },
  163. // 跳转页面回调
  164. handleGoPage(url) {
  165. if (this.isLogin()) {
  166. uni.navigateTo({
  167. url
  168. })
  169. }
  170. },
  171. changeFlag(e) {
  172. // console.log(e)
  173. this.flag = e.data
  174. this.userInfo = uni.getStorageSync('userInfo')
  175. },
  176. // 去登录文字回调
  177. goPageLogin() {
  178. uni.navigateTo({
  179. url: '/pages/login/login'
  180. })
  181. },
  182. isLogin() {
  183. if (this.flag) {
  184. return true
  185. } else {
  186. uni.showToast({
  187. title: '请先登录',
  188. icon: 'none',
  189. mask: true
  190. })
  191. setTimeout(() => {
  192. uni.navigateTo({
  193. url: '/pages/login/login'
  194. })
  195. }, 1500)
  196. }
  197. },
  198. handleGoPageHome() {
  199. let userId = uni.getStorageSync('userInfo').id
  200. uni.navigateTo({
  201. url: `/pages/myHome/myHome?userId=${userId}`
  202. })
  203. },
  204. handleShowTest() {
  205. showTest()
  206. },
  207. //购物车
  208. handleShowCar() {
  209. let userInfo = uni.getStorageSync('userInfo')
  210. let tokenId = uni.getStorageSync('tokenId')
  211. if (!userInfo || !tokenId) {
  212. uni.showModal({
  213. title: '提示',
  214. content: '您当前未登录,请授权登录查看社区信息',
  215. showCancel: false,
  216. success: (res) => {
  217. if (res.confirm) {
  218. uni.navigateTo({
  219. url: '/pages/login/login'
  220. })
  221. }
  222. }
  223. })
  224. } else {
  225. uni.navigateTo({
  226. url: '/packageShang/pages/tabbar/cart'
  227. })
  228. }
  229. },
  230. //收货地址
  231. handleShowAddress() {
  232. let userInfo = uni.getStorageSync('userInfo')
  233. let tokenId = uni.getStorageSync('tokenId')
  234. if (!userInfo || !tokenId) {
  235. uni.showModal({
  236. title: '提示',
  237. content: '您当前未登录,请授权登录查看社区信息',
  238. showCancel: false,
  239. success: (res) => {
  240. if (res.confirm) {
  241. uni.navigateTo({
  242. url: '/pages/login/login'
  243. })
  244. }
  245. }
  246. })
  247. } else {
  248. uni.navigateTo({
  249. url: '/packageShang/pages/user/address/address'
  250. })
  251. }
  252. },
  253. // 跳转到 订单
  254. toOrder(url, state) {
  255. let userInfo = uni.getStorageSync('userInfo')
  256. let tokenId = uni.getStorageSync('tokenId')
  257. if (!userInfo || !tokenId) {
  258. uni.showModal({
  259. title: '提示',
  260. content: '您当前未登录,请授权登录查看社区信息',
  261. showCancel: false,
  262. success: (res) => {
  263. if (res.confirm) {
  264. uni.navigateTo({
  265. url: '/pages/login/login'
  266. })
  267. }
  268. }
  269. })
  270. } else {
  271. uni.setStorage({
  272. key: '__order_state',
  273. data: state,
  274. success(res) {},
  275. complete() {
  276. uni.navigateTo({
  277. url
  278. })
  279. }
  280. })
  281. }
  282. }
  283. }
  284. }
  285. </script>
  286. <style lang="scss" scoped>
  287. .container {
  288. position: relative;
  289. min-height: 100vh;
  290. .title {
  291. z-index: 999;
  292. position: fixed;
  293. top: 0;
  294. left: 0;
  295. right: 0;
  296. font-size: 28rpx;
  297. color: #fff;
  298. text-align: center;
  299. }
  300. .header {
  301. position: relative;
  302. height: 480rpx;
  303. color: #fff;
  304. overflow: hidden;
  305. img {
  306. width: 100%;
  307. }
  308. .img {
  309. position: absolute;
  310. top: 190rpx;
  311. left: 32rpx;
  312. width: 140rpx;
  313. height: 140rpx;
  314. border-radius: 50%;
  315. }
  316. .name {
  317. position: absolute;
  318. top: 200rpx;
  319. left: 202rpx;
  320. font-size: 40rpx;
  321. font-weight: bold;
  322. }
  323. .number {
  324. position: absolute;
  325. top: 265rpx;
  326. left: 202rpx;
  327. font-size: 24rpx;
  328. opacity: 0.5;
  329. }
  330. .real {
  331. position: absolute;
  332. top: 285rpx;
  333. left: 202rpx;
  334. display: flex;
  335. align-items: center;
  336. box-sizing: border-box;
  337. padding-left: 13rpx;
  338. width: 179rpx;
  339. height: 42rpx;
  340. font-size: 24rpx;
  341. border-radius: 113rpx;
  342. background-color: rgba(255, 255, 255, 0.2);
  343. img {
  344. margin-right: 7rpx;
  345. width: 24rpx;
  346. height: 24rpx;
  347. }
  348. }
  349. .real2 {
  350. position: absolute;
  351. top: 285rpx;
  352. left: 202rpx;
  353. display: flex;
  354. justify-content: center;
  355. align-items: center;
  356. box-sizing: border-box;
  357. padding-left: 13rpx;
  358. padding-bottom: 5rpx;
  359. width: 179rpx;
  360. height: 42rpx;
  361. font-size: 24rpx;
  362. border-radius: 113rpx;
  363. background-color: rgba(255, 255, 255, 0.2);
  364. img {
  365. margin-left: 12rpx;
  366. width: 24rpx;
  367. height: 24rpx;
  368. }
  369. }
  370. .login {
  371. position: absolute;
  372. top: 235rpx;
  373. left: 202rpx;
  374. font-size: 40rpx;
  375. font-weight: bold;
  376. }
  377. }
  378. .body {
  379. position: absolute;
  380. top: 360rpx;
  381. width: 100%;
  382. min-height: calc(100vh - 360rpx);
  383. border-radius: 20rpx 20rpx 0 0;
  384. background-color: #f7f7f7;
  385. .myOrder {
  386. padding: 0 30rpx;
  387. margin-bottom: 23rpx;
  388. height: 224rpx;
  389. border-radius: 20rpx;
  390. background-color: #fff;
  391. .myOrder_header {
  392. display: flex;
  393. align-items: flex-end;
  394. height: 64rpx;
  395. .header_img {
  396. width: 42rpx;
  397. height: 42rpx;
  398. }
  399. .header_title {
  400. display: flex;
  401. align-items: flex-end;
  402. height: 64rpx;
  403. font-size: 32rpx;
  404. font-weight: bold;
  405. }
  406. .header_more {
  407. display: flex;
  408. align-items: center;
  409. margin-left: auto;
  410. font-size: 24rpx;
  411. color: #b3b3b3;
  412. .more_img {
  413. margin-top: -5rpx;
  414. margin-left: 10rpx;
  415. width: 30rpx;
  416. height: 30rpx;
  417. }
  418. }
  419. }
  420. .myOrder_list {
  421. display: flex;
  422. justify-content: space-around;
  423. height: 160rpx;
  424. .list_box {
  425. display: flex;
  426. flex-direction: column;
  427. justify-content: center;
  428. align-items: center;
  429. width: 140rpx;
  430. .box_img {
  431. width: 50rpx;
  432. height: 50rpx;
  433. }
  434. .box_text {
  435. margin-top: 10rpx;
  436. color: #808080;
  437. font-size: 24rpx;
  438. }
  439. }
  440. }
  441. }
  442. .body_box {
  443. padding: 0 30rpx;
  444. margin-bottom: 23rpx;
  445. border-radius: 20rpx 20rpx 0 0;
  446. background-color: #fff;
  447. .box_title {
  448. display: flex;
  449. align-items: flex-end;
  450. height: 64rpx;
  451. font-size: 32rpx;
  452. font-weight: bold;
  453. }
  454. .box_list {
  455. display: grid;
  456. grid-template-columns: repeat(4, 1fr);
  457. grid-auto-rows: 160rpx;
  458. .item_box {
  459. display: flex;
  460. flex-direction: column;
  461. justify-content: center;
  462. align-items: center;
  463. .box_img {
  464. width: 50rpx;
  465. height: 50rpx;
  466. }
  467. .box_text {
  468. margin-top: 10rpx;
  469. color: #333333;
  470. font-size: 28rpx;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. }
  477. </style>