| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- <template>
- <view>
- <!-- 头像区域 -->
- <view class="avatar-region">
- <view class="flex-items">
- <view class="font32 mar-l-20">
- 头像
- </view>
- <view class="mar-l-auto mar-r-20">
- <u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1" :maxCount="1">
- <view class="flex-items">
- <image class="avatar" :src="user.avatar||'../../../static/images/avatar.png'"
- mode="aspectFill">
- </image>
- <uni-icons color="#d0d7df" type="right" size="30"></uni-icons>
- </view>
- </u-upload>
- </view>
- </view>
- </view>
- <!-- 基本信息区域 -->
- <view class="info-region">
- <view class="font-gray mar-l-20 mar-b-30">
- 基本信息
- </view>
- <view class="flex-items mar-b-50">
- <view class="font32 mar-l-20">
- 昵称
- </view>
- <view class="mar-l-auto mar-r-20" @click="changeAccount">
- <view class="flex-items">
- <view class="font32 font-gray">
- {{user.account}}
- </view>
- <view>
- <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
- </view>
- </view>
- </view>
- </view>
- <view class="flex-items mar-b-50" @click="changeBirthday">
- <view class="font32 mar-l-20 ">
- 生日
- </view>
- <view class="mar-l-auto mar-r-20">
- <view class="flex-items">
- <view class="font32 font-gray">
- {{user.birthday}}
- </view>
- <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
- </view>
- </view>
- </view>
- <view class="flex-items mar-b-50" @click="changeSex">
- <view class="font32 mar-l-20 ">
- 性别
- </view>
- <view class="mar-l-auto mar-r-20">
- <view class="flex-items">
- <view class="font32 font-gray" v-if="user.sex==0">
- 女
- </view>
- <view class="font32 font-gray" v-if="user.sex==1">
- 男
- </view>
- <view class="font32 font-gray " v-if="user.sex==2">
- 其他
- </view>
- <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
- </view>
- </view>
- </view>
- <view class="flex-items mar-b-50">
- <view class="font32 mar-l-20 ">
- 上级昵称
- </view>
- <view class="mar-l-auto mar-r-20">
- <view class="flex-items">
- <view class="font32 font-gray ">
- {{user.parentAccount||'-'}}
- </view>
- </view>
- </view>
- </view>
- <view class="flex-items mar-b-50" @tap="goLevelPath">
- <view class="font32 mar-l-20 ">
- 会员等级
- </view>
- <view class="mar-l-auto mar-r-20">
- <view class="flex-items">
- <view class="font32 font-gray ">
- <text v-if="user.level == '0'">普通会员</text>
- <text v-else-if="user.level == '1'">S级会员</text>
- <text v-else-if="user.level == '2'">SS级会员</text>
- <text v-else-if="user.level == '3'">SSS级会员</text>
- <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
- </view>
- </view>
- </view>
- </view>
- <view class="flex-items mar-b-50" @tap="goAgentPath">
- <view class="font32 mar-l-20 ">
- 代理等级
- </view>
- <view class="mar-l-auto mar-r-20">
- <view class="flex-items">
- <view class="font32 font-gray ">
- <text v-if="user.agent == 2">荣耀代理</text>
- <text v-else-if="user.agent == 3">超凡代理</text>
- <text v-else>无</text>
- <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
- </view>
- </view>
- </view>
- </view>
- <!-- <view class="flex-items mar-b-20">
- <view class="font32 mar-l-20 ">
- 国家/地区
- </view>
- <view class="mar-l-auto mar-r-20">
- <view class="flex-items">
- <view class="font32 font-gray">
- {{user.nation}}
- </view>
- <uni-icons color="#d0d7df" type="right" size="20"></uni-icons>
- </view>
- </view>
- </view> -->
- </view>
- <view class=" flex-center">
- <!-- <button class="loginBtn" style="background-color: #3C86F7;" type="primary"
- @click="handlerLogout">退出登录</button> -->
- <button @click="handlerLogout" class="logout-button">
- 退出登录
- </button>
- </view>
- </view>
- </template>
- <script>
- import {
- memberDetail,
- memberUpdate
- } from '@/config/api';
- import {
- mapMutations,
- mapActions,
- mapGetters
- } from 'vuex';
- import {
- UPLOAD_URL
- } from '@/common/config.js'
- export default {
- data() {
- return {
- fileList: [],
- user: {},
- token: "",
- };
- },
- computed: {
- ...mapGetters(['userInfo'])
- },
- onLoad() {
- this.token = uni.getStorageSync('access_token')
- },
- onShow() {
- this.detail()
- console.log(this.user)
- },
- methods: {
- ...mapActions(['logout']),
- goAgentPath() {
- uni.showModal({
- title: '升级/续费代理',
- content: '购买代理套餐即可升级或续费代理,\n立即前往?',
- success: (res) => {
- if (res.confirm) {
- // 这里可以跳转到代理升级页面
- this.$route('/packageShop/pages/search/product-list?serachKey=' + "代理")
- }
- }
- });
- },
- goLevelPath() {
- this.$route('/packageUser/pages/level/index')
- },
- handlerLogout() {
- this.logout()
- uni.$u.toast("退出登录")
- uni.navigateBack({
- delta: 1 // delta 表示返回的页面数,1 表示返回上一页
- });
- },
- changeSex() {
- this.$route('/packageUser/pages/user-info/sex-change?id=' + this.user.sex + '&id=' + this.user.id)
- },
- changeAccount() {
- this.$route('/packageUser/pages/user-info/account-change?id=' + this.user.account + '&id=' + this.user.id)
- },
- changeBirthday() {
- this.$route('/packageUser/pages/user-info/birthday-change?account=' + this.user.birthdat + '&id=' + this
- .user.id)
- },
- // 删除图片
- deletePic(event) {
- this.fileList.splice(event.index, 1)
- },
- // 新增图片
- async afterRead(event) {
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- let lists = [].concat(event.file)
- console.log(lists, "list")
- let fileListLen = this.fileList.length
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].thumb)
- this.user.avatar = result.data.link
- let item = this.fileList[fileListLen]
- }
- memberUpdate(this.user)
- },
- uploadFilePromise(url) {
- return new Promise((resolve, reject) => {
- let a = uni.uploadFile({
- url: UPLOAD_URL,
- filePath: url,
- header: {
- "Blade-Auth": this.token
- },
- name: 'file',
- formData: {
- user: 'test'
- },
- success: (res) => {
- resolve(JSON.parse(res.data))
- }
- });
- })
- },
- async detail() {
- const data = await memberDetail()
- if (data.code == 200) {
- this.user = data.data
- uni.setStorageSync('user', this.user)
- }
- },
- goPage() {
- // this.$Router.push({ path: '/pages/user/set-avatar' });
- }
- },
- };
- </script>
- <style>
- .arrow {
- width: 32rpx;
- height: 32rpx;
- margin-top: 13rpx;
- }
- .h28 {
- height: 56rpx;
- }
- .avatar-region {
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
- border-radius: 40rpx;
- width: 700rpx;
- height: auto;
- padding-bottom: 30rpx;
- padding-top: 30rpx;
- background-color: white;
- margin-top: 30rpx;
- margin-bottom: 30rpx;
- margin-left: 25rpx;
- }
- .info-region {
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
- border-radius: 40rpx;
- width: 700rpx;
- height: auto;
- padding-bottom: 30rpx;
- padding-top: 30rpx;
- background-color: white;
- margin-top: 30rpx;
- margin-bottom: 30rpx;
- margin-left: 25rpx;
- }
- .avatar-container {
- margin-left: 50rpx;
- margin-right: 50rpx;
- }
- .avatar {
- width: 130rpx;
- height: 130rpx;
- border-radius: 50%;
- overflow: hidden;
- }
- .logout-button {
- width: 686rpx;
- height: 88rpx;
- background: #FF4748;
- border-radius: 44rpx;
- font-size: 32rpx;
- color: #FFFFFF;
- margin-top: 100rpx;
- }
- </style>
|