mine.vue 6.4 KB

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