mine.vue 7.1 KB

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