Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

枚举类型,key为表达式,报Property value expected type of string but got null #4062

Closed
MuJinYan opened this issue Aug 4, 2019 · 2 comments
Assignees

Comments

@MuJinYan
Copy link

MuJinYan commented Aug 4, 2019

问题描述
升级到1.3.11后,枚举类型的key为表达式时,会报Property value expected type of string but got null

复现步骤

import Taro, { Component } from '@tarojs/taro'
import { View, Image, Block } from '@tarojs/components'
import { connect } from '@tarojs/redux'
import * as R from 'ramda'
import {
  FantuanSearch,
  FantuanSwiper,
  FantuanFilter,
  FantuanFilterLayout,
  FullScreenLayer,
  LayerDivider,
  FantuanFailView,
  FantuanBlankView,
  LoadMore,
  LoadComplete,
  CustomModal
} from '@/components'
import { Action } from '@/utils/helpers'
import K from '@/utils/constants'
import placeholderImage from '@/images/groupbuy/placeholder-image.jpg'
import styles from './index.module.scss'
import MerchantsItem from '../common/MerchantsItem'
import UserLayout from '../home/userLayout'

@connect(({groupbuy, userInfo: {user}}) => {
  return {
    user: R.either(R.isNil, R.isEmpty)(user),
    ...R.omit([
      'merchant',
      'merchantRelated',
      'product',
      'regions',
      'secondaryType',
      'filterCondition',
      'filterConditionShow'
    ],groupbuy)
  }
})
export default class Groupbuy extends Component {
  config = {
    navigationBarTitleText: '饭团点评享惠',
    
    usingComponents: {
      'sticky': '/components/wechatComponent/sticky/index', // 使用的原生组件
      'sticky-item': '/components/wechatComponent/sticky-item/index'
    },
    enablePullDownRefresh: true,
    backgroundTextStyle: 'dark',
    onReachBottomDistance: 50
  };
  
  state = {
    scrollTop: 0,
    reachBottom: false,
    filterType: null,
    tag: false  // 防止多次触发下拉刷新
  }
  
  componentDidMount () {
    this.getData()
  }
  
  getData = (options = {}) => {
    this.props.dispatch(Action('groupbuy/fetchData', options))
    this.props.dispatch(Action('groupbuy/fetchAd'))
  }
  
  onPageScroll (event) {
    this.setState({
      scrollTop: event.scrollTop
    })
  }
  
  onPullDownRefresh() {
    if (!this.state.tag) {
      this.setState({tag: true})
      this.getData({
        status: K.PAGE_STATUS.STOPPENDING,
        callback: () => {
          this.setState({
            tag: false
          })
          Taro.stopPullDownRefresh()
        }
      })
    } else {}
  }
  
  onReachBottom() {
    const { headers: { has_more } } = this.props
    if (has_more) {
      this.setState({reachBottom: true})
      this.props.dispatch(Action('groupbuy/_loadMore'))
    } else {
      this.setState({reachBottom: false})
    }
  }
  // 改变弹窗类型,所有的弹窗均是基于一个弹出层,不同的只有内部的内容
  changeFloatLayout = (value) => {
    this.setState({
      filterType: value
    })
  }
  // 点抢购判断登录,未登录直接弹窗要求登录
  openLoginModal = (callback) => {
    const { user } = this.props
    if (user) {
      this.loginModal.open()
    } else {
      callback && callback()
    }
  }
  goSearchPage = () => {
    const { STATUS } = this.props
    if (R.includes(STATUS, [K.PAGE_STATUS.RESOLVED, K.PAGE_STATUS.BLANK])) {
      Taro.navigateTo({url: '/pages/search/groupBuySearch'})
    } else { return false }
  }
  
  render() {
    const { scrollTop, reachBottom, filterType } = this.state
    const { ads: { adType9 }, merchants, STATUS, headers: {has_more} } = this.props
    return (
      <Block>
        <FantuanSearch isFixed onClick={this.goSearchPage} />
        {
          {
           [K.PAGE_STATUS.INITIAL]: <View />,
           [K.PAGE_STATUS.PENDING]: <View>
              <View className={styles.placeholderView} />
              <Image className={styles.groupPlaceholderImage} mode='aspectFill' src={placeholderImage} />
              <View className={styles.placeholerFilter}>
                <View className={styles.placeholder}>
                  <View />
                </View>
                <View className={styles.placeholder}>
                  <View />
                </View>
                <View className={styles.placeholder}>
                  <View />
                </View>
                <View className={styles.placeholder}>
                  <View />
                </View>
              </View>
           </View>,
           [K.PAGE_STATUS.RESOLVED]: <sticky scrollTop={scrollTop}>
             <View className={styles.placeholderView} />
             <FantuanSwiper imageList={adType9} photoKey='photo' />
             <sticky-item>
               <View slot='title'>
                 <FantuanFilter
                   onClick={this.changeFloatLayout}
                 />
               </View>
               <View slot='content'>
                 {merchants.map((item) => <MerchantsItem
                   key={`card${item.id.toString()}`}
                   value={item}
                   onOpenModal={this.openLoginModal}
                 />)}
                 {(reachBottom && has_more) && <LoadMore />}
                 {R.not(has_more) && <LoadComplete />}
               </View>
             </sticky-item>
           </sticky>,
           [K.PAGE_STATUS.REJECTED]: <FullScreenLayer>
             <LayerDivider height={1}>
               <FantuanFailView onClick={this.getData} />
             </LayerDivider>
           </FullScreenLayer>,
           [K.PAGE_STATUS.BLANK]: <View>
             <View className={styles.placeholderView} />
             <FantuanSwiper imageList={adType9} photoKey='photo' />
             <FantuanFilter
               onClick={this.changeFloatLayout}
             />
             <View>
               <FantuanBlankView />
             </View>
           </View>
          }[STATUS]
        }
        <FantuanFilterLayout type={filterType} onClose={this.changeFloatLayout} />
        <UserLayout onLogin={this.goLogin} />
        <CustomModal
          ref={(node) => this.loginModal = node}
          type='confirm'
          message='需要登录才可以下单哦~'
          confirmIsLogin
        />
      </Block>
    )
  }
}

// 常量文件

export const Item = (type, value) => ({type, value});

export default {
  MOOD: {
    JOKEY: '😱',
    ANGRY: '😡'
  },
  
  
  HTTP_STATUS: {
    SUCCESS: 200,
    CLIENT_ERROR: 400,
    AUTHENTICATE: 401,
    FORBIDDEN: 403,
    NOT_FOUND: 404,
    SERVER_ERROR: 500,
    BAD_GATEWAY: 502,
    SERVICE_UNAVAILABLE: 503,
    GATEWAY_TIMEOUT: 504
  },
  
  PAGE_STATUS: {
    INITIAL: '__INITIAL__',
    PENDING: '__PENDING__',
    RESOLVED: '__RESOLVED__',
    REJECTED: '__REJECTED__',
    BLANK: '__BLANK__',
    STOPPENDING: '__STOPPENDING__',
    SEARCH: '__SEARCH__'
  }
}

报错信息
image

系统信息

  • 操作系统: mac os 10.13.6
  • Taro 版本 1.3.11
  • Node.js 版本 8.12.0
  • 报错平台 weapp
@taro-bot
Copy link

taro-bot bot commented Aug 4, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@taro-bot
Copy link

taro-bot bot commented Aug 4, 2019

CC @yuche

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants