123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <view>
- <!-- 非H5撑高元素 -->
- <!-- <view class="status_bar"></view> -->
- <!-- 头部背景 -->
- <view class="user"></view>
- <!-- 账户信息 -->
- <view class="account">
- <view class="flex account-ava">
- <image :src="avatar" mode="aspectFill" v-if="loginState"></image>
- <view class="no-ava" v-else @click="toLogin"></view>
- <view class="account-ava-name" v-if="loginState">{{ userInfo.nickName }}</view>
- <view class="account-ava-no" @click="toLogin" v-else>登录</view>
- </view>
- <view class="flex account-info" v-if="loginState">
- <navigator url="/pages/prize/index" class="flex account-info-item" hover-class="navigator-hover">
- <view>{{ initData.prizeNum }}</view>
- <view>我的奖品库</view>
- </navigator>
- <navigator url="/pages/ticket/index" class="flex account-info-item" hover-class="navigator-hover">
- <view>{{ initData.ticketNum }}</view>
- <view>我的盲票</view>
- </navigator>
- <navigator url="/pages/bean/index" class="flex account-info-item" hover-class="navigator-hover">
- <view>{{ initData.coinNum }}</view>
- <view>我的盲豆</view>
- </navigator>
- </view>
- <view class="flex account-info" v-else @click="notLogin">
- <view class="flex account-info-item">
- <view>-</view>
- <view>我的奖品库</view>
- </view>
- <view class="flex account-info-item">
- <view>-</view>
- <view>我的盲票</view>
- </view>
- <view class="flex account-info-item">
- <view>-</view>
- <view>我的盲豆</view>
- </view>
- </view>
- </view>
- <!-- 操作项 -->
- <view class="action">
- <u-cell-group :border="false">
- <u-cell icon="order" title="提货订单" :isLink="true" @click="toOrder"></u-cell>
- <u-cell icon="map" title="我的地址" :isLink="true" @click="toAddress"></u-cell>
- <u-cell icon="kefu-ermai" title="联系我们" :isLink="true" @click="contactService"></u-cell>
- <u-cell icon="info-circle" title="关于我们" :border="false" :isLink="true" :url="'/pages/about/index'">
- </u-cell>
- </u-cell-group>
- </view>
- <view class="cancel">
- <u-cell icon="close-circle" title="退出登录" :isLink="true" :border="false" @click="logout"></u-cell>
- </view>
- <custom-tab-bar :activeValue="'user'" />
- </view>
- </template>
- <script>
- import env from '../../config/env.js'
- import $http from '@/utils/request.js'
- import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
- import Auth from '../../components/auth/auth.vue'
- export default {
- components: {
- CustomTabBar,
- Auth,
- },
- data() {
- return {
- loginState: false, // 判断是否登录
- authState: false,
- userInfo: {}, //
- avatar: '',
- certifyStatus: {},
- info: {},
- authShow: false,
- initData: {},
- };
- },
- onShow() {
- this.loginState = uni.getStorageSync('token') ? true : false
- if (this.loginState) {
- this.getInit()
- this.getBaseInfo()
- }
- },
- methods: {
- // 我的数据
- getInit() {
- uni.showLoading({
- title: '加载中'
- });
- $http.post('/api/v1/mp/user/mine/init', {}).then(res => {
- uni.hideLoading();
- if (res.code == 0) {
- this.initData = res.data
- }
- }).catch(() => {
- uni.hideLoading();
- })
- },
- getBaseInfo() {
- $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
- if (res.code == 0) {
- this.userInfo = res.data
- this.avatar = env.filePublic + res.data.avatar
- }
- }).catch(() => {
- })
- },
- // 跳转登录
- toLogin() {
- uni.navigateTo({
- url: "/pages/login/index"
- })
- },
- // 我的订单
- toOrder() {
- if (!this.loginState) {
- uni.$u.toast('请登录!');
- return
- }
- uni.navigateTo({
- url: '/pages/order/index'
- })
- },
- // 我的地址
- toAddress() {
- if (!this.loginState) {
- uni.$u.toast('请登录!');
- return
- }
- uni.navigateTo({
- url: '/pages/address/index'
- })
- },
- // 没有登录
- notLogin() {
- uni.$u.toast('请登录!');
- },
- // 注销登录
- logout() {
- let _this = this
- if (!this.loginState) {
- uni.$u.toast('已退出登录!');
- return
- }
- uni.showModal({
- title: '退出登录',
- content: '确定要退出登录吗?',
- success(res) {
- if (res.confirm) {
- uni.clearStorage()
- _this.loginState = false
- _this.authState = false
- }
- }
- })
- },
- // 联系客服
- contactService() {
- // #ifdef MP-WEIXIN
- wx.openCustomerServiceChat({
- extInfo: {
- url: 'https://work.weixin.qq.com/kfid/kfc36c0d90028adbd24'
- },
- corpId: 'ww02da63d80c66284b',
- })
- // #endif
- },
- },
- onShareAppMessage(res) {
- return {
- title: '盲票,玩的就是有趣',
- path: '/pages/index/index'
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/ .u-cell__body {
- padding: 20rpx 0;
- }
- .status_bar {
- width: 100%;
- height: var(--status-bar-height);
- }
- </style>
- <style lang="scss" scoped>
- .user {
- display: flex;
- align-items: center;
- height: 300rpx;
- padding: 0 36rpx;
- // background: linear-gradient(to right, #a1c4fd 0%, #c2e9fb 100%);
- background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/my-bkgd.png) center center;
- }
- .account {
- margin: 0 20rpx;
- padding: 34rpx;
- background-color: #FFFFFF;
- border-radius: 10rpx;
- margin-top: -90rpx;
- margin-bottom: 40rpx;
- &-ava {
- justify-content: flex-start;
- margin-bottom: 46rpx;
- image {
- width: 106rpx;
- height: 106rpx;
- border-radius: 50%;
- overflow: hidden;
- }
- .no-ava {
- width: 106rpx;
- height: 106rpx;
- border-radius: 50%;
- overflow: hidden;
- background: #C0C0C0;
- }
- &-name {
- margin-left: 20rpx;
- font-size: 32rpx;
- }
- &-no {
- margin-left: 20rpx;
- color: #C0C0C0;
- font-size: 32rpx;
- }
- }
- &-info {
- justify-content: space-around;
- &-item {
- flex-direction: column;
- view {
- line-height: 40rpx;
- }
- view:first-child {
- line-height: 56rpx;
- font-size: 40rpx;
- }
- }
- }
- }
- .action {
- margin: 0 20rpx;
- padding: 10rpx 20rpx 0;
- background-color: #FFFFFF;
- border-radius: 10rpx;
- margin-bottom: 40rpx;
- }
- .cancel {
- margin: 0 20rpx;
- padding: 10rpx 20rpx;
- background-color: #FFFFFF;
- border-radius: 10rpx;
- }
- </style>
|