Comments function

dev
温雍敬 2 years ago
parent da7f53c554
commit b5786cd580

@ -16,33 +16,6 @@ App({
this.globalData = { this.globalData = {
// OPENID: wx.cloud.getWXContext().OPENID // OPENID: wx.cloud.getWXContext().OPENID
OPENID: '',
USERID: '',
ISLOGIN: false
}; };
//尝试读取本地缓存
try {
// wx.clearStorage()
this.globalData.USERID = wx.getStorageSync('user_id')
this.globalData.OPENID = wx.getStorageSync('user_openid')
} catch (e) {
console.error(e);
}
//检测用户是否首次登录
if (!this.globalData.OPENID) {
this.globalData.ISLOGIN = false
wx.cloud.callFunction({
name: "getOpenId",
success: (res) => {
this.globalData.OPENID = res.result.openid;
wx.setStorageSync('user_openid', res.result.openid)
} }
})
}
//输出全局变量
console.log("[GLOABLE] User:",this.globalData);
},
}); });

@ -1,12 +1,12 @@
{ {
"pages": [ "pages": [
"pages/Main/main", "pages/Main/main",
"pages/Msg/msg", "pages/msg/msg",
"pages/Profile/profile", "pages/Profile/profile",
"pages/Tprofile/Tprofile", "pages/Tprofile/Tprofile",
"pages/Comments/Comments",
"pages/Order/order", "pages/Order/order",
"pages/Details/details" "pages/Details/detail",
"pages/Comments/comments"
], ],
"window": { "window": {
"backgroundColor": "#FFF", "backgroundColor": "#FFF",
@ -25,7 +25,7 @@
}, },
{ {
"pagePath": "pages/Order/order", "pagePath": "pages/Order/order",
"text": "msg", "text": "order",
"iconPath": "images/msg.png", "iconPath": "images/msg.png",
"selectedIconPath": "images/msg_on.png" "selectedIconPath": "images/msg_on.png"
}, },

@ -1,271 +1,195 @@
const db = wx.cloud.database().collection("comment") // pages/Detailed/detailed.js
let id=''
let speak=''
let db = wx.cloud.database();
Page({ Page({
/**
* 页面的初始数据
*/
data: { data: {
//评论数据 good:[],
comment_list: [ plcaceHolder:'',
{ speak:'',
comment_id: 1, //评论id
comment_pr_id: 1,//评论文章所属id
comment_user_avatar: 'cloud://cloud1-7gyjwcyfbdf819da.636c-cloud1-7gyjwcyfbdf819da-1321167991/1678762683308.png', //评论用户头像(路径替换为你的图片路径)
comment_user_name: '高同学', //评论人昵称
comment_text: '您觉得这位老师的讲课方式是什么样的呢', //评论内容
comment_time: '2020年8月18日', //评论时间
reply_id: 0, //回复谁的评论默认为0
parent_id: 0, //评论所属评论id默认为0
reply_name: '' //回复评论用户的昵称 默认为''
}, },
{
comment_id: 2, /**
comment_pr_id: 1, * 生命周期函数--监听页面加载
comment_user_avatar: 'cloud://cloud1-7gyjwcyfbdf819da.636c-cloud1-7gyjwcyfbdf819da-1321167991/photo/70eb920703ebdb368681f011c75aef3.jpg', */
comment_user_name: '王同学', onLoad(options) {
comment_text: '强烈推荐这位老师,讲课幽默生动,容易接受',
comment_time: '2020年8月18日',
reply_id: 0,
parent_id: 0,
reply_name: ''
}, },
{
comment_id: 3,
comment_pr_id: 1,
comment_user_avatar: 'cloud://cloud1-7gyjwcyfbdf819da.636c-cloud1-7gyjwcyfbdf819da-1321167991/photo/4494c78cc34e0567b59bd6431df61f6.jpg', // 获取id 根据id获取数据
comment_user_name: '张剑锋', onLoad(options) {
comment_text: '老师讲的比较仔细,但好像不太适合我', console.log(options)
comment_time: '2020年8月18日',
reply_id: 0,
parent_id: 0,
reply_name: '' id=options.id
} this.getgood()
],
//回复数据
comment_list2: [
{
comment_id: 4,
comment_pr_id: 1,
comment_user_name: '张同学',
comment_user_avatar: '/images/assemblyNumber/discoveryDetails/per3.png',
comment_text: "为什么呢?",
comment_time: '2020年8月18日',
reply_id: 3,
parent_id: 3,
reply_name: ''
}, },
{
comment_id: 5,
comment_pr_id: 1,
comment_user_name: '沈非隆', getgood(){
comment_user_avatar: '/images/assemblyNumber/discoveryDetails/per4.png', let that=this
comment_text: "办理优待证大概需要多长时间呢会不会需要特别长时间", wx.cloud.database().collection('teacher_Data').doc(id).get()
comment_time: '2020年8月18日', .then(res=>{
reply_id: 3, that.setData({
parent_id: 3, good:res.data
reply_name: '张剑锋' })
} })
], },
/*定义一些数据*/ /**
focus: false, //输入框是否聚焦 * 生命周期函数--监听页面初次渲染完成
placeholder: '说点什么...', //底部输入框占字符
placeholder2: '说点什么让ta也认识看笔记的你', //顶部输入框占字符
value: null, //顶部输入框内容
comment_text: null, //底部评论框内容
/*
*以下初始化数据是用户点击任意一条评论或回复时需要设置的数据
*然后将设置好的数据传递给评论时新创建的评论数据对象
*/ */
now_reply_name: null, //当前点击的评论或回复评论的用户昵称 onReady() {
now_reply_type: 0, //当前回复类型 默认为0 1为回复评论 2为回复回复
now_parent_id: 0, //当前点击的评论或回复评论的所属评论id
now_reply: 0, //当前点击的评论或回复评论的id
//模拟用户信息
userinfo: {
nickName: '马飞', //用户昵称
avatarUrl: '/images/assemblyNumber/discoveryDetails/per5.png' //用户头像
}
}, },
//顶部评论框提交内容时触发 /**
bindconfirm(e) { * 生命周期函数--监听页面显示
var comment_text = e.detail.value //判断用户是否输入内容为空 */
if (comment_text == '') { //用户评论输入内容为空时弹出 onShow() {
wx.showToast({
title: '请输入内容', //提示内容
icon: 'none' })
} else {
var date = new Date(); //创建时间对象
var year = date.getFullYear(); //获取年
var month = date.getMonth() + 1; //获取月
var day = date.getDate(); //获取日
var hour = date.getHours(); //获取时
var minute = date.getMinutes(); //获取分
var second = date.getSeconds(); //获取秒
var time = `${year}${month}${day}${hour}${minute}${second}`; //当前时间
var comment_list = this.data.comment_list; //获取data中的评论列表
var comment_list2 = this.data.comment_list2; //获取data中的回复列表
var userinfo = this.data.userinfo; //获取当前的用户信息
var comment_user_name = userinfo.nickName //用户昵称
var comment_user_avatar = userinfo.avatarUrl //用户头像 //
var reply_id = this.data.reply_id //获取当前输入评论的id
var comment_list_length = comment_list.length; //获取当前评论数组的长度
var last_id = comment_list[comment_list_length - 1].comment_id; //获取最后一个评论的id
var comment_list2_length = comment_list2.length; //获取回复数组的长度
var last_id2 = comment_list2[comment_list2_length - 1].comment_id; //获取最后回复id
var new_id = last_id > last_id2 ? last_id + 1 : last_id2 + 1; //赋值当前评论的id
var reply_name = null;
var parent_id = 0;
var reply_id = this.data.now_reply; //获取当前输入评论的id
var comment_detail = {} //声明一个评论/回复对象
comment_detail.comment_id = new_id; //评论Id
comment_detail.comment_user_name = comment_user_name; //用户昵称
comment_detail.comment_user_avatar = comment_user_avatar; //用户头像
comment_detail.comment_text = comment_text; //评论内容
comment_detail.comment_time = time; //评论时间
comment_detail.reply_id = reply_id; //回复谁的评论的id
comment_detail.parent_id = parent_id; //评论所属哪个评论id
comment_detail.reply_name = reply_name; //回复评论人的昵称
comment_list.unshift(comment_detail);
this.setData({
value: null, //评论内容
now_reply: 0, //当前点击的评论id
now_reply_name: null, //当前点击的评论的用户昵称
now_reply_type: 0, //评论类型
now_parent_id: 0, //当前点击的评论所属哪个评论id
placeholder2: "说点什么让ta也认识看笔记的你", //输入框占字符
comment_list //评论列表
})
}
}, },
//点击用户评论或回复时触发
replyComment(e) {
var cid = e.currentTarget.dataset.cid; //当前点击的评论id // 获取评价信息
var name = e.currentTarget.dataset.name; //当前点击的评论昵称 getInputValue(event){
var pid = e.currentTarget.dataset.pid; //当前点击的评论所属评论id
var type = e.currentTarget.dataset.type; //当前回复类型
this.setData({ speak=this.data.plcaceHolder + event.detail.value
focus: true, //输入框获取焦点
placeholder: '回复' + name + '', //更改底部输入框占字符
now_reply: cid, //当前点击的评论或回复评论id
now_reply_name: name, //当前点击的评论或回复评论的用户名
now_parent_id: pid, //当前点击的评论或回复评论所属id
now_reply_type: type, //获取类型(1回复评论/2回复-回复评论)
})
}, },
//底部输入框提交内容时触发
confirm(e){ // 发送评价信息
//获取输入框输入的内容 publishComment(){
var comment_text = e.detail.value; let that=this
//判断用户是否输入内容为空 if(!that.data.good.speaklist){
if (comment_text == '') { let speaklist=[{
//用户评论输入内容为空时弹出
nickname:wx.getStorageSync('user').nickname,
speak:speak,
}]
db.collection('teacher_Data').doc(id).update({
data:{
speaklist:speaklist
}
})
.then(res=>{
that.setData({
speak:''
})
that.getgood()
wx.showToast({ wx.showToast({
title: '请输入内容', //提示内容 title:'已评价',
icon:'none'
}) })
} else {
var date = new Date(); //创建时间对象
var year = date.getFullYear(); //获取年
var month = date.getMonth() + 1; //获取月
var day = date.getDate(); //获取日
var hour = date.getHours(); //获取时
var minute = date.getMinutes(); //获取分
var second = date.getSeconds(); //获取秒
var time = `${year}${month}${day}${hour}${minute}${second}`; //当前时间
var userinfo = this.data.userinfo; //获取当前的用户信息
var comment_user_name = userinfo.nickName //用户昵称
var comment_user_avatar = userinfo.avatarUrl //用户头像
var reply_name = null; //回复评论用户的昵称
var parent_id = 0; //评论所属哪个评论的id
var reply_id = this.data.now_reply; //回复谁的评论id
var comment_list = this.data.comment_list; //获评论数据
var comment_list2 = this.data.comment_list2; //获取回复数据
var comment_list_length = comment_list.length; //获取当前评论数组的长度
var last_id = comment_list[comment_list_length - 1].comment_id; //获取最后一个评论的id
var comment_list2_length = comment_list2.length; //获取回复数组的长度
var last_id2 = comment_list2[comment_list2_length - 1].comment_id; //获取最后回复的id
var new_id = last_id > last_id2 ? last_id + 1 : last_id2 + 1; //当前将要发表的评论的id
//通过回复谁的评论id判断现在是评论还是回复
if(reply_id != 0) {
//现在是回复
var reply_type = this.data.now_reply_type; //回复类型
//通过回复类型判断是回复评论还是回复回复
if (reply_type == 1) {
//回复评论
parent_id = this.data.now_reply; //回复评论所属评论id
reply_name = this.data.now_reply_name; //回复评论用户昵称
} else {
parent_id = this.data.now_parent_id; //回复评论所属评论id
reply_name = this.data.now_reply_name; //回复评论用户昵称
}
} else {
//现在是评论
}
var comment_detail = {} //评论/回复对象
comment_detail.comment_id = new_id; //评论Id
comment_detail.comment_user_name = comment_user_name; //用户昵称
comment_detail.comment_user_avatar = comment_user_avatar; //用户头像
comment_detail.comment_text = comment_text; //评论内容
comment_detail.comment_time = time; //评论时间
comment_detail.reply_id = reply_id; //回复谁的评论的id
comment_detail.parent_id = parent_id; //评论所属哪个评论id
comment_detail.reply_name = reply_name; //回复评论人的昵称
//判断parent_id是否为0 为0就是评论 不为0就是回复
if(comment_detail.parent_id != 0) {
//回复
comment_list2.unshift(comment_detail);
} else {
//评论
comment_list.unshift(comment_detail);
}
//动态渲染
ths.setData({
//发表评论后将以下数据初始化 为下次发表评论做准备
comment_text: null, //评论内容
now_reply: 0, //当前点击的评论id
now_reply_name: null, //当前点击的评论的用户昵称
now_reply_type: 0, //评论类型
now_parent_id: 0, //当前点击的评论所属哪个评论id
placeholder: "什么...", //输入框占字符
//将加入新数据的数组渲染到页面
comment_list2 //回复列表
}) })
} }
}, else{
let newspeaklist=that.data.good.speaklist
newspeaklist.push({
nickname:wx.getStorageSync('user').nickname,
speak:speak,
//下面的方法可以绑定在输入框的bindblur属性上
blur(e) {
const text = e.detail.value.trim();
if (text == '') {
this.setData({
now_reply: 0, //当前点击的评论或回复评论的id
now_reply_name: null, //当前点击的评论或回复评论的用户昵称
now_reply_type: 0, //当前回复类型
now_parent_id: 0, //当前点击的评论或回复评论的所属评论id
placeholder: "说点什么呢,万一火了呢", //占字符
focus: false //输入框获取焦点
}) })
} console.log(newspeaklist)
},
//获取输入框内容 db.collection('teacher_Data').doc(id).update({
getCommentText(e) {
var val = e.detail.value;
wx.cloud.callFunction({
name:"sendComment",
data:{ data:{
comment :val speaklist:newspeaklist
} }
}) })
.then(res=>{
that.setData({
speak:''
})
that.getgood()
wx.showToast({
title:'已评价',
icon:'none'
})
})
}
},
// 回复评价
huifuComment(event){
let that=this
var index = event.currentTarget.dataset.index
this.setData({ this.setData({
comment_text: val plcaceHolder : '回复' + this.data.good.speaklist[index].nickname+':',
}) })
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
// 获取公司招聘数据
getList(){
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
}, },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
}) })

