Browse Source

合并冲突

master
fanp 6 years ago
parent
commit
d96e8d64cf
  1. 16
      pages/home/index.js
  2. 10
      pages/topics/index.js
  3. 63
      pages/user/index.js
  4. 4
      pages/user/index.wxml
  5. 7
      pages/user/index.wxss
  6. 16
      utils/http.js

16
pages/home/index.js

@ -28,6 +28,8 @@ Page({
currPage: 1,
})
this.fetchHomeList()
this.fetchHomeBanner()
this.fetchHomeHot()
wx.vibrateShort({
success () {
console.log('震动')
@ -46,7 +48,7 @@ Page({
this.fetchHomeList()
},
// 获取首页列表
fetchHomeList() {
fetchHomeList () {
let page = this.data.currPage
homeModel.getHomeList(page, res => {
this.setData({
@ -89,7 +91,7 @@ Page({
wx.stopPullDownRefresh()
})
},
fetchHomeBanner() {
fetchHomeBanner () {
homeModel.getHomeBanner(res => {
console.log('Banner')
console.log(res)
@ -107,7 +109,7 @@ Page({
})
})
},
fetchHomeHot() {
fetchHomeHot () {
homeModel.getHomeHot(res => {
console.log('Hot')
console.log(res)
@ -125,19 +127,19 @@ Page({
})
},
// Banner/Hot/List事件
tapSwiperItem(e) {
tapSwiperItem (e) {
console.log(e.detail)
this.gotoArticePage(e.detail.id)
},
tapFocusItem(e) {
tapFocusItem (e) {
console.log(e.detail)
this.gotoArticePage(e.detail.id)
},
clickListItem(e) {
clickListItem (e) {
console.log(e.detail)
this.gotoArticePage(e.detail.id)
},
gotoArticePage(id) {
gotoArticePage (id) {
wx.navigateTo({
url: `/pages/article/index?id=${id}`,
})

10
pages/topics/index.js

@ -23,9 +23,9 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function () {
if (!store.hasPhone()) {
if (store.hasPhone()) {
console.log('已经绑定手机号码')
} else {
console.log('未绑定手机号码')
@ -39,7 +39,7 @@ Page({
console.log('啦啦啦')
this.fetchTopicList();
},
fetchTopicList() {
fetchTopicList () {
let page = this.data.currPage
topicModel.getTopicList(page, res => {
console.log('议题列表')
@ -82,10 +82,10 @@ Page({
wx.stopPullDownRefresh()
})
},
onRefreshList() {
onRefreshList () {
this.fetchGoodIdeaList()
},
fetchGoodIdeaList() {
fetchGoodIdeaList () {
let page = this.data.currPage
topicModel.goldenList(page, res => {
console.log('金点子列表')

63
pages/user/index.js

@ -13,7 +13,7 @@ Page({
/**
* 页面的初始数据
*/
data: {
data: {
messageTotal: Number,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
authType:0,
@ -24,7 +24,7 @@ Page({
userInfo:{
type:Object,
value:{}
},
}
},
@ -37,13 +37,23 @@ Page({
onShow: function () {
console.log('啦啦啦')
this.getUserInfo()
if (store.hasPhone()) {
console.log('已经绑定手机号码')
this.getUserInfo()
} else {
console.log('未绑定手机号码')
wx.redirectTo({
url: '/pages/register/index',
})
}
},
isAuthUserInfo(){
isAuthUserInfo () {
let that = this
wx.showLoading()
return new Promise(resolve =>{
console.log('未授权')
return new Promise(resolve => {
wx.getSetting({
success(res) {
success (res) {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
wx.getUserInfo({
@ -55,13 +65,13 @@ Page({
store.saveUserInfo({
nickName: nickName,
avatarUrl: avatarUrl,
phone:''
phone: ''
})
if(nickName && avatarUrl){
if (nickName && avatarUrl) {
that.setData({
isAuth:false
},()=>{
isAuth: false
}, () => {
wx.hideLoading()
})
}
@ -73,9 +83,9 @@ Page({
})
})
},
bindGetUserInfo(e) {
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
@ -85,44 +95,43 @@ Page({
this.updateUserInfo(avatarUrl, city, country, gender, nickName, province)
this.isAuthUserInfo()
},
hasBindUserInfo(){
hasBindUserInfo () {
return store.hasBindUserInfo();
},
updateUserInfo(avatarUrl, city, country, gender, nickName, province){
userModel.updateUserInfo(avatarUrl, city, country, gender, nickName, province,res=>{
updateUserInfo (avatarUrl, city, country, gender, nickName, province) {
userModel.updateUserInfo(avatarUrl, city, country, gender, nickName, province, res => {
})
},
getUserInfo(){
userModel.getUserInfo(res=>{
getUserInfo () {
userModel.getUserInfo(res => {
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
reAuth: true
})
store.saveUserInfo({
nickName: res.result.nickName,
avatarUrl: res.result.avatarUrl,
phone: res.result.phone === null ? '' : res.result.phone
phone: res.result.phone || ''
})
} else {
console.log('未授权')
this.setData({
isAuth:true
isAuth: true
})
}
})
},
getMsgStatus(){
userModel.getMyMessageTotal(res=>{
getMsgStatus () {
userModel.getMyMessageTotal(res => {
console.log(res.result.total)
this.setData({
messageTotal: Number(res.result.total)
@ -130,17 +139,13 @@ Page({
})
},
onTapItem (e) {
const {type} = e.currentTarget.dataset
const { type } = e.currentTarget.dataset
console.log(type)
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`,
})
}
}
})

4
pages/user/index.wxml

@ -9,10 +9,10 @@
</mp-cell>
</mp-cells>
<mp-cells ext-class="page_hd" wx:if="{{isAuth}}">
<mp-cell bindtap="onTapItem" data-type="myInfo">
<mp-cell>
<view class="user_auth_hd">
<!-- <open-data class="user_logo" type="userAvatarUrl"></open-data> -->
<open-data class="user_auth_name" type="userNickName"></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>

7
pages/user/index.wxss

@ -22,8 +22,7 @@
display: flex;
flex-direction: row;
align-items: center;
overflow: hidden;
justify-content: space-between;
justify-content: center;
}
.user_logo {
width: 80px;
@ -66,8 +65,4 @@
overflow: hidden;
}
.authBtn{
margin-right:10px;
margin: 0;
/* width: 100px; */
flex-wrap: nowrap;
}

16
utils/http.js

@ -1,5 +1,5 @@
import { config } from '../config.js'
import {store} from './store.js'
import { store } from './store.js'
const Method = {
GET: 'GET',
@ -30,7 +30,7 @@ class HTTP {
'content-type': 'application/json',
}
console.log(header)
console.log(data)
console.log(data || {})
wx.request({
url: url,
data: data,
@ -48,14 +48,14 @@ class HTTP {
// token 无效
this.fetchAuthToken(res => {
// 请求Token后,重新请求URL
if(res.code == 200) {
if (res.code == 200) {
this.request(params)
}
})
} else {
console.log('数据请求失败')
wx.showToast({
title: res.data.message,
title: res.data.message || '服务器错误,请稍后重试',
icon: 'none'
})
}
@ -70,7 +70,7 @@ class HTTP {
},
fail: function (res) {
wx.showToast({
title: '网络连接错误,请求失败!',
title: '网络连接错误,请求稍后重试!',
icon: 'none'
})
params.fail && params.fail(res)
@ -78,7 +78,7 @@ class HTTP {
})
}
// 获取 Token
fetchAuthToken(success) {
fetchAuthToken (success) {
// 获取token
this._fetchWXCode().then(res => {
console.log('啦啦啦啦凉啊')
@ -102,10 +102,10 @@ class HTTP {
})
}
// 获取微信code
_fetchWXCode() {
_fetchWXCode () {
return new Promise(resolve => {
wx.login({
success(res) {
success (res) {
console.log('获取Code成功 ' + res.code)
resolve(res.code)
}

Loading…
Cancel
Save