初始化代码
This commit is contained in:
160
uniapp/uni-app/farmer/pages/finance/index.vue
Normal file
160
uniapp/uni-app/farmer/pages/finance/index.vue
Normal file
@@ -0,0 +1,160 @@
|
||||
<template>
|
||||
<view class="farmer-finance-index rel" v-if="isLoad">
|
||||
<view class="count-info flex-center flex-column c-base" :style="{background:primaryColor}">
|
||||
<view class="f-caption">可提余额(元)</view>
|
||||
<view class="price mt-sm">{{detail.cash}}</view>
|
||||
<view class="flex-center btn-list f-paragraph mt-lg pt-lg">
|
||||
<view @tap.stop="$util.goUrl({url:`/mine/pages/cash-out?type=farmer`})"
|
||||
class="item-child flex-center fill-base c-title mr-lg radius">提现</view>
|
||||
<view @tap.stop="$util.goUrl({url:`/farmer/pages/finance/record`})"
|
||||
class="item-child flex-center c-base radius">交易记录</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="money-count fill-base flex-center pt-lg pb-lg">
|
||||
<view class="item-child flex-center flex-column b-1px-r">
|
||||
<view class="flex-y-baseline f-lg-title">{{detail.total_cash}}</view>
|
||||
<view class="f-caption c-caption">总金额(元)</view>
|
||||
</view>
|
||||
<view class="item-child flex-center flex-column">
|
||||
<view class="flex-y-baseline f-lg-title">{{detail.frozen_cash}}</view>
|
||||
<view class="f-caption c-caption">实际冻结金额(元)</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="space-md"></view>
|
||||
<view class="fill-base pd-lg b-1px-b" v-for="(item,index) in list.data" :key="index">
|
||||
<view class="flex-between">
|
||||
<view class="max-446 ellipsis">{{item.order_code}}</view>
|
||||
<view class="f-title text-bold" :style="{color:index==0 ? primaryColor : '#FF5537'}">
|
||||
{{item.add==1?'+':'-'}} {{item.price}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-between f-caption c-desc mt-sm">
|
||||
<view class="c-caption">{{item.create_time_text}}</view>
|
||||
<view>{{item.type_text}}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
|
||||
</load-more>
|
||||
<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>
|
||||
|
||||
<view class="space-footer"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapState,
|
||||
mapMutations
|
||||
} from "vuex"
|
||||
import tabbar from "@/components/tabbar.vue"
|
||||
export default {
|
||||
components: {
|
||||
tabbar
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isLoad: false,
|
||||
detail: {},
|
||||
param: {
|
||||
page: 1,
|
||||
},
|
||||
list: {
|
||||
data: []
|
||||
},
|
||||
loading: true,
|
||||
lockTap: false
|
||||
}
|
||||
},
|
||||
computed: mapState({
|
||||
primaryColor: state => state.config.configInfo.primaryColor,
|
||||
subColor: state => state.config.configInfo.subColor,
|
||||
configInfo: state => state.config.configInfo,
|
||||
commonOptions: state => state.user.commonOptions,
|
||||
userInfo: state => state.user.userInfo,
|
||||
}),
|
||||
onLoad() {
|
||||
this.$util.setNavigationBarColor({
|
||||
color: '#ffffff',
|
||||
bg: '#39b54a'
|
||||
});
|
||||
this.$util.showLoading()
|
||||
this.initIndex()
|
||||
},
|
||||
onUnload() {
|
||||
this.$util.back()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
// #ifndef APP-PLUS
|
||||
uni.showNavigationBarLoading()
|
||||
// #endif
|
||||
this.initRefresh()
|
||||
uni.stopPullDownRefresh()
|
||||
},
|
||||
methods: {
|
||||
...mapMutations([]),
|
||||
async initIndex() {
|
||||
this.detail = await this.$api.farmer.farmerFinanceInfo()
|
||||
this.isLoad = true
|
||||
this.getList()
|
||||
this.$util.hideAll()
|
||||
},
|
||||
initRefresh() {
|
||||
this.param.page = 1
|
||||
this.initIndex()
|
||||
},
|
||||
async getList() {
|
||||
let {
|
||||
list: oldList,
|
||||
param
|
||||
} = this
|
||||
let newList = await this.$api.farmer.farmerFinanceList(param);
|
||||
|
||||
if (this.param.page == 1) {
|
||||
this.list = newList
|
||||
} else {
|
||||
newList.data = oldList.data.concat(newList.data)
|
||||
this.list = newList
|
||||
}
|
||||
this.loading = false
|
||||
this.$util.hideAll()
|
||||
},
|
||||
handerTabChange(index) {
|
||||
this.activeIndex = index
|
||||
// this.$util.showLoading()
|
||||
// this.param.page = 1
|
||||
// this.list.data = []
|
||||
// this.getList()
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss">
|
||||
.farmer-finance-index {
|
||||
|
||||
.count-info {
|
||||
height: 450rpx;
|
||||
|
||||
.price {
|
||||
font-size: 70rpx;
|
||||
}
|
||||
|
||||
.btn-list {
|
||||
.item-child {
|
||||
width: 240rpx;
|
||||
height: 64rpx;
|
||||
border: 1rpx solid #fff;
|
||||
transform: rotateZ(360deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.money-count {
|
||||
.item-child {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
278
uniapp/uni-app/farmer/pages/finance/record.vue
Normal file
278
uniapp/uni-app/farmer/pages/finance/record.vue
Normal file
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<view class="mine-stored-record">
|
||||
<fixed>
|
||||
<view class="fill-base b-1px-b">
|
||||
<view class="pl-lg pr-lg">
|
||||
<view class="space-lg"></view>
|
||||
<uni-segmented-control :current="typeInd" :values="typeList"
|
||||
@clickItem="handerTabChange($event,'typeInd')" style-type="button" :active-color="primaryColor">
|
||||
</uni-segmented-control>
|
||||
</view>
|
||||
<tab @change="handerTabChange($event,'activeIndex')" :list="tabList"
|
||||
:lockTap="activeIndex==2&&tabList[2].start_time&&tabList[2].end_time ? false : true"
|
||||
:activeIndex="activeIndex" :activeColor="primaryColor" :width="100/tabList.length + '%'"
|
||||
height="100rpx"></tab>
|
||||
</view>
|
||||
</fixed>
|
||||
|
||||
<view class="fill-base pd-lg b-1px-b" v-for="(item,index) in list.data" :key="index">
|
||||
<view class="flex-between">
|
||||
<view class="max-446 ellipsis">{{item.type_text}}</view>
|
||||
<view class="text-bold" :style="{color:primaryColor}">{{item.add==1?'+':'-'}} {{item.price}}</view>
|
||||
</view>
|
||||
<view class="flex-between f-caption c-caption mt-sm">{{item.create_time_text}}</view>
|
||||
</view>
|
||||
|
||||
<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
|
||||
</load-more>
|
||||
<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>
|
||||
|
||||
<view class="space-footer"></view>
|
||||
|
||||
<uni-popup ref="show_choose_time" type="top" :custom="true" :maskClick="false">
|
||||
<view style="height: 184rpx;"></view>
|
||||
<view class="popup-choose-time fill-base f-paragraph c-desc pt-lg pb-lg radius-bottom-34">
|
||||
<view class="time-item flex-center pt-lg">
|
||||
<view @tap.stop="toShowTime('start_time')" class="item-child flex-center flex-column">
|
||||
<view>开始时间</view>
|
||||
<view class="mt-sm" :style="{color:tabList[2].start_time ? primaryColor : '#999'}">
|
||||
{{tabList[2].start_time || '选择时间'}}
|
||||
</view>
|
||||
</view>
|
||||
<view @tap.stop="toShowTime('end_time')" class="item-child flex-center flex-column b-1px-l">
|
||||
<view>结束时间</view>
|
||||
<view class="mt-sm" :style="{color:tabList[2].end_time ? primaryColor : '#999'}">
|
||||
{{tabList[2].end_time || '选择时间'}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="button-item flex-center">
|
||||
<view @tap.stop="toConfirm(1)" class="item-child disabled flex-center"> 取消 </view>
|
||||
<view @tap.stop="toConfirm(2)" class="item-child flex-center"
|
||||
:style="{background: primaryColor,color:'#fff'}"> 确定
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
|
||||
<w-picker mode="date" :startYear="startYear" :endYear="endYear" :value="tabList[0].end_time" :current="false"
|
||||
fields="day" @confirm="onConfirm($event)" :disabled-after="false" ref="day" :themeColor="primaryColor"
|
||||
:visible.sync="showDate">
|
||||
</w-picker>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mapState,
|
||||
} from "vuex"
|
||||
import uniSegmentedControl from "@/components/uni-segmented-control.vue"
|
||||
import wPicker from "@/components/w-picker/w-picker.vue";
|
||||
export default {
|
||||
components: {
|
||||
uniSegmentedControl,
|
||||
wPicker
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
startYear: '',
|
||||
endYear: '',
|
||||
showKey: '',
|
||||
showDate: false,
|
||||
typeList: [{
|
||||
id: 1,
|
||||
title: '收入记录'
|
||||
}, {
|
||||
id: 0,
|
||||
title: '支出记录'
|
||||
}],
|
||||
typeInd: 0,
|
||||
activeIndex: 0,
|
||||
tabList: [{
|
||||
id: 1,
|
||||
title: '本周',
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
}, {
|
||||
id: 2,
|
||||
title: '本月',
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
}, {
|
||||
id: 3,
|
||||
title: '自定义',
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
}],
|
||||
preTime: {
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
},
|
||||
param: {
|
||||
page: 1,
|
||||
start_time: '',
|
||||
end_time: ''
|
||||
},
|
||||
list: {
|
||||
data: []
|
||||
},
|
||||
loading: true,
|
||||
lockTap: false
|
||||
}
|
||||
},
|
||||
computed: mapState({
|
||||
primaryColor: state => state.config.configInfo.primaryColor,
|
||||
subColor: state => state.config.configInfo.subColor,
|
||||
}),
|
||||
onLoad() {
|
||||
this.$util.showLoading()
|
||||
this.initIndex()
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
// #ifndef APP-PLUS
|
||||
uni.showNavigationBarLoading()
|
||||
// #endif
|
||||
this.initRefresh()
|
||||
uni.stopPullDownRefresh()
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.list.current_page >= this.list.last_page || this.loading) return
|
||||
this.param.page = this.param.page + 1
|
||||
this.loading = true
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
initIndex() {
|
||||
let cur_time = new Date(Math.ceil(new Date().getTime()))
|
||||
const currentDate = new Date()
|
||||
//返回date是一周中的某一天
|
||||
const week = currentDate.getDay()
|
||||
//一天的毫秒数
|
||||
const millisecond = 1000 * 60 * 60 * 24
|
||||
//减去的天数
|
||||
const minusDay = week != 0 ? week - 1 : 6
|
||||
//本周 周一
|
||||
const monday = new Date(currentDate.getTime() - minusDay * millisecond)
|
||||
//本周 周日
|
||||
const sunday = new Date(monday.getTime() + 6 * millisecond)
|
||||
|
||||
this.tabList[0].start_time = this.$util.formatTime(monday, 'YY-M-D')
|
||||
this.tabList[0].end_time = this.$util.formatTime(sunday, 'YY-M-D')
|
||||
this.tabList[1].start_time = this.$util.formatTime(cur_time, 'YY-M') + '-01'
|
||||
this.tabList[1].end_time = this.$util.formatTime(cur_time, 'YY-M-D')
|
||||
let year = this.$util.formatTime(cur_time, 'YY') * 1
|
||||
this.startYear = year - 5
|
||||
this.endYear = year
|
||||
this.param.page = 1
|
||||
this.getList()
|
||||
},
|
||||
initRefresh() {
|
||||
this.param.page = 1
|
||||
this.initIndex()
|
||||
},
|
||||
async getList() {
|
||||
let {
|
||||
list: oldList,
|
||||
activeIndex,
|
||||
tabList,
|
||||
typeList,
|
||||
typeInd
|
||||
} = this
|
||||
let {
|
||||
start_time,
|
||||
end_time
|
||||
} = tabList[activeIndex]
|
||||
let param = this.$util.deepCopy(this.param)
|
||||
param.add = typeList[typeInd].id
|
||||
param.start_time = this.$util.DateToUnix(start_time)
|
||||
param.end_time = this.$util.DateToUnix(end_time) + 24 * 3600 - 1
|
||||
let newList = await this.$api.farmer.farmerFinanceList(param);
|
||||
|
||||
if (this.param.page == 1) {
|
||||
this.list = newList
|
||||
} else {
|
||||
newList.data = oldList.data.concat(newList.data)
|
||||
this.list = newList
|
||||
}
|
||||
this.loading = false
|
||||
this.$util.hideAll()
|
||||
},
|
||||
handerTabChange(index, key, ind = 2) {
|
||||
this[key] = index;
|
||||
if (key == 'activeIndex') {
|
||||
let methodModel = index == ind ? 'open' : 'close'
|
||||
this.$refs.show_choose_time[methodModel]()
|
||||
if (index == ind) return
|
||||
} else {
|
||||
this.$refs.show_choose_time.close()
|
||||
}
|
||||
this.$util.showLoading()
|
||||
this.param.page = 1
|
||||
this.list.data = []
|
||||
this.getList()
|
||||
},
|
||||
toShowTime(key, ind = 2) {
|
||||
if (key == 'end_time' && !this.tabList[ind].start_time) {
|
||||
this.$util.showToast({
|
||||
title: `请选择开始时间`
|
||||
})
|
||||
return
|
||||
}
|
||||
this.showKey = key
|
||||
this.showDate = true
|
||||
},
|
||||
async onConfirm(val, ind = 2) {
|
||||
let {
|
||||
start_time,
|
||||
end_time
|
||||
} = this.tabList[ind]
|
||||
let {
|
||||
showKey
|
||||
} = this
|
||||
if ((end_time && showKey == 'start_time' && this.$util.DateToUnix(end_time) < this.$util.DateToUnix(val
|
||||
.result)) || (
|
||||
showKey == 'end_time' && this.$util.DateToUnix(start_time) > this.$util.DateToUnix(val.result)
|
||||
)) {
|
||||
this.$util.showToast({
|
||||
title: `结束时间不能小于开始时间`
|
||||
})
|
||||
return
|
||||
}
|
||||
this.tabList[ind][showKey] = val.result;
|
||||
if (showKey == 'end_time') {
|
||||
this.showDate = false
|
||||
}
|
||||
},
|
||||
toConfirm(type, ind = 2) {
|
||||
let {
|
||||
start_time = '',
|
||||
end_time = ''
|
||||
} = type == 1 ? this.preTime : this.tabList[ind]
|
||||
if (type == 1) {
|
||||
this.tabList[ind].start_time = start_time
|
||||
this.tabList[ind].end_time = end_time
|
||||
} else {
|
||||
if (!start_time || !end_time) {
|
||||
this.$util.showToast({
|
||||
title: !start_time ? `请选择开始时间` : `请选择结束时间`
|
||||
})
|
||||
return
|
||||
}
|
||||
this.preTime.start_time = start_time
|
||||
this.preTime.end_time = end_time
|
||||
}
|
||||
this.activeIndex = start_time && end_time ? ind : 0
|
||||
this.$refs.show_choose_time.close()
|
||||
this.$util.showLoading()
|
||||
this.param.page = 1
|
||||
this.list.data = []
|
||||
this.getList()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<style lang="scss">
|
||||
</style>
|
||||
Reference in New Issue
Block a user