mine.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="container">
  3. <view class="user">
  4. <view class="userInfo">
  5. <image @click="toUserInfo" 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="$navigateTo('/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="https://mall.rongtongh.cn/storage/img/mine/title.png" mode=""></image>
  40. </view>
  41. <view class="menuList">
  42. <view class="menu" @click="pageTo('/pages/addressManage/addressManage')">
  43. <image src="https://mall.rongtongh.cn/storage/img/mine/menu1.png"></image>
  44. <span>地址管理</span>
  45. </view>
  46. <view class="menu">
  47. <image src="https://mall.rongtongh.cn/storage/img/mine/menu2.png"></image>
  48. <span>消费记录</span>
  49. </view>
  50. <view class="menu">
  51. <image src="https://mall.rongtongh.cn/storage/img/mine/menu3.png"></image>
  52. <span>加群交流</span>
  53. </view>
  54. <view class="menu">
  55. <image src="https://mall.rongtongh.cn/storage/img/mine/menu4.png"></image>
  56. <span>游戏规则</span>
  57. </view>
  58. <view class="menu">
  59. <image src="https://mall.rongtongh.cn/storage/img/mine/menu5.png"></image>
  60. <span>用户协议</span>
  61. </view>
  62. <view class="menu">
  63. <image src="https://mall.rongtongh.cn/storage/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. toUserInfo() {
  96. this.$navigateTo('/pages/user/user')
  97. if (this.isLogin) {
  98. this.$navigateTo('/pages/user/user')
  99. }
  100. },
  101. getUserInfo() {
  102. userInfoApi().then(res => {
  103. console.log(res, '详细用户信息')
  104. this.userInfoDetail = res.data
  105. })
  106. },
  107. toLogin() {
  108. wx.navigateTo({url: '/pages/login/login'})
  109. },
  110. pageTo(url) {
  111. wx.navigateTo({url: url})
  112. },
  113. }
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .container {
  118. background: #9EC8F9;
  119. padding: 0 10px;
  120. overflow: scroll;
  121. }
  122. .user {
  123. background: #fff;
  124. border-radius: 10px;
  125. padding: 0 10px;
  126. position: relative;
  127. margin-top: 10vw;
  128. .userInfo {
  129. display: flex;
  130. .userPhoto {
  131. width: 74px;
  132. height: 74px;
  133. border-radius: 50%;
  134. border: solid 3px #6BAFFF;
  135. position: relative;
  136. top: -20px;
  137. background: #dedede;
  138. }
  139. .info {
  140. padding: 10px;
  141. .name {
  142. font-weight: 600;
  143. }
  144. .loginText {
  145. font-weight: 600;
  146. }
  147. .id {
  148. margin-top: 5px;
  149. font-size: 13px;
  150. }
  151. }
  152. }
  153. .row {
  154. display: flex;
  155. justify-content: space-around;
  156. .box {
  157. display: flex;
  158. flex-direction: column;
  159. text-align: center;
  160. padding: 20px 10px;
  161. .label {
  162. margin-top: 5px;
  163. font-size: 15px;
  164. }
  165. .value {
  166. font-size: 20px;
  167. font-weight: 600;
  168. }
  169. }
  170. }
  171. }
  172. .menus {
  173. margin-top: 20px;
  174. background: #fff;
  175. border-radius: 10px;
  176. // padding: 0 10px;
  177. .title {
  178. position: relative;
  179. left: -10px;
  180. top: -10px;
  181. width: calc(100% + 10px);
  182. height: 55px;
  183. image {
  184. width: 100%;
  185. height: 100%;
  186. }
  187. }
  188. .menuList {
  189. display: grid;
  190. grid-template-columns: 1fr 1fr 1fr;
  191. padding: 20px 20px 0 20px;
  192. .menu {
  193. margin-bottom: 30px;
  194. display: flex;
  195. flex-direction: column;
  196. justify-content: center;
  197. align-items: center;
  198. image {
  199. width: 36px;
  200. height: 36px;
  201. }
  202. span {
  203. margin-top: 10px;
  204. font-size: 14px;
  205. }
  206. }
  207. }
  208. }
  209. </style>