提交 d4406440 authored 作者: 王鹏飞's avatar 王鹏飞

修复修改密码成功没有提示的问题;修复消息已读未读状态错误的问题;

上级 de0d539f
......@@ -4,14 +4,14 @@ const util = require('../utils/util.js')
*/
/* 获取我的消息信息 */
const getMyMsg = (callback) => {
const getMyMsg = callback => {
util.requestApi({
url: util.config.URL_PATH1 + '/v2/education/message/my',
callback: function (res) {
let list = Array.isArray(res.data) ? res.data : res.data.list || []
let json = list.map(function (_, i) {
return {
isRead: false,
isRead: _.status === 1,
id: _.id,
text: _.message_body,
time: _.created_time,
......@@ -22,6 +22,17 @@ const getMyMsg = (callback) => {
}
})
}
// 读消息
const readMessage = (messageId, callback) => {
util.requestApi({
url: util.config.URL_PATH1 + `/v2/education/message/${messageId}`,
method: 'POST',
callback: function (res) {
callback(res.data)
}
})
}
module.exports = {
getMyMsg: getMyMsg
getMyMsg: getMyMsg,
readMessage
}
......@@ -21,7 +21,7 @@ Page({
*/
onLoad: function (options) {
wx.showLoading({ title: '页面加载中...', mask: true })
MsgApi.getMyMsg((json) => {
MsgApi.getMyMsg(json => {
this.setData({ msgList: json })
wx.hideLoading()
})
......@@ -49,7 +49,7 @@ Page({
// 显示顶部刷新图标
wx.showNavigationBarLoading()
wx.showLoading({ title: '更新中...', mask: true })
MsgApi.getMyMsg((json) => {
MsgApi.getMyMsg(json => {
this.setData({ msgList: json.list })
wx.hideLoading()
// 隐藏导航栏加载框
......@@ -70,10 +70,14 @@ Page({
* 是否可以打开查看消息
*/
canishow: function (e) {
let i = e.currentTarget.dataset.index
const { index: i, id } = e.currentTarget.dataset
let cname = 'msgList[' + i + '].isShow'
this.setData({ [cname]: !this.data.msgList[i].isShow })
cname = 'msgList[' + i + '].isRead'
!this.data.msgList[i].isRead &&
MsgApi.readMessage(id, res => {
console.log(res)
})
this.setData({ [cname]: true })
/* 如果需要,再调用已读接口 */
},
......@@ -81,7 +85,6 @@ Page({
* 滚动到底部,加载更多数据
*/
loadmore: function () {
let _that = this
wx.showLoading({ title: '数据加载中...', mask: true })
setTimeout(function () {
wx.showToast({ title: '没有更多了', icon: 'none' })
......
<!--pages/learnSystem/message/message.wxml-->
<scroll-view class='msg-scroll' scroll-y bindscrolltolower="loadmore">
<block wx:for='{{msgList}}' wx:key='{{index}}'>
<view class='item-msg' bindtap='canishow' data-index='{{index}}'>
<view class='item-msg' bindtap='canishow' data-index='{{index}}' data-id="{{item.id}}">
<view class='flag {{item.isRead ? "read" : ""}}'>{{item.isRead ? '已读' : 'new'}}</view>
<rich-text class='text {{item.isShow ? "" : "on"}}' nodes="{{item.text}}"></rich-text>
<view class='ellipsis {{item.isShow ? "on" : ""}}'>....</view>
......
......@@ -36,16 +36,22 @@ Page({
},
// 修改成功
handleSuccess(data) {
wx.setStorage({ key: 'token', data: data.TGC })
wx.switchTab({ url: '/pages/learnSystem/home/home' })
wx.showModal({
content: '密码修改成功',
showCancel: false,
confirmText: '去登录',
success(res) {
wx.navigateTo({ url: '/pages/login/index' })
}
})
},
// 发送验证码
handleSendCode() {
if (this.data.disabled) {
return
}
if (!/^1[3-9][0-9]{9}$/.test(this.data.account)) {
wx.showToast({ title: '请输入手机号', icon: 'none' })
if (!(/^1[3-9]\d{9}$/.test(this.data.account) || /@/.test(this.data.account))) {
wx.showToast({ title: '请输入邮箱或手机号', icon: 'none' })
return
}
this.handleSendCodeRequest()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论