This commit is contained in:
Renpc-kilig 2020-07-02 19:07:43 +08:00
commit b7497f1066
9 changed files with 408 additions and 119 deletions

View File

@ -1,7 +1,12 @@
{
"pages": [
"pages/venue/venue",
"pages/friendCircle/friendCircle",
"pages/index/index",
"pages/venue/venue",
"pages/broadcastList/broadcastList",
"pages/orderDetail/orderDetail",
"pages/myVenueOrder/myVenueOrder",
"pages/book/book",
"pages/broadcast/broadcast",
"pages/activityDialog/activityDialog",
"pages/teamDetail/teamDetail",
@ -11,7 +16,6 @@
"pages/heritage/heritage",
"pages/broadcastDetail/broadcastDetail",
"pages/venueDetail/venueDetail",
"pages/book/book",
"pages/register/register",
"pages/login/login",
"pages/newVolunteerActivity/newVolunteerActivity",

View File

@ -120,126 +120,10 @@ Page({
url: '../myVolunteerActivity/myVolunteerActivity',
})
},
// 判断用户是否为随机名称
isRandomName: function () {
var self = this
wx.getStorage({
key: 'isRandomUsername',
success: function (res) {
if (res.data == 1) {
wx.hideTabBar()
self.setData({
randomName: true
})
}
}
})
},
// 取消绑定手机
cancelPhone: function () {
this.setData({
showPhone: false
})
wx.showTabBar()
},
// 获取输入的手机号
phoneNum: function (res) {
this.setData({
phone: res.detail.value
})
console.log(this.data.phone)
},
// 校验手机号
testPhone: function () {
var self = this
if (self.data.phone) {
if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(self.data.phone)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none',
duration: 1500
})
} else {
self.getCode()
}
} else {
wx.showToast({
title: '手机号不能为空',
icon: 'none',
duration: 1500
})
}
},
// 获取验证码
getCode: function () {
var self = this
app.restAjax.get(app.restAjax.path('{usercenterUrl}/api/sms/getverificationcode/' + self.data.phone, [app.usercenterUrl]), {}, null,
function (code, data) {
if (code == 200) {
console.log(data)
self.setData({
gotCode: true
})
self.data.timer = setInterval(function () {
var cur = self.data.restTime - 1
console.log(cur)
if (cur == 0) {
clearInterval(self.data.timer)
self.setData({
restTime: 120,
gotCode: false
})
}
self.setData({
restTime: cur
})
}, 1000)
}
},
function (code, data) {
console.log(data)
wx.showToast({
title: data.msg,
icon: 'none',
duration: 1500
})
} )
},
// 提交绑定手机
submitPhone: function () {
var self = this
app.restAjax.put(app.restAjax.path('{usercenterUrl}/app/user/updateminiappdefaultusername', [app.usercenterUrl]), {
phone: self.data.phone,
verificationCode: self.data.code
}, {
headers: {
token: self.data.token
}
}, function (code, data) {
console.log(data)
wx.setStorageSync('token', data.data);
wx.setStorageSync('isRandomUsername', 0)
clearInterval(self.data.timer)
self.setData({
showPhone: false,
restTime: 120
})
self.getUserInfo()
}, function (code, data) {
console.log(data)
})
},
// 验证码
inputCode: function (e) {
this.setData({
code: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.isRandomName()
this.getToken()
},

View File

@ -0,0 +1,66 @@
// pages/friendCircle/friendCircle.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

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

View File

@ -0,0 +1,59 @@
<view class="friend-circle">
<view class="friend-circle-box">
<view class="avatar">
<image src="../../images/avatar.png"></image>
</view>
<view class="content">
<view class="name">张三</view>
<view class="text">内容内容内容内容内容</view>
<view class="date">2020-01-01 00:00:00</view>
</view>
</view>
<view class="friend-circle-box">
<view class="avatar">
<image src="../../images/avatar.png"></image>
</view>
<view class="content">
<view class="name">张三</view>
<view class="text">内容内容内容内容内容</view>
<view class="photo-one">
<image src="../../images/center-bg.png"></image>
</view>
<view class="date">2020-01-01 00:00:00</view>
</view>
</view>
<view class="friend-circle-box">
<view class="avatar">
<image src="../../images/avatar.png"></image>
</view>
<view class="content">
<view class="name">张三</view>
<view class="text">内容内容内容内容内容</view>
<view class="photo-more">
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
<image src="../../images/center-bg.png"></image>
</view>
<view class="date">2020-01-01 00:00:00</view>
</view>
</view>
<view class="friend-circle-box">
<view class="avatar">
<image src="../../images/avatar.png"></image>
</view>
<view class="content">
<view class="name">张三</view>
<view class="text">内容内容内容内容内容</view>
<view class="video">
<video src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"></video>
</view>
<view class="date">2020-01-01 00:00:00</view>
</view>
</view>
</view>

View File

@ -0,0 +1,48 @@
.friend-circle{
padding: 30rpx;
}
.friend-circle-box{
margin-bottom: 20rpx;
display: flex;
justify-content: space-between;
border-bottom: 1px solid #DEDEDE;
padding-bottom: 10rpx;
}
.avatar{
width: 8%;
}
.avatar image{
width: 100%;
height: 50rpx;
}
.content{
width: 90%;
}
.name{
font-size: 30rpx;
color: #949494;
}
.text{
font-size: 32rpx;
color: #000;
margin: 10rpx 0;
}
.date{
font-size: 28rpx;
color: #949494;
}
.photo-one image{
width: 80%;
}
.photo-more image{
width: 32%;
height: 150rpx;
margin-right: 2%;
margin-bottom: 10rpx;
}
.photo-more image:nth-child(3n){
margin-right: 0;
}
.video video{
width: 80%;
}

View File

@ -4,6 +4,11 @@ Page({
* 页面的初始数据
*/
data: {
randomName: '',
showPhone: true,
gotCode: false,
restTime: 120,
timer: '',
indicatorDots: true,
autoplay: true,
token: '',
@ -26,7 +31,8 @@ Page({
live: {
liveUrl: app.liveUrl,
liveList: []
}
},
usercenterUrl: app.usercenterUrl
},
doLogin: function () {
var self = this;
@ -158,6 +164,129 @@ Page({
url: '../heritage/heritage',
})
},
// 获取输入的手机号
phoneNum: function (res) {
this.setData({
phone: res.detail.value
})
console.log(this.data.phone)
},
// 校验手机号
testPhone: function () {
var self = this
if (self.data.phone) {
if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(self.data.phone)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none',
duration: 1500
})
} else {
self.getCode()
}
} else {
wx.showToast({
title: '手机号不能为空',
icon: 'none',
duration: 1500
})
}
},
// 获取验证码
getCode: function () {
var self = this
app.restAjax.get(app.restAjax.path('{usercenterUrl}/api/sms/getverificationcode/' + self.data.phone, [app.usercenterUrl]), {}, null,
function (code, data) {
if (code == 200) {
console.log(data)
self.setData({
gotCode: true
})
self.data.timer = setInterval(function () {
var cur = self.data.restTime - 1
console.log(cur)
if (cur == 0) {
clearInterval(self.data.timer)
self.setData({
restTime: 120,
gotCode: false
})
}
self.setData({
restTime: cur
})
}, 1000)
}
},
function (code, data) {
console.log(data)
wx.showToast({
title: data.msg,
icon: 'none',
duration: 1500
})
} )
},
// 提交绑定手机
submitPhone: function () {
var self = this
app.restAjax.put(app.restAjax.path('{usercenterUrl}/app/user/updateminiappdefaultusername', [app.usercenterUrl]), {
phone: self.data.phone,
verificationCode: self.data.code
}, {
headers: {
token: self.data.token
}
}, function (code, data) {
console.log(data)
wx.setStorageSync('token', data.data);
wx.setStorageSync('isRandomUsername', 0)
clearInterval(self.data.timer)
self.setData({
showPhone: false,
restTime: 120
})
self.getUserInfo()
}, function (code, data) {
console.log(data)
})
},
// 验证码
inputCode: function (e) {
this.setData({
code: e.detail.value
})
},
// 判断用户是否为随机名称
isRandomName: function () {
var self = this
wx.getStorage({
key: 'isRandomUsername',
success: function (res) {
if (res.data == 1) {
wx.hideTabBar()
self.setData({
randomName: true
})
}
}
})
},
// 获取用户信息
getUserInfo: function () {
var self = this
app.restAjax.get(app.restAjax.path('{usercenterUrl}/app/user/getappuser', [app.usercenterUrl]), {}, {
headers: {
token: self.data.token
}
}, function (code, data) {
self.setData({
userInfo: data
})
}, function (code, data) {
console.log(data)
})
},
/**
* 生命周期函数--监听页面加载
*/
@ -169,6 +298,7 @@ Page({
self.doGetLiveList();
self.doGetVenueList();
self.doGetActivityList();
self.isRandomName();
},
/**

View File

@ -125,4 +125,20 @@
<view class="broadcast-status" wx:else>错误</view>
</view>
</view>
</view>
<view class="set-phone" wx:if="{{randomName && showPhone}}">
<view class="set-phone-box">
<view class="tips">您还没有绑定手机号,请先绑定手机号</view>
<view class="phone-input">
<input placeholder="请输入手机号" bindinput="phoneNum" class="phone-input"></input>
</view>
<view class="code-input">
<input placeholder="请输入验证码" bindinput="inputCode"></input>
<view class="get-code" bindtap="testPhone" wx:if="{{!gotCode}}">获取验证码</view>
<view class="got-code" wx:else>{{restTime}}</view>
</view>
<view class="set-phone-btn-box">
<view class="set-phone-btn" bindtap="submitPhone">确认</view>
</view>
</view>
</view>

View File

@ -156,4 +156,83 @@
color: #fff;
font-size: 26rpx;
border-radius: 10rpx;
}
.set-phone{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, .6);
z-index: 100;
}
.set-phone-box{
width: 96%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #fff;
border-radius: 10rpx;
padding: 30rpx;
box-sizing: border-box;
}
.tips{
font-size: 28rpx;
color: #000;
}
.phone-input{
margin: 25rpx 0;
}
.code-input{
display: flex;
justify-content: space-between;
margin-bottom: 25rpx;
}
.code-input input{
width: 70%;
height: 55rpx;
border: 1px solid #dedede;
border-radius: 10rpx;
padding: 0 10rpx;
box-sizing: border-box;
font-size: 28rpx;
}
.phone-input input{
width: 100%;
height: 55rpx;
border: 1px solid #dedede;
border-radius: 10rpx;
padding: 0 10rpx;
box-sizing: border-box;
font-size: 28rpx;
}
.get-code, .got-code{
font-size: 28rpx;
background: rgba(159,21,18,.1);
color: #9F1512;
width: 28%;
line-height: 55rpx;
text-align: center;
border-radius: 10rpx;
}
.got-code{
background: #fff;
color: #4a4d52;
border: 1px solid #eaeaea;
}
.set-phone-btn-box{
display: flex;
justify-content: space-between;
}
.set-phone-btn{
width: 100%;
height: 65rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
color: #fff;
background: #9F1512;
border-radius: 10rpx;
}