my.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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. <!-- 是否实名认证区域 -->
  17. <!-- <view class="real" v-if="userInfo.card_number">
  18. <img src="../../static/my/true.png" />
  19. 已实名认证
  20. </view>
  21. <view class="real2" v-if="flag" v-else>
  22. 去认证
  23. <img src="../../static/my/right2.png" />
  24. </view> -->
  25. <view class="login" v-if="!flag" @click="goPageLogin">去登录</view>
  26. </view>
  27. <!-- 内容区域 -->
  28. <view class="body">
  29. <!-- 订单管理区域 -->
  30. <view class="body_item" @click="handleGoPage('/pages/orderManage/orderManage')">
  31. <img class="img" src="../../static/my/order.png" />
  32. 订单管理
  33. <img class="img_icon" src="../../static/my/right3.png" />
  34. </view>
  35. <!-- 我的评价区域 -->
  36. <view class="body_item" @click="handleGoPage('/pages/myEvaluate/myEvaluate')">
  37. <img class="img" src="../../static/my/evaluate.png" />
  38. 我的评价
  39. <img class="img_icon" src="../../static/my/right3.png" />
  40. </view>
  41. <!-- 收藏/住过区域 -->
  42. <view class="body_item" @click="handleGoPage('/pages/collect/collect')">
  43. <img class="img" src="../../static/my/collect.png" />
  44. 收藏/住过
  45. <img class="img_icon" src="../../static/my/right3.png" />
  46. </view>
  47. <!-- 我的卡券区域 -->
  48. <view class="body_item" @click="handleGoPage('/pages/myCoupon/myCoupon')">
  49. <img class="img" src="../../static/my/coupon.png" />
  50. 我的卡券
  51. <img class="img_icon" src="../../static/my/right3.png" />
  52. </view>
  53. <!-- 投诉进度区域 -->
  54. <view class="body_item" @click="handleGoPage('/pages/myComplaint/myComplaint')">
  55. <img class="img" src="../../static/my/complaint.png" />
  56. 投诉进度
  57. <img class="img_icon" src="../../static/my/right3.png" />
  58. </view>
  59. <!-- 常用旅客区域 -->
  60. <view class="body_item" @click="handleGoPage('/pages/common/common')">
  61. <img class="img2" src="../../static/my/people.png" />
  62. 常用旅客
  63. <img class="img_icon" src="../../static/my/right3.png" />
  64. </view>
  65. <!-- 我是商户区域 -->
  66. <!-- <view class="body_item" @click="handleClick(1)">
  67. <img class="img2" src="../../static/my/shop.png" />
  68. 我是商户
  69. <img class="img_icon" src="../../static/my/right3.png" />
  70. </view> -->
  71. <!-- 我是业主区域 -->
  72. <!-- <view class="body_item" @click="handleClick(2)">
  73. <img class="img2" src="../../static/my/shop2.png" />
  74. 我是业主
  75. <img class="img_icon" src="../../static/my/right3.png" />
  76. </view> -->
  77. <!-- 设置区域 -->
  78. <view class="body_item" @click="handleGoPage('/pages/set/set')">
  79. <img class="img3" src="../../static/my/set.png" />
  80. 设置
  81. <img class="img_icon" src="../../static/my/right3.png" />
  82. </view>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. export default {
  88. data() {
  89. return {
  90. // 是否登录标识
  91. flag: false,
  92. // 用户信息
  93. userInfo: {},
  94. // 状态栏高度
  95. statusBarH: 0,
  96. // 胶囊按钮栏高度
  97. customBarH: 0,
  98. // 顶部页面标题栏显示隐藏控制
  99. headerType: false
  100. }
  101. },
  102. created() {
  103. // 获取系统信息
  104. uni.getSystemInfo({
  105. success: (e) => {
  106. // 获取状态栏高度
  107. this.statusBarH = e.statusBarHeight + 10
  108. // // 获取菜单按钮栏高度
  109. let custom = uni.getMenuButtonBoundingClientRect()
  110. this.customBarH = custom.height + 10
  111. }
  112. })
  113. },
  114. onPageScroll(e) {
  115. if (e.scrollTop > 50) {
  116. this.headerType = true
  117. } else {
  118. this.headerType = false
  119. }
  120. },
  121. onLoad() {
  122. uni.$on('changeFlag', this.changeFlag)
  123. },
  124. onShow() {
  125. let openid = uni.getStorageSync('openid')
  126. if (openid) {
  127. this.flag = true
  128. this.userInfo = uni.getStorageSync('userInfo')
  129. } else {
  130. this.flag = false
  131. }
  132. },
  133. methods: {
  134. // 跳转页面回调
  135. handleGoPage(url) {
  136. if (this.isLogin()) {
  137. uni.navigateTo({
  138. url
  139. })
  140. }
  141. },
  142. changeFlag(e) {
  143. // console.log(e)
  144. this.flag = e.data
  145. this.userInfo = uni.getStorageSync('userInfo')
  146. },
  147. handleClick(type) {
  148. // 1为商户,2为业主
  149. uni.login({
  150. provider: 'weixin',
  151. success: (res) => {
  152. this.handleQuery(type, res.code)
  153. }
  154. })
  155. },
  156. // 查询请求
  157. async handleQuery(type, code) {
  158. if (type === 1) {
  159. // 查询商家是否绑定
  160. const res = await this.$myRequest({
  161. url: '/mhotel/appget_user_ma.action',
  162. data: {
  163. code
  164. }
  165. })
  166. if (res.code === 200) {
  167. let data = JSON.stringify(res.data)
  168. uni.navigateTo({
  169. url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
  170. })
  171. } else {
  172. uni.navigateTo({
  173. url: '/pages/shop/shop'
  174. })
  175. }
  176. } else if (type === 2) {
  177. // 查询业主是否已绑定
  178. const res = await this.$myRequest({
  179. url: '/mhotel/appgetUser.action',
  180. data: {
  181. code
  182. }
  183. })
  184. if (res.code === 200) {
  185. let data = JSON.stringify(res.data)
  186. uni.navigateTo({
  187. url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
  188. })
  189. } else {
  190. uni.navigateTo({
  191. url: '/pages/shop2/shop2'
  192. })
  193. }
  194. }
  195. },
  196. // 去登录文字回调
  197. goPageLogin() {
  198. uni.navigateTo({
  199. url: '/pages/login/login'
  200. })
  201. },
  202. isLogin() {
  203. if (this.flag) {
  204. return true
  205. } else {
  206. uni.showToast({
  207. title: '请先登录',
  208. icon: 'none',
  209. mask: true
  210. })
  211. setTimeout(() => {
  212. uni.navigateTo({
  213. url: '/pages/login/login'
  214. })
  215. }, 1500)
  216. }
  217. }
  218. }
  219. }
  220. </script>
  221. <style lang="scss" scoped>
  222. .container {
  223. position: relative;
  224. min-height: 100vh;
  225. .title {
  226. z-index: 999;
  227. position: fixed;
  228. top: 0;
  229. left: 0;
  230. right: 0;
  231. font-size: 28rpx;
  232. color: #fff;
  233. text-align: center;
  234. }
  235. .header {
  236. position: relative;
  237. height: 480rpx;
  238. color: #fff;
  239. overflow: hidden;
  240. img {
  241. width: 100%;
  242. }
  243. .img {
  244. position: absolute;
  245. top: 190rpx;
  246. left: 32rpx;
  247. width: 140rpx;
  248. height: 140rpx;
  249. border-radius: 50%;
  250. }
  251. .name {
  252. position: absolute;
  253. top: 200rpx;
  254. left: 202rpx;
  255. font-size: 40rpx;
  256. font-weight: bold;
  257. }
  258. .number {
  259. position: absolute;
  260. top: 265rpx;
  261. left: 202rpx;
  262. font-size: 24rpx;
  263. opacity: 0.5;
  264. }
  265. .real {
  266. position: absolute;
  267. top: 285rpx;
  268. left: 202rpx;
  269. display: flex;
  270. align-items: center;
  271. box-sizing: border-box;
  272. padding-left: 13rpx;
  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-right: 7rpx;
  280. width: 24rpx;
  281. height: 24rpx;
  282. }
  283. }
  284. .real2 {
  285. position: absolute;
  286. top: 285rpx;
  287. left: 202rpx;
  288. display: flex;
  289. justify-content: center;
  290. align-items: center;
  291. box-sizing: border-box;
  292. padding-left: 13rpx;
  293. padding-bottom: 5rpx;
  294. width: 179rpx;
  295. height: 42rpx;
  296. font-size: 24rpx;
  297. border-radius: 113rpx;
  298. background-color: rgba(255, 255, 255, 0.2);
  299. img {
  300. margin-left: 12rpx;
  301. width: 24rpx;
  302. height: 24rpx;
  303. }
  304. }
  305. .login {
  306. position: absolute;
  307. top: 235rpx;
  308. left: 202rpx;
  309. font-size: 40rpx;
  310. font-weight: bold;
  311. }
  312. }
  313. .body {
  314. position: absolute;
  315. top: 360rpx;
  316. box-sizing: border-box;
  317. padding: 0 30rpx;
  318. width: 100%;
  319. min-height: calc(100vh - 360rpx);
  320. border-radius: 20rpx 20rpx 0 0;
  321. background-color: #fff;
  322. .body_item {
  323. display: flex;
  324. align-items: center;
  325. height: 121rpx;
  326. font-size: 28rpx;
  327. border-bottom: 1rpx solid #e6e6e6;
  328. .img {
  329. margin-right: 17rpx;
  330. width: 53rpx;
  331. height: 53rpx;
  332. }
  333. .img2 {
  334. margin-right: 22rpx;
  335. width: 42rpx;
  336. height: 42rpx;
  337. }
  338. .img3 {
  339. margin-right: 18rpx;
  340. width: 50rpx;
  341. height: 50rpx;
  342. }
  343. .img_icon {
  344. margin-left: auto;
  345. width: 49rpx;
  346. height: 49rpx;
  347. }
  348. }
  349. }
  350. }
  351. </style>