mine.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="container">
  3. <view class="user">
  4. <view class="userInfo">
  5. <image @click="toUserInfo" class="userPhoto" :src="userInfo.avatar"></image>
  6. <uni-badge class="message" :text="massageNum" absolute="rightTop" size="small" :max-num="99" :offset="[4, 4]">
  7. <image
  8. class="icon"
  9. :src="$fileUrl() + '/mine/massage.png'"
  10. mode="widthFix"
  11. @click="$navigateTo('/pages/message/message')"
  12. ></image>
  13. </uni-badge>
  14. <view class="info">
  15. <view class="name" v-if="hasLogin">
  16. {{userInfo.nickname || ''}}
  17. </view>
  18. <view class="loginText" @click="toLogin" v-else>
  19. 点击登录
  20. </view>
  21. <view class="id">
  22. ID: <span v-if="hasLogin">{{userId || ''}}</span>
  23. <image class="copy" :src="$fileUrl() + '/mine/copy.png'" mode="widthFix"></image>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="row">
  28. <view class="box">
  29. <view class="value" style="color: #FF2C43;">
  30. {{ userInfoDetail.integral || 0}}
  31. </view>
  32. <view class="label">
  33. 积分
  34. </view>
  35. </view>
  36. <view class="box" @click="$navigateTo('/pages/coupon/coupon')">
  37. <view class="value">
  38. {{ userInfoDetail.couponNum || 0}}
  39. </view>
  40. <view class="label">
  41. 优惠卷
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="menus">
  47. <view class="title">
  48. <image :src="$fileUrl() + '/mine/title.png'" mode=""></image>
  49. </view>
  50. <view class="menuList">
  51. <view class="menu" @click="pageTo('/pages/addressManage/addressManage')">
  52. <image :src="$fileUrl() + '/mine/menu1.png'"></image>
  53. <span>地址管理</span>
  54. </view>
  55. <view class="menu" @click="pageTo('/pages/consumptionRecords/consumptionRecords')">
  56. <image :src="$fileUrl() + '/mine/menu2.png'"></image>
  57. <span>消费记录</span>
  58. </view>
  59. <view class="menu">
  60. <image :src="$fileUrl() + '/mine/menu3.png'"></image>
  61. <span>加群交流</span>
  62. </view>
  63. <view class="menu">
  64. <image :src="$fileUrl() + '/mine/menu4.png'"></image>
  65. <span>游戏规则</span>
  66. </view>
  67. <view class="menu">
  68. <image :src="$fileUrl() + '/mine/menu5.png'"></image>
  69. <span>用户协议</span>
  70. </view>
  71. <view class="menu">
  72. <image :src="$fileUrl() + '/mine/menu6.png'"></image>
  73. <span>联系客服</span>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import {
  81. userInfoApi
  82. } from "@/api/user.js"
  83. import {
  84. messageListApi,
  85. } from "@/api/message.js"
  86. export default {
  87. data() {
  88. return {
  89. isLogin: false,
  90. userInfo: null,
  91. userId: '-',
  92. hasLogin: false,
  93. userInfoDetail: {},
  94. massageNum: 0
  95. }
  96. },
  97. onShow() {
  98. // this.userInfo = wx.getStorageSync('userInfo');
  99. this.userId = wx.getStorageSync('userId');
  100. //获取用户的登录信息
  101. if (wx.getStorageSync('token')) {
  102. this.hasLogin = true
  103. getApp().globalData.hasLogin = true
  104. // 获取用户信息详情
  105. this.getUserInfo()
  106. this.getMassage()
  107. } else {
  108. this.userInfo = null
  109. this.hasLogin = false
  110. getApp().globalData.hasLogin = false
  111. this.userInfoDetail = {}
  112. }
  113. },
  114. methods: {
  115. getMassage() {
  116. let params = {
  117. page: 1,
  118. limit: 1,
  119. status: 0,
  120. }
  121. messageListApi(params).then(res => {
  122. this.massageNum = res.data.total
  123. })
  124. },
  125. toUserInfo() {
  126. this.$navigateTo('/pages/user/user')
  127. if (this.isLogin) {
  128. this.$navigateTo('/pages/user/user')
  129. }
  130. },
  131. getUserInfo() {
  132. userInfoApi().then(res => {
  133. console.log(res, '详细用户信息')
  134. this.userInfoDetail = res.data
  135. // wx.setStorageSync('userInfo', res.data)
  136. this.userInfo = res.data;
  137. })
  138. },
  139. toLogin() {
  140. wx.navigateTo({url: '/pages/login/login'})
  141. },
  142. pageTo(url) {
  143. wx.navigateTo({url: url})
  144. },
  145. }
  146. }
  147. </script>
  148. <style scoped lang="scss">
  149. .container {
  150. background: #9EC8F9;
  151. padding: 0 10px;
  152. overflow: scroll;
  153. }
  154. .user {
  155. background: #fff;
  156. border-radius: 10px;
  157. padding: 0 10px;
  158. position: relative;
  159. margin-top: 10vw;
  160. .userInfo {
  161. display: flex;
  162. .message {
  163. position: absolute;
  164. right: 10px;
  165. top: 8px;
  166. .icon {
  167. width: 30px;
  168. }
  169. }
  170. .userPhoto {
  171. width: 74px;
  172. height: 74px;
  173. border-radius: 50%;
  174. border: solid 3px #6BAFFF;
  175. position: relative;
  176. top: -20px;
  177. background: #dedede;
  178. }
  179. .info {
  180. padding: 10px;
  181. .name {
  182. font-weight: 600;
  183. }
  184. .loginText {
  185. font-weight: 600;
  186. }
  187. .id {
  188. margin-top: 5px;
  189. font-size: 13px;
  190. display: flex;
  191. align-items: center;
  192. .copy {
  193. width: 14px;
  194. margin-left: 5px;
  195. }
  196. }
  197. }
  198. }
  199. .row {
  200. display: flex;
  201. justify-content: space-around;
  202. .box {
  203. display: flex;
  204. flex-direction: column;
  205. text-align: center;
  206. padding: 20px 10px;
  207. .label {
  208. margin-top: 5px;
  209. font-size: 15px;
  210. }
  211. .value {
  212. font-size: 20px;
  213. font-weight: 600;
  214. }
  215. }
  216. }
  217. }
  218. .menus {
  219. margin-top: 20px;
  220. background: #fff;
  221. border-radius: 10px;
  222. // padding: 0 10px;
  223. .title {
  224. position: relative;
  225. left: -10px;
  226. top: -10px;
  227. width: calc(100% + 10px);
  228. height: 55px;
  229. image {
  230. width: 100%;
  231. height: 100%;
  232. }
  233. }
  234. .menuList {
  235. display: grid;
  236. grid-template-columns: 1fr 1fr 1fr;
  237. padding: 20px 20px 0 20px;
  238. .menu {
  239. margin-bottom: 30px;
  240. display: flex;
  241. flex-direction: column;
  242. justify-content: center;
  243. align-items: center;
  244. image {
  245. width: 36px;
  246. height: 36px;
  247. }
  248. span {
  249. margin-top: 10px;
  250. font-size: 14px;
  251. }
  252. }
  253. }
  254. }
  255. </style>