@ -1,61 +1,29 @@
<!-- 评论-回复-回复评论显示区域 --> <!--pages/Detailed/detailed.wxml-->
<view class="container">
<!-- 总共评论数 -->
<view class="total">共{{comment_list.length + comment_list2.length}}条评论</view>
<!-- END -->
<!-- 评论框 -->
<!-- <input confirm-type="send" class="container_inp" value="{{value}}" placeholder="{{ placeholder2 }}" placeholder-class="container_place" bindconfirm="bindconfirm"></input> -->
<input confirm-type="send" class="container_inp" value="{{value}}" placeholder="{{ placeholder2 }}" placeholder-class="container_place" bindconfirm="bindconfirm"></input> <view class="comment-box" wx:if="{{good.speaklist.length > 0}}">
<view class="comment-right">
<block wx:for="{{good.speaklist}}" wx:key="index">
<view class="comment-one" >
<image src="/images/profile.png" class="comment-face" bindtap="huifuComment" data-index="{{index}}"></image>
<view class="comment-content">
<view class="nickname-time">
<view class="comment-nickname">{{item.nickname}}</view>
<!-- END -->
<!-- 用户评论回复显示区域 -->
<view class="container-item" wx:for="{{comment_list}}" wx:for-item="list" wx:key="key">
<image class="item_img" src="{{list.comment_user_avatar}}"></image>
<view class="item_right">
<view class="right_name">{{list.comment_user_name}}</view>
<view class="right_content">
<text class="right_content_txt" bindtap='replyComment' data-type="1" data-name='{{list.comment_user_name}}' data-cid='{{list.comment_id}}' data-pid="{{list.parent_id}}">{{list.comment_text}}</text>
<text class="right_content_txt2">{{list.comment_time}}</text>
<!-- 回复评论 -->
<!-- 判断回复列表数据中的parent_id和评论列表数据的comment_id是否相等 相等就显示 不等就不显示 -->
<view class="reply" wx:for="{{comment_list2}}" wx:for-item="list2" wx:key="list2" wx:if="{{list2.parent_id == list.comment_id}}">
<image class="reply_img" src="{{list2.comment_user_avatar}}"></image>
<view class="reply_right">
<view class="right_name">{{list2.comment_user_name}}</view>
<text wx:if="{{list2.reply_name == ''}}" class="right_content_txt" bindtap='replyComment' data-type="2" data-name='{{list2.comment_user_name}}' data-cid='{{list2.comment_id}}' data-pid="{{list2.parent_id}}">{{list2.comment_text}}</text>
<text wx:if="{{list2.reply_name != ''}}" bindtap='replyComment' data-type="2" data-name='{{list2.comment_user_name}}' data-cid='{{list2.comment_id}}' data-pid="{{list2.parent_id}}" class="right_content_txt">回复 <text class="right_name">{{list2.reply_name}}</text>{{list2.comment_text}}</text>
<text class="right_content_txt2">{{list2.comment_time}}</text>
</view> </view>
<view class="comment-text" selectable="true"bindtap="SCpl" data-index="{{index}}" >
<text wx:if="{{item.toOpenid}}">回复<text class="comment-obj">{{item.toNickname}}</text></text>{{item.speak}}
</view> </view>
</view> </view>
</view> </view>
</block>
</view> </view>
<!-- END -->
<!-- 结束 -->
<view class="end">
<text class="end_txt" space="nbsp">— THE END —</text>
</view>
<!-- END -->
</view>
<!-- END -->
<!-- 底部评论 -->
<view class="foot">
<view class="say">
<view class="flex">
<!-- <image class="say_img" src=" "></image> -->
<input confirm-type="send" class="say_inp" placeholder="{{ placeholder }}" value="{{ comment_text }}" focus="{{ focus }}" bindblur="blur" bindconfirm="confirm"></input>
</view> </view>
<!-- 底部 -->
<view style="height:200rpx"></view>
<view class="pub-comment" >
<view class="pub-left">
<input class="pub-input" cursor-spacing="10px" placeholder="{{plcaceHolder}}" bindinput="getInputValue" value="{{speak}}" bindconfirm="publishComment"></input>
</view> </view>
<!-- <image class="foot_img" src=" "></image> --> <view class="pub-button" bindtap="publishComment">发送</view>
<text class="foot_num">210</text>
<!-- <image class="foot_img2" src=" "></image> -->
<text class="foot_num"> 368</text>
</view> </view>
<!-- END -->

