mine.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="container">
  3. <view class="user">
  4. <view class="userInfo">
  5. <image class="userPhoto" :src="userInfo.avatarUrl"></image>
  6. <view class="info">
  7. <view class="name" v-if="hasLogin">
  8. {{userInfo.nickName}}
  9. </view>
  10. <view class="loginText" @click="toLogin" v-else>
  11. 点击登录
  12. </view>
  13. <view class="id">
  14. ID: {{userId}}
  15. </view>
  16. </view>
  17. <view class="" @click="loginOut">
  18. 退出登录
  19. </view>
  20. </view>
  21. <view class="row">
  22. <view class="box">
  23. <view class="value" style="color: #FF2C43;">
  24. 1000
  25. </view>
  26. <view class="label">
  27. 积分
  28. </view>
  29. </view>
  30. <view class="box">
  31. <view class="value">
  32. 2
  33. </view>
  34. <view class="label">
  35. 优惠卷
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="menus">
  41. <view class="title">
  42. <image src="/static/img/mine/title.png" mode=""></image>
  43. </view>
  44. <view class="menuList">
  45. <view class="menu" @click="pageTo('/pages/addressManage/addressManage')">
  46. <image src="/static/img/mine/menu1.png"></image>
  47. <span>地址管理</span>
  48. </view>
  49. <view class="menu">
  50. <image src="/static/img/mine/menu2.png"></image>
  51. <span>消费记录</span>
  52. </view>
  53. <view class="menu">
  54. <image src="/static/img/mine/menu3.png"></image>
  55. <span>加群交流</span>
  56. </view>
  57. <view class="menu">
  58. <image src="/static/img/mine/menu4.png"></image>
  59. <span>游戏规则</span>
  60. </view>
  61. <view class="menu">
  62. <image src="/static/img/mine/menu5.png"></image>
  63. <span>用户协议</span>
  64. </view>
  65. <view class="menu">
  66. <image src="/static/img/mine/menu6.png"></image>
  67. <span>联系客服</span>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. export default {
  75. data() {
  76. return {
  77. isLogin: false,
  78. userInfo: null,
  79. userId: '-',
  80. hasLogin: false,
  81. }
  82. },
  83. onShow() {
  84. //获取用户的登录信息
  85. if (wx.getStorageSync('token')) {
  86. this.userInfo = wx.getStorageSync('userInfo');
  87. this.userId = wx.getStorageSync('userId');
  88. this.hasLogin = true
  89. }
  90. },
  91. methods: {
  92. toLogin() {
  93. wx.navigateTo({url: '/pages/login/login'})
  94. },
  95. pageTo(url) {
  96. wx.navigateTo({url: url})
  97. },
  98. loginOut() {
  99. wx.removeStorageSync('userInfo')
  100. wx.removeStorageSync('userId')
  101. wx.removeStorageSync('token')
  102. getApp().globalData.hasLogin = false;
  103. this.hasLogin = false
  104. }
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .container {
  110. background: #9EC8F9;
  111. padding: 0 10px;
  112. overflow: scroll;
  113. }
  114. .user {
  115. background: #fff;
  116. border-radius: 10px;
  117. padding: 0 10px;
  118. position: relative;
  119. margin-top: 10vw;
  120. .userInfo {
  121. display: flex;
  122. .userPhoto {
  123. width: 74px;
  124. height: 74px;
  125. border-radius: 50%;
  126. border: solid 3px #6BAFFF;
  127. position: relative;
  128. top: -20px;
  129. background: #dedede;
  130. }
  131. .info {
  132. padding: 10px;
  133. .name {
  134. font-weight: 600;
  135. }
  136. .loginText {
  137. font-weight: 600;
  138. }
  139. .id {
  140. margin-top: 5px;
  141. font-size: 13px;
  142. }
  143. }
  144. }
  145. .row {
  146. display: flex;
  147. justify-content: space-around;
  148. .box {
  149. display: flex;
  150. flex-direction: column;
  151. text-align: center;
  152. padding: 20px 10px;
  153. .label {
  154. margin-top: 5px;
  155. font-size: 15px;
  156. }
  157. .value {
  158. font-size: 20px;
  159. font-weight: 600;
  160. }
  161. }
  162. }
  163. }
  164. .menus {
  165. margin-top: 20px;
  166. background: #fff;
  167. border-radius: 10px;
  168. // padding: 0 10px;
  169. .title {
  170. position: relative;
  171. left: -10px;
  172. top: -10px;
  173. width: calc(100% + 10px);
  174. height: 55px;
  175. image {
  176. width: 100%;
  177. height: 100%;
  178. }
  179. }
  180. .menuList {
  181. display: grid;
  182. grid-template-columns: 1fr 1fr 1fr;
  183. padding: 20px 20px 0 20px;
  184. .menu {
  185. margin-bottom: 30px;
  186. display: flex;
  187. flex-direction: column;
  188. justify-content: center;
  189. align-items: center;
  190. image {
  191. width: 36px;
  192. height: 36px;
  193. }
  194. span {
  195. margin-top: 10px;
  196. font-size: 14px;
  197. }
  198. }
  199. }
  200. }
  201. </style>