diff --git a/models/topic.js b/models/topic.js
index 1558065..f01061d 100644
--- a/models/topic.js
+++ b/models/topic.js
@@ -50,6 +50,7 @@ class TopicModel extends HTTP {
let params = {
url: TopicBaseUrl.topic_detail_url+`${id}`,
method: Method.POST,
+ data:{},
success: success
}
this.request(params)
@@ -73,6 +74,7 @@ class TopicModel extends HTTP {
let params = {
url: TopicBaseUrl.topic_collect_url + `${id}`,
method: Method.POST,
+ data:{},
success: success
}
this.request(params)
@@ -82,6 +84,7 @@ class TopicModel extends HTTP {
let params = {
url: TopicBaseUrl.topic_unCollect_url + `${id}`,
method: Method.POST,
+ data: {},
success: success
}
this.request(params)
diff --git a/models/user.js b/models/user.js
index b9a82cc..8ba4376 100644
--- a/models/user.js
+++ b/models/user.js
@@ -8,7 +8,7 @@ const UserConst = {
user_myTopics_url:'/api/group/groupByUser', // 我的议题
user_myActivity_url:'/api/activity/activityList', // 我的活动
- user_updateUserInfo_url:'/api/miniuser/updateUserInfo' // 更新用户信息
+ user_updateUserInfo_url:'/api/miniuser/updateMiniUser' // 更新用户信息
}
class UserModel extends HTTP {
constructor () {
@@ -19,23 +19,24 @@ class UserModel extends HTTP {
let params = {
url: UserConst.user_getInfo_url,
method: Method.GET,
+ data:{},
success: success,
}
this.request(params)
}
- updateUserInfo(avatarUrl, city, country, gender, nickName, province, success){
+ updateUserInfo(avatarUrl, nickName, phone, company, position, success){
let params = {
url: UserConst.user_updateUserInfo_url,
method: Method.POST,
data: {
- avatarUrl: avatarUrl,
- city: city,
- country: country,
- gender, gender,
- nickName: nickName,
- province: province,
+ isRegister: 2, //1.注册 2.修改用户信息
+ avatar: avatarUrl,
+ realName: nickName,
+ phone: phone,
+ company: company,
+ position, position
},
success: success
}
diff --git a/pages/topics/interactive/topicArticle/index.js b/pages/topics/interactive/topicArticle/index.js
index 383f6a5..8750720 100644
--- a/pages/topics/interactive/topicArticle/index.js
+++ b/pages/topics/interactive/topicArticle/index.js
@@ -57,7 +57,6 @@ Page({
let topicId = this.data.topicId
console.log('议题详情' + topicId)
topicModel.getTopicDetail(topicId,res => {
- console.log(res)
let data = res.result
this.setData({
topicId: data.id,
@@ -71,7 +70,6 @@ Page({
detail:data.content,
imgArr: data.images.split(";").slice(0, -1)
})
- console.log(this.data.imgArr)
})
},
fetchDetailComment(){
@@ -79,7 +77,6 @@ Page({
let page = this.data.currPage
topicModel.getTopicDetailComment(topicId,page,res => {
console.log('议题评论')
- console.log(res)
const datas = res.result.list
let tempDatas = []
@@ -115,7 +112,6 @@ Page({
})
}
}
- console.log(this.data.commentList)
wx.stopPullDownRefresh()
})
},
@@ -123,7 +119,6 @@ Page({
let topicId = this.data.topicId
topicModel.topicCollect(topicId,res =>{
console.log('收藏')
- console.log(res)
if(res.code === 200){
this.fetchDetail()
wx.showToast({
@@ -138,7 +133,6 @@ Page({
let topicId = this.data.topicId
topicModel.topicUnCollect(topicId, res => {
console.log('取消收藏')
- console.log(res)
if (res.code === 200) {
this.fetchDetail()
wx.showToast({
@@ -151,7 +145,6 @@ Page({
fetchTopicCommentPraise(commentId){
topicModel.topicCommentPraise(commentId,res =>{
- console.log(res)
if (res.code === 200) {
wx.showToast({
title: res.message,
diff --git a/pages/user/index.js b/pages/user/index.js
index ed332d8..bfed207 100644
--- a/pages/user/index.js
+++ b/pages/user/index.js
@@ -21,32 +21,33 @@ Page({
isAuth:false,
nickName:'',
avatarUrl:'',
+ userInfo:{
+ type:Object,
+ value:{}
+ },
},
+
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
+
+ },
+ onShow: function () {
+ console.log('啦啦啦')
this.getUserInfo()
},
isAuthUserInfo(){
let that = this
wx.showLoading()
- console.log('未授权')
return new Promise(resolve =>{
-
- that.setData({
- authType: 1
- }, () => {
- wx.hideLoading()
- })
wx.getSetting({
success(res) {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
wx.getUserInfo({
success: function (res) {
- // console.log(res.userInfo)
let nickName = res.userInfo.nickName
let avatarUrl = res.userInfo.avatarUrl
@@ -89,7 +90,7 @@ Page({
},
updateUserInfo(avatarUrl, city, country, gender, nickName, province){
userModel.updateUserInfo(avatarUrl, city, country, gender, nickName, province,res=>{
-
+
})
},
getUserInfo(){
@@ -97,7 +98,11 @@ Page({
let nickName = res.result.nickName
let avatarUrl = res.result.avatarUrl
if (nickName && avatarUrl){
+ console.log('已授权')
+ console.log(res.result)
+ let userInfo = res.result
this.setData({
+ userInfo: res.result,
avatarUrl: res.result.avatarUrl,
nickName: res.result.nickName,
reAuth:true
@@ -127,56 +132,15 @@ Page({
onTapItem (e) {
const {type} = e.currentTarget.dataset
console.log(type)
- wx.navigateTo({
- url: `/pages/user/${type}/index`,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ console.log(this.data.userInfo)
+ if (type === 'myInfo'){
+ wx.navigateTo({
+ url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}`,
+ })
+ } else {
+ wx.navigateTo({
+ url: `/pages/user/${type}/index`,
+ })
+ }
}
})
\ No newline at end of file
diff --git a/pages/user/index.wxss b/pages/user/index.wxss
index d5c7e12..f872bb3 100644
--- a/pages/user/index.wxss
+++ b/pages/user/index.wxss
@@ -28,7 +28,7 @@
.user_logo {
width: 80px;
height: 80px;
- border-radius: 40px;
+ border-radius: 5px;
}
.user_name {
width: 400rpx;
diff --git a/pages/user/myInfo/index.js b/pages/user/myInfo/index.js
index 6b43400..fa16d38 100644
--- a/pages/user/myInfo/index.js
+++ b/pages/user/myInfo/index.js
@@ -1,66 +1,135 @@
// pages/user/myInfo/index.js
+import { store } from '../../../utils/store.js'
+import { config } from '../../../config.js'
+import { UserModel } from '../../../models/user.js'
+let userModel = new UserModel()
Page({
/**
* 页面的初始数据
*/
data: {
-
+ avatarUrl:String,
+ nikeName: String,
+ phone: String,
+ company: String,
+ position: String,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
-
+ console.log(options)
+ this.setData({
+ avatarUrl: options.userIcon,
+ nikeName: options.userName,
+ phone: options.userPhone || '',
+ company: options.company || '',
+ position: options.position || '',
+ })
},
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
+ onTapItem(e) {
+ const { type } = e.currentTarget.dataset
+ console.log(type)
+ if(type === 'userIcon'){
+ this.upload()
+ }
},
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
+ upload(){
+ let that = this
+
+ wx.chooseImage({
+ success(res) {
+ wx.showLoading()
+ const tempFilePaths = res.tempFilePaths
+ console.log(res)
+ const token = store.readToken()
+ wx.uploadFile({
+ url: config.api_url + "/api/common/upload",
+ filePath: tempFilePaths[0],
+ header: {
+ 'token': token,
+ 'content-type': 'application/json',
+ },
+ name: 'files',
+ success(res) {
+ console.log(res);
+ const data = JSON.parse(res.data)
+ const image = {
+ url: config.api_url + '/' + data.result.imgUrl,
+ }
+ that.setData({
+ avatarUrl: image.url
+ },()=>{
+ wx.hideLoading()
+ })
+ }
+ })
+ }
+ })
},
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
+ getUserInfo(){
+ userModel.getUserInfo(res => {
+ let nickName = res.result.nickName
+ let avatarUrl = res.result.avatarUrl
+ this.setData({
+ avatarUrl: res.result.avatarUrl,
+ nikeName: res.result.nickName,
+ phone: res.result.phone || '',
+ company: res.result.company || '',
+ position: res.result.position || '',
+ })
+ store.saveUserInfo({
+ nickName: res.result.nickName,
+ avatarUrl: res.result.avatarUrl,
+ phone: res.result.phone || ''
+ })
+ })
},
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
+ bindNikeNameInput(e){
+ this.setData({
+ nikeName:e.detail.value
+ })
},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
+ bindPhoneInput(e) {
+ this.setData({
+ phone: e.detail.value
+ })
},
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
+ bindCompanyInput(e) {
+ this.setData({
+ company: e.detail.value
+ })
},
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
+ bindPositionInput(e) {
+ this.setData({
+ position: e.detail.value
+ })
+ },
+ submit(){
+ let avatarUrl = this.data.avatarUrl
+ let nikeName = this.data.nikeName
+ let phone = this.data.phone
+ let company = this.data.company
+ let position = this.data.position
+
+ userModel.updateUserInfo(avatarUrl, nikeName, phone, company, position, res => {
+ // that.getUserInfo()
+ if(res.code === 200){
+ wx.showToast({
+ title: '修改成功',
+ icon: 'none',
+ duration: 2000,
+ success(res) {
+ setTimeout(function () {
+ wx.navigateBack({
+ delta: 1
+ })
+ }, 2000)
+ }
+ })
+ }
+ })
}
})
\ No newline at end of file
diff --git a/pages/user/myInfo/index.json b/pages/user/myInfo/index.json
index 47e544f..dba7d7d 100644
--- a/pages/user/myInfo/index.json
+++ b/pages/user/myInfo/index.json
@@ -1,4 +1,8 @@
{
"navigationBarTitleText": "个人资料",
- "usingComponents": {}
+ "usingComponents": {
+ "e-ibutton": "/components/image-button/index",
+ "mp-cells": "/components/weui/cells/cells",
+ "mp-cell": "/components/weui/cell/cell"
+ }
}
\ No newline at end of file
diff --git a/pages/user/myInfo/index.wxml b/pages/user/myInfo/index.wxml
index 52a6fe1..3e823f4 100644
--- a/pages/user/myInfo/index.wxml
+++ b/pages/user/myInfo/index.wxml
@@ -1,2 +1,38 @@
-pages/user/myInfo/index.wxml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/user/myInfo/index.wxss b/pages/user/myInfo/index.wxss
index 617704e..eaff6bb 100644
--- a/pages/user/myInfo/index.wxss
+++ b/pages/user/myInfo/index.wxss
@@ -1 +1,74 @@
-/* pages/user/myInfo/index.wxss */
\ No newline at end of file
+/* pages/user/myInfo/index.wxss */
+.container {
+ background-color: #FAFAFA;
+ height: 100vh;
+}
+.page_hd {
+ border-bottom: 7px solid #f7f7f7;
+}
+.page_hd .weui-cells:before {
+ border-top: 0px solid white;
+}
+.page_hd .weui-cells:after {
+ border-bottom: 0px solid white;
+}
+.user_hd {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ overflow: hidden;
+}
+.user_auth_hd {
+ display: flex;
+ flex-direction: row;
+ align-items: center;
+ overflow: hidden;
+ justify-content: space-between;
+}
+.user_logo {
+ width: 60px;
+ height: 60px;
+ border-radius: 5px;
+}
+.user_name {
+ width: 400rpx;
+ color: #292E3E;
+ padding-left: 10px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+}
+/* 页面body */
+.page_bd .weui-cell{
+ padding: 10px 16px 10px 16px;
+}
+.weui-cell_wxss{
+
+}
+.weui-cell__ft{
+ width: 70%;
+}
+.page_bd .weui-cell__hd {
+ display: flex;
+ align-items: center;
+ font-size: 14px;
+}
+.page_bd .weui-cell__icon {
+ width: 19px;
+ height: 16px;
+ padding: 0 10px 0 0;
+}
+.msg_footer{
+ font-size: 14px;
+ border: 1px solid #AAAAAA;
+ border-radius: 4px;
+ height: 30px;
+ text-align: left;
+}
+.btnView{
+ position: fixed;
+ padding: 10px 20px 20px 20px;
+ bottom: 0;
+ left: 0;
+ right: 0;
+}
\ No newline at end of file