Browse Source

增加积分管理模块

release
ZhaoTongYao 4 years ago
parent
commit
022a3adb0b
  1. 41
      api/pointManagement.js
  2. BIN
      subpages/pointManagement/images/point-back.png
  3. 99
      subpages/pointManagement/pages/pointClear/pointClear.js
  4. 7
      subpages/pointManagement/pages/pointClear/pointClear.json
  5. 33
      subpages/pointManagement/pages/pointClear/pointClear.wxml
  6. 125
      subpages/pointManagement/pages/pointClear/pointClear.wxss
  7. 240
      subpages/pointManagement/pages/pointList/pointList.js
  8. 9
      subpages/pointManagement/pages/pointList/pointList.json
  9. 59
      subpages/pointManagement/pages/pointList/pointList.wxml
  10. 202
      subpages/pointManagement/pages/pointList/pointList.wxss

41
api/pointManagement.js

@ -0,0 +1,41 @@
var fly = require('../utils/request.js')
/**
* @param userId 用户ID
* @param operationType 积分操作类型 0-减积分1-加积分
* @param points 操作积分值
*/
// 积分核销接口
export function pointSverification(params) {
return fly.post('work/pointsverification/pointsverification', params)
}
/**
* @param typeKey 网格grid_party
*/
// 根据机构类型获取机构信息
export function getDeptInfo(typeKey) {
return fly.get(`work/pointsverification/getdeptinfo/${typeKey}`)
}
/**
* 工作端积分核销记录接口
* @param pageIndex Number 页码
* @param pageSize Number 页容量
* @param startTime 开始时间
* @param endTime 结束时间
* @param deptId 部门ID
*/
export function getVerificationLogs({
pageIndex,
pageSize,
startTime,
endTime,
deptId,
}) {
return fly.get("work/pointsverification/verificationlogs", {
pageIndex,
pageSize,
startTime,
endTime,
deptId,
})
}

BIN
subpages/pointManagement/images/point-back.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

99
subpages/pointManagement/pages/pointClear/pointClear.js

@ -0,0 +1,99 @@
import {
pointSverification
} from '../../../../api/pointManagement.js'
let util = require('../../../../utils/util.js')
Page({
data: {
peopleNum: 0,
faceImg: '', //用户头像
points: 0, //用户积分
realName: '', //用户真实姓名
userId: "", //用户ID
operationType: 0,
remark: "",
isFlag: true, //按钮防点击
},
onLoad: function (options) {
this.setData({
faceImg: options.faceImg, //用户头像
points: options.points, //用户积分
realName: options.realName, //用户真实姓名
userId: options.userId, //用户ID
})
},
onChange(e) {
this.setData({
peopleNum: e.detail.value,
})
},
pointSverification() {
if (!this.data.isFlag) return
if (this.data.peopleNum == 0) {
wx.showToast({
icon: 'none',
title: '操作积分值必须大于0',
duration: 1000,
})
return
}
if (this.data.peopleNum > parseInt(this.data.points)) {
wx.showToast({
icon: 'none',
title: '用户积分不足',
duration: 2000,
})
return
}
if (this.data.remark == '') {
wx.showToast({
icon: 'none',
title: '请输入核销说明',
duration: 1000,
})
return
}
this.setData({
isFlag: false
})
/**
* @param userId 用户ID
* @param operationType 积分操作类型 0-减积分1-加积分
* @param points 操作积分值
*/
let para = {
userId: this.data.userId,
operationType: this.data.operationType,
points: this.data.peopleNum,
remark: this.data.remark
}
pointSverification(para).then((res) => {
wx.showModal({
title: '',
content: '操作成功',
showCancel: false,
success: (res) => {
if (res.confirm) {
this.setData({
isFlag: true
})
wx.navigateBack({
delta: 1
})
}
}
})
}).catch((err) => {
this.setData({
isFlag: true
})
})
},
// 双向绑定 内容输入框
bindTextareaInput(e) {
this.setData({
remark: e.detail.value.trim()
})
},
})

7
subpages/pointManagement/pages/pointClear/pointClear.json

@ -0,0 +1,7 @@
{
"usingComponents": {
"wux-cell": "../../../../dist/cell/index",
"wux-input-number": "../../../../dist/input-number/index"
},
"navigationBarTitleText": "积分核销"
}

33
subpages/pointManagement/pages/pointClear/pointClear.wxml

