my.vue 7.4 KB

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