@ -1,158 +1,98 @@
/* 评论-回复-回复评论显示区域 */ /* pages/Detailed/detailed.wxss */
.container {
width: 718rpx;
margin-top: 39rpx;
padding-left: 32rpx;
}
.total {
font-size: 24rpx;
color: #999999;
margin-left: 1rpx;
}
.container_inp {
width: 661rpx;
height: 32rpx;
background-color: #F2F2F2;
border-radius: 8rpx;
padding: 17rpx 0rpx 15rpx 25rpx;
margin-top: 24rpx;
margin-bottom: 47rpx;
}
.container_place { /* 留言部分 */
font-size: 24rpx; .comment-box {
color: #999999; background-color: white;
display: flex;
flex-direction: row;
padding-top: 20rpx;
} }
.container-item { .comment-one {
display: flex; display: flex;
margin-bottom: 34rpx; flex-direction: row;
align-items: flex-start; margin: 0 20rpx 40rpx 20rpx;
} }
.item_img { .comment-face {
width: 64rpx; width: 70rpx;
height: 64rpx; height: 70rpx;
margin-right: 17rpx; border-radius: 50rpx;
margin-right: 20rpx;
} }
.item_right { .nickname-time {
display: inline-block; display: flex;
width: 636rpx; flex-direction: row;
border-bottom: 2rpx solid #E5E5E5; justify-content: space-between;
padding-bottom: 40rpx; width: 600rpx;
} }
.right_name { .comment-nickname {
font-size: 24rpx; color: #586B94;
color: #999999; font-weight: 550;
}
.right_content { font-size: 30rpx;
width: 603rpx;
margin-top: 20rpx;
} }
.right_content_txt { .comment-time {
color: #7F7F7F;
font-size: 26rpx; font-size: 26rpx;
color: #333333;
} }
.right_content_txt2 { .comment-text {
font-size: 24rpx; margin-top: 14rpx;
color: #CCCCCC;
margin-left: 30rpx;
}
.reply { font-size: 28rpx;
display: flex; width: 606rpx;
margin-top: 32rpx;
align-items: flex-start;
}
.reply_img { word-wrap: break-word;
width: 40rpx; word-break: break-all;
height: 40rpx;
margin-right: 17rpx;
}
.reply_right { letter-spacing: 2rpx;
display: inline-block; display: inline-block;
width: 546rpx;
}
/* 结束 */
.end {
margin-top: 47rpx;
margin-bottom: 48rpx;
text-align: center;
} }
.end_txt { .comment-obj {
font-size: 24rpx; color: #586B94;
color: #999999; font-weight: 550;
} }
/* 底部评论 */ /* 发布评论 */
.foot { .pub-comment {
width: 686rpx; background-color: white;
padding: 17rpx 32rpx; padding: 20rpx 40rpx;
background-color: #FFFFFF;
box-shadow: 0rpx -1rpx 4rpx 0rpx rgba(0, 0, 0, 0.08);
position: fixed;
bottom: 0;
left: 0;
}
.say {
display: inline-block;
width: 360rpx;
padding: 20rpx 0rpx 10rpx 24rpx;
background-color: #F2F2F2;
border-radius: 8rpx;
}
.flex {
display: flex; display: flex;
flex-direction: row;
align-items: center; align-items: center;
position: fixed;
bottom: 0;
} }
.say_img { .pub-left {
width: 24rpx; background-color: #fff;
height: 24rpx; color: #7F7F7F;
margin-right: 13rpx; border-radius: 10rpx;
/* vertical-align: 10rpx; */ margin-right: 20rpx;
} }
.say_inp { .pub-input {
display: inline-block; padding: 10rpx 20rpx;
width: 300rpx; width: 500rpx;
height: 33rpx; background-color: rgb(250, 251, 253);
} }
.say_place { .pub-button {
font-size: 28rpx; color: #7F7F7F;
color: #333333; border: solid 1rpx #7F7F7F;
border-radius: 10rpx;
padding: 10rpx 20rpx;
} }
.foot_img {
width: 45rpx;
height: 40rpx;
margin-left: 50rpx;
margin-right: 17rpx;
}
.foot_num {
font-size: 24rpx;
vertical-align: 10rpx;
}
.foot_img2 { .comment-right{
width: 40rpx; width: 100%;
height: 40rpx;
margin-left: 30rpx;
margin-right: 17rpx;
} }

