Browse Source

Merge refs/remotes/origin/master into refs/heads/master

master
lqq 6 years ago
parent
commit
0c9f25a2f9
  1. 3
      app.json
  2. 14
      pages/topics/index.js
  3. 41
      pages/user/index.js
  4. 13
      pages/user/index.wxml
  5. 2
      pages/user/index.wxss
  6. 2
      pages/user/myInfo/index.wxml
  7. 110
      pages/weChatAuth/index.js
  8. 3
      pages/weChatAuth/index.json
  9. 22
      pages/weChatAuth/index.wxml
  10. 51
      pages/weChatAuth/index.wxss
  11. 11
      project.config.json

3
app.json

@ -20,7 +20,8 @@
"pages/topics/interactive/submitTopic/index",
"pages/topics/interactive/topicArticle/index",
"pages/billboards/park/park-category/index",
"pages/billboards/park/park-detail/index"
"pages/billboards/park/park-detail/index",
"pages/weChatAuth/index"
],
"window": {
"backgroundTextStyle": "light",

14
pages/topics/index.js

@ -70,8 +70,20 @@ Page({
}
} else {
console.log('未绑定微信')
wx.showModal({
title: '温馨提示',
content: '是否前往绑定微信?',
success(res) {
if (res.confirm) {
wx.redirectTo({
url: '/pages/weChatAuth/index',
})
} else if (res.cancel) {
wx.switchTab({
url: '/pages/user/index',
url: '/pages/home/index',
})
}
}
})
}
},

41
pages/user/index.js

