mine.vue 6.1 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>点击登录</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. <button class="menu btn" open-type="contact">
  67. <image :src="$fileUrl() + '/mine/menu6.png'"></image>
  68. <span>联系客服</span>
  69. </button>
  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. .btn {
  141. border: none;
  142. outline: none;
  143. background-color: #fff;
  144. &::after {
  145. border: none;
  146. }
  147. }
  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. display: flex;
  190. align-items: center;
  191. .copy {
  192. width: 14px;
  193. margin-left: 5px;
  194. }
  195. }
  196. }
  197. }
  198. .row {
  199. display: flex;
  200. justify-content: space-around;
  201. .box {
  202. display: flex;
  203. flex-direction: column;
  204. text-align: center;
  205. padding: 20px 10px;
  206. .label {
  207. margin-top: 5px;
  208. font-size: 15px;
  209. }
  210. .value {
  211. font-size: 20px;
  212. font-weight: 600;
  213. }
  214. }
  215. }
  216. }
  217. .menus {
  218. margin-top: 20px;
  219. background: #fff;
  220. border-radius: 10px;
  221. // padding: 0 10px;
  222. .title {
  223. position: relative;
  224. left: -10px;
  225. top: -10px;
  226. width: calc(100% + 10px);
  227. height: 55px;
  228. image {
  229. width: 100%;
  230. height: 100%;
  231. }
  232. }
  233. .menuList {
  234. display: grid;
  235. grid-template-columns: 1fr 1fr 1fr;
  236. padding: 20px 20px 0 20px;
  237. .menu {
  238. margin-bottom: 30px;
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: center;
  242. align-items: center;
  243. image {
  244. width: 36px;
  245. height: 36px;
  246. }
  247. span {
  248. margin-top: 10px;
  249. font-size: 14px;
  250. }
  251. }
  252. }
  253. }
  254. </style>