123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <template>
- <view class="container">
- <view class="user">
- <view class="userInfo">
- <image @click="toUserInfo" class="userPhoto" :src="userInfo.avatar"></image>
- <uni-badge class="message" :text="massageNum" absolute="rightTop" size="small" :max-num="99" :offset="[4, 4]">
- <image
- class="icon"
- :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/massage.png'"
- mode="widthFix"
- @click="$navigateTo('/pages/message/message')"
- ></image>
- </uni-badge>
- <view class="info">
- <view class="name" v-if="hasLogin">
- {{ userInfo.nickname || '' }}
- </view>
- <view class="loginText" @click="toLogin" v-else>点击登录</view>
- <view class="id">
- ID:
- <span v-if="hasLogin">{{ userId || '' }}</span>
- <image
- class="copy"
- :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/copy.png'"
- mode="widthFix"
- ></image>
- </view>
- </view>
- </view>
- <view class="row">
- <view class="box">
- <view class="value" style="color: #ff2c43">
- {{ userInfoDetail.integral || 0 }}
- </view>
- <view class="label">积分</view>
- </view>
- <view class="box" @click="$navigateTo('/pages/coupon/coupon')">
- <view class="value">
- {{ userInfoDetail.couponNum || 0 }}
- </view>
- <view class="label">优惠卷</view>
- </view>
- </view>
- </view>
- <view class="menus">
- <view class="title">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/title.png'" mode=""></image>
- </view>
- <view class="menuList">
- <view class="menu" @click="pageTo('/pages/addressManage/addressManage')">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu1.png'"></image>
- <span>地址管理</span>
- </view>
- <view class="menu" @click="pageTo('/pages/consumptionRecords/consumptionRecords')">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu2.png'"></image>
- <span>消费记录</span>
- </view>
- <view class="menu" @click="showQRcode">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu3.png'"></image>
- <span>加群交流</span>
- </view>
- <view class="menu" @click="$navigateTo('/pages/rule/rule', { type: 0 })">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu4.png'"></image>
- <span>游戏规则</span>
- </view>
- <view class="menu" @click="$navigateTo('/pages/userAgreement/userAgreement')">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu5.png'"></image>
- <span>用户协议</span>
- </view>
- <button class="menu btn" open-type="contact">
- <image :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/mine/menu6.png'"></image>
- <span>联系客服</span>
- </button>
- </view>
- </view>
- <uni-popup class="popup" ref="popup" type="center">
- <image class="qrcodeImg" :src="'https://file.rongcyl.cn/festatic/bkm/imgv2/QRcode.png'" mode="widthFix" />
- </uni-popup>
- </view>
- </template>
- <script>
- import { userInfoApi } from '@/api/user.js'
- import { messageListApi } from '@/api/message.js'
- export default {
- data() {
- return {
- isLogin: false,
- userInfo: null,
- userId: '-',
- hasLogin: false,
- userInfoDetail: {},
- massageNum: 0,
- }
- },
- onShow() {
- // this.userInfo = wx.getStorageSync('userInfo');
- this.userId = wx.getStorageSync('userId')
- //获取用户的登录信息
- if (wx.getStorageSync('token')) {
- this.hasLogin = true
- getApp().globalData.hasLogin = true
- // 获取用户信息详情
- this.getUserInfo()
- this.getMassage()
- } else {
- this.userInfo = null
- this.hasLogin = false
- getApp().globalData.hasLogin = false
- this.userInfoDetail = {}
- }
- },
- methods: {
- getMassage() {
- let params = {
- page: 1,
- limit: 1,
- status: 0,
- }
- messageListApi(params).then(res => {
- this.massageNum = res.data.total
- })
- },
- toUserInfo() {
- this.$navigateTo('/pages/user/user')
- if (this.isLogin) {
- this.$navigateTo('/pages/user/user')
- }
- },
- getUserInfo() {
- userInfoApi().then(res => {
- console.log(res, '详细用户信息')
- this.userInfoDetail = res.data
- // wx.setStorageSync('userInfo', res.data)
- this.userInfo = res.data
- })
- },
- toLogin() {
- wx.navigateTo({ url: '/pages/login/login' })
- },
- pageTo(url) {
- wx.navigateTo({ url: url })
- },
- showQRcode() {
- this.$refs.popup.open()
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .btn {
- border: none;
- outline: none;
- background-color: #fff;
- &::after {
- border: none;
- }
- }
- .container {
- background: #9ec8f9;
- padding: 0 10px;
- overflow: scroll;
- }
- .user {
- background: #fff;
- border-radius: 10px;
- padding: 0 10px;
- position: relative;
- margin-top: 10vw;
- .userInfo {
- display: flex;
- .message {
- position: absolute;
- right: 10px;
- top: 8px;
- .icon {
- width: 30px;
- }
- }
- .userPhoto {
- width: 74px;
- height: 74px;
- border-radius: 50%;
- border: solid 3px #6bafff;
- position: relative;
- top: -20px;
- background: #dedede;
- }
- .info {
- padding: 10px;
- .name {
- font-weight: 600;
- }
- .loginText {
- font-weight: 600;
- }
- .id {
- margin-top: 5px;
- font-size: 13px;
- display: flex;
- align-items: center;
- .copy {
- width: 14px;
- margin-left: 5px;
- }
- }
- }
- }
- .row {
- display: flex;
- justify-content: space-around;
- .box {
- display: flex;
- flex-direction: column;
- text-align: center;
- padding: 20px 10px;
- .label {
- margin-top: 5px;
- font-size: 15px;
- }
- .value {
- font-size: 20px;
- font-weight: 600;
- }
- }
- }
- }
- .menus {
- margin-top: 20px;
- background: #fff;
- border-radius: 10px;
- // padding: 0 10px;
- .title {
- position: relative;
- left: -10px;
- top: -10px;
- width: calc(100% + 10px);
- height: 55px;
- image {
- width: 100%;
- height: 100%;
- }
- }
- .menuList {
- display: grid;
- grid-template-columns: 1fr 1fr 1fr;
- padding: 20px 20px 0 20px;
- .menu {
- margin-bottom: 30px;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- image {
- width: 36px;
- height: 36px;
- }
- span {
- margin-top: 10px;
- font-size: 14px;
- }
- }
- }
- }
- .qrcodeImg {
- width: 70vw;
- border-radius: 5px;
- }
- </style>
|