@ -15,16 +15,6 @@ Page({
*/
data: {
messageTotal: Number,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
authType:0,
reAuth:false,
isAuth:false,
nickName:'',
avatarUrl:'',
userInfo:{
type:Object,
value:{}
}
},
@ -35,31 +25,15 @@ Page({
},
onShow: function () {
if (store.hasBindUserInfo()) {
this.getUserInfo()
},
// 授权登录
bindGetUserInfo (e) {
//console.log(e.detail.userInfo)
if (e.detail.userInfo){
let avatarUrl = e.detail.userInfo.avatarUrl
let nickName = e.detail.userInfo.nickName
store.saveUserInfo({
nickName: nickName,
avatarUrl: avatarUrl,
phone: ''
} else {
wx.redirectTo({
url: '/pages/weChatAuth/index',
})
this.sendUserInfo(e.detail.userInfo)
}
},
// 上传用户信息
sendUserInfo(weChatInfo){
userModel.sendUserInfo(weChatInfo, res => {
this.getUserInfo()
})
},
// 获取用户信息
getUserInfo () {
userModel.getUserInfo(res => {
@ -73,8 +47,6 @@ Page({
userInfo: res.result,
avatarUrl: res.result.avatarUrl,
nickName: res.result.nickName,
reAuth: true,
isAuth: false
},()=>{
if (store.hasPhone()) {
//console.log('已经绑定手机号码')
@ -103,11 +75,6 @@ Page({
avatarUrl: res.result.avatarUrl,
phone: res.result.phone || ''
})
} else {
//console.log('未授权')
this.setData({
isAuth: true
})
}
})
},

13
pages/user/index.wxml

@ -1,6 +1,6 @@
<!--pages/user/index.wxml-->
<view class="container">
<mp-cells ext-class="page_hd" wx:if="{{reAuth}}">
<mp-cells ext-class="page_hd">
<mp-cell bindtap="onTapItem" data-type="myInfo">
<view class="user_hd" wx:if="{{avatarUrl && nickName}}">
<image slot="icon" class="user_logo" src="{{avatarUrl}}"/>
@ -8,17 +8,6 @@
</view>
</mp-cell>
</mp-cells>
<mp-cells ext-class="page_hd" wx:if="{{isAuth}}">
<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>
<!-- 需要使用 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
bindtap="onTapItem" data-type="myMessage"

2
pages/user/index.wxss

@ -64,5 +64,3 @@
text-overflow: ellipsis;
overflow: hidden;
}
.authBtn{
}

2
pages/user/myInfo/index.wxml

@ -13,7 +13,7 @@
title="名字"
ext-class="cell-item">
<!-- <view slot="footer" class="msg_footer" >{{nikeName}}</view> -->
<input slot="footer" class="footer_input" maxlength="120" bindinput="bindNickNameInput" value="{{nickName}}"></input>
<input slot="footer" class="footer_input_phone" maxlength="120" bindinput="bindNickNameInput" value="{{nickName}}" disabled></input>
</mp-cell>
<mp-cell
bindtap="onTapItem" data-type="userPhone"

110
pages/weChatAuth/index.js

@ -0,0 +1,110 @@
// pages/weChatAuth/index.js
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({
/**
* 页面的初始数据
*/
data: {
canIUse: wx.canIUse('button.open-type.getUserInfo'),
nickName: '',
avatarUrl: '',
userInfo: {
type: Object,
value: {}
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
// 授权登录
bindGetUserInfo(e) {
//console.log(e.detail.userInfo)
if (e.detail.userInfo) {
let avatarUrl = e.detail.userInfo.avatarUrl
let nickName = e.detail.userInfo.nickName
store.saveUserInfo({
nickName: nickName,
avatarUrl: avatarUrl,
phone: ''
})
this.sendUserInfo(e.detail.userInfo)
}
},
// 上传用户信息
sendUserInfo(weChatInfo) {
userModel.sendUserInfo(weChatInfo, res => {
this.getUserInfo()
})
},
// 获取用户信息
getUserInfo() {
userModel.getUserInfo(res => {
console.log(res)
let nickName = res.result.nickName
let avatarUrl = res.result.avatarUrl
if (nickName && avatarUrl) {
//console.log('已授权')
this.setData({
userInfo: res.result,
avatarUrl: res.result.avatarUrl,
nickName: res.result.nickName,
reAuth: true,
isAuth: false
}, () => {
if (store.hasPhone()) {
//console.log('已经绑定手机号码')
} else {
//console.log('未绑定手机号码')
wx.showModal({
title: '温馨提示',
content: '是否前往验证手机号码?',
success(res) {
if (res.confirm) {
wx.redirectTo({
url: '/pages/register/index',
})
} else if (res.cancel) {
wx.switchTab({
url: '/pages/home/index',
})
}
}
})
}
})
store.saveUserInfo({
nickName: res.result.nickName,
avatarUrl: res.result.avatarUrl,
phone: res.result.phone || ''
})
} else {
//console.log('未授权')
this.setData({
isAuth: true
})
}
})
}
})

3
pages/weChatAuth/index.json

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

22
pages/weChatAuth/index.wxml

@ -0,0 +1,22 @@
<!--pages/weChatAuth/index.wxml-->
<view class="container">
<navigator open-type="switchTab" url="/pages/home/index">
<image class="auth_cancel" src="/images/common/close.png"></image>
</navigator>
<view class="page_bd">
<view class="image_view">
<view class="title">市北人才</view>
<image class="img" src="/images/temp_1.png"></image>
</view>
<view class="description">
<view class="h1">
Hi,请登录~
</view>
<view>
授权后,可以更好的体验我们哦~
</view>
</view>
<button class="authBtn" type="primary" wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">微信用户登录</button>
<view wx:else>请升级微信版本</view>
</view>
</view>

51
pages/weChatAuth/index.wxss

@ -0,0 +1,51 @@
/* pages/weChatAuth/index.wxss */
.container {
position: relative;
padding: 0 20px;
display: flex;
height: 100vh;
justify-items: center;
align-items: center;
}
.auth_cancel {
position: absolute;
padding: 10px;
width: 30px;
height: 30px;
top: 0;
right: 20px;
}
.page_bd {
height: 65vh;
width: 100%;
}
.image_view{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.img{
width: 180px;
height: 120px;
}
.title{
font-size: 20px;
padding: 10px;
}
.description{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.h1{
padding: 20px 0 10px;
font-size: 20px;
font-weight: bold;
}
.authBtn{
background-color: rgb(32,192,100);
top: 40px;
}

11
project.config.json

@ -49,6 +49,10 @@
"currentL": -1,
"list": []
},
"gamePlugin": {
"current": -1,
"list": []
},
"miniprogram": {
"current": 7,
"list": [
@ -105,6 +109,13 @@
"id": -1,
"name": "Topics",
"pathName": "pages/topics/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/weChatAuth/index",
"pathName": "pages/weChatAuth/index",
"scene": null
}
]

Loading…
Cancel
Save