@ -0,0 +1,70 @@
// pages/Detailed/detailed.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Page({
/**
* 页面的初始数据
*/
data:{
avatarUrl: defaultAvatarUrl,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
var index = options.index; // 第一个页面传递过来的教师索引
var teacherInfo = this.data.teacher[index];
// 使用索引在教师数组中获取对应的教师信息
// var teacherInfo = this.data.teacher[index];
// 继续处理教师信息
// 调用云函数获取教师信息
wx.cloud.callFunction({
name: "detailed",
success: (res) => {
this.setData({
teacher: res.result.data
})
// console.log(this.data.teacher[1]);
}
})
},
changeTab(e) {
const index = e.currentTarget.dataset.index;
this.setData({
currentTab: parseInt(index)
});
},
onAddButtonTap: function() {
this.setData({
showPopup: true
});
},
onBackButtonTap: function() {
this.setData({
showPopup: false
});
},
handleSubmit: function() {
// 处理....
// 提交成功后隐藏弹窗
this.setData({
showPopup: false
});
},
navToComments: () => {
wx.navigateTo({
url: '/pages/Comments/Comments',
})
},
inputChange(e) {
this.setData({
inputValue: e.detail.value
});
},
})

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

@ -0,0 +1,16 @@
<!--pages/detail/detail.wxml-->
<!--pages/Detailed/detailed.wxml-->
<view style="background-color: #FFFFFF; margin: 15rpx; border-radius: 25rpx;">
<view class="avatar-wrapper">
<image class="avatar" src="{{avatarUrl}}"></image>
<text>
姓名: 老师
科目: NULL
空闲时间: NULL
学历: NULL
时薪: NULL
</text>
</view>
<view style="margin: 20rpx;">综合评分: 10.0</view>
</view>

