mine.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. <uni-badge class="message" :text="massageNum" absolute="rightTop" size="small" :max-num="99" :offset="[4, 4]">
  7. <image
  8. class="icon"
  9. src="https://mall.rongtongh.cn/storage/img/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="https://mall.rongtongh.cn/storage/img/mine/title.png" mode=""></image>
  48. </view>
  49. <view class="menuList">
  50. <view class="menu" @click="pageTo('/pages/addressManage/addressManage')">
  51. <image src="https://mall.rongtongh.cn/storage/img/mine/menu1.png"></image>
  52. <span>地址管理</span>
  53. </view>
  54. <view class="menu">
  55. <image src="https://mall.rongtongh.cn/storage/img/mine/menu2.png"></image>
  56. <span>消费记录</span>
  57. </view>
  58. <view class="menu">
  59. <image src="https://mall.rongtongh.cn/storage/img/mine/menu3.png"></image>
  60. <span>加群交流</span>
  61. </view>
  62. <view class="menu">
  63. <image src="https://mall.rongtongh.cn/storage/img/mine/menu4.png"></image>
  64. <span>游戏规则</span>
  65. </view>
  66. <view class="menu">
  67. <image src="https://mall.rongtongh.cn/storage/img/mine/menu5.png"></image>
  68. <span>用户协议</span>
  69. </view>
  70. <view class="menu">
  71. <image src="https://mall.rongtongh.cn/storage/img/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.hasLogin = false
  108. getApp().globalData.hasLogin = false
  109. this.userInfoDetail = {}
  110. }
  111. },
  112. methods: {
  113. getMassage() {
  114. let params = {
  115. page: 1,
  116. limit: 1,
  117. status: 0,
  118. }
  119. messageListApi(params).then(res => {
  120. this.massageNum = res.data.total
  121. })
  122. },
  123. toUserInfo() {
  124. this.$navigateTo('/pages/user/user')
  125. if (this.isLogin) {
  126. this.$navigateTo('/pages/user/user')
  127. }
  128. },
  129. getUserInfo() {
  130. userInfoApi().then(res => {
  131. console.log(res, '详细用户信息')
  132. this.userInfoDetail = res.data
  133. })
  134. },
  135. toLogin() {
  136. wx.navigateTo({url: '/pages/login/login'})
  137. },
  138. pageTo(url) {
  139. wx.navigateTo({url: url})
  140. },
  141. }
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .container {
  146. background: #9EC8F9;
  147. padding: 0 10px;
  148. overflow: scroll;
  149. }
  150. .user {
  151. background: #fff;
  152. border-radius: 10px;
  153. padding: 0 10px;
  154. position: relative;
  155. margin-top: 10vw;
  156. .userInfo {
  157. display: flex;
  158. .message {
  159. position: absolute;
  160. right: 10px;
  161. top: 8px;
  162. .icon {
  163. width: 30px;
  164. }
  165. }
  166. .userPhoto {
  167. width: 74px;
  168. height: 74px;
  169. border-radius: 50%;
  170. border: solid 3px #6BAFFF;
  171. position: relative;
  172. top: -20px;
  173. background: #dedede;
  174. }
  175. .info {
  176. padding: 10px;
  177. .name {
  178. font-weight: 600;
  179. }
  180. .loginText {
  181. font-weight: 600;
  182. }
  183. .id {
  184. margin-top: 5px;
  185. font-size: 13px;
  186. }
  187. }
  188. }
  189. .row {
  190. display: flex;
  191. justify-content: space-around;
  192. .box {
  193. display: flex;
  194. flex-direction: column;
  195. text-align: center;
  196. padding: 20px 10px;
  197. .label {
  198. margin-top: 5px;
  199. font-size: 15px;
  200. }
  201. .value {
  202. font-size: 20px;
  203. font-weight: 600;
  204. }
  205. }
  206. }
  207. }
  208. .menus {
  209. margin-top: 20px;
  210. background: #fff;
  211. border-radius: 10px;
  212. // padding: 0 10px;
  213. .title {
  214. position: relative;
  215. left: -10px;
  216. top: -10px;
  217. width: calc(100% + 10px);
  218. height: 55px;
  219. image {
  220. width: 100%;
  221. height: 100%;
  222. }
  223. }
  224. .menuList {
  225. display: grid;
  226. grid-template-columns: 1fr 1fr 1fr;
  227. padding: 20px 20px 0 20px;
  228. .menu {
  229. margin-bottom: 30px;
  230. display: flex;
  231. flex-direction: column;
  232. justify-content: center;
  233. align-items: center;
  234. image {
  235. width: 36px;
  236. height: 36px;
  237. }
  238. span {
  239. margin-top: 10px;
  240. font-size: 14px;
  241. }
  242. }
  243. }
  244. }
  245. </style>