feat: 数组排序reverse

This commit is contained in:
eric
2022-11-26 12:01:33 +08:00
parent 91b15419af
commit 0555fb9392
5 changed files with 75 additions and 25 deletions

View File

@@ -1,6 +1,6 @@
import { Button, Cell, Toast } from "@antmjs/vantui";
import { RichText, View } from "@tarojs/components";
import Taro, { getCurrentInstance } from "@tarojs/taro";
import Taro, { getCurrentInstance, useShareTimeline } from "@tarojs/taro";
import react, { useEffect, useState } from "react";
import {
addTable,
@@ -30,6 +30,27 @@ const details = () => {
});
}, []);
// 分享到朋友圈
useShareTimeline(() => {
return {
title: "分享朋友圈", //字符串 自定义标题
// query: `id=${this.data.shop.shop_id}`, //页面携带参数
// imageUrl: moments //图片地址
};
});
useEffect(() => {
// 设置允许分享
Taro.showShareMenu({
withShareTicket: true,
});
// 其他分享
Taro.updateShareMenu({
withShareTicket: true,
success() {},
});
}, []);
useEffect(() => {
// (dataSource?.useridArr ?? []).length > 0 &&
Taro.cloud.callFunction({
@@ -55,17 +76,22 @@ const details = () => {
let newBottom = screenHeight - safeArea?.bottom ?? 0;
setbottomheight(newBottom);
getDetail();
}, []);
// 获取详情
const getDetail = () => {
let objParams = {
tableName: "details",
id: id,
okFun: (res) => {
console.log("res", res);
setdataSource(res?.data ?? []);
setdataSource((res?.data ?? []));
},
};
getTableid(objParams); //指定活动详情id
// getTable(objParams);
}, []);
// getTable(objParams)
};
// console.log('SafeAreaResult',Taro.getSystemInfoSync())
@@ -220,11 +246,13 @@ const details = () => {
message: "取消成功",
selector: "#vanToast-demo2",
onClose: () => {
// 刷新数据
getDetail();
// 返回首页 [上一页]
Taro.navigateBack({
// url: "/pages/home/index",
delta: 1,
});
// Taro.navigateBack({
// // url: "/pages/home/index",
// delta: 1,
// });
},
});
},
@@ -266,11 +294,14 @@ const details = () => {
message: "报名成功",
selector: "#vanToast-demo2",
onClose: () => {
// 刷新数据
getDetail();
// 返回首页 [上一页]
Taro.navigateBack({
// url: "/pages/home/index",
delta: 1,
});
// Taro.navigateBack({
// // url: "/pages/home/index",
// delta: 1,
// });
},
});
},

View File

@@ -11,7 +11,7 @@ import {
Tag,
Toast,
} from "@antmjs/vantui";
import { Input, OfficialAccount, View } from "@tarojs/components";
import { Input, OfficialAccount, View, WebView } from "@tarojs/components";
import React, { useCallback, useEffect, useState } from "react";
import { Swiper, SwiperItem, Image } from "@antmjs/vantui";
import react from "react";
@@ -130,7 +130,7 @@ const Home = () => {
};
// 上传到云存储
const uploadTaro = (tempFilePaths: any,lbsInfo:any) => {
const uploadTaro = (tempFilePaths: any, lbsInfo: any) => {
// 云开发存储文件 [/自动创建文件路径]
Taro.cloud.uploadFile({
cloudPath: `images/checkIn/${new Date()?.getTime()}.png`,
@@ -138,7 +138,7 @@ const Home = () => {
success: (res: any) => {
// get resource ID
console.log("res", res?.fileID);
checkIn({ imageUrl: res?.fileID,lbsInfo: lbsInfo});
checkIn({ imageUrl: res?.fileID, lbsInfo: lbsInfo });
// 跳转到目的页面,打开新页面
// Taro.navigateTo({
@@ -168,7 +168,7 @@ const Home = () => {
// 签到
const checkIn = async (data: any) => {
console.log('data=====',data)
console.log("data=====", data);
let postData = {
tableName: "userInfo",
keyValue: { openId: openid },
@@ -184,8 +184,8 @@ const Home = () => {
{
imageUrl: data?.imageUrl,
checkTime: new Date().valueOf(), //打卡时间
latitude:data?.lbsInfo?.latitude,
longitude:data?.lbsInfo?.longitude
latitude: data?.lbsInfo?.latitude,
longitude: data?.lbsInfo?.longitude,
// remark: fieldValues?.remark,
// location: address,
},
@@ -231,7 +231,7 @@ const Home = () => {
});
};
const chooseImage = (lbsInfo:any) => {
const chooseImage = (lbsInfo: any) => {
// 相机拍照
Taro.chooseImage({
count: 1, // 默认9
@@ -248,7 +248,7 @@ const Home = () => {
// url: `/pages/home/components/CheckIn/index?fileID=${tempFilePaths?.[0]}`,
// });
uploadTaro(tempFilePaths,lbsInfo);
uploadTaro(tempFilePaths, lbsInfo);
},
complete: () => {
// 刷新页面数据
@@ -392,12 +392,12 @@ const Home = () => {
// 拍照上传
chooseImage(lbsInfo);
},
fail:()=>{
fail: () => {
Toast.fail({
message: "定位授权异常,无法签到打卡",
selector: "#vanToast-demo2",
});
}
},
});
// chooseImage();
} else {
@@ -489,7 +489,7 @@ const Home = () => {
{/* 截取数组2个活动 */}
{details?.length > 0 && (
<View>
{(details?.splice(0, 2) ?? []).map((item: any, index: any) => {
{(details?.reverse()?.splice(0, 2) ?? []).map((item: any, index: any) => {
return (
<View
onClick={() => {
@@ -545,6 +545,17 @@ const Home = () => {
打开视频号主页
</View> */}
{/* 个人小程序无法打开公众号文章 */}
{/* <WebView src="https://mp.weixin.qq.com/s/LkjkAWW9VUB90KoyZpI5Fg" onMessage={() => {}} /> */}
<View onClick={()=>{
Taro.requestSubscribeMessage({
tmplIds:["oyY-sN3yBm4JRch1PoT-Cj7049c9vyZAMs1LwnUma4I"], //模板id
success:(res:any)=>{
console.log('res',res)
}
})
}}></View>
<Toast id="vanToast-demo2" />
<TabbarCom active={0} />