my.vue 12 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('/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. <img class="header_img" src="../../static/my/myorder5.png" />
  54. <view class="header_title">商城订单</view>
  55. <view class="header_more" @click="toOrder('/packageShang/pages/user/order/order', '全部')">
  56. 全部订单
  57. <img class="more_img" src="../../static/my/right.png" />
  58. </view>
  59. </view>
  60. <view class="myOrder_list">
  61. <view class="list_box" @click="toOrder('/packageShang/pages/user/order/order', '待付款')">
  62. <img class="box_img" src="../../static/my/myorder.png" />
  63. <view class="box_text">待付款</view>
  64. </view>
  65. <view class="list_box" @click="toOrder('/packageShang/pages/user/order/order', '待发货')">
  66. <img class="box_img" src="../../static/my/myorder2.png" />
  67. <view class="box_text">待发货</view>
  68. </view>
  69. <view class="list_box" @click="toOrder('/packageShang/pages/user/order/order', '待收货')">
  70. <img class="box_img" src="../../static/my/myorder3.png" />
  71. <view class="box_text">待收货</view>
  72. </view>
  73. <view class="list_box" @click="toOrder('/packageShang/pages/user/order/order', '待评价')">
  74. <img class="box_img" src="../../static/my/myorder4.png" />
  75. <view class="box_text">待评价</view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 常用工具区域 -->
  80. <view class="body_box">
  81. <view class="box_title">常用工具</view>
  82. <view class="box_list">
  83. <view class="item_box" @click="handleShowCar">
  84. <img class="box_img" src="../../static/my/shopcar.png" />
  85. <view class="box_text">购物车</view>
  86. </view>
  87. <view class="item_box" @click="handleShowAddress">
  88. <img class="box_img" src="../../static/my/address.png" />
  89. <view class="box_text">收货地址</view>
  90. </view>
  91. <view class="item_box" @click="handleGoPageHome">
  92. <img class="box_img" src="../../static/my/center.png" />
  93. <view class="box_text">个人主页</view>
  94. </view>
  95. <view class="item_box" @click="handleGoPage('/pages/set/set')">
  96. <img class="box_img" src="../../static/my/set.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. handleShowCar(){
  199. let userInfo = uni.getStorageSync('userInfo')
  200. let tokenId = uni.getStorageSync('tokenId')
  201. if (!userInfo || !tokenId) {
  202. uni.showModal({
  203. title: '提示',
  204. content: '您当前未登录,请授权登录查看社区信息',
  205. showCancel: false,
  206. success: (res) => {
  207. if (res.confirm) {
  208. uni.navigateTo({
  209. url: '/pages/login/login'
  210. })
  211. }
  212. }
  213. })
  214. }else{
  215. uni.navigateTo({
  216. url:'/packageShang/pages/tabbar/cart'
  217. })
  218. }
  219. },
  220. //收货地址
  221. handleShowAddress(){
  222. let userInfo = uni.getStorageSync('userInfo')
  223. let tokenId = uni.getStorageSync('tokenId')
  224. if (!userInfo || !tokenId) {
  225. uni.showModal({
  226. title: '提示',
  227. content: '您当前未登录,请授权登录查看社区信息',
  228. showCancel: false,
  229. success: (res) => {
  230. if (res.confirm) {
  231. uni.navigateTo({
  232. url: '/pages/login/login'
  233. })
  234. }
  235. }
  236. })
  237. }else{
  238. uni.navigateTo({
  239. url:'/packageShang/pages/user/address/address'
  240. })
  241. }
  242. },
  243. // 跳转到 订单
  244. toOrder(url, state) {
  245. let userInfo = uni.getStorageSync('userInfo')
  246. let tokenId = uni.getStorageSync('tokenId')
  247. if (!userInfo || !tokenId) {
  248. uni.showModal({
  249. title: '提示',
  250. content: '您当前未登录,请授权登录查看社区信息',
  251. showCancel: false,
  252. success: (res) => {
  253. if (res.confirm) {
  254. uni.navigateTo({
  255. url: '/pages/login/login'
  256. })
  257. }
  258. }
  259. })
  260. }else{
  261. uni.setStorage({
  262. key: '__order_state',
  263. data: state,
  264. success(res) {
  265. },
  266. complete() {
  267. uni.navigateTo({
  268. url
  269. });
  270. }
  271. });
  272. }
  273. },
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .container {
  279. position: relative;
  280. min-height: 100vh;
  281. .title {
  282. z-index: 999;
  283. position: fixed;
  284. top: 0;
  285. left: 0;
  286. right: 0;
  287. font-size: 28rpx;
  288. color: #fff;
  289. text-align: center;
  290. }
  291. .header {
  292. position: relative;
  293. height: 480rpx;
  294. color: #fff;
  295. overflow: hidden;
  296. img {
  297. width: 100%;
  298. }
  299. .img {
  300. position: absolute;
  301. top: 190rpx;
  302. left: 32rpx;
  303. width: 140rpx;
  304. height: 140rpx;
  305. border-radius: 50%;
  306. }
  307. .name {
  308. position: absolute;
  309. top: 200rpx;
  310. left: 202rpx;
  311. font-size: 40rpx;
  312. font-weight: bold;
  313. }
  314. .number {
  315. position: absolute;
  316. top: 265rpx;
  317. left: 202rpx;
  318. font-size: 24rpx;
  319. opacity: 0.5;
  320. }
  321. .real {
  322. position: absolute;
  323. top: 285rpx;
  324. left: 202rpx;
  325. display: flex;
  326. align-items: center;
  327. box-sizing: border-box;
  328. padding-left: 13rpx;
  329. width: 179rpx;
  330. height: 42rpx;
  331. font-size: 24rpx;
  332. border-radius: 113rpx;
  333. background-color: rgba(255, 255, 255, 0.2);
  334. img {
  335. margin-right: 7rpx;
  336. width: 24rpx;
  337. height: 24rpx;
  338. }
  339. }
  340. .real2 {
  341. position: absolute;
  342. top: 285rpx;
  343. left: 202rpx;
  344. display: flex;
  345. justify-content: center;
  346. align-items: center;
  347. box-sizing: border-box;
  348. padding-left: 13rpx;
  349. padding-bottom: 5rpx;
  350. width: 179rpx;
  351. height: 42rpx;
  352. font-size: 24rpx;
  353. border-radius: 113rpx;
  354. background-color: rgba(255, 255, 255, 0.2);
  355. img {
  356. margin-left: 12rpx;
  357. width: 24rpx;
  358. height: 24rpx;
  359. }
  360. }
  361. .login {
  362. position: absolute;
  363. top: 235rpx;
  364. left: 202rpx;
  365. font-size: 40rpx;
  366. font-weight: bold;
  367. }
  368. }
  369. .body {
  370. position: absolute;
  371. top: 360rpx;
  372. width: 100%;
  373. min-height: calc(100vh - 360rpx);
  374. border-radius: 20rpx 20rpx 0 0;
  375. background-color: #f7f7f7;
  376. .myOrder {
  377. padding: 0 30rpx;
  378. margin-bottom: 23rpx;
  379. height: 224rpx;
  380. border-radius: 20rpx;
  381. background-color: #fff;
  382. .myOrder_header {
  383. display: flex;
  384. align-items: flex-end;
  385. height: 64rpx;
  386. .header_img {
  387. width: 42rpx;
  388. height: 42rpx;
  389. }
  390. .header_title {
  391. margin-left: 11rpx;
  392. font-size: 28rpx;
  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>