@ -0,0 +1,33 @@
<view class="point-clear">
<view class="clear-header">
<image class="clear-header-bac" src="../../images/point-back.png"></image>
<view class="info">
<view class="info-left">
<image class="" src="{{faceImg}}"></image>
<text class="">{{realName}}</text>
</view>
<view class="info-right">
<text class="info-right-text">剩余积分</text>
<text class="" style="text-align:center">{{points}}</text>
</view>
</view>
</view>
<view class="clear-content">
<view class="cleaar-num">
<text class="">本次核销积分</text>
<wux-input-number color="assertive" controlled="{{true}}" step="{{ 1 }}" disabled="{{ false }}" default-value="{{peopleNum}}" value="{{ peopleNum }}" min="{{ 0 }}" slot="footer" bind:change="onChange" bind:focus="onfocusNumber" />
</view>
</view>
<view class="clear-content-textarea">
<textarea maxlength="10" value="{{remark}}" bindinput="bindTextareaInput">
<view class="textarea-placeholder" style="display: {{remark ? 'none': 'block'}}">
<view>核销说明(10个字以内)</view>
</view>
</textarea>
</view>
<view class="button-footer">
<view class="footer" bind:tap="pointSverification">
<text class="">提交</text>
</view>
</view>
</view>

125
subpages/pointManagement/pages/pointClear/pointClear.wxss

File diff suppressed because one or more lines are too long

240
subpages/pointManagement/pages/pointList/pointList.js

