小程序源码
This commit is contained in:
54
source/wx/xzs-student/pages/my/index/index.js
Normal file
54
source/wx/xzs-student/pages/my/index/index.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
spinShow: false,
|
||||
info: {}
|
||||
},
|
||||
|
||||
onLoad: function(options) {
|
||||
this.loadUserInfo()
|
||||
},
|
||||
loadUserInfo() {
|
||||
let _this = this
|
||||
_this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
app.formPost('/api/wx/student/user/current', null).then(res => {
|
||||
if (res.code == 1) {
|
||||
_this.setData({
|
||||
info: res.response
|
||||
});
|
||||
}
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
},
|
||||
logOut() {
|
||||
let _this = this
|
||||
_this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
app.formPost('/api/wx/student/auth/unBind', null).then(res => {
|
||||
if (res.code == 1) {
|
||||
wx.setStorageSync('token', '')
|
||||
wx.reLaunch({
|
||||
url: '/pages/user/bind/index',
|
||||
});
|
||||
}
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
}
|
||||
})
|
||||
9
source/wx/xzs-student/pages/my/index/index.json
Normal file
9
source/wx/xzs-student/pages/my/index/index.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-cell-group": "/component/iView/cell-group/index",
|
||||
"i-cell": "/component/iView/cell/index",
|
||||
"i-icon": "/component/iView/icon/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index"
|
||||
}
|
||||
}
|
||||
46
source/wx/xzs-student/pages/my/index/index.wxml
Normal file
46
source/wx/xzs-student/pages/my/index/index.wxml
Normal file
@@ -0,0 +1,46 @@
|
||||
<view class="userinfo">
|
||||
<block>
|
||||
<image class="userinfo-avatar" src="{{info.imagePath}}"></image>
|
||||
<text class="userinfo-nickname">{{info.userName}}</text>
|
||||
</block>
|
||||
</view>
|
||||
<view>
|
||||
<i-cell-group i-class="my-group-margin">
|
||||
<i-cell title="个人资料" is-link url="/pages/my/info/index">
|
||||
<i-icon type="mine_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
<i-cell title="个人动态" is-link url="/pages/my/log/index">
|
||||
<i-icon type="collection_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
<i-cell title="消息" is-link url="/pages/my/message/list/index">
|
||||
<i-icon type="message_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
</i-cell-group>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<i-cell-group i-class="my-group-margin">
|
||||
<i-cell title="设置" is-link url="/pages/dashboard/index">
|
||||
<i-icon type="setup_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
<i-cell title="反馈" is-link url="/pages/dashboard/index">
|
||||
<i-icon type="praise_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
<i-cell title="关于" is-link url="/pages/dashboard/index">
|
||||
<i-icon type="prompt_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
</i-cell-group>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<i-cell-group i-class="my-group-margin">
|
||||
<i-cell title="退出账号" bind:click="logOut">
|
||||
<i-icon type="flashlight_fill" slot="icon" size="20" />
|
||||
</i-cell>
|
||||
</i-cell-group>
|
||||
</view>
|
||||
|
||||
<view class="copyright">武汉思维跳跃科技有限公司 提供技术支持</view>
|
||||
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
32
source/wx/xzs-student/pages/my/index/index.wxss
Normal file
32
source/wx/xzs-student/pages/my/index/index.wxss
Normal file
@@ -0,0 +1,32 @@
|
||||
/**index.wxss**/
|
||||
|
||||
.userinfo {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
background: #598ce4;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.userinfo-avatar {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.userinfo-nickname {
|
||||
color: white;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
|
||||
.my-group-margin{
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.copyright{
|
||||
color: #8c8c8c;
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
68
source/wx/xzs-student/pages/my/info/index.js
Normal file
68
source/wx/xzs-student/pages/my/info/index.js
Normal file
@@ -0,0 +1,68 @@
|
||||
// pages/user/info/index.js
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
spinShow: false,
|
||||
levelIndex: 0
|
||||
},
|
||||
onLoad: function(options) {
|
||||
this.loadUserInfo()
|
||||
},
|
||||
loadUserInfo() {
|
||||
let _this = this
|
||||
_this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
app.formPost('/api/wx/student/user/current', null).then(res => {
|
||||
if (res.code == 1) {
|
||||
_this.setData({
|
||||
userInfo: res.response,
|
||||
levelIndex: res.response.userLevel-1
|
||||
});
|
||||
}
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
},
|
||||
bindLevelChange: function(e) {
|
||||
this.setData({
|
||||
levelIndex: e.detail.value
|
||||
})
|
||||
},
|
||||
bindDateChange(e) {
|
||||
let {
|
||||
value
|
||||
} = e.detail;
|
||||
this.setData({
|
||||
"userInfo.birthDay": value
|
||||
})
|
||||
},
|
||||
formSubmit: function(e) {
|
||||
let _this = this
|
||||
wx.showLoading({
|
||||
title: '提交中',
|
||||
mask: true
|
||||
})
|
||||
app.formPost('/api/wx/student/user/update', e.detail.value)
|
||||
.then(res => {
|
||||
if (res.code == 1) {
|
||||
wx.reLaunch({
|
||||
url: '/pages/my/index/index',
|
||||
});
|
||||
} else {
|
||||
app.message(res.message, 'error')
|
||||
}
|
||||
wx.hideLoading()
|
||||
}).catch(e => {
|
||||
app.message(e, 'error')
|
||||
wx.hideLoading()
|
||||
})
|
||||
}
|
||||
})
|
||||
11
source/wx/xzs-student/pages/my/info/index.json
Normal file
11
source/wx/xzs-student/pages/my/info/index.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-button": "/component/iView/button/index",
|
||||
"i-panel": "/component/iView/panel/index",
|
||||
"i-input": "/component/iView/input/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index",
|
||||
"i-radio-group": "/component/iView/radio-group/index",
|
||||
"i-radio": "/component/iView/radio/index"
|
||||
}
|
||||
}
|
||||
40
source/wx/xzs-student/pages/my/info/index.wxml
Normal file
40
source/wx/xzs-student/pages/my/info/index.wxml
Normal file
@@ -0,0 +1,40 @@
|
||||
<wxs module="enumItem" src="../../../wxs/enumItem.wxs"></wxs>
|
||||
|
||||
<form bindsubmit='formSubmit'>
|
||||
<i-panel title="真实姓名">
|
||||
<i-input value="{{ userInfo.realName }}" name="realName" maxlength="-1" />
|
||||
</i-panel>
|
||||
<i-panel title="年龄">
|
||||
<i-input value="{{ userInfo.age }}" name="age" maxlength="-1" />
|
||||
</i-panel>
|
||||
<i-panel title="性别">
|
||||
<radio-group class="radio-group my-info-sex" name="sex">
|
||||
<label class="radio my-info-sex-item" wx:for="{{ enumItem.state.user.sexEnum }}" wx:key="{{item.key}}" wx:for-item="radioItem">
|
||||
<radio color="#2d8cf0" value="{{radioItem.key}}" checked="{{radioItem.key===userInfo.sex}}" />
|
||||
<text>{{radioItem.value}}</text>
|
||||
</label>
|
||||
</radio-group>
|
||||
</i-panel>
|
||||
<i-panel title="出生日期">
|
||||
<picker class="weui-btn" mode="date" value="{{userInfo.birthDay}}" bindchange="bindDateChange">
|
||||
<view class="i-cell i-input exam-pick-input">{{ userInfo.birthDay }}</view>
|
||||
<i-input value="{{ userInfo.birthDay }}" class="exam-hidden" name="birthDay" maxlength="-1" />
|
||||
</picker>
|
||||
</i-panel>
|
||||
<i-panel title="手机">
|
||||
<i-input value="{{ userInfo.phone }}" name="phone" maxlength="-1" />
|
||||
</i-panel>
|
||||
<i-panel title="年级">
|
||||
<picker mode="selector" range="{{ enumItem.state.user.levelEnum }}" range-key="{{'value'}}" value="{{levelIndex}}" bindchange="bindLevelChange">
|
||||
<view class="i-cell i-input exam-pick-input">{{ enumItem.state.user.levelEnum[levelIndex].value }}</view>
|
||||
<i-input value="{{enumItem.state.user.levelEnum[levelIndex].key}}" maxlength="-1" name="userLevel" class="exam-hidden" />
|
||||
</picker>
|
||||
</i-panel>
|
||||
<view>
|
||||
<button class="i-btn i-btn- i-btn-primary i-btn-square" form-type='submit'>保存</button>
|
||||
</view>
|
||||
|
||||
</form>
|
||||
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
18
source/wx/xzs-student/pages/my/info/index.wxss
Normal file
18
source/wx/xzs-student/pages/my/info/index.wxss
Normal file
@@ -0,0 +1,18 @@
|
||||
.my-info-sex {
|
||||
height: 45px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.my-info-sex-item {
|
||||
line-height: 45px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.my-info-level {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.my-info-level-item {
|
||||
line-height: 45px;
|
||||
margin-left: 25px;
|
||||
}
|
||||
32
source/wx/xzs-student/pages/my/log/index.js
Normal file
32
source/wx/xzs-student/pages/my/log/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
logList: null,
|
||||
len: 0
|
||||
},
|
||||
onLoad: function(options) {
|
||||
this.search();
|
||||
},
|
||||
search: function() {
|
||||
let _this = this
|
||||
_this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
app.formPost('/api/wx/student/user/log', null).then(res => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
if (res.code === 1) {
|
||||
_this.setData({
|
||||
logList: res.response,
|
||||
len: res.response.length
|
||||
});
|
||||
}
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
}
|
||||
})
|
||||
9
source/wx/xzs-student/pages/my/log/index.json
Normal file
9
source/wx/xzs-student/pages/my/log/index.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-steps": "/component/iView/steps/index",
|
||||
"i-step": "/component/iView/step/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index",
|
||||
"i-panel": "/component/iView/panel/index"
|
||||
}
|
||||
}
|
||||
18
source/wx/xzs-student/pages/my/log/index.wxml
Normal file
18
source/wx/xzs-student/pages/my/log/index.wxml
Normal file
@@ -0,0 +1,18 @@
|
||||
<view class="user-log-page">
|
||||
<view wx:for="{{logList}}" data-item="item" wx:key="{{item.id}}" class="i-step-item i-step-process i-step-vertical" style="width : 100%;">
|
||||
<view class="i-step-item-ico">
|
||||
<view class="i-step-ico"></view>
|
||||
<view class="i-step-line" wx:if="{{ index !== len - 1 }}"></view>
|
||||
</view>
|
||||
<view class="i-step-item-main">
|
||||
<view class="i-step-item-title">
|
||||
{{item.createTime}}
|
||||
</view>
|
||||
<view class="i-step-item-content">
|
||||
{{item.content}}
|
||||
</view>
|
||||
</view>
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
</view>
|
||||
</view>
|
||||
24
source/wx/xzs-student/pages/my/log/index.wxss
Normal file
24
source/wx/xzs-student/pages/my/log/index.wxss
Normal file
@@ -0,0 +1,24 @@
|
||||
/* pages/user/log/index.wxss */
|
||||
@import '/component/iView/steps/index.wxss';
|
||||
@import '/component/iView/step/index.wxss';
|
||||
|
||||
.i-step-ico {
|
||||
background: #fff !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
.i-step-item-title {
|
||||
font-size: 12px;
|
||||
font-weight: 400 !important;
|
||||
}
|
||||
|
||||
.i-step-item-content {
|
||||
font-size: 12px;
|
||||
font-weight: 400 !important;
|
||||
}
|
||||
|
||||
.user-log-page {
|
||||
background: #fff;
|
||||
padding: 5px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
79
source/wx/xzs-student/pages/my/message/info/index.js
Normal file
79
source/wx/xzs-student/pages/my/message/info/index.js
Normal file
@@ -0,0 +1,79 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
message: null
|
||||
},
|
||||
|
||||
onLoad: function(options) {
|
||||
let msgId = options.id;
|
||||
let _this = this
|
||||
_this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
app.formPost('/api/wx/student/user/message/detail/' + msgId, null).then(res => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
if (res.code === 1) {
|
||||
_this.setData({
|
||||
message: res.response,
|
||||
});
|
||||
app.formPost('/api/wx/student/user/message/read/' + msgId, null);
|
||||
}
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
|
||||
}
|
||||
})
|
||||
7
source/wx/xzs-student/pages/my/message/info/index.json
Normal file
7
source/wx/xzs-student/pages/my/message/info/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-panel": "/component/iView/panel/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index"
|
||||
}
|
||||
}
|
||||
19
source/wx/xzs-student/pages/my/message/info/index.wxml
Normal file
19
source/wx/xzs-student/pages/my/message/info/index.wxml
Normal file
@@ -0,0 +1,19 @@
|
||||
<view class="msg-page">
|
||||
<view class="msg-title">
|
||||
<h1>{{message.title}}</h1>
|
||||
</view>
|
||||
<view>
|
||||
<view class="msg-content">
|
||||
<h1>发送人:{{message.sendUserName}}</h1>
|
||||
</view>
|
||||
<view class="msg-content">
|
||||
<h1>发送时间:{{message.createTime}}</h1>
|
||||
</view>
|
||||
<view class="msg-content">
|
||||
<h1>发送内容:{{message.content}}</h1>
|
||||
</view>
|
||||
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
</view>
|
||||
</view>
|
||||
16
source/wx/xzs-student/pages/my/message/info/index.wxss
Normal file
16
source/wx/xzs-student/pages/my/message/info/index.wxss
Normal file
@@ -0,0 +1,16 @@
|
||||
.msg-page {
|
||||
background: white;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 10px 0px;
|
||||
}
|
||||
|
||||
.msg-title {
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.msg-content {
|
||||
padding: 8px 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
72
source/wx/xzs-student/pages/my/message/list/index.js
Normal file
72
source/wx/xzs-student/pages/my/message/list/index.js
Normal file
@@ -0,0 +1,72 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
spinShow: false,
|
||||
loadMoreLoad: false,
|
||||
loadMoreTip: '暂无数据',
|
||||
queryParam: {
|
||||
pageIndex: 1,
|
||||
pageSize: app.globalData.pageSize
|
||||
},
|
||||
tableData: [],
|
||||
total: 1
|
||||
},
|
||||
onLoad: function(options) {
|
||||
this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
this.search(true);
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
this.setData({
|
||||
spinShow: true
|
||||
});
|
||||
if (!this.loading) {
|
||||
this.setData({
|
||||
['queryParam.pageIndex']: 1
|
||||
});
|
||||
this.search(true)
|
||||
}
|
||||
},
|
||||
onReachBottom() {
|
||||
if (!this.loading && this.data.queryParam.pageIndex < this.data.total) {
|
||||
this.setData({
|
||||
loadMoreLoad: true,
|
||||
loadMoreTip: '正在加载'
|
||||
});
|
||||
this.setData({
|
||||
['queryParam.pageIndex']: this.data.queryParam.pageIndex + 1
|
||||
});
|
||||
this.search(false)
|
||||
}
|
||||
},
|
||||
search: function(override) {
|
||||
let _this = this
|
||||
app.formPost('/api/wx/student/user/message/page', this.data.queryParam).then(res => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
wx.stopPullDownRefresh()
|
||||
if (res.code === 1) {
|
||||
const re = res.response
|
||||
_this.setData({
|
||||
['queryParam.pageIndex']: re.pageNum,
|
||||
tableData: override ? re.list : this.data.tableData.concat(re.list),
|
||||
total: re.pages
|
||||
});
|
||||
|
||||
if (re.pageNum >= re.pages) {
|
||||
this.setData({
|
||||
loadMoreLoad: false,
|
||||
loadMoreTip: '暂无数据'
|
||||
});
|
||||
}
|
||||
}
|
||||
}).catch(e => {
|
||||
_this.setData({
|
||||
spinShow: false
|
||||
});
|
||||
app.message(e, 'error')
|
||||
})
|
||||
}
|
||||
})
|
||||
10
source/wx/xzs-student/pages/my/message/list/index.json
Normal file
10
source/wx/xzs-student/pages/my/message/list/index.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"i-cell-group": "/component/iView/cell-group/index",
|
||||
"i-cell": "/component/iView/cell/index",
|
||||
"i-load-more": "/component/iView/load-more/index",
|
||||
"i-message": "/component/iView/message/index",
|
||||
"i-spin": "/component/iView/spin/index"
|
||||
},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
10
source/wx/xzs-student/pages/my/message/list/index.wxml
Normal file
10
source/wx/xzs-student/pages/my/message/list/index.wxml
Normal file
@@ -0,0 +1,10 @@
|
||||
<wxs module="enumItem" src="../../../../wxs/enumItem.wxs"></wxs>
|
||||
<view>
|
||||
<i-cell-group>
|
||||
<i-cell wx:for="{{tableData}}" data-item="item" label="{{item.content}}" wx:key="{{item.id}}" url="/pages/my/message/info/index?id={{item.id}}" title="{{item.title}}" lable="{{item.content}}" is-link value="{{enumItem.format(enumItem.state.user.message.readText,item.readed)}}"></i-cell>
|
||||
</i-cell-group>
|
||||
</view>
|
||||
|
||||
<i-load-more tip="{{loadMoreTip}}" loading="{{loadMoreLoad}}" />
|
||||
<i-spin size="large" fix wx:if="{{ spinShow }}"></i-spin>
|
||||
<i-message id="message" />
|
||||
1
source/wx/xzs-student/pages/my/message/list/index.wxss
Normal file
1
source/wx/xzs-student/pages/my/message/list/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
/* pages/user/message/index.wxss */
|
||||
Reference in New Issue
Block a user