@ -0,0 +1,15 @@
/* pages/detail/detail.wxss *//* pages/Detailed/detailed.wxss */
.avatar-wrapper {
display: flex;
justify-content: left;
}
/* 子元素选择器 */
.avatar-wrapper > image {
height: 100px;
width: 100px;
border-style: solid;
border-color: #000;
border-width: 1px;
margin: 20px;
}

@ -1,4 +1,4 @@
const app = getApp(); //const that = this;
const db = wx.cloud.database().collection("student_Demands"); const db = wx.cloud.database().collection("student_Demands");
// pages/MainTest/MainTest.js // pages/MainTest/MainTest.js
Page({ Page({
@ -19,9 +19,6 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
// wx.showLoading({
// title: '加载中',
// })
//检测用户是否注册过 //检测用户是否注册过
// wx.cloud.database() // wx.cloud.database()
// .collection('user_Data') // .collection('user_Data')
@ -72,9 +69,10 @@ Page({
}); });
}, },
navToComments: () => { navToComments(e){
wx.navigateTo({ wx.navigateTo({
url: '/pages/Comments/Comments', url: '/pages/Comments/comments?id=' + e.currentTarget.dataset.id,
}) })
}, },
@ -87,7 +85,6 @@ Page({
} }
}) })
}, },
// contactTeacher(event) { // contactTeacher(event) {
// // console.log(event); // // console.log(event);
// wx.makePhoneCall({ // wx.makePhoneCall({
@ -99,7 +96,6 @@ Page({
inputValue: e.detail.value inputValue: e.detail.value
}); });
}, },
recommend() { recommend() {
// TODO // TODO
this.setData({ this.setData({

@ -15,8 +15,8 @@
<view class="tab"> <view class="tab">
<view class="tab-item" bindtap="changeTab" data-index="0">教员列表</view> <view class="tab-item" bindtap="changeTab" data-index="0">教员风采</view>
<view class="tab-item" bindtap="changeTab" data-index="1">系统推荐</view> <view class="tab-item" bindtap="changeTab" data-index="1">学员情况</view>
</view> </view>
<view class="content"> <view class="content">
@ -32,11 +32,11 @@
</view> </view>
</view> </view>
<view class="show_information" wx:for="{{teacher}}" data-index="{{index}}"wx:key="_id"> <view class="show_information" wx:for="{{teacher}}" wx:key="_id">
<!-- //当每通过一个教员上传的简历信息则创建一个 --> <!-- //当每通过一个教员上传的简历信息则创建一个 -->
<view class="content-container" bind:tap="navToDetails"> <view class="content-container">
<image class="image" src="/images/user.png"></image> <image class="image" src="/images/user.png"></image>
<view class="text-container"> <view class="text-container"bind:tap="navToDetails">
<text class="title">{{item.name}}</text> <text class="title">{{item.name}}</text>
<view> <view>
<text class="description"> <text class="description">
@ -48,7 +48,7 @@
</view> </view>
</view> </view>
<view class="button-container"> <view class="button-container">
<button bind:tap="navToComments" class="button">评论</button> <button bindtap="navToComments" data-id="{{item._id}}" class="button">评论</button>
<!-- <button bind:tap="contactTeacher" data-item="{{item.phone}}" class="button">联系</button> --> <!-- <button bind:tap="contactTeacher" data-item="{{item.phone}}" class="button">联系</button> -->
<button bind:tap="reserved" class="button">预约</button> <button bind:tap="reserved" class="button">预约</button>
</view> </view>
@ -119,6 +119,7 @@
</view> </view>
</view> </view>
<view class="page-container"> <view class="page-container">
<!-- 页面内容 --> <!-- 页面内容 -->
<view class="popup" hidden="{{!showPopup}}"> <view class="popup" hidden="{{!showPopup}}">
@ -149,4 +150,5 @@
</view> </view>
</view> </view>

@ -27,12 +27,12 @@
</view> </view>
<view class="input-group"> <view class="input-group">
<text>居住地址:</text> <text>居住地址:</text>
<input type="text"name="address" placeholder="输入现居住地址" class="input" /> <input type="text"name="address" placeholder="输入就读专业及年级" class="input" />
</view> </view>
</view> </view>
<!-- <view class="container"> <view class="container">
<text>空闲时间:</text> <text>空闲时间:</text>
<view class="table-container"> <view class="table-container">
<view class="row"> <view class="row">
@ -119,34 +119,8 @@
</view> </view>
</view> </view>
</view> </view>
</view> -->
<view class="container">
<text>空闲时间:</text>
<view class="table-container">
<view class="row">
<view class="cell"></view>
<view class="header-cell">周一</view>
<view class="header-cell">周二</view>
<view class="header-cell">周三</view>
<view class="header-cell">周四</view>
<view class="header-cell">周五</view>
<view class="header-cell">周六</view>
<view class="header-cell">周日</view>
</view>
<block wx:for="{{['上午', '中午', '下午']}}" wx:key="index">
<view class="row">
<view class="cell">{{item}}</view>
<block wx:for="{{[0, 1, 2, 3, 4, 5, 6]}}" wx:key="index">
<view class="checkbox-cell">
<checkbox bindchange="checkboxChange" value="{{index}}-{{loop.index0}}"></checkbox>
</view>
</block>
</view>
</block>
</view>
</view> </view>
<view class="container"> <view class="container">
<view class="input-group"> <view class="input-group">
<text>教员风采:</text> <text>教员风采:</text>
@ -170,5 +144,4 @@
</view> </view>
</form> </form>
</view> </view>

@ -1,18 +1,12 @@
const db = wx.cloud.database().collection("user_Data"); const db = wx.cloud.database().collection("user_Data");
const _ = wx.cloud.database().command
const app = getApp()
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' //默认头像地址 const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' //默认头像地址
Page({ Page({
//页面数据 //页面数据
data:{ data:{
avatarUrl: defaultAvatarUrl, avatarUrl: defaultAvatarUrl,
nickname: "",
gender: "",
birthday: "", birthday: "",
region:"", region:"",
contact: "",
information: ""
}, },
onLoad(options) { onLoad(options) {
@ -27,44 +21,6 @@ Page({
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
//获取用户信息
if (!app.globalData.USERID) {
db.add({
data: {
nickname: '',
gender: '',
birthday: '',
region: '',
contact: '',
information: ''
},
success: (res) => {
app.globalData.USERID = res._id
wx.setStorageSync('user_id', res._id)
console.log("[PROFILE] AddNewUser");
}
})
} else {
db.where({
_openid: app.globalData.OPENID
}).get({
success:(res) => {
var data = res.data[0]
this.setData({
nickname: data.nickname,
gender: data.gender,
birthday: data.birthday,
region: data.region,
contact: data.contact,
information: data.information
})
app.globalData.USERID = data._id
// app.globalData.ISLOGIN = true
console.log("[PROFILE] UserQuery", data);
}
})
}
}, },
//选择头像后存储头像地址 //选择头像后存储头像地址
@ -78,41 +34,22 @@ Page({
try { try {
wx.setStorageSync('avatarUrl', avatarUrl) wx.setStorageSync('avatarUrl', avatarUrl)
} catch (e) { } catch (e) {
console.log(e); console.log(e,"sssss");
} }
}, },
//表单提交方法 //表单提交方法
submit: function(e){ submit: function(e){
console.log("[PROFILE] SubmitData", e.detail.value); wx.setStorageSync('user',e.detail.value)
//todo: 添加输入检测
//输入检测,检测输入是否为空 //往数据库里插入的方法
if(!this.cheakFrom(e.detail.value)) { db.add({
return
}
//往数据库里更新的方法
db.where({
_openid: app.globalData.OPENID
}).update({
//传入数据 //传入数据
data: { data: e.detail.value,
nickname: this.data.nickname,
gender: this.data.gender,
birthday: this.data.birthday,
region: this.data.region,
contact: this.data.contact,
information: this.data.information
},
//成功后执行的方法 //成功后执行的方法
success:(res) => { success:(res) => {
console.log("[PROFILE] SubmitDone",res) console.log(res,"ssss")
wx.showToast({
title: '提交成功',
icon: 'success',
duration: 2000
})
} }
}) })
}, },
@ -136,38 +73,6 @@ Page({
this.setData({ this.setData({
region: e.detail.value, region: e.detail.value,
}); });
},
//更新页面的性别信息
genderChange: function(e){
this.setData({
gender: e.detail.value,
});
},
cheakFrom: function(e) {
var hint;
if (e.nickname == "") {
hint = "昵称为空!"
} else if (e.gender == "") {
hint = "性别为空!"
} else if (e.birthday == "") {
hint = "年龄为空!"
} else if (e.region == "") {
hint = "地区为空!"
} else if (e.contact == "") {
hint = "联系方式为空!"
} else if (e.information == "") {
hint = "基本情况为空!"
} else{
return true
}
wx.showToast({
title: hint,
icon: 'error',
duration: 2000
})
return false
} }
}); });

@ -5,25 +5,25 @@
</view> </view>
<button class="avatar-wrapper" hover-class="none" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar"> <button class="avatar-wrapper" hover-class="none" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image class="avatar" src="{{avatarUrl}}"/> <image class="avatar" src="{{avatarUrl}}"></image>
</button> </button>
<form bindsubmit="submit"> <form bindsubmit="submit">
<view class="section"> <view class="section">
<view class="title">昵称:</view> <view class="title">昵称:</view>
<input type="nickname" class="input" model:value="{{nickname}}" name="nickname" placeholder="昵称" /> <input type="nickname" class="input" name="nickname" placeholder="昵称" />
</view> </view>
<view class="section"> <view class="section">
<view class="title">性别:</view> <view class="title">性别:</view>
<radio-group class="mg" name="gender" bindchange="genderChange"> <radio-group class="mg" name="gender">
<label > <label >
<radio value="man" checked="{{gender == 'man'}}"/> <radio value="man" />
</label> </label>
<label > <label >
<radio value="woman" checked="{{gender == 'woman'}}"/> <radio value="woman" />
</label> </label>
</radio-group> </radio-group>
@ -31,26 +31,26 @@
<view class="section"> <view class="section">
<view class="title">年龄:</view> <view class="title">年龄:</view>
<picker bindchange="dateChange" fields="year" model:value="{{birthday}}" mode="date" class="input" name="birthday"> <picker bindchange="dateChange" fields="year" value="{{birthday}}" mode="date" class="input" name="birthday">
<view class="picker">出生年:{{birthday}}</view> <view class="picker">出生年:{{birthday}}</view>
</picker> </picker>
</view> </view>
<view class="section"> <view class="section">
<view class="title">地区:</view> <view class="title">地区:</view>
<picker bindchange="regionChange" model:value="{{region}}" mode="region" class="input" name="region"> <picker bindchange="regionChange" value="{{region}}" value="{{region}}"mode="region" class="input" name="region">
<view class="picker">当前选择:{{region}}</view> <view class="picker">当前选择:{{region}}</view>
</picker> </picker>
</view> </view>
<view class="section"> <view class="section">
<view class="title">可以添加到你的联系方式:</view> <view class="title">可以添加到你的联系方式:</view>
<input type="input" class="input" name="contact" model:value="{{contact}}" placeholder="请输入" /> <input type="input" class="input" name="contact" placeholder="请输入" />
</view> </view>
<view class="section"> <view class="section">
<view class="title">你的基本情况:</view> <view class="title">你的基本情况:</view>
<input type="input" class="input" name="information" model:value="{{information}}" placeholder="请输入" /> <input type="input" class="input" name="information" placeholder="请输入" />
</view> </view>
<view class="area"> <view class="area">

@ -68,10 +68,10 @@
"tabIndent": "insertSpaces", "tabIndent": "insertSpaces",
"tabSize": 2 "tabSize": 2
}, },
"appid": "wxa443f40488e954d4",
"libVersion": "2.14.1", "libVersion": "2.14.1",
"packOptions": { "packOptions": {
"ignore": [], "ignore": [],
"include": [] "include": []
}, }
"appid": "wxa443f40488e954d4"
} }

@ -51,10 +51,24 @@
"pathName": "pages/updateRecordSuccess/index", "pathName": "pages/updateRecordSuccess/index",
"query": "", "query": "",
"scene": null "scene": null
},
{
"name": "",
"pathName": "pages/Comments/Comments",
"query": "",
"launchMode": "default",
"scene": null
},
{
"name": "",
"pathName": "pages/Main/main",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }
}, },
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "miniProgram3" "projectname": "miniprogram"
} }
Loading…
Cancel
Save