123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <view class="index container">
- <nav-header>个人信息</nav-header>
- <view class="content">
- <view class="row" v-for="(item,index) in list" :key="index" @click="clickitem(item.e)">
- <view class="">
- {{item.name}}
- </view>
- <view class="" v-if="item.showimg">
- <image :src="item.img || '../../../static/login/logo.png'" mode=""
- style="width: 88rpx;height: 88rpx;border-radius: 50%;"></image>
- </view>
- <view class="" v-else>
- {{item.right}}
- </view>
- <view class="" v-if="item.icon">
- <image :src="item.icon" v-if="item.e=='5'" @click="copy(item.right)" mode="widthFix" style="width: 48rpx;"></image>
- <image :src="item.icon" v-else mode="widthFix" style="width: 48rpx;"></image>
- </view>
- </view>
- </view>
- <!-- 修改名称弹出框 -->
- <view class="pop_ocy" v-if="show_set_name">
- <view class="pop_content">
- <u--input placeholder="请输入要修改的昵称" border="surround" v-model="value" :color="'#000'" :maxlength="'12'">
- </u--input>
- <view class="btn">
- <view class="systemBcg" @click="setname">
- 修改
- </view>
- <view class="systemBcg" @click="show_set_name=false">
- 取消
- </view>
- </view>
- </view>
- </view>
- <!-- 修改名称弹出框 结束-->
- </view>
- </template>
- <script>
- import navHeader from "@/components/my/nav_header.vue"
- export default {
- components: {
- navHeader
- },
- onShow() {
- this.get_user_info()
- },
- data() {
- return {
- userinfo: {},
- list: [{
- name: "头像",
- showimg: true,
- right: "",
- img: "",
- e: "1",
- icon:'../../../static/my/arrow_right.png'
- },
- {
- name: "昵称",
- showimg: false,
- right: "",
- img: "",
- e: "2",
- icon:'../../../static/my/arrow_right.png'
- },
- {
- name: "手机号",
- showimg: false,
- right: "",
- img: "",
- // e: "4",
- // icon:'../../../static/my/arrow_right.png'
- },
- {
- name: "钱包地址",
- showimg: false,
- right: "",
- img: "",
- e: "5",
- icon:'/static/my/copy2.png',
- }
- ],
- value: "",
- show_set_name: false
- }
- },
- methods: {
- //当前行数点击事件
- clickitem(e) {
- if (e == 1) {
- this.choosePhoto()
- } else if (e == 2) {
- this.show_set_name = true
- }else if(e == 4){
- this.$api.to("/pages/my/userinfo/bindphone/bindphone")
- }
- },
- //获取用户信息
- get_user_info() {
- this.api.get_user_info()
- this.user_info = uni.getStorageSync("user_info")
- this.list[0].img = this.user_info.headimg
- this.list[1].right = this.user_info.nickname
- this.list[2].right = this.user_info.phone
- this.list[3].right = this.plusXing(this.user_info.hash,6,6)
- // console.log(this.list)
- },
- plusXing(str, frontLen, endLen) {
- if (!str) return
- var len = str.length - frontLen - endLen;
- var xing = '';
- // len
- for (var i = 0; i < 6; i++) {
- xing += '*';
- }
- return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
- },
- copy(val) {
- this.$api.setclip(val)
- },
- //选择图片当头像
- choosePhoto() {
- var that = this
- uni.chooseImage({
- count: 1, //最多可以选择的图片张数,默认9
- sourceType: ['album'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项
- sizeType: ['original'], //original 原图,compressed 压缩图,默认二者都有
- success(res) {
- // 调用上传图片的接口
- // this.uploadPhoto(res.tempFilePaths);
- // that.list[0].img=res.tempFilePaths[0]
- //上传图片
- that.$api.upload(res.tempFilePaths[0]).then(res => {
- // console.log(res)
- //请求设置个人信息借口
- that.api.set_user_info("", res).then(res1 => {
- if (res1.code == 1) {
- uni.showToast({
- title: "更换头像成功",
- duration:2000
- })
- // that.get_user_info()
- setTimeout(()=> {
- that.$api.totabar('/pages/my/my')
- },1000)
- }
- })
- })
- },
- fail() {
- console.log('失败', err);
- },
- complete() {
- console.log('结束');
- },
- })
- },
- setname() {
- //修改个人名称
- this.api.set_user_info(this.value, "").then(res1 => {
- if (res1.code == 1) {
- uni.showToast({
- title: "修改名称成功"
- })
- this.get_user_info()
- //关闭弹出层
- this.show_set_name = false
- //渲染当前名称
- this.list[1].right = res1.data.nickname
- }
- })
- }
- }
- }
- </script>
- <style scoped>
- .index {
- box-sizing: border-box;
- padding-top: 100rpx;
- }
- image {
- display: block;
- }
- .content {
- margin: 20rpx auto;
- }
- .row {
- display: flex;
- width: 710rpx;
- height: 110rpx;
- margin: 0 auto;
- }
- .row>view {
- align-self: center;
- box-sizing: border-box;
- margin: 10rpx;
- }
- .row>view:nth-child(2) {
- margin-left: auto;
- }
- .row>view:nth-child(3) {
- /* margin-left: auto; */
- }
- .btn {
- /* width: 710rpx; */
- display: flex;
- justify-content: space-between;
- }
- .btn>view {
- width: 170rpx;
- height: 58rpx;
- border-radius: 32rpx;
- margin-top: 50rpx;
- text-align: center;
- line-height: 58rpx;
- font-size: 26rpx;
- color: #000;
- }
- .btn>view:last-child {
- width: 170rpx;
- height: 58rpx;
- border-radius: 32rpx;
- margin-top: 50rpx;
- text-align: center;
- line-height: 58rpx;
- font-size: 26rpx;
- }
- .pop_content {
- width: 450rpx;
- padding: 80rpx 50rpx 40rpx;
- border-radius: 20rpx;
- background-color: #fff;
- }
- </style>
|