mine.vue 6.0 KB

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