소스 검색

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
乐豆明细对接

1004749546@qq.com 4 년 전
부모
커밋
e5f7456c71
5개의 변경된 파일174개의 추가작업 그리고 60개의 파일을 삭제
  1. 9 0
      api/user.js
  2. 85 0
      libs/getDate.js
  3. 5 0
      package-lock.json
  4. 1 0
      package.json
  5. 74 60
      pages/userCenter/ldDetailed.vue

+ 9 - 0
api/user.js

@@ -130,4 +130,13 @@ export const getMessage = params => {
     data: params,
     method: 'post'
   })
+}
+// 乐豆使用明细
+export const ldUsedQuery = params => { 
+  let url = `customerGoldLog/queryByMonth`
+  return axios.request({
+    url: url,
+    data: params,
+    method: 'post'
+  })
 }

+ 85 - 0
libs/getDate.js

@@ -0,0 +1,85 @@
+// 引入 moment 时间插件
+import moment from 'moment'
+// 获取今日/昨日/本周/上周/本月/上月 时间
+export default {
+  // 获取今日的开始结束时间
+  getToday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().startOf('day').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取昨日的开始结束时间
+  getYesterday () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().add(-1, 'days').startOf('day').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().add(-1, 'days').endOf('day').valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取当前周的开始到当天结束时间
+  getCurrWeekDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().week(moment().week()).startOf('week').add('days').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取上一周的开始结束时间
+  getLastWeekDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().week(moment().week() - 1).startOf('week').add('days').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().week(moment().week() - 1).endOf('week').add('days').valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取当前月的开始到当天结束时间
+  getCurrMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month()).startOf('month').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取上一个月的开始结束时间
+  getLastMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 1).startOf('month').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().month(moment().month() - 1).endOf('month').valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取上2个月的开始结束时间
+  getLastTwoMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 2).startOf('month').valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().month(moment().month() - 2).endOf('month').valueOf()).format('YYYY-MM-DD')
+    return obj
+  },
+  // 获取3个月前到今天的开始结束时间
+  getThreeMonthDays () {
+    const obj = {
+      starttime: '',
+      endtime: ''
+    }
+    obj.starttime = moment(moment().month(moment().month() - 3).valueOf()).format('YYYY-MM-DD')
+    obj.endtime = moment(moment().valueOf()).format('YYYY-MM-DD')
+    return obj
+  }
+}

+ 5 - 0
package-lock.json

@@ -4,6 +4,11 @@
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
+    "moment": {
+      "version": "2.29.1",
+      "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
+      "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
+    },
     "uview-ui": {
       "version": "1.7.8",
       "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.7.8.tgz",

+ 1 - 0
package.json

@@ -14,6 +14,7 @@
   "author": "",
   "license": "ISC",
   "dependencies": {
+    "moment": "^2.29.1",
     "uview-ui": "^1.7.7"
   }
 }

+ 74 - 60
pages/userCenter/ldDetailed.vue

@@ -2,22 +2,25 @@
 	<view class="ldDetailed-container">
 		<!-- 筛选菜单 -->
 		<u-dropdown ref="uDropdown" class="filter-dropdown">
-			<u-dropdown-item v-model="queryParam.recordType" :title="titType" :options="optionsType" @change="searchHandle(1)"></u-dropdown-item>
-			<u-dropdown-item v-model="queryParam.recordScope" :title="titScope" :options="optionsScope" @change="searchHandle(1)"></u-dropdown-item>
+			<u-dropdown-item v-model="queryParam.changeType" :title="titType" :options="optionsType" @change="searchHandle()"></u-dropdown-item>
+			<u-dropdown-item v-model="timeScope" :title="titScope" :options="optionsScope" @change="searchHandle()"></u-dropdown-item>
 		</u-dropdown>
 		<scroll-view class="scroll-con" scroll-y @scrolltolower="onreachBottom">
 			<!-- 列表数据 -->
 			<view class="cell-item-con">
 				<view class="cell-item" v-for="(item, index) in listdata" :key="index">
