|
|
@@ -0,0 +1,207 @@
|
|
|
+import { Component } from 'react'
|
|
|
+import { View, Text, Swiper, SwiperItem, Image } from '@tarojs/components'
|
|
|
+import './index.less'
|
|
|
+import Taro, { useDidHide, useReady, Current } from "@tarojs/taro"
|
|
|
+import React, { useState, useEffect, onLoad, useLayoutEffect } from 'react'
|
|
|
+import Recall from '../../components/recall'
|
|
|
+import Weather from '../../components/weather'
|
|
|
+import { formatRichText } from "../../assets/js/filter"
|
|
|
+import { test } from "../../server/index"
|
|
|
+const Index = () => {
|
|
|
+ const [choice, setChoice] = useState(1)
|
|
|
+ //商品是否召回,true为召回
|
|
|
+ const [ifrecall, setIfrecall] = useState(true)
|
|
|
+ //设置产地天气定位城市ID,94为杭州
|
|
|
+ const [cityId, setCityId] = useState(94)
|
|
|
+ //生产追溯是否展开,true为初始不展开,false展开
|
|
|
+ const [ifshow, setIfshow] = useState(true)
|
|
|
+ const [froms, setFroms] = useState([])
|
|
|
+ const [promesslist, setpromesslist] = useState([])
|
|
|
+ const [wuliulist, setwuliulist] = useState([])
|
|
|
+ const [thinglist, setthinglist] = useState([])
|
|
|
+ const [addmesslist, setaddmesslist] = useState([])
|
|
|
+
|
|
|
+ const setChoice1 = () => {
|
|
|
+ setChoice(1)
|
|
|
+ console.log(froms);
|
|
|
+ }
|
|
|
+ const setChoice2 = () => {
|
|
|
+ setChoice(2)
|
|
|
+ }
|
|
|
+ const findmore = () => {
|
|
|
+ ifshow === false ? setIfshow(true) : setIfshow(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ const went = (url) => {
|
|
|
+ Taro.navigateTo({
|
|
|
+ url: url
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // const pages = getCurrentPages()
|
|
|
+ // const current = pages[pages.length - 1]
|
|
|
+ // const eventChannel = current.getOpenerEventChannel()
|
|
|
+ // eventChannel.emit('someEvent', 1);
|
|
|
+
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const id = Current.router.params.id;
|
|
|
+ console.log(id);
|
|
|
+ if (id)
|
|
|
+ test({ sourceCode: id }).then(e => {
|
|
|
+ console.log(e);
|
|
|
+ const res = e.data.data;
|
|
|
+ setFroms(res.supplySourceCodeInfoList)
|
|
|
+ //setpromesslist([{title: '产品名称', mess: '宫廷御用菜' }])
|
|
|
+ })
|
|
|
+
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ // const froms = [{ title: '产前阶段:种植', time: '2021-09-11', name: '张和农', text: '操作描述:自然气候条件独特,常年云雾缭绕,周 边环境污染,是生产优质自然生态蔬菜园。' },
|
|
|
+ // { title: '产前阶段:除虫', time: '2021-09-12', name: '张和农', text: '操作描述:自然气候条件独特,常年云雾缭绕,周边环境污染,是生产优质自然生态蔬菜园。' },
|
|
|
+ // { title: '产前阶段:仓储信息', time: '2021-09-12', name: '张和农', text: '操作描述:自然气候条件独特,常年云雾缭绕,周边环境污染,是生产优质自然生态蔬菜园。' },
|
|
|
+ // { title: '产前阶段:仓储信息', time: '2021-09-12', name: '张和农', text: '操作描述:自然气候条件独特,常年云雾缭绕,周边环境污染,是生产优质自然生态蔬菜园。' },
|
|
|
+ // { title: '产前阶段:仓储信息', time: '2021-09-12', name: '张和农', text: '操作描述:自然气候条件独特,常年云雾缭绕,周边环境污染,是生产优质自然生态蔬菜园。' },
|
|
|
+ // { title: '产前阶段:仓储信息', time: '2021-09-12', name: '张和农', text: '操作描述:自然气候条件独特,常年云雾缭绕,周边环境污染,是生产优质自然生态蔬菜园。' }]
|
|
|
+
|
|
|
+ // const promesslist = [{ title: '产品名称', mess: '宫廷御用菜' }, { title: '产品分类', mess: '蔬菜' }, { title: '产品规格', mess: '2000g' }, { title: '建议价', mess: '38元/斤' }, { title: '溯源码', mess: '0253111625362354' }]
|
|
|
+ // const wuliulist = [{ com: '优鲜购有限公司(采购商)', tel: 12034131310 }, { com: '果乐汇有限公司(供应商)', tel: 12034131310 }]
|
|
|
+ // const thinglist = [{ title: '大方土特产,独特配方专业人士手艺的测试测试测试', address: '新疆维吾尔', price: 430 }, { title: '大方土特产,独特配方专业人士手艺的测试测试测试', address: '新疆维吾尔', price: 430 }
|
|
|
+ // , { title: '大方土特产,独特配方专业人士手艺的测试测试测试', address: '杭州', price: 430 }, { title: '大方土特产,独特配方专业人士手艺的测试测试测试', address: '徐州', price: 430 }]
|
|
|
+ // const addmesslist = [{ title: '产地名称', text: '宫廷御用莲' }, { title: '详细地址', text: '北京市东城区东区路112号' }, { title: '负责人', text: '韩建' }]
|
|
|
+ return (
|
|
|
+ <View className='message'>
|
|
|
+ <View className='tab'>
|
|
|
+ <View className={choice === 1 ? 'tablist' : 'tablistfan'} onClick={setChoice1}>产品介绍</View>
|
|
|
+ <View className={choice === 2 ? 'tablist' : 'tablistfan'} onClick={setChoice2}>产地介绍</View>
|
|
|
+ <View className={choice === 1 ? 'tabhua1' : 'tabhua2'}></View>
|
|
|
+ </View>
|
|
|
+ <View className="chanpin" style={choice == 1 ? 'display:block' : 'display:none'}>
|
|
|
+ <Recall props={ifrecall}></Recall>
|
|
|
+ <View className="mes">
|
|
|
+ <View className="productfrom">
|
|
|
+ <View className="bigtitle">生产追溯</View>
|
|
|
+ <View className="allmessage">
|
|
|
+ <View className="contens">
|
|
|
+ {
|
|
|
+ froms.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <View className={index == froms.length - 1 ? 'noline conten' : 'conten'} key={index} style={index < 3 || ifshow == false ? 'visibility:visible' : 'display:none'}>
|
|
|
+ <View className="inner">
|
|
|
+ <View className="title">{item.title}阶段</View>
|
|
|
+ <View className="time">{item.createTime.split(' ')[0]}</View>
|
|
|
+ <View className="name">{item.createName}</View>
|
|
|
+ <View className="text">{item.content}</View>
|
|
|
+ <View className="pic"></View>
|
|
|
+ </View>
|
|
|
+ </View>)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className={ifshow == false ? 'more' : 'less'} onClick={findmore}>{ifshow == false ? '收起' : '点击查看更多'}</View>
|
|
|
+ </View>
|
|
|
+ <View className="showpic"></View>
|
|
|
+ <View className="promessage">
|
|
|
+ <View className="messtitle">产品信息</View>
|
|
|
+ <View className="small1">该批次产品已追溯</View>
|
|
|
+ <View className="small2">190022次</View>
|
|
|
+ {
|
|
|
+ promesslist.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <View className="messdiv">
|
|
|
+ <View className="mess1">{item.title}</View>
|
|
|
+ <View className="mess2">{item.mess}</View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ <View className="messdiv">
|
|
|
+ <View className="mess1">认证标识</View>
|
|
|
+ <View className="iconpic"></View>
|
|
|
+ </View>
|
|
|
+ <View className="messdiv" style='border:none' onClick={went.bind(this, `/pages/complaint/index`)}>
|
|
|
+ <View className="mess1">投诉建议</View>
|
|
|
+ <View className="icon2"></View>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="videodiv">
|
|
|
+ <View className="title">产品短片</View>
|
|
|
+ <View className="video"></View>
|
|
|
+ </View>
|
|
|
+ <View className="wuliumessage">
|
|
|
+ <View className="title">物流信息</View>
|
|
|
+ {
|
|
|
+ wuliulist.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <View className="wuliudiv" style={index === wuliulist.length - 1 ? 'border:none' : ''}>
|
|
|
+ <View className="commess">{item.com}</View>
|
|
|
+ {/* <View className="tel">联系电话:{item.tel}</View> */}
|
|
|
+ <View className="icon"></View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ <View className="advicetitle">优品推荐</View>
|
|
|
+ {
|
|
|
+ thinglist.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <View className="thingdiv" style={index % 2 == 0 ? 'margin-right:10px' : ''} onClick={went.bind(this, `/pages/commodity/index`)}>
|
|
|
+ <View className="pic"></View>
|
|
|
+ <View className="title">大方土特产,独特配方专业人士手艺的测试测试测试</View>
|
|
|
+ <View className="has">认证商品</View>
|
|
|
+ <View className="address">新疆维吾尔</View>
|
|
|
+ <View className="price">¥430</View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ <View className="chandi" style={choice == 1 ? 'display:none' : 'display:block'}>
|
|
|
+ <Swiper
|
|
|
+ className='swiper-body'
|
|
|
+ indicatorDots
|
|
|
+ indicatorColor='#999'
|
|
|
+ indicatorActiveColor='#333'
|
|
|
+ current
|
|
|
+ duration={500}
|
|
|
+ interval={5000}
|
|
|
+ circular
|
|
|
+ autoplay>
|
|
|
+ <SwiperItem>
|
|
|
+ <View className='demo-text-1'>1</View>
|
|
|
+ </SwiperItem>
|
|
|
+ <SwiperItem>
|
|
|
+ <View className='demo-text-2'>2</View>
|
|
|
+ </SwiperItem>
|
|
|
+ <SwiperItem>
|
|
|
+ <View className='demo-text-3'>3</View>
|
|
|
+ </SwiperItem>
|
|
|
+ </Swiper>
|
|
|
+ <View className="promessage">
|
|
|
+ <View className="messtitle">产地信息</View>
|
|
|
+ <View className="small1">该批次产品已追溯</View>
|
|
|
+ <View className="small2">190022次</View>
|
|
|
+ {
|
|
|
+ addmesslist.map((item, index) => {
|
|
|
+ return (
|
|
|
+ <View className="messdiv" style={index == 0 ? 'margin-top:14px' : ''}>
|
|
|
+ <View className="mess1">{item.title}</View>
|
|
|
+ <View className="mess2">{item.text}</View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </View>
|
|
|
+ <View className="videodiv">
|
|
|
+ <View className="title">生产基地短片</View>
|
|
|
+ <Image className="video" src='http://api.k780.com/upload/weather/d/1.gif'></Image>
|
|
|
+ </View>
|
|
|
+ <Weather props={{ weaId: cityId }}></Weather>
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ )
|
|
|
+}
|
|
|
+export default Index
|