my.vue 6.6 KB

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