-					<text class="cell-item-month">{{item.month}}</text>
-					<view class="cell-item-main" v-for="(subItem, ind) in item.list" :key="ind">
-						<text :class="['cell-item-pic', subItem.type == 1?'orange':'']">{{subItem.type == 1 ? '收' : '支'}}</text>
+					<text class="cell-item-month" v-if="timeScope == 'threeMonth'">{{item.month}}</text>
+					<view class="cell-item-main" v-for="(subItem, ind) in item.monthDataList" :key="ind">
+						<text :class="['cell-item-pic', subItem.changeType == 'ADD'?'orange':'']">{{subItem.changeType == 'ADD' ? '收' : '支'}}</text>
 						<view class="cell-item-c">
-							<text class="cell-item-des">{{subItem.dec}}</text>
-							<text class="cell-item-date">{{subItem.creatDate}}</text>
+							<text class="cell-item-des">{{subItem.remarks}}</text>
+							<text class="cell-item-date">{{subItem.createDate}}</text>
 						</view>
-						<text :class="['cell-item-score', Number(subItem.score) > 0 ? 'red' : 'black']">{{Number(subItem.score)>0 ? '+'+subItem.score : subItem.score}}</text>
+						<text :class="['cell-item-score', subItem.changeType == 'ADD' ? 'red' : 'black']">
+						{{subItem.changeType == 'ADD' ? '+'+subItem.changeNum : subItem.changeNum}}
+						</text>
 					</view>
+					<u-empty class="nodata" :text="noDataText" v-if="item.monthDataList.length==0 && status!='loading'" mode="list"></u-empty>
 				</view>
 			</view>
 			<u-empty class="nodata" :text="noDataText" v-if="listdata.length==0 && status!='loading'" mode="list"></u-empty>
@@ -29,92 +32,98 @@
 </template>
 
 <script>
