import { Button, Card, Cell, Col, Divider, Grid, GridItem, Row, Skeleton, Tab, Tabs, Tag, Toast, } from "@antmjs/vantui"; import { Input, OfficialAccount, Swiper, View, WebView, // ChannelVideo, SwiperItem, Ad, } from "@tarojs/components"; import React, { useCallback, useEffect, useState } from "react"; import { Image } from "@antmjs/vantui"; import react from "react"; import { NoticeBar } from "@antmjs/vantui"; import Taro, { useShareTimeline } from "@tarojs/taro"; import { Tabbar, TabbarItem } from "@antmjs/vantui"; import TabbarCom from "../components/TabbarCom"; import { cloudcall, getTable, getTableid, phoneLogin, updateTableid, } from "@/utils/index"; import { Icon } from "@antmjs/vantui"; import "./index.scss"; import { Search } from "@antmjs/vantui"; import ActiveCard from "../components/ActiveCard"; import { Dialog } from "@antmjs/vantui"; import { Loading } from "@antmjs/vantui"; import InfoCard from "./components/InfoCard"; import WeGroup from "./components/WeGroup"; import QRcode from "../../images/QRcode.png"; import mylife from "../../images/mylife.jpg"; import { Radio, RadioGroup } from "@antmjs/vantui"; import { Steps } from "@antmjs/vantui"; const Home = () => { // const { images } = COMMON const [value, setValue] = react.useState("1"); const [initPage1, setInitPage1] = react.useState(0); const [active, setActive] = react.useState(0); const [show, setShow] = react.useState(false); const [isEnded, setisEnded] = react.useState(false); // const [value, setValue] = react.useState(""); const [SearchValue, setSearchValue] = useState(""); const [details, setdetails] = useState([ { title: "自由职业交流会", address: "深圳莲花山", date: "20231123", tagName: "报名中", tagCode: "ut ipsum esse Excepteur velit", Status: "dolor", images: [], peopleArr: [], detailsId: "laboris pariatur commodo", startTime: -83917740.70315647, endTime: -52170253.25949725, rules: [], isDelete: false, useridArr: [], latitude: "velit ea do i", longitude: "voluptate sint dolore ", }, ]); //活动详情 // 系统配置 const [systemConfig, setsystemConfig] = useState({}); const [openid, setopenid] = useState(); const [isIn, setisIn] = useState(false); const [addData, setaddData]: any = useState(null); const onChange = (e) => {}; // useEffect(() => { // getLogin(); // }, []); const getLogin = async () => { let isLogin: any = await phoneLogin(); console.log("isLogin", isLogin); setisIn(isLogin); }; Taro.useShareAppMessage((res) => { if (res.from === "button") { // 来自页面内转发按钮 console.log(res.target); } return { title: "cityNew", path: `/pages/home/index`, }; }); // 分享到朋友圈 useShareTimeline(() => { return { title: "一起来玩吧", //字符串 自定义标题 // query: `id=${this.data.shop.shop_id}`, //页面携带参数 // imageUrl: moments //图片地址 }; }); // 云托管测试 const testCloud = async () => { const res = await cloudcall({ path: "/feishu", method: "GET", }); console.log("业务返回结果", res); }; // 云托管本地测试 const testPost = async () => { const res = await cloudcall({ path: "/nihao", method: "POST", }); console.log("业务返回结果", res); }; useEffect(() => { // testCloud(); // testPost() }, []); useEffect(() => { // 设置标题 definePageConfig({ navigationBarTitleText: "首页", }); // 设置允许分享 Taro.showShareMenu({ withShareTicket: true, }); // 其他分享 Taro.updateShareMenu({ withShareTicket: true, success() {}, }); }, []); const steps = [ { text: "步骤一", // desc: '描述信息', }, { text: "步骤二", // desc: '描述信息', }, { text: "步骤三", // desc: '描述信息', }, { text: "步骤四", // desc: '描述信息', }, ]; useEffect(() => { getsystemConfig(); //获取系统配置 // getdetails(); //获取活动详情 // setTimeout(() => { // getdetails(); //获取活动详情 // }, 1000); // getAd(); }, []); // useEffect(() => { // Taro.cloud.callFunction({ // name: "getOpenid", // complete: async (res: any) => { // console.log("callFunction test result: ", res); // let newopenid = res?.result?.event?.userInfo?.openId; // setopenid(newopenid); // }, // }); // }, [isIn]); const listener = function (res) { console.log("isEnded", res.isEnded); setisEnded(res.isEnded); if (!!res.isEnded) { setShow(true); } else { setShow(false); } }; const listenerErr = function (err) { console.log("err", err); }; const getAd = async () => { // 激励视频广告 let res = await Taro.createRewardedVideoAd({ adUnitId: "adunit-406f7f94d37c2243", //小程序广告位 ID }); res.onClose(listener); res.onClose(listenerErr); // 加载激励广告数据 await res .load() .then(async () => { await res.show(); }) .catch((err) => { console.log("err", err); }); // 设置激励广告变量 setaddData(res); }; const gotoMylife=()=>{ // 跳转到目的页面,打开新页面 Taro.navigateTo({ url: "/pages/mylife/index", }); } const getdetails = async () => { let objParams = { tableName: "details", // id: "80516fb66370bcf300b8f43c5f4dd52b", okFun: async (res: any) => { console.log("details11--", res); // await setdetails(res?.data ?? []); }, }; await getTable(objParams); }; const getsystemConfig = async () => { let objParams = { tableName: "systemConfig", // id: "80516fb66370bcf300b8f43c5f4dd52b", okFun: async (res: any) => { console.log("systemConfig--", res); await setsystemConfig(res?.data ?? []); // setTimeout(() => { // getdetails(); // }, 800); }, }; await getTable(objParams); }; // 上传到云存储 const uploadTaro = (tempFilePaths: any, lbsInfo: any) => { // 云开发存储文件 [/自动创建文件路径] Taro.cloud.uploadFile({ cloudPath: `images/checkIn/${new Date()?.getTime()}.png`, filePath: tempFilePaths?.[0], // 文件路径 success: (res: any) => { // get resource ID console.log("res", res?.fileID); checkIn({ imageUrl: res?.fileID, lbsInfo: lbsInfo }); // 跳转到目的页面,打开新页面 // Taro.navigateTo({ // url: `/pages/home/components/CheckIn/index?fileID=${res?.fileID}`, // }); }, fail: (err: any) => { // handle error console.log("err", err); }, }); }; const onSearch = (e: any) => { console.log("e---", e); // Toast.show(`search: ${e.detail}`); // setSearchValue(e?.detail); setSearchValue(""); // 跳转到目的页面,打开新页面 Taro.navigateTo({ url: "/pages/activityList/index", }); }; const onCancel = (e: any) => { // Toast.show(`onCancel`); }; // 签到 const checkIn = async (data: any) => { console.log("data=====", data); let postData = { tableName: "userInfo", keyValue: { openId: openid }, okFun: (res: any) => { console.log("提交打卡,res", res); let newobj = { tableName: "userInfo", id: res?.data?.[0]?._id, objData: { checkInArr: [ ...(res?.data?.[0]?.checkInArr ?? []), { imageUrl: data?.imageUrl, checkTime: new Date().valueOf(), //打卡时间 latitude: data?.lbsInfo?.latitude, longitude: data?.lbsInfo?.longitude, // remark: fieldValues?.remark, // location: address, }, ], }, okFun: (okFunres: any) => { console.log("提交打卡,res", okFunres); Toast.success({ message: "打卡成功", selector: "#vanToast-demo2", duration: 2000, onClose: () => { // 跳转到打卡页面 // 返回首页 [上一页] // Taro.navigateBack({ // delta: 1, // }); }, }); }, }; updateTableid({ ...newobj }); }, }; // 查询openid getTable({ ...postData }); }; // 获取地理位置 const getLocation = async () => { // 获取地理位置 Taro.getLocation({ type: "wgs84", success: function (res: any) { // 地理位置信息-经纬度 console.log("lbsres---", res); const latitude = res.latitude; const longitude = res.longitude; const speed = res.speed; const accuracy = res.accuracy; }, }); }; const chooseImage = (lbsInfo: any) => { // 相机拍照 Taro.chooseImage({ count: 1, // 默认9 // , 'compressed' sizeType: ["original"], // 可以指定是原图还是压缩图,默认二者都有 // 'album', sourceType: ["camera"], // 可以指定来源是相册还是相机,默认二者都有,在H5浏览器端支持使用 `user` 和 `environment`分别指定为前后摄像头 success: function (res: any) { // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 let tempFilePaths = res.tempFilePaths; console.log("tempFilePaths===", tempFilePaths); // 跳转页面 // Taro.navigateTo({ // url: `/pages/home/components/CheckIn/index?fileID=${tempFilePaths?.[0]}`, // }); uploadTaro(tempFilePaths, lbsInfo); }, complete: () => { // 刷新页面数据 getsystemConfig(); //获取系统配置 setTimeout(() => { getdetails(); //获取活动详情 }, 800); }, }); }; const showAd = () => { // addData.show(); getAd(); }; return ( {/* 请选择正确的给微信公众号名称 setValue(e.detail)}> 异度世界 hackrobot 极客小助手 */} {" "} 我的生活日记 对事物的看法 {/* 设置了视频弹窗广告 */} 读书笔记 参加的线上线下活动 旅游过的城市 {/* {String(show)} */} {/* {String(isEnded)} */} {/* 二维码 */} {/* banner广告 */} {/* console.log("ad onLoad")} onError={() => console.log("ad onError")} onClose={() => console.log("ad onClose")} /> */} { setShow(false); setisEnded(false); }} > {/* */} {/* 通知条 */} {/* {systemConfig?.length > 0 && !systemConfig?.[0]?.notice?.isHidden && ( )} */} {/* 顶部 */} {/* 深圳 */} {/* */} {/* 深圳 */} {/* setShow(true)}> 深圳 */} {/* 搜索框 */} {/* setSearchValue(e.detail)} placeholder="请输入搜索关键词" style={{ width: "320px" }} onSearch={onSearch} // onCancel={onCancel} /> */} {/* 轮播图 */} {/* {systemConfig?.length > 0 && ( {(systemConfig?.[0]?.imagesArr ?? []).map( (item: any, index: any) => ( ) )} )} */} {/* 模块 */} {/* { // getLocation(); if (isIn) { // 获取定位信息 Taro.getLocation({ type: "gcj02", //返回可以用于 Taro.openLocation的经纬度 success: function (res: any) { console.log("lbs", res); const latitude = res?.latitude; const longitude = res?.longitude; let lbsInfo = { latitude: res?.latitude, longitude: res?.longitude, }; // 拍照上传 chooseImage(lbsInfo); }, fail: () => { Toast.fail({ message: "定位授权异常,无法签到打卡", selector: "#vanToast-demo2", }); }, }); // chooseImage(); } else { await getdetails(); Toast.fail({ message: "请先登录", selector: "#vanToast-demo2", duration: 2000, onClose: () => { // 跳转到目的页面,打开新页面 Taro.navigateTo({ url: "/pages/my/index", }); }, }); } }} /> */} {/* { // 跳转到目的页面,打开新页面 Taro.navigateTo({ url: "/pages/mountainPeak/index", }); }} /> */} {/* { // 跳转到目的页面,打开新页面 Taro.navigateTo({ url: "/pages/activityList/index", }); }} /> */} {/* { Toast.fail({ message: "参加1次活动后,可发起组队", selector: "#vanToast-demo2", }); // 跳转到目的页面,打开新页面 // Taro.navigateTo({ // url: "/pages/formSubmit/index", // }); }} /> */} {/* { // 打开视频号-指定视频 Taro.openChannelsActivity({ // finderUserName: "sphqzUmI0BlppCI", //视频号id, finderUserName: systemConfig?.[0]?.videoObj?.finderUserName ?? "sphqzUmI0BlppCI", feedId: systemConfig?.[0]?.videoObj?.feedId ?? "export/UzFfAgtgekIEAQAAAAAAeIIQA5S-0wAAAAstQy6ubaLX4KHWvLEZgBPEj6MUcExXaL37zNPgMJpEUVVnZ9njxR_hb9_u-bQj", //视频 feedId success: (res: any) => { console.log("res", res); }, }); // 打开视频号主页 [接口异常] // Taro.openChannelsUserProfile({ // finderUserName: "sphqzUmI0BlppCI", //视频号id // success: (res: any) => { // console.log("res", res); // }, // // }); }} /> */} {/* { // 跳转到目的页面,打开新页面 Taro.navigateTo({ url: "/pages/home/components/Certified/index", }); }} /> */} {/* // */} {/* 分割线 */} {/* */} {/* 离我最近/天气/动态展示 */} {/* 离你最近 (5km) {`天气晴雨[动画效果]`} 温度 是否开放 */} {/* 日期页签 */} {/* {}}> 今天 明天 后天 周六 周日 */} {/* 离我最近 */} {/* 理我最近 梧桐山 5km 七娘山 3km 莲花山 2km */} {/* 截取数组2个活动 */} {/* {details?.length > 0 ? ( {(details?.reverse()?.splice(0, 2) ?? []).map( (item: any, index: any) => { return ( { console.log("Card"); Taro.navigateTo({ url: `/pages/activityList/components/details/index?id=${item?._id}`, }); }} > ); } )} ) : ( )} */} {/* 加入微信群 */} {/* */} {/* 打卡精选 */} {/* 瀑布流 */} {/* */} {/* 直播live专区 */} {/* 视频号直播 */} {/* 小红书图文/视频信息流 */} {/* 打开信息流 */} {/* 扫码的场景(才会显示) */} {/* */} {/* 个人版本未生效 */} {/* { console.log("加载成功", res); }} onError={(res: any) => { console.log("加载失败", res); }} > */} {/* */} {/* 打开视频号主页-需要开放平台主主体认证 */} {/* { Taro.openChannelsUserProfile({ finderUserName: "sphqzUmI0BlppCI", //视频号id success: (res: any) => { console.log("加载成功", res); }, fail: (error: any) => { console.log("加载成功", error); }, }); }} > {" "} 打开视频号主页 */} {/* 个人小程序无法打开公众号文章 */} {/* {}} /> */} {/* { Taro.requestSubscribeMessage({ tmplIds:["oyY-sN3yBm4JRch1PoT-Cj7049c9vyZAMs1LwnUma4I"], //模板id success:(res:any)=>{ console.log('res',res) } }) }}>订阅消息 */} {/* */} {/* 打开视频号 */} {/* { Taro.openChannelsActivity({ finderUserName: "sphqzUmI0BlppCI", //视频号id feedId: "export/UzFfAgtgekIEAQAAAAAAeIIQA5S-0wAAAAstQy6ubaLX4KHWvLEZgBPEj6MUcExXaL37zNPgMJpEUVVnZ9njxR_hb9_u-bQj", //视频 feedId success: (res: any) => { console.log("res", res); }, }); }} > 打开视频号 */} {/* @ts-ignore */} {/* */} {/* @ts-ignore */} {/* */} {/* 底部tabbar */} {/* */} ); }; export default Home;