mine.vue 4.2 KB

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