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. let openid = uni.getStorageSync('openid')
  74. if (openid) {
  75. this.flag = true
  76. this.userInfo = uni.getStorageSync('userInfo')
  77. } else {
  78. this.flag = false
  79. }
  80. },
  81. onShow() {
  82. // console.log(121)
  83. },
  84. methods: {
  85. changeFlag(e) {
  86. // console.log(e)
  87. this.flag = e.data
  88. this.userInfo = uni.getStorageSync('userInfo')
  89. },
  90. handleClick(type) {
  91. // 1为商户,2为业主
  92. uni.login({
  93. provider: 'weixin',
  94. success: (res) => {
  95. this.handleQuery(type, res.code)
  96. }
  97. })
  98. },
  99. // 查询请求
  100. async handleQuery(type, code) {
  101. if (type === 1) {
  102. // 查询商家是否绑定
  103. const res = await this.$myRequest({
  104. url: '/mhotel/appget_user_ma.action',
  105. data: {
  106. code
  107. }
  108. })
  109. if (res.code === 200) {
  110. let data = JSON.stringify(res.data)
  111. uni.navigateTo({
  112. url: `/pages/shopInfo/shopInfo?type=1&data=${data}`
  113. })
  114. } else {
  115. uni.navigateTo({
  116. url: '/pages/shop/shop'
  117. })
  118. }
  119. } else if (type === 2) {
  120. // 查询业主是否已绑定
  121. const res = await this.$myRequest({
  122. url: '/mhotel/appgetUser.action',
  123. data: {
  124. code
  125. }
  126. })
  127. if (res.code === 200) {
  128. let data = JSON.stringify(res.data)
  129. uni.navigateTo({
  130. url: `/pages/shopInfo/shopInfo?type=2&data=${data}`
  131. })
  132. } else {
  133. uni.navigateTo({
  134. url: '/pages/shop2/shop2'
  135. })
  136. }
  137. }
  138. },
  139. // 去登录文字回调
  140. goPageLogin() {
  141. uni.navigateTo({
  142. url: '/pages/login/login'
  143. })
  144. },
  145. // 点击订单管理按钮回调
  146. goPageOrder() {
  147. if (this.isLogin()) {
  148. uni.navigateTo({
  149. url: '/pages/orderManage/orderManage'
  150. })
  151. }
  152. },
  153. // 点击常用旅客按钮回调
  154. goPageCommon() {
  155. if (this.isLogin()) {
  156. uni.navigateTo({
  157. url: '/pages/common/common'
  158. })
  159. }
  160. },
  161. // 点击设置按钮回调
  162. goPageSet() {
  163. if (this.isLogin()) {
  164. uni.navigateTo({
  165. url: '/pages/set/set'
  166. })
  167. }
  168. },
  169. isLogin() {
  170. if (this.flag) {
  171. return true
  172. } else {
  173. uni.showToast({
  174. title: '请先登录',
  175. icon: 'none',
  176. mask: true
  177. })
  178. setTimeout(() => {
  179. uni.navigateTo({
  180. url: '/pages/login/login'
  181. })
  182. }, 1500)
  183. }
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .container {
  190. position: relative;
  191. min-height: 100vh;
  192. background-color: #ebeced;
  193. .header {
  194. position: relative;
  195. height: 480rpx;
  196. color: #fff;
  197. overflow: hidden;
  198. img {
  199. width: 100%;
  200. }
  201. .title {
  202. position: absolute;
  203. top: 65rpx;
  204. left: 342rpx;
  205. font-size: 28rpx;
  206. color: #fff;
  207. }
  208. .img {
  209. position: absolute;
  210. top: 190rpx;
  211. left: 32rpx;
  212. width: 140rpx;
  213. height: 140rpx;
  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>