mine.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. this.userInfo = wx.getStorageSync('userInfo');
  86. this.userId = wx.getStorageSync('userId');
  87. //获取用户的登录信息
  88. if (wx.getStorageSync('token')) {
  89. this.hasLogin = true
  90. getApp().globalData.hasLogin = true
  91. // 获取用户信息详情
  92. this.getUserInfo()
  93. } else {
  94. this.hasLogin = false
  95. getApp().globalData.hasLogin = false
  96. this.userInfoDetail = {}
  97. }
  98. },
  99. methods: {
  100. toUserInfo() {
  101. this.$navigateTo('/pages/user/user')
  102. if (this.isLogin) {
  103. this.$navigateTo('/pages/user/user')
  104. }
  105. },
  106. getUserInfo() {
  107. userInfoApi().then(res => {
  108. console.log(res, '详细用户信息')
  109. this.userInfoDetail = res.data
  110. })
  111. },
  112. toLogin() {
  113. wx.navigateTo({url: '/pages/login/login'})
  114. },
  115. pageTo(url) {
  116. wx.navigateTo({url: url})
  117. },
  118. }
  119. }
  120. </script>
  121. <style scoped lang="scss">
  122. .container {
  123. background: #9EC8F9;
  124. padding: 0 10px;
  125. overflow: scroll;
  126. }
  127. .user {
  128. background: #fff;
  129. border-radius: 10px;
  130. padding: 0 10px;
  131. position: relative;
  132. margin-top: 10vw;
  133. .userInfo {
  134. display: flex;
  135. .userPhoto {
  136. width: 74px;
  137. height: 74px;
  138. border-radius: 50%;
  139. border: solid 3px #6BAFFF;
  140. position: relative;
  141. top: -20px;
  142. background: #dedede;
  143. }
  144. .info {
  145. padding: 10px;
  146. .name {
  147. font-weight: 600;
  148. }
  149. .loginText {
  150. font-weight: 600;
  151. }
  152. .id {
  153. margin-top: 5px;
  154. font-size: 13px;
  155. }
  156. }
  157. }
  158. .row {
  159. display: flex;
  160. justify-content: space-around;
  161. .box {
  162. display: flex;
  163. flex-direction: column;
  164. text-align: center;
  165. padding: 20px 10px;
  166. .label {
  167. margin-top: 5px;
  168. font-size: 15px;
  169. }
  170. .value {
  171. font-size: 20px;
  172. font-weight: 600;
  173. }
  174. }
  175. }
  176. }
  177. .menus {
  178. margin-top: 20px;
  179. background: #fff;
  180. border-radius: 10px;
  181. // padding: 0 10px;
  182. .title {
  183. position: relative;
  184. left: -10px;
  185. top: -10px;
  186. width: calc(100% + 10px);
  187. height: 55px;
  188. image {
  189. width: 100%;
  190. height: 100%;
  191. }
  192. }
  193. .menuList {
  194. display: grid;
  195. grid-template-columns: 1fr 1fr 1fr;
  196. padding: 20px 20px 0 20px;
  197. .menu {
  198. margin-bottom: 30px;
  199. display: flex;
  200. flex-direction: column;
  201. justify-content: center;
  202. align-items: center;
  203. image {
  204. width: 36px;
  205. height: 36px;
  206. }
  207. span {
  208. margin-top: 10px;
  209. font-size: 14px;
  210. }
  211. }
  212. }
  213. }
  214. </style>