mine.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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" @click="showQRcode">
  59. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu3.png'"></image>
  60. <span>加群交流</span>
  61. </view>
  62. <view class="menu" @click="$navigateTo('/pages/rule/rule', { type: 0 })">
  63. <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu4.png'"></image>
  64. <span>游戏规则</span>
  65. </view>
  66. <view class="menu" @click="$navigateTo('/pages/userAgreement/userAgreement')">
  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. <uni-popup class="popup" ref="popup" type="center">
  77. <image class="qrcodeImg" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/QRcode.png'" mode="widthFix" />
  78. </uni-popup>
  79. </view>
  80. </template>
  81. <script>
  82. import { userInfoApi } from '@/api/user.js'
  83. import { messageListApi } from '@/api/message.js'
  84. export default {
  85. data() {
  86. return {
  87. isLogin: false,
  88. userInfo: null,
  89. userId: '-',
  90. hasLogin: false,
  91. userInfoDetail: {},
  92. massageNum: 0,
  93. }
  94. },
  95. onShow() {
  96. // this.userInfo = wx.getStorageSync('userInfo');
  97. this.userId = wx.getStorageSync('userId')
  98. //获取用户的登录信息
  99. if (wx.getStorageSync('token')) {
  100. this.hasLogin = true
  101. getApp().globalData.hasLogin = true
  102. // 获取用户信息详情
  103. this.getUserInfo()
  104. this.getMassage()
  105. } else {
  106. this.userInfo = null
  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. // wx.setStorageSync('userInfo', res.data)
  134. this.userInfo = res.data
  135. })
  136. },
  137. toLogin() {
  138. wx.navigateTo({ url: '/pages/login/login' })
  139. },
  140. pageTo(url) {
  141. wx.navigateTo({ url: url })
  142. },
  143. showQRcode() {
  144. this.$refs.popup.open()
  145. },
  146. },
  147. }
  148. </script>
  149. <style scoped lang="scss">
  150. .btn {
  151. border: none;
  152. outline: none;
  153. background-color: #fff;
  154. &::after {
  155. border: none;
  156. }
  157. }
  158. .container {
  159. background: #9ec8f9;
  160. padding: 0 10px;
  161. overflow: scroll;
  162. }
  163. .user {
  164. background: #fff;
  165. border-radius: 10px;
  166. padding: 0 10px;
  167. position: relative;
  168. margin-top: 10vw;
  169. .userInfo {
  170. display: flex;
  171. .message {
  172. position: absolute;
  173. right: 10px;
  174. top: 8px;
  175. .icon {
  176. width: 30px;
  177. }
  178. }
  179. .userPhoto {
  180. width: 74px;
  181. height: 74px;
  182. border-radius: 50%;
  183. border: solid 3px #6bafff;
  184. position: relative;
  185. top: -20px;
  186. background: #dedede;
  187. }
  188. .info {
  189. padding: 10px;
  190. .name {
  191. font-weight: 600;
  192. }
  193. .loginText {
  194. font-weight: 600;
  195. }
  196. .id {
  197. margin-top: 5px;
  198. font-size: 13px;
  199. display: flex;
  200. align-items: center;
  201. .copy {
  202. width: 14px;
  203. margin-left: 5px;
  204. }
  205. }
  206. }
  207. }
  208. .row {
  209. display: flex;
  210. justify-content: space-around;
  211. .box {
  212. display: flex;
  213. flex-direction: column;
  214. text-align: center;
  215. padding: 20px 10px;
  216. .label {
  217. margin-top: 5px;
  218. font-size: 15px;
  219. }
  220. .value {
  221. font-size: 20px;
  222. font-weight: 600;
  223. }
  224. }
  225. }
  226. }
  227. .menus {
  228. margin-top: 20px;
  229. background: #fff;
  230. border-radius: 10px;
  231. // padding: 0 10px;
  232. .title {
  233. position: relative;
  234. left: -10px;
  235. top: -10px;
  236. width: calc(100% + 10px);
  237. height: 55px;
  238. image {
  239. width: 100%;
  240. height: 100%;
  241. }
  242. }
  243. .menuList {
  244. display: grid;
  245. grid-template-columns: 1fr 1fr 1fr;
  246. padding: 20px 20px 0 20px;
  247. .menu {
  248. margin-bottom: 30px;
  249. display: flex;
  250. flex-direction: column;
  251. justify-content: center;
  252. align-items: center;
  253. image {
  254. width: 36px;
  255. height: 36px;
  256. }
  257. span {
  258. margin-top: 10px;
  259. font-size: 14px;
  260. }
  261. }
  262. }
  263. }
  264. .qrcodeImg {
  265. width: 70vw;
  266. border-radius: 5px;
  267. }
  268. </style>