123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- export default {
- namespace: 'mine_account',
- state: {
- accountData: [],
- accountBalance: 0,
- isRefreshing: false,
- totalPages: 2,
- // 0:隐藏footer 1:已加载完成,没有更多数据 2 :显示加载中
- showFoot: 0,
- },
- reducers: {
- accountReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- accBalanceReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- },
- effects: {
- // 账户余额
- *AccountSagas(action, { call, put }) {
- try {
- let foot = 0,
- search = {}
- if (action.payload.forUse !== 'slipOn') {
- yield put(
- createAction('castReducer')({
- isRefreshing: true,
- })
- )
- } else {
- yield put(
- createAction('castReducer')({
- showFoot: 2,
- })
- )
- }
- customerinfo = { search_EQ_customer: CUSTOMERINFO.id }
- search = {
- ...action.payload.pageInfo,
- ...action.payload.searchInfo,
- ...customerinfo,
- }
- const hotdata = yield call(() => authService.getBalanceChange(search))
- if (hotdata && hotdata.data) {
- if (action.payload.pageInfo.page >= hotdata.data.totalPages) {
- foot = 1
- }
- yield put(
- createAction('accountReducer')({
- accountData: action.payload.accountReturn.concat(
- hotdata.data.content
- ),
- isRefreshing: false,
- totalPages: hotdata.data.totalPages,
- isRefreshing: false,
- showFoot: foot,
- })
- )
- } else {
- yield put(
- createAction('accountReducer')({
- isRefreshing: false,
- })
- )
- }
- } catch (error) {
- yield put(
- createAction('accountReducer')({
- isRefreshing: false,
- showFoot: 1,
- })
- )
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 账户 预付余额
- *getAccountBalance(action, { call, put }) {
- try {
- let search = {},
- customerinfo = { customerId: CUSTOMERINFO.id }
- search = {
- ...action.payload.searchInfo,
- ...customerinfo,
- }
- const hotdata = yield call(() => authService.getPrepayBalance(search))
- if (hotdata && hotdata.data) {
- yield put(
- createAction('accBalanceReducer')({
- accountBalance: hotdata.data,
- })
- )
- }
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- },
- }
|