提交 07221063 编写于 作者: K kongbai121

拉取

上级 4dfa8ca9
......@@ -32,12 +32,12 @@ App({
token: null,
//图片网络路径
httpUrl:"http://localhost:8088/images",
// httpUrl:"https://kongbai121.xyz/images",
// httpUrl:"http://10.170.15.123:8088/images",
httpUrl:"https://kongbai121.xyz/images",
//后台地址
myUrl:"http://localhost:8080",
// myUrl:"https://kongbai121.xyz/miniapp",
// myUrl:"http://10.170.15.123:8080",
myUrl:"https://kongbai121.xyz/miniapp",
//(为了减轻服务器负担,只在演示时开)
//我的页面数据更新定时器开关
......
{
"pages": [
"pages/forum/forum",
"pages/letterList/letterList",
"pages/letter/letter",
"pages/resources/resources",
"pages/newInformationtwo/newInformationtwo",
"pages/newInformation/newInformation",
"pages/own/own",
"pages/newInformationthree/newInformationthree",
"pages/chat/chat",
"pages/release/release",
"pages/data/data",
"pages/chatRelease/chatRelease",
"pages/chatDetailed/chatDetailed",
"pages/ownData/ownData",
"pages/ownTreeData/ownTreeData",
"pages/information/information",
......@@ -49,6 +48,12 @@
"iconPath": "/images/resources1.png",
"selectedIconPath": "/images/resources2.png"
},
{
"pagePath": "pages/letterList/letterList",
"text": "私信",
"iconPath": "/images/sixin1.png",
"selectedIconPath": "/images/sixin2.png"
},
{
"pagePath": "pages/own/own",
"text": "我",
......
......@@ -16,6 +16,14 @@ Page({
userMessage: ''
},
// 树洞详细里面的图片放大功能
bigImage(e){
wx.previewImage({
current: 'e.currentTarget.dataset.imgsrc', // 当前显示图片的http链接
urls: [e.currentTarget.dataset.imgsrc] // 需要预览的图片http链接列表
})
},
//----------------------------获取文章详情---------------------------
tree() {
var that = this;
......
......@@ -38,7 +38,7 @@
<view class="center">
<view class="center_text">{{tree.body}}</view>
<view class="center_image">
<image wx:if="{{tree.image!=null&&tree.image!=''}}" src="{{tree.image}}" mode='widthFix'></image>
<image wx:if="{{tree.image!=null&&tree.image!=''}}" src="{{tree.image}}" mode='widthFix' bindtap="bigImage" data-imgsrc="{{tree.image}}"></image>
<image wx:if="{{tree.image==null||tree.image==''}}" src="/images/nome.png" mode='widthFix'></image>
</view>
</view>
......
......@@ -13,8 +13,71 @@ Page({
articleId: null,
comment: [],
sendInfo: '',
userMessage: ''
userMessage: '',
showDialog: false,
showDialogtwo: false,
imgs:'',
names:'',
noSignIn:'您还未登录,请前往登录',
commentOne:'我来抢楼',
fuId:''
},
// 点击回复评论
clickComment(e){
// console.log(e);
var that = this;
wx.request({
url: app.globalData.myUrl + '/comment/deliver',
method:'GET',
data:{
fuId:e.currentTarget.dataset.fuid
}
})
},
// 文章详细里面的图片放大功能
bigImage(e){
wx.previewImage({
current: 'e.currentTarget.dataset.imgsrc', // 当前显示图片的http链接
urls: [e.currentTarget.dataset.imgsrc] // 需要预览的图片http链接列表
})
},
/**
* 发私信
*/
fasixin(e){
// console.log(e.currentTarget.dataset.userid);
let userid = e.currentTarget.dataset.userid;
wx.navigateTo({
url: '/pages/letter/letter?userid='+userid,
})
},
// 单击头像弹窗
/**
* 控制 pop 的打开关闭
* 该方法作用有2:
* 1:点击弹窗以外的位置可消失弹窗
* 2:用到弹出或者关闭弹窗的业务逻辑时都可调用
*/
toggleDialog() {
this.setData({
showDialog: !this.data.showDialog
});
},
toggleDialogtwo(e) {
// console.log(e);
this.setData({
showDialogtwo: !this.data.showDialogtwo,
imgs:e.currentTarget.dataset.imgs,
names:e.currentTarget.dataset.names,
userid:e.currentTarget.dataset.userid
});
},
//----------------------------获取文章详情---------------------------
article() {
......
<!-- 文章详细 -->
<view class="bg"></view>
<view class="all">
......@@ -11,12 +12,12 @@
<!-- 博主信息 -->
<view class="head_left">
<!-- 左边头像 -->
<image src="{{article.user.avatarUrl}}"></image>
<image src="{{article.user.avatarUrl}}" bindtap="toggleDialog"></image>
</view>
<view class="head_right">
<!-- 右边博主名称、发布时间 -->
<view class="head_name">{{article.user.nickName}}</view>
<view class="head_name" bindtap="toggleDialog">{{article.user.nickName}}</view>
<view class="head_time">{{article.releaseTime}}</view>
<view class="headimage">
<image class="headimageto" src="/images/lajitong.png" bindtap='deleteArticle'></image>
......@@ -29,7 +30,7 @@
<view class="center">
<view class="center_text">{{article.body}}</view>
<view class="center_image">
<image wx:if="{{article.image!=null&&article.image!=''}}" src="{{article.image}}" mode='widthFix'></image>
<image wx:if="{{article.image!=null&&article.image!=''}}" src="{{article.image}}" mode='widthFix' bindtap="bigImage" data-imgsrc="{{article.image}}"></image>
<image wx:if="{{article.image==null||article.image==''}}" src="/images/nome.png" mode='widthFix'></image>
</view>
</view>
......@@ -38,27 +39,30 @@
<text class="tail_text">全部回复</text>
<!-- 评论用户信息 -->
<view class="tail" wx:for="{{comment}}" wx:key="index">
<view class="tail_left">
<image src="{{item.user.avatarUrl}}"></image>
</view> <!-- 头像 -->
<view class="tail_name">{{item.user.nickName}}</view> <!-- id -->
<view class="tail_left"> <!-- 头像 -->
<image src="{{item.user.avatarUrl}}" bindtap="toggleDialogtwo" data-imgs="{{item.user.avatarUrl}}" data-names="{{item.user.nickName}}" data-userid="{{item.user.id}}"></image>
</view>
<view class="tail_name" bindtap="toggleDialogtwo" data-imgs="{{item.user.avatarUrl}}" data-names="{{item.user.nickName}}" data-userid="{{item.user.id}}">{{item.user.nickName}}</view> <!-- id -->
<view class="tail_time">{{item.deliverTime}}</view> <!-- 评论时间 -->
<image class="tailImageTo" src="/images/lajitong.png" bindtap='deleteComment' id="{{item.id}}">
</image>
<view class="tail_center">
<text>{{item.content}}</text>
<text class="tail_center_text" bindtap="clickComment" data-fuid="{{item.user.nickName}}">{{item.content}}</text>
<view class="hr"></view>
<view class="father">
<text>shui回复{{fuId}}:32165451</text>
</view>
</view>
</view>
<!-- 评论输入框 -->
<form class="one" bindreset="cleanInput">
<view class="shuru">
<input id="comment" name="comment" auto-height placeholder="我来抢楼" class="thuru_input" bindinput="bindMessage"
<input id="comment" name="comment" auto-height placeholder="{{commentOne}}" class="thuru_input" bindinput="bindMessage"
wx:if="{{hasLogin}}" />
<input id="comment" name="comment" auto-height placeholder="您还未登录,请前往登录" class="thuru_input" bindinput="bindMessage"
<input id="comment" name="comment" auto-height placeholder="{{noSignIn}}" class="thuru_input" bindinput="bindMessage"
wx:if="{{!hasLogin}}" />
</view>
......@@ -66,4 +70,29 @@
<button id='sand' formType="reset" wx:if="{{hasLogin&&userMessage != ''}}">提交</button>
<button id='sandNull' wx:if="{{hasLogin&&userMessage == ''}}">提交</button>
</form>
</view>
\ No newline at end of file
</view>
<view class="zan-dialog {{ showDialog ? 'zan-dialog--show' : '' }}">
<!-- 如果想点击弹窗外不隐藏,取消bindtap点击事件即可 -->
<view class="zan-dialog__mask" bindtap="toggleDialog" />
<view class="zan-dialog__container">
<view class="zan-dialog__content">
<!-- 吧主信息:头像、名字 -->
<image src="{{article.user.avatarUrl}}"></image>
<text class="head_Name">{{article.user.nickName}}</text>
<view class="information" data-userid="{{article.user.id}}" bindtap="fasixin">发私信</view>
</view>
</view>
</view>
<view class="zan-dialog {{ showDialogtwo ? 'zan-dialog--show' : '' }}">
<!-- 如果想点击弹窗外不隐藏,取消bindtap点击事件即可 -->
<view class="zan-dialog__mask" bindtap="toggleDialogtwo" />
<view class="zan-dialog__container">
<view class="zan-dialog__content">
<!-- 吧主信息:头像、名字 -->
<image src="{{imgs}}"></image>
<text class="head_Name">{{names}}</text>
<view class="information" bindtap="fasixin" data-userid="{{userid}}" >发私信</view>
</view>
</view>
</view>
......@@ -106,7 +106,8 @@
background-color: #fff;
border-radius: 10rpx;
padding: 20rpx;
padding-bottom: 0;
margin-bottom: 20rpx;
/* padding-bottom: 0; */
}
.tail_text {
display: inline-block;
......@@ -159,14 +160,16 @@
left: 15rpx;
top: -10rpx;
}
.tail_center text {
.tail_center{
position: relative;
display: inline-block;
top: -90rpx;
left: -16rpx;
padding-bottom: 30rpx;
padding-left: 80rpx;
}
.tail_center .tail_center_text {
width: 478rpx;
word-wrap: break-word;
text-indent: 0.5em;
......@@ -182,9 +185,10 @@
}
.hr {
width: 96%;
width: 84%;
border-top: 1rpx dashed rgba(153, 153, 153, 0.4);
margin: -65rpx 0rpx 30rpx 10rpx;
/* margin: -65rpx 0rpx 30rpx 10rpx; */
margin: 10rpx 0;
}
.one {
......@@ -243,4 +247,68 @@
border-radius: 32rpx;
right: 40rpx;
top: 20rpx;
}
/* 评论回复 */
.father{
width: 530rpx;
background-color: rgb(246, 246, 246);
}
/* 头像弹窗 */
.zan-dialog__mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
background: rgba(0, 0, 0, 0.4); /*设置阴影半透明背景如: background: rgba(0, 0, 0, 0.4);*/
display: none;
}
.zan-dialog__container {
position: fixed;
bottom: 400rpx;
width: 650rpx; /*弹窗布局宽*/
height: 350rpx; /*弹窗布局高,与下面弹出距离transform有关*/
margin-left: 50rpx;
background: #f8f8f8;
transform: translateY(300%); /*弹框弹出距离,与弹框布局高度有关,如300%表示弹起距离为3倍弹窗高度 */
transition: all 0.4s ease;
z-index: 12;
border-radius: 20rpx;
}
.zan-dialog--show .zan-dialog__container {
transform: translateY(0);
}
.zan-dialog--show .zan-dialog__mask {
display: block;
}
.zan-dialog__content{
display: flex;
align-items:center;
flex-direction:column;
margin-top: 20rpx;
}
.zan-dialog__content image{
width: 70px;
height: 70px;
border-radius: 50%;
display: block;
/* margin: 0 auto; */
}
.zan-dialog__content .head_Name{
display: block;
height: 30rpx;
}
.zan-dialog__content .information{
width: 200rpx;
height: 70rpx;
background-color: #01c55f;
color: #fff;
text-align: center;
line-height: 70rpx;
border-radius: 50rpx;
margin-top: 57rpx;
}
\ No newline at end of file
......@@ -23,7 +23,6 @@
<view class="pro_show_title">
<view class="deleteLine"></view>
<view class="proShowText">你好,新同学</view>
</view>
<view class="proShowText-top">
学渣来了都变学霸
......
// pages/letter/letter.js
//获取应用实例
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
userid:'',
content:'',
chatList:[]
},
deliver(){
var that = this;
if (!app.globalData.hasLogin) {
wx.showModal({
title: '提示',
content: '你还没有登录喔',
success: function (res) {
if (res.confirm) { //这里是点击了确定以后
wx.switchTab({
url: '/pages/own/own',
})
} else { //这里是点击了取消以后
that.errShowToast('你还没有登录喔');
}
}
})
return;
}
wx.request({
url: app.globalData.myUrl+'/chat/deliver',
data: {
token: app.globalData.token,
content:"",
fromUserId:that.data.userid
},
success: (res) => {
// console.log(res);
if (!res.data.success) {
that.errShowToast(res.data.msg)
}
},
fail: (res) => {},
complete: (res) => {},
})
},
/**
* 获取输入框信息
*/
confirmPassword(e) {
// console.log(e.detail.value);
this.setData({
content:e.detail.value
})
},
/**
* 发送信息
*/
deliver(){
var that = this;
if (!app.globalData.hasLogin) {
wx.showModal({
title: '提示',
content: '你还没有登录喔',
success: function (res) {
if (res.confirm) { //这里是点击了确定以后
wx.switchTab({
url: '/pages/own/own',
})
} else { //这里是点击了取消以后
that.errShowToast('你还没有登录喔');
}
}
})
return;
}
if (that.data.userid == "" || that.data.content == "") {
that.errShowToast("请输入评论内容");
return;
}
wx.request({
url: app.globalData.myUrl+'/chat/deliver',
data: {
token: app.globalData.token,
content:that.data.content,
toUserId:that.data.userid
},
success: (res) => {
that.setData({
content:""
})
that.load();
if (!res.data.success) {
that.errShowToast(res.data.msg)
}
// console.log(res);
},
fail: (res) => {},
complete: (res) => {},
})
},
/**
* 加载聊天信息
*/
load(){
var that = this;
if (!app.globalData.hasLogin) {
wx.showModal({
title: '提示',
content: '你还没有登录喔',
success: function (res) {
if (res.confirm) { //这里是点击了确定以后
wx.switchTab({
url: '/pages/own/own',
})
} else { //这里是点击了取消以后
that.errShowToast('你还没有登录喔');
}
}
})
return;
}
wx.request({
url: app.globalData.myUrl+'/chat/get',
data: {
token: app.globalData.token,
fromUserId:that.data.userid
},
success: (res) => {
// console.log(res.data.msg);
if (res.data.success) {
that.setData({
chatList:res.data.msg
})
}else{
that.errShowToast(res.data.msg)
}
},
fail: (res) => {},
complete: (res) => {},
})
},
//---------------------------函数封装------------------------------
errShowToast: function (toastText) {
wx.showToast({
title: toastText,
image: '/images/password.png',
duration: 2000
});
},
sucShowToast: function (toastText) {
wx.showToast({
title: toastText,
duration: 2000
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log(options);
this.setData({
userid:options.userid
})
this.load();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.load();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "私聊",
"enablePullDownRefresh": true
}
\ No newline at end of file
<view class="all" wx:for="{{chatList}}" wx:key="this">
<!-- 单个聊天框 -->
<view class="one" wx:if="{{item.userId == userid}}">
<!-- 头像 -->
<image src="{{item.user.avatarUrl}}"></image>
<!-- id -->
<view class="name">{{item.user.nickName}}</view>
<!-- 小三角 -->
<view class="leftTriangle"></view>
<view class="leftMessage"><text>{{item.content}}</text></view>
</view>
<view class="two" wx:if="{{item.userId != userid}}">
<!-- 头像 -->
<image src="{{item.user.avatarUrl}}"></image>
<!-- 小三角 -->
<view class="rightTriangle"></view>
<view class="rightMessage"><text>{{item.content}}</text></view>
</view>
</view>
<!-- 评论输入框 -->
<form class="oneComment" bindreset="cleanInput">
<view class="shuru">
<input id="comment" name="comment" auto-height placeholder="请输入信息" class="thuru_input" bindinput="bindMessage"
wx:if="{{!hasLogin}}" bindinput="confirmPassword" value="{{content}}"/>
</view>
<view class="button enter" bindtap="deliver">
发送
</view>
</form>
<view class="bottom"></view>
\ No newline at end of file
.all{
padding: 0 20rpx;
}
.bottom{
height: 1rpx;
width: 1rpx;
margin-bottom: 100rpx;
}
.one{
overflow: hidden;
padding: 20rpx;
}
.one image{
width: 85rpx;
height: 85rpx;
border-radius: 50%;
float: left;
padding: 10rpx;
}
/* id */
.name{
margin-left: 121rpx;
font-size: 23rpx;
color: rgb(140, 140, 140);
}
/* 左小三角 */
.leftTriangle{
float: left;
margin-top: 35rpx;
width: 0;
height: 0;
border-top: 8rpx solid transparent;
border-right: 12rpx solid yellowgreen;
border-bottom: 8rpx solid transparent;
}
/* 聊天框 */
.leftMessage{
float: left;
margin-top: 10rpx;
border-radius: 10rpx;
width: 65%;
word-break:break-all;
word-wrap:break-word;
white-space:normal;
/* border: 1rpx solid red; */
}
.leftMessage text{
width: auto;
float: left;
background-color: yellowgreen;
line-height: 40rpx;
border-radius: 10rpx;
font-size: 14px;
padding: 20rpx;
display: inline-block;
}
/* 右边聊天框 */
.two{
overflow: hidden;
padding: 20rpx;
}
.two image{
width: 85rpx;
height: 85rpx;
border-radius: 50%;
float: right;
padding: 10rpx;
}
/* 右小三角 */
.rightTriangle{
float: right;
margin-top: 35rpx;
width: 0;
height: 0;
border-top: 8rpx solid transparent;
border-left: 12rpx solid yellowgreen;
border-bottom: 8rpx solid transparent;
}
/* 聊天框 */
.rightMessage{
/* display: flex; */
float: right;
margin-top: 10rpx;
border-radius: 10rpx;
width: 65%;
word-break:break-all;
word-wrap:break-word;
white-space:normal;
/* border: 1rpx solid red; */
}
.rightMessage text{
float: right;
width: auto;
background-color: yellowgreen;
line-height: 40rpx;
border-radius: 10rpx;
font-size: 14px;
padding: 20rpx;
display: inline-block;
}
/* 聊天框 */
.oneComment {
width: 100%;
background-color: #fff;
border-radius: 5rpx 5rpx 0rpx 0rpx;
height: 100rpx;
position: fixed;
bottom: 0rpx;
left: 0rpx;
_position: absolute;
}
.shuru {
position: fixed;
height: 60rpx;
width: 70%;
text-align: left;
background-color: #fff;
bottom: 0rpx;
left: 20rpx;
_position: absolute;
margin: 0rpx;
padding-top: 10rpx;
padding-left: 20rpx;
border-radius: 30rpx;
margin-bottom: 15rpx;
border: 3rpx solid #8abdfe;
}
.button{
border: 1rpx solid #8abdfe;
width: 100rpx;
height: 53rpx;
text-align: center;
line-height: 53rpx;
float: right;
position: absolute;
top: 20rpx;
right: 38rpx;
border-radius: 25rpx;
}
.enter{
background-color: #07c160;
border: 1rpx solid #07c160;
color: #fff;
}
\ No newline at end of file
// pages/letterList/letterList.js
//获取应用实例
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
chatList:[]
},
/**
* 路由
*/
beng(e){
// console.log(e.currentTarget.dataset.idd);
wx.navigateTo({
url: '/pages/letter/letter?userid='+ e.currentTarget.dataset.idd
})
},
load(){
var that = this;
if (!app.globalData.hasLogin) {
wx.showModal({
title: '提示',
content: '你还没有登录喔',
success: function (res) {
if (res.confirm) { //这里是点击了确定以后
wx.switchTab({
url: '/pages/own/own',
})
} else { //这里是点击了取消以后
that.errShowToast('你还没有登录喔');
}
}
})
return;
}
wx.request({
url: app.globalData.myUrl+'/chat/list',
data: {
token: app.globalData.token
},
success: (res) => {
// console.log(res);
if (res.data.success) {
that.setData({
chatList:res.data.msg
})
}else{
that.errShowToast(res.data.msg)
}
// console.log(that.data.chatList);
},
fail: (res) => {},
complete: (res) => {},
})
},
//---------------------------函数封装------------------------------
errShowToast: function (toastText) {
wx.showToast({
title: toastText,
image: '/images/password.png',
duration: 2000
});
},
sucShowToast: function (toastText) {
wx.showToast({
title: toastText,
duration: 2000
});
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.load()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.load()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {},
"navigationBarTitleText": "私信列表",
"enablePullDownRefresh": true
}
\ No newline at end of file
<!-- 私信 -->
<view class="all" wx:for="{{chatList}}" wx:key="index">
<!-- 单个聊天框 -->
<view class="single" bindtap="beng" data-idd="{{item.toUser.id}}">
<!-- 未读信息数量 -->
<view class="marks" wx:if="{{item.unreadNum != 0}}">
<text>{{item.unreadNum}}</text>
</view>
<view class="left">
<!-- 左边头像 -->
<image src="{{item.toUser.avatarUrl}}"></image>
</view>
<!-- 右边个人信息 -->
<view class="right">
<view class="flex">
<!-- 用户id -->
<text class="title">{{item.toUser.nickName}}</text>
<!-- 最近一条聊天记录 -->
<text class="nextTitle">{{item.content}}</text>
</view>
</view>
<!-- 最右边的时间 -->
<view class="rightEnd">
<text class="time">{{item.ofTime}}</text>
</view>
</view>
</view>
\ No newline at end of file
.single{
padding: 20rpx 20rpx;
/* border-bottom: 1rpx solid #ccc; */
display: flex;
position: relative;
background: #fff;
margin: 10rpx 0;
border-radius: 10rpx;
}
.marks{
position: absolute;
top: 7px;
left: 83rpx;
width: 35rpx;
height: 35rpx;
line-height: 35rpx;
background: red;
border-radius: 50%;
color: white;
text-align: center;
font-size: 22rpx;
}
.left{
width: 85rpx;
height: 85rpx;
}
.left image{
width: 100%;
height: 100%;
border-radius: 50%;
}
.right{
display: flex;
margin-left: 20rpx;
font-size: 32rpx;
}
.right .title{
font-weight: regular;
font-size: 17px;
}
.right .nextTitle{
font-size: 28rpx;
color: #888;
width: 250rpx;
overflow: hidden;
text-overflow:ellipsis;
}
.right text{
display: block;
}
.rightEnd{
position: absolute;
right: 0rpx;
top: -8rpx;
padding: 10rpx;
}
.rightEnd text{
color: #888;
font-size: 23rpx;
}
\ No newline at end of file
// pages/newInformationthree/newInformationthree.js
//获取应用实例
const app = getApp()
wx.cloud.init()
Page({
/**
* 页面的初始数据
*/
data: {
titleImg: '/images/own/logo.jpg',
userName: '',
password: '',
confirmPassword: '',
placeholderInput: '请输入账号',
disabled: false,
loginBtnName: "绑定",
placeholder: "确认密码",
msg:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// console.log(options.titleImg);
this.setData({titleImg:options.titleImg})
// console.log(app.globalData.token);
wx: wx.request({
url: app.globalData.myUrl + '/userByWeb/getUsername',
method: "GET",
data: {
"token": app.globalData.token
},
success: (result) => {
// console.log(result.data);
// 判断是否成功获取用户名
if (result.data.msg===null) {
wx.showToast({
title: '您还没有绑定喔',
icon: 'none',
duration: 1000
})
this.setData({
msg:result.data.msg
})
return;
} else {
// 直接获取用户名
// console.log(2);
this.setData({
userName: result.data.msg,
placeholderInput: result.data.msg,
disabled: true,
loginBtnName: "修改",
placeholder: "修改密码"
})
}
},
fail: (res) => {
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
// 账号
usernameInput(e) {
let userName = e.detail.value;
// console.log(e);
if (!(/^[a-zA-Z][a-zA-Z0-9_]{4,11}/.test(userName))) {
wx.showToast({
title: '字母开头,不能为空格',
duration: 500,
icon: 'none'
});
return;
} else {
this.setData({
// 清除空格符 变为空
userName: userName,
userName: userName.replace(/\s+/g, ''),
})
// console.log(this.data.userName);
}
// 正则使用
// console.log(1);
},
// 密码
passwordInput(e) {
// console.log(e);
let password = e.detail.value;
// 正则
if (!(/^[a-zA-Z]\w{5,17}$/.test(password))) {
wx.showToast({
title: '字母开头,长度5~17位',
duration: 500,
icon: 'none'
});
return
};
this.setData({
password: password,
password: password.replace(/\s+/g, ''),
})
// console.log(this.data.password);
},
// 确认密码
confirmPassword(e) {
// console.log(e);
let confirmPassword = e.detail.value;
if (!(this.data.password == confirmPassword)) {
wx.showToast({
title: '密码不一致',
duration: 500,
icon: 'none'
});
return;
}
this.setData({
confirmPassword: confirmPassword,
confirmPassword: confirmPassword.replace(/\s+/g, ''),
})
// console.log(confirmPassword);
},
// 重置
resetSalaryBtn(e) {
this.setData({
userName: '',
password: '',
confirmPassword: ''
})
},
// 登录处理
login() {
let userName=this.data.userName;
let password=this.data.password;
var that = this;
if (this.data.userName.length == 0 || this.data.password.length == 0) {
wx.showToast({
title: '账号或密码不能为空',
icon: 'none',
duration: 1000
})
return;
}
if (this.data.msg===null) {
// msg为空 就绑定账户
// url: app.globalData.myUrl + '/userByWeb/getUsername',
wx:wx.request({
url:app.globalData.myUrl + '/userByWeb/register',
method:"GET",
data:{
"token": app.globalData.token,
username:userName,
password:password
},
// Howe10086
success:(res)=>{
wx.showToast({
title: '绑定成功',
icon: 'none',
duration: 1000
}),
this.setData({
userName: res.data.msg,
placeholderInput: res.data.msg,
disabled: true,
loginBtnName: "修改",
placeholder: "修改密码"
})
},
fail:()=>{
wx.showToast({
title: '绑定失败',
icon: 'none',
duration: 1000
})
}
})
}else{
// 否则就是修改
wx:wx.request({
url:app.globalData.myUrl + '/userByWeb/update',
method:"GET",
data:{
"token": app.globalData.token,
username:userName,
password:password
},
// Howe10086
success:(res)=>{
wx.showToast({
title: '修改成功',
icon: 'none',
duration: 1000
})
},
fail:()=>{
wx.showToast({
title: '修改失败',
icon: 'none',
duration: 1000
})
}
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!-- 账号设置 -->
<view class="login-from">
<!-- 头像 -->
<view class="titleImg">
<image src="{{titleImg}}" mode="widthFix"></image>
</view>
<!--账号-->
<view class="inputView">
<view>
<image class="nameImage" src="/images/account (1).png" mode="widthFix"></image>
<text>账号</text>
</view>
<input class="inputText" placeholder="{{placeholderInput}}" bindinput="usernameInput" value="{{userName}}" maxlength="11" disabled="{{disabled}}" />
</view>
<!--密码-->
<view class="inputView">
<view>
<image class="nameImage" src="/images/account (1).png" mode="widthFix"></image>
<text>密码</text>
</view>
<input class="inputText" password="true" placeholder="请输入密码" bindinput="passwordInput" value="{{password}}" maxlength="17" />
</view>
<!-- 确认密码 -->
<view class="inputView">
<input class="inputText" password="true" placeholder="{{placeholder}}" bindinput="confirmPassword" value="{{confirmPassword}}" maxlength="17" />
</view>
<!--按钮-->
<view class="loginBtnView">
<button class="resetBtn" type="default" size="{{mini}}" plain="{{plain}}"
bindtap="resetSalaryBtn" form-type="reset ">重置</button>
</view>
<view class="loginBtnView">
<button class="loginBtn" type="primary" size="{{mini}}" plain="{{plain}}"
bindtap="login" form-type="submit">{{loginBtnName}}</button>
</view>
</view>
\ No newline at end of file
.login-from{
width: 90vw;
background: #fff;
margin: 60rpx auto;
padding: 30rpx;
box-sizing: border-box;
border-radius: 20rpx;
box-shadow: 0rpx 0rpx 5rpx #95b6e0 inset;
}
/* 头像 */
.login-from .titleImg{
padding-top: 30rpx;
}
.login-from .titleImg image{
width: 26%;
display: block;
border-radius: 50%;
margin: auto;
box-shadow: 0rpx 0rpx 10rpx #95b6e0;
}
.login-from .inputView{
width: 80%;
/* background: #999; */
margin: 30rpx auto;
}
.login-from .inputView view{
display: flex;
align-items: center;
justify-content: center;
}
.login-from .inputView view image{
width: 50rpx;
margin-top: 10rpx;
display: block;
}
.login-from .inputView view text{
display: block;
color: #8abdfe;
margin-top: 16rpx;
}
.login-from .inputView .loginLab{
color: aliceblue;
line-height: 50rpx;
}
.inputView .inputText{
margin: 10rpx;
height: 80rpx;
text-align: center;
background: #eaf1fe;
border-radius: 30rpx;
box-shadow: 0rpx 0rpx 3rpx #95b6e0;
}
/* 按钮 */
.loginBtnView {
margin: 30rpx auto;
}
\ No newline at end of file
......@@ -303,6 +303,18 @@ Page({
url: '/pages/newInformationtwo/newInformationtwo'
})
},
// 账号设置
newInformationthree(e) {
var that = this;
if (!app.globalData.hasLogin) {
that.errShowToast('你还没有登录喔');
return;
}
// console.log(e.currentTarget.dataset.titleimg);
wx.navigateTo({
url: '/pages/newInformationthree/newInformationthree?titleImg='+e.currentTarget.dataset.titleimg
})
},
//------------------------定时器(为了减轻服务器负担,只在演示时开)----------------------------
time: function () {
......
......@@ -51,9 +51,11 @@
</navigator>
</view>
<view>
<navigator class="information">
<text>隐私</text>
<navigator class="information" bindtap='newInformationthree' data-titleImg="{{user.avatarUrl}}">
<text>账号设置</text>
<image src="/images/own/return.png"></image>
<text class="num"
wx:if="{{user.unreadOpinion!=null&&user.unreadOpinion!=''&&user.unreadOpinion>0}}">{{user.unreadOpinion}}</text>
</navigator>
</view>
<view>
......
......@@ -100,6 +100,7 @@
font-size: 30rpx;
line-height: 80rpx;
position: relative;
padding-left: 20rpx;
}
.information text{
color: #696969;
......@@ -108,10 +109,10 @@
.popup view{
margin: 15rpx auto;
background-color: #fff;
padding-left: 20rpx;
/* padding-left: 20rpx; */
/* border-bottom: 1rpx solid #8abdfe; */
/* border-top: 1rpx solid #8abdfe; */
border-radius: 20rpx;
border-radius: 10rpx;
}
.information .num{
background-color: #ff0000;
......
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": false,
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": false,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.15.0",
"appid": "wx2a727597141f9017",
"projectname": "a_mini_demo",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": false,
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": false,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": false,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.17.0",
"appid": "wx2a727597141f9017",
"projectname": "a_mini_demo",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"list": []
},
"plugin": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": []
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册