+	import {ldUsedQuery} from '@/api/user.js'
+	import getDate from '@/libs/getDate'
+	import moment from 'moment'
 	export default {
 		data() {
 			return {
-				listdata: [
-					{
-						month: '本月',
-						list: [
-							{ type: 1, dec: '投递可回收物获得乐豆', creatDate: '2020-11-04 14:08', score: +25 },
-							{ type: 2, dec: '投递可回收物获得乐豆', creatDate: '2020-11-04 14:08', score: -30 },
-							{ type: 3, dec: '投递可回收物获得乐豆', creatDate: '2020-11-04 14:08', score: -15 },
-						]
-					},
-					{
-						month: '10月',
-						list: [
-							{ type: 1, dec: '投递可回收物获得乐豆', creatDate: '2020-11-04 14:08', score: +25 },
-							{ type: 2, dec: '投递可回收物获得乐豆', creatDate: '2020-11-04 14:08', score: -30 },
-							{ type: 3, dec: '投递可回收物获得乐豆', creatDate: '2020-11-04 14:08', score: -15 },
-						]
-					}
-				],
+				listdata: [],
 				pageNo: 1,  //  当前页码
 				pageSize: 10,  //  每页条数
 				total: 0,  //  数据总条数
 				noDataText: '暂无数据',  //  列表请求状态提示语
 				status: 'loadmore',  //  加载中状态
+				timeScope: 'threeMonth', // 时间类别 1:近三个月 2:本月 3:本月前一月 4:本月前2月
 				queryParam: {  //  过滤条件
-					recordType: '',
-					recordScope: ''
+					changeType: '', // 金币变更类型
 				},
 				optionsType: [
-					{ label: '所有记录', value: 1, },
-					{ label: '获取记录', value: 2, },
-					{ label: '使用记录', value: 3, }
+					{ label: '所有记录', value: '', },
+					{ label: '获取记录', value: 'ADD', },
+					{ label: '使用记录', value: 'SUB', }
 				]
 			}
 		},
 		onShow() {
-			this.searchHandle(1)
+			this.searchHandle()
 		},
 		onLoad() {
+			this.timeScope = 'threeMonth'
+			this.queryParam.changeType = ''
 		},
 		computed: {
+			// 时间过滤条件
 			optionsScope(){  //  过滤条件  近3个月
 				let arr = [
-					{ label: '近3个月', value: 1 },
-					{ label: '本月', value: 2 }
+					{ label: '近3个月', value: 'threeMonth' },
+					{ label: '本月', value: 'thisMonth' }
 				]
-				arr[2] = { label: new Date().getMonth() + '月', value: 3 }
-				arr[3] = { label: new Date().getMonth()-1 + '月', value: 4 }
+				arr[2] = { label: new Date().getMonth() + '月', value: 'lastMonth' }
+				arr[3] = { label: new Date().getMonth()-1 + '月', value: 'lastTwoMonth' }
 				return arr
 			},
 			titType(){  //  过滤条件 所有记录 title
-				const row = this.optionsType.find(item => item.value == this.queryParam.recordType)
+				const row = this.optionsType.find(item => item.value == this.queryParam.changeType)
 				return row ? row.label : this.optionsType[0].label
 			},
 			titScope(){  //  过滤条件 近3个月 title
-				const row = this.optionsScope.find(item => item.value == this.queryParam.recordScope)
+				const row = this.optionsScope.find(item => item.value == this.timeScope)
 				return row ? row.label : this.optionsScope[0].label
-			}
+			},
+			// 查询时间段
+			queryDate() {
+				var dt = new Date();
+				const threeTime = dt.setMonth( dt.getMonth()-2 )
+				const quickType = {
+				  threeMonth: [moment(getDate.getThreeMonthDays().starttime), moment(getDate.getThreeMonthDays().endtime)],
+				  lastMonth: [moment(getDate.getLastMonthDays().starttime), moment(getDate.getLastMonthDays().endtime)],
+				  thisMonth: [moment(getDate.getCurrMonthDays().starttime), moment(getDate.getCurrMonthDays().endtime)],
+				  lastTwoMonth: [moment(getDate.getLastTwoMonthDays().starttime), moment(getDate.getLastTwoMonthDays().endtime)],
+				}
+				let queryTime = {
+					beginDate: quickType[this.timeScope][0].format('YYYY-MM-DD'),
+					endDate: quickType[this.timeScope][1].format('YYYY-MM-DD')
+				}
+				return queryTime
+			},
+			
 		},
 		methods:{
 			// 搜索查询
-			searchHandle (pageNo) {
+			searchHandle () {
 				this.status = "loading"
-				pageNo ? this.pageNo = pageNo : null
-				// searchSuppliers({
-				// 	pageNo: this.pageNo,
-				// 	pageSize: this.pageSize,
-				// 	queryWord: this.queryValue
-				// }).then(res => {
-				// 	if (res.status == 200) {
-				// 		if(this.pageNo>1){
-				// 			this.listdata = this.listdata.concat(res.data.list || [])
-				// 		}else{
-				// 			this.listdata = res.data.list || []
-				// 		}
-				// 		this.total = res.data.count || 0
-				// 		this.listdata.length == 0 && this.queryValue != '' ? this.noDataText = '没有搜索到相关结果' : this.noDataText = '暂无数据'
-				// 	} else {
-				// 		this.noDataText = res.message
-				// 		this.listdata = []
-				// 		this.total = 0
-				// 	}
+				let params = Object.assign(this.queryParam,this.queryDate)
+				console.log(params,'pppppppp')
+				ldUsedQuery(params).then(res => {
+					console.log(res,'pppppppp')
+					if (res.status == 200) {
+						let list = res.data
+						// 查询3个月时 数据处理
+						if (this.timeScope == 'threeMonth') {
+							list.map(item=>{
+								let m = moment(item.month).month()+1
+								item.month = (m == moment().month()+1) ? '本月' : m+'月'
+							})
+						}
+						this.listdata = list
+					} else {
+						this.noDataText = res.message
+						this.listdata = []
+						this.total = 0
+					}
 					this.status = "loadmore"
-				// })
+				})
 			},
 			// scroll-view到底部加载更多
 			onreachBottom() {
@@ -131,8 +140,13 @@
 </script>
 
 <style lang="less">
+	page{
+		height: 100%;
+		background-color: #fff;
+	}
 	.ldDetailed-container{
 		width: 100%;
+		height: 100%;
 		// 筛选菜单
 		.filter-dropdown{
 			background-color: #fff!important;