正在显示
1 个修改的文件
包含
55 行增加
和
58 行删除
| @@ -6,16 +6,23 @@ | @@ -6,16 +6,23 @@ | ||
| 6 | <view class="oneSettingV2-c-1-l">头像</view> | 6 | <view class="oneSettingV2-c-1-l">头像</view> |
| 7 | <view class="oneSettingV2-c-1-r"> | 7 | <view class="oneSettingV2-c-1-r"> |
| 8 | <avatar selWidth="100rpx" selHeight="100rpx" @upload="myUpload" | 8 | <avatar selWidth="100rpx" selHeight="100rpx" @upload="myUpload" |
| 9 | - :avatarSrc="userdata.img?$service.getimg(userdata.img):imgUrl" | 9 | + :avatarSrc="userdata.img?$service.getimg(userdata.img):'/static/images/tx.png'" |
| 10 | avatarStyle="width: 100rpx;height: 100rpx;border-radius: 50%;" inner=true></avatar> | 10 | avatarStyle="width: 100rpx;height: 100rpx;border-radius: 50%;" inner=true></avatar> |
| 11 | </view> | 11 | </view> |
| 12 | </view> | 12 | </view> |
| 13 | <view class="oneSettingV2-c-1"> | 13 | <view class="oneSettingV2-c-1"> |
| 14 | <view class="oneSettingV2-c-1-l">姓名</view> | 14 | <view class="oneSettingV2-c-1-l">姓名</view> |
| 15 | - <view class="oneSettingV2-c-1-r">{{userdata.title}}</view> | 15 | + <view class="oneSettingV2-c-1-r"> |
| 16 | + <input v-model="userdata.title" placeholder="请输入" /> | ||
| 17 | + </view> | ||
| 16 | </view> | 18 | </view> |
| 17 | 19 | ||
| 18 | </view> | 20 | </view> |
| 21 | + | ||
| 22 | + <view class="btn" @click="submit"> | ||
| 23 | + 提交 | ||
| 24 | + </view> | ||
| 25 | + | ||
| 19 | </view> | 26 | </view> |
| 20 | </view> | 27 | </view> |
| 21 | </template> | 28 | </template> |
| @@ -23,48 +30,32 @@ | @@ -23,48 +30,32 @@ | ||
| 23 | <script> | 30 | <script> |
| 24 | import Vue from 'vue' | 31 | import Vue from 'vue' |
| 25 | import { | 32 | import { |
| 26 | - mapState, | ||
| 27 | - mapMutations | 33 | + mapState |
| 28 | } from 'vuex' | 34 | } from 'vuex' |
| 29 | - var that | ||
| 30 | export default { | 35 | export default { |
| 31 | data() { | 36 | data() { |
| 32 | return { | 37 | return { |
| 33 | - imgUrl: '/static/images/tx.png', | ||
| 34 | - userName: "学员01", | ||
| 35 | - gender: "男", | ||
| 36 | - studentNum: "ZZ202012058", | ||
| 37 | - identity:0, | ||
| 38 | - userdata:{ | ||
| 39 | - img:'' | ||
| 40 | - } | 38 | + userdata: {} |
| 41 | } | 39 | } |
| 42 | }, | 40 | }, |
| 43 | onLoad(option) { | 41 | onLoad(option) { |
| 44 | - that=this | ||
| 45 | - console.log(option); | ||
| 46 | - this.identity=uni.getStorageSync('identity') | ||
| 47 | this.userdata=this.userDatas | 42 | this.userdata=this.userDatas |
| 48 | }, | 43 | }, |
| 49 | computed: { | 44 | computed: { |
| 50 | - ...mapState(['userDatas']), | 45 | + ...mapState(['userDatas']), |
| 51 | }, | 46 | }, |
| 52 | methods: { | 47 | methods: { |
| 53 | // 更新头像 | 48 | // 更新头像 |
| 54 | myUpload(rsp) { | 49 | myUpload(rsp) { |
| 55 | var avatar = rsp.path | 50 | var avatar = rsp.path |
| 56 | - // console.log(avatar) | ||
| 57 | - // Vue.set(that.userdata,'head_portrait',avatar) | ||
| 58 | - // return | ||
| 59 | this.$service.wx_upload(avatar).then(res => { | 51 | this.$service.wx_upload(avatar).then(res => { |
| 60 | 52 | ||
| 61 | - that.btn_kg = 0 | 53 | + this.btn_kg = 0 |
| 62 | console.log(res) | 54 | console.log(res) |
| 63 | if (res.code == 1) { | 55 | if (res.code == 1) { |
| 64 | var datas = res.data | 56 | var datas = res.data |
| 65 | - console.log(that.userdata) | ||
| 66 | - Vue.set(that.userdata,'img',datas) | ||
| 67 | - that.setmsg() | 57 | + console.log('datas', datas) |
| 58 | + Vue.set(this.userdata,'img',datas) | ||
| 68 | } else { | 59 | } else { |
| 69 | if (res.msg) { | 60 | if (res.msg) { |
| 70 | uni.showToast({ | 61 | uni.showToast({ |
| @@ -79,7 +70,7 @@ | @@ -79,7 +70,7 @@ | ||
| 79 | } | 70 | } |
| 80 | } | 71 | } |
| 81 | }).catch(e => { | 72 | }).catch(e => { |
| 82 | - that.btn_kg = 0 | 73 | + this.btn_kg = 0 |
| 83 | console.log(e) | 74 | console.log(e) |
| 84 | uni.showToast({ | 75 | uni.showToast({ |
| 85 | icon: 'none', | 76 | icon: 'none', |
| @@ -87,27 +78,28 @@ | @@ -87,27 +78,28 @@ | ||
| 87 | }) | 78 | }) |
| 88 | }) | 79 | }) |
| 89 | }, | 80 | }, |
| 90 | - setmsg(){ | ||
| 91 | - var datas = { | ||
| 92 | - img:that.userdata.img | ||
| 93 | - } | ||
| 94 | - var jkurl = '/my/save' | ||
| 95 | - | ||
| 96 | - that.$service.P_post(jkurl, datas).then(res => { | ||
| 97 | - that.btnkg = 0 | ||
| 98 | - console.log(res) | 81 | + submit() { |
| 82 | + uni.showLoading({ | ||
| 83 | + title: '提交中', | ||
| 84 | + mask: true | ||
| 85 | + }) | ||
| 86 | + | ||
| 87 | + const { img, title } = this.userdata; | ||
| 88 | + | ||
| 89 | + this.$service.P_post('/lecturer/update_info', { | ||
| 90 | + img_url: img, | ||
| 91 | + title, | ||
| 92 | + }).then(res => { | ||
| 93 | + uni.hideLoading(); | ||
| 99 | if (res.code == 1) { | 94 | if (res.code == 1) { |
| 100 | - that.htmlReset = 0 | ||
| 101 | - var datas = res.data | ||
| 102 | - console.log(typeof datas) | ||
| 103 | - | ||
| 104 | - if (typeof datas == 'string') { | ||
| 105 | - datas = JSON.parse(datas) | ||
| 106 | - } | ||
| 107 | - console.log(res) | ||
| 108 | - | ||
| 109 | - } else { | ||
| 110 | - | 95 | + uni.showToast({ |
| 96 | + icon:'none', | ||
| 97 | + title:'保存成功' | ||
| 98 | + }) | ||
| 99 | + setTimeout(function(){ | ||
| 100 | + uni.navigateBack() | ||
| 101 | + },1000) | ||
| 102 | + }else { | ||
| 111 | if (res.msg) { | 103 | if (res.msg) { |
| 112 | uni.showToast({ | 104 | uni.showToast({ |
| 113 | icon: 'none', | 105 | icon: 'none', |
| @@ -120,25 +112,15 @@ | @@ -120,25 +112,15 @@ | ||
| 120 | }) | 112 | }) |
| 121 | } | 113 | } |
| 122 | } | 114 | } |
| 115 | + | ||
| 116 | + | ||
| 123 | }).catch(e => { | 117 | }).catch(e => { |
| 124 | - that.htmlReset = 1 | ||
| 125 | - that.btnkg = 0 | ||
| 126 | - // that.$refs.htmlLoading.htmlReset_fuc(1) | ||
| 127 | - console.log(e) | 118 | + uni.hideLoading() |
| 128 | uni.showToast({ | 119 | uni.showToast({ |
| 129 | icon: 'none', | 120 | icon: 'none', |
| 130 | title: '获取数据失败,请检查您的网络连接' | 121 | title: '获取数据失败,请检查您的网络连接' |
| 131 | }) | 122 | }) |
| 132 | }) | 123 | }) |
| 133 | - }, | ||
| 134 | - getimg(img){ | ||
| 135 | - return this.$service.getimg(img) | ||
| 136 | - }, | ||
| 137 | - logout_fuc(){ | ||
| 138 | - uni.removeStorageSync('token') | ||
| 139 | - uni.reLaunch({ | ||
| 140 | - url:'/pages/login/login' | ||
| 141 | - }) | ||
| 142 | } | 124 | } |
| 143 | } | 125 | } |
| 144 | } | 126 | } |
| @@ -168,6 +150,8 @@ | @@ -168,6 +150,8 @@ | ||
| 168 | .oneSettingV2-c-1-r{ | 150 | .oneSettingV2-c-1-r{ |
| 169 | font-size: 28rpx; | 151 | font-size: 28rpx; |
| 170 | color: #646464; | 152 | color: #646464; |
| 153 | + flex: 1; | ||
| 154 | + text-align: right; | ||
| 171 | } | 155 | } |
| 172 | } | 156 | } |
| 173 | } | 157 | } |
| @@ -259,4 +243,17 @@ | @@ -259,4 +243,17 @@ | ||
| 259 | color: #2D81FF; | 243 | color: #2D81FF; |
| 260 | } | 244 | } |
| 261 | } | 245 | } |
| 246 | + | ||
| 247 | + | ||
| 248 | + .btn { | ||
| 249 | + height: 88rpx; | ||
| 250 | + line-height: 88rpx; | ||
| 251 | + background: #2D81FF; | ||
| 252 | + border-radius: 44rpx; | ||
| 253 | + text-align: center; | ||
| 254 | + font-size: 34rpx; | ||
| 255 | + font-family: PingFang SC; | ||
| 256 | + font-weight: 500; | ||
| 257 | + color: #FFFFFF; | ||
| 258 | + } | ||
| 262 | </style> | 259 | </style> |
-
请 注册 或 登录 后发表评论