index.jsx 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import React, { useState, useEffect } from 'react'
  2. import Taro, { Current } from '@tarojs/taro'
  3. import request, { apis } from '@/utils/request'
  4. import { useModel } from '@/store'
  5. import Page from '@/layouts'
  6. import '@/assets/css/reset.less'
  7. import '@/assets/css/iconfont.less'
  8. import './index.less'
  9. export default function ShangPinXiangQing () {
  10. const { user } = useModel('user')
  11. const [CurrnetId] = useState(Current.router.params.id) // 当前id
  12. const [GoodsDetail, setGoodsDetail] = useState(null) // 商品详情
  13. useEffect(() => {
  14. Init()
  15. }, [])
  16. const Init = () => {
  17. request({ ...apis.getGoodsDetail, args: { id: CurrnetId } }).then((res) => {
  18. setGoodsDetail(res)
  19. })
  20. }
  21. return (
  22. <Page>
  23. <view className='ShangPinXiangQing'>
  24. <view className='Info'>
  25. <view className='Img'>
  26. <image mode='aspectFill' src={GoodsDetail === null ? null : GoodsDetail.imgUrl} className='centerLabel'></image>
  27. </view>
  28. <view className='Title'>
  29. <text>{GoodsDetail === null ? '' : GoodsDetail.goodsName}</text>
  30. </view>
  31. <view className='flex-h'>
  32. <text>{GoodsDetail === null ? '' : GoodsDetail.pointPrice}</text>
  33. <text className='flex-item'>积分</text>
  34. <text>剩余数量</text>
  35. <text>{GoodsDetail === null ? '' : GoodsDetail.inventory}</text>
  36. </view>
  37. </view>
  38. <view className='Detail'>
  39. <view className='Title'>
  40. <view className='Line'></view>
  41. <text>产品详情</text>
  42. <image mode='widthFix' src={GoodsDetail === null ? null : GoodsDetail.detailImgUrl} style={{ width: `100%` }}></image>
  43. </view>
  44. <view className='BottomBtn'>
  45. <text className='active' onClick={() => { Taro.navigateTo({ url: `/pages/FuLi/ShangPinDuiHuan/index?id=${CurrnetId}` }) }}>立即兑换</text>
  46. </view>
  47. </view>
  48. </view>
  49. </Page>
  50. )
  51. }