Browse Source

update user

master
fanp 6 years ago
parent
commit
42b9388d16
  1. 32
      models/user.js
  2. 35
      pages/topics/goodIdea/index.js
  3. 2
      pages/topics/index.js
  4. 52
      pages/topics/interactive/topicArticle/index.js
  5. 11
      pages/topics/interactive/topicArticle/index.wxml
  6. 7
      pages/topics/interactive/topicArticle/index.wxss
  7. 85
      pages/user/index.js
  8. 14
      pages/user/index.wxml
  9. 20
      pages/user/index.wxss
  10. 30
      pages/user/myFavorite/index.js
  11. 35
      pages/user/myIdea/index.js
  12. 11
      pages/user/myMessage/cell/index.js

32
models/user.js

@ -1,17 +1,45 @@
import { HTTP, Method} from '../utils/http.js'
const UserConst = {
user_info: '', // 个人信息
user_getInfo_url: '/api/miniuser/getInfo', // 个人信息
user_unMessage_url:'/api/message/page', // 我的消息未读
user_myMessage_url:'/api/message/page', // 我的消息
user_myFavorite_url: '/api/collect/collectionList', // 我的收藏
user_goldenList_url: '/api/comment/goldenList', // 我的金点子
user_myTopics_url:'/api/group/groupByUser', // 我的议题
user_myActivity_url:'/api/activity/activityList' // 我的活动
user_myActivity_url:'/api/activity/activityList', // 我的活动
user_updateUserInfo_url:'/api/miniuser/updateUserInfo' // 更新用户信息
}
class UserModel extends HTTP {
constructor () {
super()
}
getUserInfo(success){
let params = {
url: UserConst.user_getInfo_url,
method: Method.GET,
success: success,
}
this.request(params)
}
updateUserInfo(avatarUrl, city, country, gender, nickName, province, success){
let params = {
url: UserConst.user_updateUserInfo_url,
method: Method.POST,
data: {
avatarUrl: avatarUrl,
city: city,
country: country,
gender, gender,
nickName: nickName,
province: province,
},
success: success
}
this.request(params)
}
getMyMessageList(page, success){
let params = {

35
pages/topics/goodIdea/index.js

@ -14,40 +14,7 @@ Component({
* 组件的初始数据
*/
data: {
list: [
{
ideaId: '1',
userIcon: "",
userName: "用户名",
time: "刚刚",
isGoodIdea: 1,
praiseNum: "30",
detail: {
title: "习近平主持政治局第十七次集体... 拷贝",
userIcon: "",
userName: "用户名",
time: "刚刚",
commentNum: "33",
text: "【内容以实际活动为准】市北区位于青岛市主城区地理位置的中心,西部濒临胶州湾,东部与崂山区为邻,北部与李沧区接壤,南部与市南区毗"
}
},
{
ideaId: "2",
userIcon: "",
userName: "用户名",
time: "1分钟前",
isGoodIdea: 0,
praiseNum: "30",
detail: {
title: "习近平主持政治局第十七次集体... 拷贝",
userIcon: "",
userName: "用户名",
time: "刚刚",
commentNum: "33",
text: "市北区位于青岛市主城区地理位置的中心,西部濒临胶州湾,东部与崂山区为邻,北部与李沧区接壤,南部与市南区毗连,东西最大距离11. 拷贝 2"
}
}
]
list: []
},
/**

2
pages/topics/index.js

@ -25,7 +25,7 @@ Page({
*/
onLoad: function () {
if (!store.hasPhone()) {
if (store.hasPhone()) {
console.log('已经绑定手机号码')
} else {
console.log('未绑定手机号码')

52
pages/topics/interactive/topicArticle/index.js

@ -12,37 +12,16 @@ Page({
* 页面的初始数据
*/
data: {
title:"市北区举行国际航运贸易金融创新中心核心区产业建设",
time:"6月7日",
userInfo:{
icon:"",
name:"用户名",
company:"青岛誉群投资有限公司",
position:"董事长"
},
detail:"9月16日晚7时,市北区委、区政府在区机关二楼会议厅举行国际航运贸易金融创新中心核心区产业招商工作方案答辩。这是市北区借鉴市委、市政府推动15个攻势作战经验,围绕创新中心核心区建设举行的首场答辩。区委书记张新竹主持答辩并讲话。",
imgArr:['http://bpic.588ku.com/element_origin_min_pic/16/10/30/528aa13209e86d5d9839890967a6b9c1.jpg',
'http://bpic.588ku.com/element_origin_min_pic/16/10/30/54fcef525fa8f6037d180f3c26f3be65.jpg',
'http://bpic.588ku.com/element_origin_min_pic/16/10/30/62e3ca3a02dddb002eff00482078d194.jpg',
'http://bpic.588ku.com/element_origin_min_pic/16/10/31/c7167fcfb4ebcd12621c05b0c852e98e.jpg'
],
title:String,
time: String,
groupAvator: String,
author:String,
company:String,
position:String,
detail: String,
imgArr:[],
comments:[
{
userIcon:"",
userName:"用户名",
detail:"评论内容",
time:"刚刚",
praiseNum:"30"
},
{
userIcon: "",
userName: "用户名",
detail: "评论内容",
time: "1小时前",
praiseNum: "30"
}
],
comments:[],
unStar: '/images/common/star.png',
star: '/images/common/star_light.png',
@ -131,12 +110,10 @@ Page({
isCollect: data.isCollect,
title:data.title,
time: data.createTime,
userInfo:{
icon: data.groupAvator,
name:data.author,
company: data.company,
position: data.position,
},
groupAvator: data.groupAvator,
author: data.author,
company: data.company,
position: data.position,
detail:data.content,
imgArr: data.images.split(";").slice(0, -1)
})
@ -255,6 +232,9 @@ Page({
})
this.fetchTopicCommentPraise(selectItem.id)
// 评论点赞
},
onTapComment(){
},
previewImg: function (e) {
console.log(e.currentTarget.dataset.index);

11
pages/topics/interactive/topicArticle/index.wxml

@ -14,14 +14,14 @@
</view>
<view class="topic_userInfo">
<view class="user_icon">
<image src="{{userInfo.icon}}"></image>
<image src="{{groupAvator}}"></image>
</view>
<view class="user_text">
<view>
{{userInfo.name}}
{{author}}
</view>
<view>
{{userInfo.company + ' ' + userInfo.position}}
{{company + ' ' + position}}
</view>
</view>
</view>
@ -39,7 +39,10 @@
<view class="section_line"></view>
<view class="topic_comment">
<view class="topic_comment_top">
{{'评论 ' + comments.length}}
<view>
{{'评论 ' + comments.length}}
</view>
<button class="commnetBtn" size="mini" bindtap="onTapComment">评论</button>
</view>
<view class="comment_info" wx:for="{{commentList}}" wx:key="{{index}}">
<view class="comment_info_left">

7
pages/topics/interactive/topicArticle/index.wxss

@ -97,9 +97,16 @@ image{
flex-direction: column;
}
.topic_comment_top{
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
height: 40px;
/* border-bottom: 1px solid #E7E7E7; */
}
.commnetBtn{
margin: 0;
}
.comment_info{
padding: 10px 0;
display: flex;

85
pages/user/index.js

@ -2,8 +2,11 @@
import dayjs from '../../utils/dayjs/index.js'
import relativeTime from '../../utils/dayjs/relativeTime.js'
dayjs.extend(relativeTime);
import { store } from '../../utils/store.js'
import { UserModel } from '../../models/user.js'
let userModel = new UserModel()
import { AuthModel } from '../../models/auth.js'
let authModel = new AuthModel()
Page({
@ -11,15 +14,80 @@ Page({
* 页面的初始数据
*/
data: {
messageTotal: Number
messageTotal: Number,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
authType:0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getMsgStatus()
this.getUserInfo()
this.isAuthUserInfo()
},
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
console.log(nickName, avatarUrl)
if(nickName && avatarUrl){
that.setData({
authType: 2
},()=>{
wx.hideLoading()
})
}
}
})
}
}
})
})
},
bindGetUserInfo(e) {
console.log(e.detail.userInfo)
let avatarUrl = e.detail.userInfo.avatarUrl
let city = e.detail.userInfo.city
let country = e.detail.userInfo.country
let gender = e.detail.userInfo.gender
let nickName = e.detail.userInfo.nickName
let province = e.detail.userInfo.province
this.updateUserInfo(avatarUrl, city, country, gender, nickName, province)
this.isAuthUserInfo()
},
hasBindUserInfo(){
return store.hasBindUserInfo();
},
updateUserInfo(avatarUrl, city, country, gender, nickName, province){
userModel.updateUserInfo(avatarUrl, city, country, gender, nickName, province,res=>{
console.log(res)
})
},
getUserInfo(){
userModel.getUserInfo(res=>{
console.log(res)
})
},
getMsgStatus(){
userModel.getMyMessageTotal(res=>{
console.log(res.result.total)
@ -31,11 +99,14 @@ Page({
onTapItem (e) {
const {type} = e.currentTarget.dataset
console.log(type)
if(type != 'myInfo'){
wx.navigateTo({
url: `/pages/user/${type}/index`,
})
}
wx.navigateTo({
url: `/pages/user/${type}/index`,
})
// if(type != 'myInfo'){
// wx.navigateTo({
// url: `/pages/user/${type}/index`,
// })
// }
},
/**
* 生命周期函数--监听页面初次渲染完成

14
pages/user/index.wxml

@ -1,6 +1,6 @@
<!--pages/user/index.wxml-->
<view class="container">
<mp-cells ext-class="page_hd">
<mp-cells ext-class="page_hd" wx:if="{{authType === 2}}">
<mp-cell bindtap="onTapItem" data-type="myInfo">
<view class="user_hd">
<!-- <image slot="icon" class="user_logo" src=""/> -->
@ -9,7 +9,17 @@
<open-data class="user_name" type="userNickName" lang="zh_CN"></open-data>
</view>
</mp-cell>
</mp-cells>
<mp-cells ext-class="page_hd" wx:if="{{authType === 1}}">
<mp-cell bindtap="onTapItem" data-type="myInfo">
<view class="user_auth_hd">
<open-data class="user_logo" type="userAvatarUrl"></open-data>
<open-data class="user_auth_name" type="userNickName"></open-data>
<!-- 需要使用 button 来授权登录 -->
<button class="authBtn" size="mini" wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">授权登录</button>
<view wx:else>请升级微信版本</view>
</view>
</mp-cell>
</mp-cells>
<mp-cells ext-class="page_bd">
<mp-cell

20
pages/user/index.wxss

@ -18,6 +18,13 @@
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: 80px;
height: 80px;
@ -50,4 +57,17 @@
border-radius: 4px;
position: absolute;
background-color: red;
}
.user_auth_name{
width: 150px;
color: #292E3E;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.authBtn{
margin-right:10px;
margin: 0;
/* width: 100px; */
flex-wrap: nowrap;
}

30
pages/user/myFavorite/index.js

@ -10,35 +10,7 @@ Page({
* 页面的初始数据
*/
data: {
list: [
{
topicId: '1',
title: "市北区举行国际航运贸易金融创新中心核心区产业建设",
topicImg: "asdsad",
userIcon: "",
userName: "用户名",
time: "刚刚",
commentNum: "33",
},
{
topicId: "2",
title: "《大众日报》市北区举行国际航运贸易金融创新中心核心区产业建设",
topicImg: "",
userIcon: "",
userName: "用户名",
time: "1分钟前",
commentNum: "33",
},
{
topicId: "3",
title: "青岛医疗人工智能科技创新中心落户市北",
topicImg: "asdsadad",
userIcon: "",
userName: "用户名",
time: "1分钟前",
commentNum: "33",
}
],
list: [],
currentPage:1
},

35
pages/user/myIdea/index.js

@ -11,40 +11,7 @@ Page({
* 页面的初始数据
*/
data: {
list: [
// {
// ideaId: '1',
// userIcon: "",
// userName: "用户名",
// time: "刚刚",
// isGoodIdea: 1,
// praiseNum: "30",
// detail: {
// title: "习近平主持政治局第十七次集体... 拷贝",
// userIcon: "",
// userName: "用户名",
// time: "刚刚",
// commentNum: "33",
// text: "【内容以实际活动为准】市北区位于青岛市主城区地理位置的中心,西部濒临胶州湾,东部与崂山区为邻,北部与李沧区接壤,南部与市南区毗"
// }
// },
// {
// ideaId: "2",
// userIcon: "",
// userName: "用户名",
// time: "1分钟前",
// isGoodIdea: 0,
// praiseNum: "30",
// detail: {
// title: "习近平主持政治局第十七次集体... 拷贝",
// userIcon: "",
// userName: "用户名",
// time: "刚刚",
// commentNum: "33",
// text: "市北区位于青岛市主城区地理位置的中心,西部濒临胶州湾,东部与崂山区为邻,北部与李沧区接壤,南部与市南区毗连,东西最大距离11. 拷贝 2"
// }
// }
],
list: [],
currentPage: 1
},

11
pages/user/myMessage/cell/index.js

@ -20,17 +20,6 @@ Component({
methods: {
onTap() {
this.triggerEvent('clickListItem', { itemData: this.properties.itemData })
},
msgType_level(level){
switch (level){
case 0:
return "活动消息";
case 1:
return "消息提醒";
case 2:
return "系统消息";
}
}
}
})

Loading…
Cancel
Save