提交 4baf8177 编写于 作者: M m0_74163447

后端交互

上级 7f31d405
......@@ -8,7 +8,7 @@
</view>
<view class="info">
<view class="info1">
<view class="head-portrait"></view>
<view class="head-portrait" :style="'background: url('+headPortraitIcon+') no-repeat center/cover #eeeeee;'"></view>
<view class="nickname">{{nickname}}</view>
</view>
<view class="info2">
......@@ -20,10 +20,7 @@
<view class="team-icon"></view>
<view class="team-name">运动小队:{{teamName}}</view>
</view>
<view class="point">
<view class="point-icon"></view>
<view class="point-num">运动积分:{{point}}</view>
</view>
</view>
</view>
<view>
......@@ -33,7 +30,7 @@
<view>我的帖子</view>
</view>
<view class="running-record">
<view class="running-record-icon"></view>
<view class="running-record-icon" @click="goToRunningRecord()"></view>
<view>运动记录</view>
</view>
<view class="setting">
......@@ -55,11 +52,11 @@
export default {
data () {
return {
iStatusBarHeight:0,
nickname:'王二蛋',
schoolName:'福州大学',
teamName:'must go',
point:'1250'
headPortraitIcon:'',
nickname:'',
schoolName:'',
teamName:'',
point:''
}
},
methods:{
......@@ -77,10 +74,31 @@
uni.navigateTo({
url: '/pages/my/my-resetpassword'
})
}
},
goToRunningRecord() {
uni.navigateTo({
url: '/pages/my/my-running-record'
})
},
getData() {
uniCloud.callFunction({
name: 'fe-my-information',
data: {userId:'6450da43e1a35c371b3699cc'}
})
.then(res => {
this.headPortraitIcon=res.result.data.icon,
this.nickname=res.result.data.username,
this.schoolName=res.result.data.school,
this.teamName=res.result.data.team,
//this.activityList=res.result.data.activityList,
console.log(res);
});
},
},
onLoad() {
plus.navigator.setStatusBarBackground('#EDEEF0');
this.getData()
}
}
</script>
......@@ -120,8 +138,8 @@
height: 200rpx;
border-radius: 50%;
background-size:100% 100%;
background-image:url("/static/my/main/head-portrait.png") ;
background-repeat:no-repeat;
/* background-image:url("/static/my/main/head-portrait.png") ;
background-repeat:no-repeat; */
float: left;
}
.nickname{
......@@ -139,21 +157,21 @@
border-radius: 20rpx;
background-color: #FFFFFF;
width:75%;
height: 60%;
height: 40%;
margin-top: 50px;
margin-left: auto;
margin-right: auto;
}
.school{
height: 30%;
margin-top: 20rpx;
height: 50%;
}
.school-icon{
width: 70rpx;
height: 70rpx;
margin-top: 50rpx;
width: 100rpx;
height: 100rpx;
margin-top: 30rpx;
margin-left: 50rpx;
background-size:100% 100%;
background-image:url("/static/my/main/school-icon.png");
......@@ -162,23 +180,23 @@
}
.school-name{
width: 320rpx;
width: 340rpx;
height: 30rpx;
margin-top: 60rpx;
margin-right: 55rpx;
margin-right: 45rpx;
font-size: 35rpx;
text-align: left;
float: right;
}
.team{
height: 30%;
height: 50%;
}
.team-icon{
width: 70rpx;
height: 70rpx;
margin-top: 50rpx;
width: 100rpx;
height: 100rpx;
margin-top: 40rpx;
margin-left: 50rpx;
background-size:100% 100%;
background-image:url("/static/my/main/team-icon.png");
......@@ -187,43 +205,19 @@
}
.team-name{
width: 320rpx;
height: 30rpx;
margin-top: 60rpx;
margin-right: 55rpx;
font-size: 35rpx;
text-align: left;
float: right;
}
.point{
height: 30%;
}
.point-icon{
width: 70rpx;
height: 70rpx;
margin-top: 50rpx;
margin-left: 50rpx;
background-size:100% 100%;
background-image:url("/static/my/main/point-icon.png");
background-repeat:no-repeat;
float: left;
}
.point-num{
width: 320rpx;
width: 340rpx;
height: 30rpx;
margin-top: 60rpx;
margin-right: 55rpx;
margin-right: 45rpx;
font-size: 35rpx;
text-align: left;
float: right;
}
.func{
width:75%;
margin-top: 30rpx;
/* margin-top: 10rpx; */
margin-left: auto;
margin-right: auto;
display: flex;
......
......@@ -6,15 +6,14 @@
<span class="empty"></span>
</view>
<view class="container">
<view class="ui-all">
<view class="avatar" @tap="avatarChoose">
<view class="avatar" @tap="avatarChoose">
<view class="imgAvatar">
<view class="iavatar" :style="'background: url('+avatar+') no-repeat center/cover #eeeeee;'">
</view>
</view>
<text v-if="avatar">修改头像</text>
<text v-if="!avatar">设置头像</text>
<view class="iavatar" :style="'background: url('+avatar+') no-repeat center/cover #eeeeee;'"></view>
</view>
<text>修改头像</text>
<button v-if="!avatar" open-type="getUserInfo" @tap="getUserInfo" class="getInfo"></button>
</view>
<view class="ui-list">
......@@ -30,9 +29,9 @@
</view>
<view class="ui-list right">
<text>性别</text>
<picker @change="bindPickerChange" mode='selector' range-key="name" :value="index1" :range="sex">
<picker @change="bindPickerChange" mode='selector' range-key="name" :value="index1" :range="selectSex">
<view class="picker">
{{sex[index1].name}}
{{selectSex[index1].name}}
</view>
</picker>
</view>
......@@ -46,27 +45,25 @@
</view>
<button class="save" @tap="savaInfo">保 存 修 改</button>
</view>
</view>
</view>
</template>
<script>
import {
pathToBase64,
base64ToPath
} from 'js_sdk/mmmm-image-tools/index.js';
export default {
data() {
return {
sex: [{
selectSex: [{
id: 1,
name: ''
}, {
id: 2,
name: ''
}],
index1: 0,
index1: '0',
school: [{
id: 1,
name: '福州大学'
......@@ -74,13 +71,13 @@
id: 2,
name: 'xx大学'
}],
index2: 0,
index2: '0',
avatar: '',
// url: '',
nickName: '王二蛋',
mobile: '15305986885',
headimg: ''
schoolName:'',
nickName: '',
mobile: '',
sex:'',
}
},
......@@ -101,26 +98,41 @@
this.mobile = e.detail.value;
},
avatarChoose() {
let that = this;
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function(res) {
var tempFilePaths = res.tempFilePaths;
pathToBase64(tempFilePaths[0]) //图像转base64工具
.then(base64 => {
that.avatar = base64;
//将文件转化为base64并显示
// that.avatarUpload(base64); //同时将头像上传至数据库进行存储
}).catch(error => {
console.error(error)
})
}
uniCloud.chooseAndUploadFile({
type: 'image',
success(res) {
that.avatar = res["tempFiles"][0]["url"];
//console.log(res);
//console.log(this.avatar);
},
fail() {},
complete() {}
});
},
// avatarChoose() {
// let that = this;
// uni.chooseImage({
// count: 1,
// sizeType: ['original', 'compressed'],
// sourceType: ['album', 'camera'],
// success: function(res) {
// var tempFilePaths = res.tempFilePaths;
// pathToBase64(tempFilePaths[0]) //图像转base64工具
// .then(base64 => {
// that.avatar = base64;
// //将文件转化为base64并显示
// // that.avatarUpload(base64); //同时将头像上传至数据库进行存储
// }).catch(error => {
// console.error(error)
// })
// }
// });
// },
getUserInfo() {
uni.getUserProfile({
......@@ -145,18 +157,20 @@
// })
// }
// },
savaInfo () {
savaInfo() {
uni.showModal({
title: '温馨提示', //提示标题
content: '确认修改你的个人信息吗', //提示内容
showCancel: true, //是否显示取消按钮
success:res => {
success: res => {
if (res.confirm) { //confirm为ture,代表用户点击确定
let that = this;
let gender = that.selectSex[that.index1].name;
let school = that.school[that.index2].name;
let nickname = that.nickName;
let mobile = that.mobile;
// let updata = {};
let headimg = that.avatar;
let updata = {};
if (!nickname) {
uni.showToast({
title: '请填写昵称',
......@@ -165,14 +179,15 @@
});
return;
}
// updata.nickname = nickname;
// if (!headimg) {
// headimg = that.avater;
// }
// updata.headimg = headimg;
// updata.gender = gender;
updata.nickname = nickname;
if (!headimg) {
headimg = that.avater;
}
updata.headimg = headimg;
updata.gender = gender;
updata.school = school;
if (that.isPoneAvailable(mobile)) {
// updata.mobile = mobile;
updata.mobile = mobile;
} else {
uni.showToast({
title: '手机号码有误,请重填',
......@@ -181,7 +196,7 @@
});
return;
}
this.Upload(updata);
// that.updata(updata);
} else if (res.cancel) { //cancel为ture,代表用户点击取消
console.log('点击了取消按钮');
......@@ -190,7 +205,7 @@
})
},
isPoneAvailable(poneInput) {
var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;
if (!myreg.test(poneInput)) {
......@@ -232,10 +247,22 @@
uni.navigateBack({
delta: 1, //返回层数,2则上上页
})
}
},
Upload(updata) {
uniCloud.callFunction({
name: 'fe-my-modifyinformation',
data: {userId:'6450da43e1a35c371b3699cc',icon:updata.headimg,username:updata.nickname,school:updata.school,phone:updata.mobile,gender:updata.gender}
})
.then(res => {
console.log(res);
});
},
},
onLoad() {
plus.navigator.setStatusBarBackground('#EDEEF0');
//this.getData();
}
}
......
......@@ -10,22 +10,22 @@
<span class="empty"></span>
</view>
<view class="content">
<veiw class="password">
<view class="password">
<span>&ensp;&ensp;码:</span>
<input placeholder="请输入原密码" type="text" :password="showPassword" name="input"></input>
<!-- <text :class="[!showPassword ?'cuIcon-attentionfill' : 'cuIcon-attentionforbidfill']" class="text-gray" @click="showPwd" ></text> -->
<!-- <input type="safe-password" :value="originalPassword" :valplaceholder='请输入原密码'></input> -->
</veiw>
<veiw class="password">
</view>
<view class="password">
<span>&ensp;&ensp;码:</span>
<input placeholder="请输入新密码" type="text" @input="bindNewPassword" :password="showPassword"
name="input"></input>
</veiw>
<veiw class="password">
</view>
<view class="password">
<span>确认密码:</span>
<input placeholder="请确认密码" type="text" @input="bindConfirmPassword" :password="showPassword"
name="input"></input>
</veiw>
</view>
</view>
<view class="confirm">
<button class="confirm-btn" @click="confirmModification()">确认修改</button>
......@@ -38,6 +38,7 @@
data() {
return {
showPassword: true,
password:'1223',
newPassword: '',
confirmPassword: '',
}
......@@ -61,8 +62,10 @@
success: res => {
if (res.confirm) { //confirm为ture,代表用户点击确定
let that = this;
let password = that.password;
let newPassword = that.newPassword;
let confirmPassword = that.confirmPassword;
let updata = {};
if (!that.isPasswordAvailable(newPassword)) {
uni.showToast({
title: '密码长度在8-20位!',
......@@ -78,9 +81,10 @@
});
return;
} else {
// updata.mobile = mobile;
//return;
updata.password = password;
updata.newPassword = newPassword;
}
this.Upload(updata);
} else if (res.cancel) { //cancel为ture,代表用户点击取消
console.log('点击了取消按钮');
}
......@@ -109,6 +113,17 @@
delta: 1, //返回层数,2则上上页
})
},
Upload(updata) {
uniCloud.callFunction({
name: 'fe-my-resetpassword',
data: {userId:'6450da43e1a35c371b3699cc',password:updata.password,newPassword:updata.newPassword}
})
.then(res => {
console.log(res);
});
},
onload() {
plus.navigator.setStatusBarBackground('#EDEEF0');
}
......
......@@ -44,9 +44,11 @@
showCancel: true, //是否显示取消按钮
success: function (res) {
if (res.confirm) { //confirm为ture,代表用户点击确定
console.log('点击了确定按钮');
uni.navigateTo({
url: '/pages/login/login'
})
} else if (res.cancel) { //cancel为ture,代表用户点击取消
console.log('点击了取消按钮');
}
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册