123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import { createAction, NavigationActions } from '../../utils'
- import * as authService from '../../services/auth'
- export default {
- namespace: 'attention',
- state: {
- attentData: [],
- isRefreshing: false,
- },
- reducers: {
- attentionListReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- updateReducer(state, { payload }) {
- return { ...state, ...payload }
- },
- // shopIdsReducer(state, { payload }) {
- // return { ...state, ...payload };
- // }
- },
- effects: {
- // 查看关注列表
- *getAttentionList(action, { call, put }) {
- try {
- let attentData = []
- yield put(
- createAction('attentionListReducer')({
- isRefreshing: true,
- })
- )
- const attention = yield call(() =>
- authService.checkAttention({ customer: CUSTOMERINFO.id })
- )
- if (attention && attention.data) {
- attention.data.map(item => {
- if (item.storelist) {
- attentData = attentData.concat(item.storelist)
- }
- })
- yield put(
- createAction('attentionListReducer')({ attentData: attentData })
- )
- }
- } catch (error) {
- yield put(
- createAction('attentionListReducer')({
- isRefreshing: false,
- })
- )
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 添加关注
- *addAttention(action, { call, put }) {
- try {
- const attentionAdd = yield call(() =>
- authService.addAttention(action.payload)
- )
- yield put(createAction('getAttentionList')())
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 删除关注商品行
- *delAttention(action, { call, put }) {
- try {
- const delAttent = yield call(() =>
- authService.delAttention({
- customer: CUSTOMERINFO.id,
- id: action.payload,
- })
- )
- yield put(createAction('getAttentionList')())
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 删除关注商品行
- *delAttentionByGoodsId(action, { call, put }) {
- try {
- const delAttent = yield call(() =>
- authService.delAttentionByGood({
- customer: CUSTOMERINFO.id,
- goodsId: action.payload.goodsId,
- saleOrg: action.payload.saleOrg,
- })
- )
- yield put(createAction('getAttentionList')())
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- // 删除关注商品行
- *updateAttention(action, { call, put }) {
- try {
- yield put(
- createAction('updateReducer')({
- attentData: action.payload.attentData,
- })
- )
- } catch (error) {
- console.log(
- error,
- '-----error的完整信息' + '\n' + error.response.data.message,
- '-----相关错误信息'
- )
- }
- },
- },
- }
|