@ -0,0 +1,240 @@
import {
$wuxSelect
} from '../../../../dist/index'
import {
getDeptInfo,
getVerificationLogs
} from '../../../../api/pointManagement.js'
let util = require('../../../../utils/util.js')
Page({
data: {
visibleTimeLeft: false,
visibleTimeRight: false,
/****时间选择器 *****/
value1: [],
value2: [],
value3: "",
displayValue1: '请选择开始时间',
displayValue2: '请选择截至时间',
displayValue3: '请选择所属网格',
optionsGrid: [],
valueRight: [],
lang: 'zh_CN',
typeKey: "grid_party",
pageIndex: 1,
pageSize: 15,
startTime: "",
endTime: "",
deptId: '',
pointList: [],
loadMoreVisible: false, //false
loadMoreType: "none",
nodata: false,
pointsTotal: 0,
optionsGridOrgin: [],
},
onLoad: function (options) {
this.getDeptInfo()
this.getVerificationLogs()
console.log('当天时间', util.getData())
this.setData({
value1: util.getData().split('-'),
value2: util.getData().split('-'),
})
},
selectTapLeft() {
this.setData({
visibleTimeLeft: true,
});
},
selectTapRight() {
this.setData({
visibleTimeRight: true,
});
},
selectTapGrid() {
wx.showLoading({
duration: 2000
})
$wuxSelect('#wux-select1').open({
options: this.data.optionsGrid,
onConfirm: (value, index, options) => {
console.log('onConfirm', value, index, options)
if (index !== -1) {
this.setData({
value3: value,
displayValue3: options[index],
})
}
this.setData({
deptId: this.data.optionsGridOrgin[index].id,
pointList: [],
pageIndex: 1
})
this.getVerificationLogs()
},
})
},
setValue(values, key) {
this.setData({
[`value${key}`]: values.value,
[`displayValue${key}`]: values.label,
// [`displayValue${key}`]: values.displayValue.join(' '),
})
},
onConfirmLeft(e) {
const {
mode
} = e.currentTarget.dataset
this.setValue(e.detail, mode)
this.setData({
pageIndex: 1,
visibleTimeLeft: false,
pointList: [],
startTime: this.data.displayValue1
})
this.getVerificationLogs()
},
onConfirmRight(e) {
const {
mode
} = e.currentTarget.dataset
this.setValue(e.detail, mode)
this.setData({
pageIndex: 1,
visibleTimeRight: false,
pointList: [],
endTime: this.data.displayValue2
})
this.getVerificationLogs()
},
cancelTimeLeft() {
this.setData({
visibleTimeLeft: false,
})
},
cancelTimeRight() {
this.setData({
visibleTimeRight: false,
})
},
clearValue1() {
this.setData({
startTime: '',
displayValue1: "请选择开始时间",
pointList: [],
value1: util.getData().split('-'),
})
this.getVerificationLogs()
},
clearValue2() {
this.setData({
endTime: '',
displayValue2: "请选择截至时间",
pointList: [],
value2: util.getData().split('-'),
})
this.getVerificationLogs()
},
clearValue3() {
this.setData({
deptId: '',
displayValue3: '请选择所属网格',
pointList: [],
})
this.getVerificationLogs()
},
// 所属网格
getDeptInfo() {
getDeptInfo(this.data.typeKey).then((res) => {
console.log('所属网格', res)
let optionsGrid = []
res.data.forEach((item) => {
optionsGrid.push(item.name)
})
this.setData({
optionsGrid,
optionsGridOrgin: res.data
})
}).catch((err) => {})
},
// 工作端积分核销记录接口
// 获取居民兑换记录接口
getVerificationLogs() {
// 判断时间问题
// let startTime = 0
// let endTime = 0
// this.data.value1.forEach((item) => {
// startTime += Number(item)
// })
// this.data.value2.forEach((item) => {
// endTime += Number(item)
// })
// if (startTime > endTime) {
// wx.showToast({
// icon: 'none',
// title: '开始时间不能晚于截止时间',
// duration: 1500,
// })
// return
// } else if (startTime < endTime) {
// this.setData({
// pointList: [],
// })
// }
/**
* 工作端积分核销记录接口
* @param pageIndex Number 页码
* @param pageSize Number 页容量
* @param startTime 开始时间
* @param endTime 结束时间
* @param deptId 部门ID
*/
let para = {
pageIndex: this.data.pageIndex,
pageSize: this.data.pageSize,
startTime: this.data.startTime,
endTime: this.data.endTime,
deptId: this.data.deptId
}
this.setData({
loadMoreVisible: true,
nodata: false,
loadMoreType: "loading",
})
getVerificationLogs(para).then((res) => {
this.setData({
// loadMoreVisible: false,
loadMoreType: res.data.verificationLogs.length === this.data.pageSize ? 'loading' : 'none',
pointList: this.data.pointList.concat(res.data.verificationLogs),
pointsTotal: res.data.pointsTotal
})
if (this.data.pointList.length == 0) {
this.setData({
loadMoreVisible: false,
nodata: true
})
}
}).catch(() => {
this.setData({
loadMoreVisible: false,
nodata: true,
})
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
console.log('下拉了')
if (this.data.loadMoreType === 'loading') {
this.setData({
loadMoreVisible: true,
})
this.data.pageIndex += 1
this.getVerificationLogs()
}
},
})

9
subpages/pointManagement/pages/pointList/pointList.json

@ -0,0 +1,9 @@
{
"usingComponents": {
"wux-date-picker": "../../../../dist/date-picker/index",
"wux-select": "../../../../dist/select/index",
"load-more": "../../../../components/loadMore/loadMore",
"no-data": "../../../../components/nodata/nodata"
},
"navigationBarTitleText": "核销记录"
}

59
subpages/pointManagement/pages/pointList/pointList.wxml

@ -0,0 +1,59 @@
<view class="point-list-box">
<view class="select-time">
<text class="select-time1">时间</text>
<view class='select_box'>
<view class='select' bind:tap='selectTapLeft'>
<text class='select_text'>{{displayValue1}}</text>
<image class='select_img image' src='../../../images/clear-icon.png' catch:tap="clearValue1"></image>
</view>
</view>
<text class="select-and">至</text>
<view class='select_box'>
<view class='select' bind:tap='selectTapRight'>
<text class='select_text'>{{displayValue2}}</text>
<image class='select_img image' src='../../../images/clear-icon.png' catch:tap="clearValue2"></image>
</view>
</view>
<wux-date-picker visible="{{visibleTimeLeft}}" controlled mode="date" value="{{ value1 }}" lang="{{ lang }}" data-mode="1" bind:confirm="onConfirmLeft" bind:cancel="cancelTimeLeft"></wux-date-picker>
<wux-date-picker visible="{{visibleTimeRight}}" controlled mode="date" value="{{ value2 }}" lang="{{ lang }}" data-mode="2" bind:confirm="onConfirmRight" bind:cancel="cancelTimeRight"></wux-date-picker>
</view>
<view style="background:#f7f7f7;height:20rpx"></view>
<view class="point-content">
<view class="content-grid">
<text class="">所属网格</text>
<view class='select_box' style="width:550rpx">
<view class='select' bind:tap='selectTapGrid'>
<text class='select_text'>{{displayValue3}}</text>
<image class='select_img image' src='../../../images/clear-icon.png' catch:tap="clearValue3"></image>
</view>
</view>
<wux-select id="wux-select1" />
</view>
<view class="exchange-time">
<view class="time-title">
<text class="" style="margin-left:32rpx">用户</text>
<text class="" style="margin-left:148rpx">兑换时间</text>
<text class="" style="margin-left:140rpx">核销说明</text>
<text class="" style="margin-left:70rpx">积分</text>
<!-- <text class="">用户</text>
<text class="">兑换时间</text>
<text class="">核销说明</text>
<text class="">积分</text> -->
</view>
<view class="time-item-box">
<view class="time-item" wx:for="{{pointList}}" wx:key="index">
<text class="time-item-name">{{item.realName}}</text>
<text class="time-item-time">{{item.operationTime}}</text>
<text class="time-item-remark">{{item.remark?item.remark:'暂无核销记录说明'}}</text>
<text class="time-item-num">{{item.operationType==='1'? '+':'-'}}{{item.points}}</text>
</view>
</view>
</view>
<load-more loadMoreVisible="{{loadMoreVisible}}" loadMoreType="{{loadMoreType}}" load-more-child='load-more-exchange'></load-more>
</view>
<no-data isShow="{{nodata}}" wx:if="{{nodata}}"></no-data>
<view class="point-footer">
<text class="point-footer-text">核销总积分:</text>
<text class="point-footer-num">{{pointsTotal}}</text>
</view>
</view>

202
subpages/pointManagement/pages/pointList/pointList.wxss

@ -0,0 +1,202 @@
page {
background: #fff;
}
.point-list-box {
box-sizing: border-box;
height: auto;
width: 100%;
}
.select-time {
box-sizing: border-box;
height: 100rpx;
width: 100%;
background: #fff;
display: flex;
align-items: center;
padding: 20rpx;
}
.select-time1 {
color: #333;
font-size: 32rpx;
}
.seleted {
width: 100%;
height: 194rpx;
box-sizing: border-box;
background: #fff;
/* overflow: hidden; */
}
.select_box {
background: #fff;
width: 280rpx;
height: 64rpx;
margin: 0 auto;
}
.select {
box-sizing: border-box;
width: 100%;
height: 58rpx;
border: 1px solid #efefef;
border-radius: 8rpx;
display: flex;
align-items: center;
padding: 0 15rpx;
background: #F4F4F4;
}
.select_text {
font-size: 24rpx;
flex: 1;
color: #BABABA;
}
.select_img {
width: 40rpx;
height: 40rpx;
display: block;
transition: transform 0.3s;
}
.select_img_rotate {
transform: rotate(180deg);
}
.option_box {
position: absolute;
top: 58rpx;
left: 20rpx;
width: 661rpx;
/* border: 1px solid #efefef; */
box-sizing: border-box;
height: 0;
overflow-y: auto;
border-top: 0;
background: #fff;
transition: height 0.3s;
z-index: 999;
}
.option {
display: block;
line-height: 40rpx;
font-size: 30rpx;
border-bottom: 1px solid #efefef;
padding: 10rpx;
margin-left: 10rpx;
color: #BABABA;
}
.image {
width: 28rpx;
height: 28rpx;
}
.select-and {
color: #666;
font-size: 30rpx;
}
/* 下来框样式结束 */
.point-content {
box-sizing: border-box;
width: 100%;
height: auto;
background: #fff;
/* margin-top: 20rpx; */
padding: 20rpx;
}
.content-grid {
display: flex;
font-size: 32rpx;
color: #333;
}
.exchange-time .time-title {
box-sizing: border-box;
width: 100%;
font-weight: bold;
font-size: 26rpx;
color: #151515;
margin-top: 30rpx;
/* display: flex;
justify-content: space-between; */
}
.exchange-time .time-item-box .time-item {
box-sizing: border-box;
width: 100%;
display: flex;
/* justify-content: space-between; */
font-size: 26rpx;
margin-top: 50rpx;
}
.exchange-time .time-item-box .time-item .time-item-name {
width: 20%;
color: #151515;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-right: 20rpx;
}
.exchange-time .time-item-box .time-item .time-item-time {
color: #151515;
margin-right: 20rpx;
}
.exchange-time .time-item-box .time-item .time-item-remark {
width: 25%;
color: #151515;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-right: 10rpx;
}
.exchange-time .time-item-box .time-item .time-item-num {
width: 10%;
color: #D60000;
text-align: center;
}
.point-footer {
box-sizing: border-box;
width: 100%;
display: flex;
/* justify-content: right; */
justify-content: flex-end;
align-items: center;
position: fixed;
bottom: 0rpx;
z-index: 3;
padding: 20rpx;
border-radius: 10rpx;
background: #f6f6f6;
}
.point-footer-text {
font-weight: bold;
color: #333;
font-size: 32rpx;
}
.point-footer-num {
font-weight: bold;
color: #D60000;
font-size: 34rpx;
}
.load-more-exchange {
background: #fff !important;
margin-bottom: 100rpx !important;
}
Loading…
Cancel
Save