index.jsx 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 { getShareObject } from '@/utils/share.js'
  7. import '@/assets/css/reset.less'
  8. import '@/assets/css/iconfont.less'
  9. import './index.less'
  10. export default function ShangPinXiangQing () {
  11. const { user } = useModel('user')
  12. const [CurrnetId] = useState(Current.router.params.id) // 当前id
  13. const [GoodsDetail, setGoodsDetail] = useState(null) // 商品详情
  14. Taro.useShareAppMessage(() => {
  15. return getShareObject({
  16. title: GoodsDetail.goodsName,
  17. id: CurrnetId,
  18. image: GoodsDetail.imgUrl
  19. }, user)
  20. })
  21. useEffect(() => {
  22. Init()
  23. }, [])
  24. const Init = () => {
  25. request({ ...apis.getGoodsDetail, args: { id: CurrnetId } }).then((res) => {
  26. setGoodsDetail(res)
  27. })
  28. }
  29. return (
  30. <Page>
  31. <view className='ShangPinXiangQing'>
  32. <view className='Info'>
  33. <view className='Img'>
  34. <image mode='aspectFit' src={GoodsDetail === null ? null : GoodsDetail.imgUrl}></image>
  35. </view>
  36. <view className='Title'>
  37. <text>{GoodsDetail === null ? '' : GoodsDetail.goodsName}</text>
  38. </view>
  39. <view className='flex-h'>
  40. <text>{GoodsDetail === null ? '' : GoodsDetail.pointPrice}</text>
  41. <text className='flex-item'>积分</text>
  42. <text>剩余数量</text>
  43. <text>{GoodsDetail === null ? '' : GoodsDetail.inventory}</text>
  44. </view>
  45. </view>
  46. <view className='Detail'>
  47. <view className='Title'>
  48. <view className='Line'></view>
  49. <text>产品详情</text>
  50. </view>
  51. <image mode='aspectFit' src={GoodsDetail === null ? null : GoodsDetail.detailImgUrl} style={{ width: `100%` }}></image>
  52. <text className='Tips'>免责申明:本站商品信息均来自于合作方,其真实性、准确性和合法性由信息拥有者(合作方)负责。本站不提供任何保证,并不承担任何法律责任</text>
  53. <view className='BottomBtn'>
  54. <text className='active' onClick={() => { Taro.navigateTo({ url: `/pages/FuLi/ShangPinDuiHuan/index?id=${CurrnetId}` }) }}>立即兑换</text>
  55. </view>
  56. </view>
  57. </view>
  58. </Page>
  59. )
  60. }