123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <view class="main">
- <view class="user" @click="go('/pages/user/info')">
- <image :src="user.avatarUrl ? user.avatarUrl : '../../static/favicon.png'" class="head"></image>
- <view class="con" v-if="user.id">
- <view class="nickName">微信用户</view>
- <view class="welcome">欢迎使用承揽时代</view>
- </view>
- <view class="con" v-else>
- <view class="nickName">你还没登录</view>
- <view class="welcome">欢迎使用承揽时代</view>
- </view>
- <view class="icon"></view>
- </view>
- <view class="cmd">
- <view class="s_item" @click="go('auth')">
- <text class="icon ic"></text>
- <text class="title">我的认证</text>
- <text class="icon arrow"></text>
- </view>
- <view class="s_item" @click="go('contract')">
- <text class="icon ic"></text>
- <text class="title">我的签约</text>
- <text class="icon arrow"></text>
- </view>
- <view class="s_item" @click="go('company')">
- <text class="icon ic"></text>
- <text class="title">关联企业</text>
- <text class="icon arrow"></text>
- </view>
- <view class="s_item" @click="go('packages')">
- <text class="icon ic"></text>
- <text class="title">我的接包</text>
- <text class="icon arrow"></text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- ip: this.http.ip,
- user: {}
- };
- },
- onShow() {
- /* this.user = {
- token: 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjI2NTFjMmU4LTAxNzEtNDQwYS04YjA2LTcwOWI3N2ZhNGZiZCJ9.zb2gQaeHZApJkbo4LoSeZfnVVsJJ-QabY7FnsVn13Kf1KUgKeBQ82bwhzD-CqchI1dhUOQFoVh__zeJaJHFWGg'
- };
- uni.setStorageSync('user', this.user); */
- if (this.hasLogin()) {
- this.getUserInfo();
- }
- },
- methods: {
- getUserInfo() {
- this.http.request({
- url: '/app/user/info',
- success: (res) => {
- this.user = res.data.data;
- }
- });
- },
- go(url) {
- if (this.hasLogin()) {
- if (url == 'auth') {
- uni.navigateTo({ url: '/pages/auth/index' });
- }
- if (url == 'company' && this.user.isAuthentication === 1) {
- uni.navigateTo({ url: '/pages/company/index' });
- }
- if (url == 'packages' && this.user.isCompany > 0 && this.user.isContract == 1) {
- uni.switchTab({ url: '/pages/packages/index' });
- }
- if (url == 'contract' && this.user.isContract == 1) {
- this.look();
- }
- } else {
- uni.navigateTo({ url: '/pages/user/login' });
- }
- },
- //查看合同
- look() {
- uni.downloadFile({
- url: this.user.isContract == 0 ? this.ip + this.contract.url : this.ip + '/app/contract/look',
- header: { Authorization: this.getUser().token },
- success: (res) => {
- uni.openDocument({
- filePath: res.tempFilePath,
- showMenu: true,
- success: (res) => {}
- });
- }
- });
- },
- //退出登录
- exit(url) {
- uni.showModal({
- title: '提示',
- content: '确定退出登录?',
- success: (res) => {
- if (res.confirm) {
- this.http.request({
- url: this.http.urls.logout,
- success: (res) => {
- uni.removeStorageSync('user');
- uni.$emit('top');
- uni.switchTab({
- url: '/pages/index/index'
- });
- }
- });
- }
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- .main {
- padding: 20px;
- }
- .user {
- overflow: hidden;
- image {
- float: left;
- width: 60px;
- height: 60px;
- border-radius: 50%;
- }
- .con {
- float: left;
- padding-left: 15px;
- .nickName {
- padding-top: 5px;
- }
- .welcome {
- font-size: 13px;
- padding-top: 5px;
- color: #989898;
- }
- }
- .icon {
- float: right;
- margin-top: 14px;
- }
- }
- .exit {
- width: 40%;
- margin-top: 20px;
- }
- </style>
|