mine.vue 5.3 KB

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