feat: 封装增删查改函数
This commit is contained in:
2
dist/app.js
vendored
2
dist/app.js
vendored
File diff suppressed because one or more lines are too long
4
dist/base.wxml
vendored
4
dist/base.wxml
vendored
@@ -37,6 +37,10 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template name="tmpl_0_46">
|
||||
<rich-text nodes="{{xs.b(i.p0,[])}}" space="{{i.p1}}" user-select="{{xs.b(i.p2,false)}}" style="{{i.st}}" class="{{i.cl}}" bindtap="eh" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}"></rich-text>
|
||||
</template>
|
||||
|
||||
<template name="tmpl_0_4">
|
||||
<text selectable="{{xs.b(i.p1,!1)}}" space="{{i.p2}}" decode="{{xs.b(i.p0,!1)}}" user-select="{{xs.b(i.p3,false)}}" style="{{i.st}}" class="{{i.cl}}" id="{{i.uid||i.sid}}" data-sid="{{i.sid}}">
|
||||
<block wx:for="{{i.cn}}" wx:key="sid">
|
||||
|
||||
2
dist/common.js
vendored
2
dist/common.js
vendored
@@ -1,2 +1,2 @@
|
||||
/*! For license information please see common.js.LICENSE.txt */
|
||||
"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([["common"],{"./src/pages/components/TabbarCom/index.tsx":function(e,n,t){var o=t("./node_modules/@antmjs/vantui/es/tabbar/index.js"),a=t("./node_modules/@antmjs/vantui/es/tabbar-item/index.js"),i=t("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),s=t("./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js"),r=t("webpack/container/remote/@tarojs/taro"),l=t.n(r),d=t("webpack/container/remote/react"),c=t.n(d),u=t("webpack/container/remote/react/jsx-runtime");n.default=function TabbarCom(e){var n,t=c().useState(null!==(n=null==e?void 0:e.active)&&void 0!==n?n:0),r=(0,i.default)(t,2),d=r[0],m=r[1];return(0,u.jsx)(s.View,{style:{marginTop:"40px"},children:(0,u.jsxs)(o.default,{active:d,onChange:function onChange(e){console.log("e",e),m(null==e?void 0:e.detail),0===(null==e?void 0:e.detail)&&l().redirectTo({url:"/pages/home/index"}),1===(null==e?void 0:e.detail)&&l().redirectTo({url:"/pages/activityList/index"}),2===(null==e?void 0:e.detail)&&l().redirectTo({url:"/pages/my/index"})},safeAreaInsetBottom:!0,children:[(0,u.jsx)(a.default,{icon:"home-o",children:"首页"}),(0,u.jsx)(a.default,{icon:"friends-o",children:"活动"}),(0,u.jsx)(a.default,{icon:"setting-o",children:"我的"})]})})}}}]);
|
||||
"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([["common"],{"./src/pages/components/TabbarCom/index.tsx":function(e,n,t){var o=t("./node_modules/@antmjs/vantui/es/tabbar/index.js"),a=t("./node_modules/@antmjs/vantui/es/tabbar-item/index.js"),i=t("./node_modules/@babel/runtime/helpers/esm/slicedToArray.js"),s=t("./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js"),l=t("webpack/container/remote/@tarojs/taro"),c=t.n(l),r=t("webpack/container/remote/react"),d=t.n(r),u=t("webpack/container/remote/react/jsx-runtime");n.default=function TabbarCom(e){var n,t=d().useState(null!==(n=null==e?void 0:e.active)&&void 0!==n?n:0),l=(0,i.default)(t,2),r=l[0],m=l[1];return(0,u.jsx)(s.View,{style:{marginTop:"40px"},children:(0,u.jsxs)(o.default,{active:r,onChange:function onChange(e){console.log("e",e),m(null==e?void 0:e.detail),0===(null==e?void 0:e.detail)&&c().redirectTo({url:"/pages/home/index"}),1===(null==e?void 0:e.detail)&&c().redirectTo({url:"/pages/activityList/index"}),2===(null==e?void 0:e.detail)&&c().redirectTo({url:"/pages/my/index"})},safeAreaInsetBottom:!0,children:[(0,u.jsx)(a.default,{icon:"home-o",children:"首页"}),(0,u.jsx)(a.default,{icon:"friends-o",children:"活动"}),(0,u.jsx)(a.default,{icon:"setting-o",children:"我的"})]})})}},"./src/utils/index.ts":function(e,n,t){t.d(n,{getTable:function(){return i},getTableid:function(){return s}});var o=t("webpack/container/remote/@tarojs/taro"),a=t.n(o),i=function getTable(e){var n=e.env,t=e.tableName,o=e.okFun,i=a().cloud.database({env:n}),s=null==i?void 0:i.collection(t);null==s||s.get({success:function success(e){o(e)}})},s=function getTableid(e){var n=e.env,t=e.tableName,o=e.id,i=e.okFun,s=a().cloud.database({env:n}),l=null==s?void 0:s.collection(t);null==l||l.doc(o).get({success:function success(e){i(e)}})}}}]);
|
||||
4
dist/common.js.LICENSE.txt
vendored
4
dist/common.js.LICENSE.txt
vendored
@@ -12,6 +12,10 @@
|
||||
|
||||
/*! react/jsx-runtime */
|
||||
|
||||
/*!****************************!*\
|
||||
!*** ./src/utils/index.ts ***!
|
||||
\****************************/
|
||||
|
||||
/*!**************************************************!*\
|
||||
!*** ./src/pages/components/TabbarCom/index.tsx ***!
|
||||
\**************************************************/
|
||||
|
||||
2
dist/pages/home/index.js
vendored
2
dist/pages/home/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/pages/home/index.js.LICENSE.txt
vendored
2
dist/pages/home/index.js.LICENSE.txt
vendored
@@ -6,6 +6,8 @@
|
||||
|
||||
/*! ../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[9].use[1]!./index.tsx */
|
||||
|
||||
/*! ../../utils/index */
|
||||
|
||||
/*! ../common/jumpLink */
|
||||
|
||||
/*! ../common/utils */
|
||||
|
||||
2
dist/pages/mountainPeak/index.js
vendored
2
dist/pages/mountainPeak/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/pages/mountainPeak/index.js.LICENSE.txt
vendored
2
dist/pages/mountainPeak/index.js.LICENSE.txt
vendored
@@ -1,5 +1,7 @@
|
||||
/*! ../../../node_modules/thread-loader/dist/cjs.js!../../../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[9].use[1]!./index.tsx */
|
||||
|
||||
/*! ../../utils/index */
|
||||
|
||||
/*! ../info/index */
|
||||
|
||||
/*! ../wxs/utils */
|
||||
|
||||
12
dist/pages/mountainPeak/index.wxss
vendored
12
dist/pages/mountainPeak/index.wxss
vendored
@@ -6,3 +6,15 @@
|
||||
!*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[0].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].oneOf[0].use[2]!./node_modules/@antmjs/vantui/es/sidebar-item/index.css ***!
|
||||
\*****************************************************************************************************************************************************************************************************************************/
|
||||
.van-sidebar-item{display:block;box-sizing:border-box;overflow:hidden;border-left:6rpx solid transparent;-webkit-user-select:none;user-select:none;padding:40rpx 24rpx 40rpx 16rpx;padding:var(--sidebar-padding,40rpx 24rpx 40rpx 16rpx);font-size:28rpx;font-size:var(--sidebar-font-size, 28rpx);line-height:40rpx;line-height:var(--sidebar-line-height, 40rpx);color:#323233;color:var(--sidebar-text-color,#323233);background-color:#f7f8fa;background-color:var(--sidebar-background-color,#f7f8fa)}.van-sidebar-item__text{position:relative;display:inline-block;word-break:break-all}.van-sidebar-item--hover:not(.van-sidebar-item--disabled){background-color:#f2f3f5;background-color:var(--sidebar-active-color,#f2f3f5)}.van-sidebar-item::after{border-bottom-width:2rpx}.van-sidebar-item--selected{color:#323233;color:var(--sidebar-selected-text-color,#323233);font-weight:500;font-weight:var(--sidebar-selected-font-weight,500);border-color:#ee0a24;border-color:var(--sidebar-selected-border-color,#ee0a24)}.van-sidebar-item--selected::after{border-right-width:2rpx}.van-sidebar-item--selected,.van-sidebar-item--selected.van-sidebar-item--hover{background-color:#fff;background-color:var(--sidebar-selected-background-color,#fff)}.van-sidebar-item--disabled{color:#c8c9cc;color:var(--sidebar-disabled-text-color,#c8c9cc)}
|
||||
/*!************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
|
||||
!*** css ./node_modules/cache-loader/dist/cjs.js!./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[0].use[2]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[0].use[3]!./node_modules/resolve-url-loader/index.js!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[0].use[5]!./src/pages/mountainPeak/index.scss ***!
|
||||
\************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
|
||||
.peakContent {
|
||||
background-color: yellow;
|
||||
display: -webkit-flex;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-webkit-flex-direction: row;
|
||||
-ms-flex-direction: row;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
16
dist/project.private.config.json
vendored
16
dist/project.private.config.json
vendored
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "我的",
|
||||
"pathName": "pages/my/index",
|
||||
"query": "",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
2
dist/taro.js
vendored
2
dist/taro.js
vendored
@@ -1,2 +1,2 @@
|
||||
/*! For license information please see taro.js.LICENSE.txt */
|
||||
"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([["taro"],{"./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js":function(e,n,t){t.d(n,{Image:function(){return i},Navigator:function(){return c},ScrollView:function(){return a},Text:function(){return r},View:function(){return o}});var o="view",r="text",a="scroll-view",c="navigator",i="image"},"./node_modules/@tarojs/webpack5-runner/dist/template/comp.js":function(e,n,t){var o=t("webpack/container/remote/@tarojs/runtime");Component((0,o.createRecursiveComponentConfig)())},"./node_modules/@tarojs/webpack5-runner/dist/template/custom-wrapper.js":function(e,n,t){var o=t("webpack/container/remote/@tarojs/runtime");Component((0,o.createRecursiveComponentConfig)("custom-wrapper"))}}]);
|
||||
"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([["taro"],{"./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js":function(e,t,n){n.d(t,{Image:function(){return u},Navigator:function(){return i},RichText:function(){return r},ScrollView:function(){return c},Text:function(){return a},View:function(){return o}});var o="view",r="rich-text",a="text",c="scroll-view",i="navigator",u="image"},"./node_modules/@tarojs/webpack5-runner/dist/template/comp.js":function(e,t,n){var o=n("webpack/container/remote/@tarojs/runtime");Component((0,o.createRecursiveComponentConfig)())},"./node_modules/@tarojs/webpack5-runner/dist/template/custom-wrapper.js":function(e,t,n){var o=n("webpack/container/remote/@tarojs/runtime");Component((0,o.createRecursiveComponentConfig)("custom-wrapper"))}}]);
|
||||
17
src/app.ts
17
src/app.ts
@@ -1,11 +1,22 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
import { Component } from "react";
|
||||
import "./app.scss";
|
||||
class App extends Component<any> {
|
||||
componentDidMount() {}
|
||||
componentDidMount() {
|
||||
Taro.cloud.init({
|
||||
env: 'cloud1-5g5xrgza12a0dd6d',
|
||||
traceUser:true
|
||||
})
|
||||
|
||||
componentDidShow () {}
|
||||
const a = new Taro.cloud.Cloud({
|
||||
resourceEnv: 'cloud1-5g5xrgza12a0dd6d',
|
||||
})
|
||||
a.init()
|
||||
}
|
||||
|
||||
componentDidHide () {}
|
||||
componentDidShow() {}
|
||||
|
||||
componentDidHide() {}
|
||||
|
||||
// this.props.children 是将要会渲染的页面
|
||||
render() {
|
||||
|
||||
@@ -9,13 +9,14 @@ import {
|
||||
Tag,
|
||||
} from "@antmjs/vantui";
|
||||
import { View } from "@tarojs/components";
|
||||
import React, { useCallback } from "react";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
import { Swiper, SwiperItem, Image } from "@antmjs/vantui";
|
||||
import react from "react";
|
||||
import { NoticeBar } from "@antmjs/vantui";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { Tabbar, TabbarItem } from "@antmjs/vantui";
|
||||
import TabbarCom from "../components/TabbarCom";
|
||||
import { getTable, getTableid } from "../../utils/index";
|
||||
|
||||
const Home = () => {
|
||||
// const { images } = COMMON
|
||||
@@ -27,6 +28,18 @@ const Home = () => {
|
||||
"cloud://cloud1-5g5xrgza12a0dd6d.636c-cloud1-5g5xrgza12a0dd6d-1253665791/images.jpg",
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
let objParams={
|
||||
tableName: "test",
|
||||
id: "80516fb66370bcf300b8f43c5f4dd52b",
|
||||
okFun: (res) => {
|
||||
console.log("res", res);
|
||||
},
|
||||
}
|
||||
getTable(objParams)
|
||||
getTableid(objParams);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View>
|
||||
{/* 通知条 */}
|
||||
@@ -126,7 +139,7 @@ const Home = () => {
|
||||
<TabbarItem icon="setting-o">我的</TabbarItem>
|
||||
</Tabbar> */}
|
||||
|
||||
<TabbarCom active={0}/>
|
||||
<TabbarCom active={0} />
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
5
src/pages/mountainPeak/index.scss
Normal file
5
src/pages/mountainPeak/index.scss
Normal file
@@ -0,0 +1,5 @@
|
||||
.peakContent{
|
||||
background-color: yellow;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
@@ -1,23 +1,49 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { RichText, View } from "@tarojs/components";
|
||||
import react from "react";
|
||||
import { Sidebar, SidebarItem } from "@antmjs/vantui";
|
||||
import "./index.scss";
|
||||
import {test} from '../../utils/index'
|
||||
|
||||
|
||||
const mountainPeak = () => {
|
||||
const state: any = {
|
||||
nodes: [
|
||||
{
|
||||
name: "div",
|
||||
attrs: {
|
||||
class: "div_class",
|
||||
style: "line-height: 60px; color: red;",
|
||||
},
|
||||
children: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Hello World!",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
return (
|
||||
<View>
|
||||
<View className={`peakContent`}>
|
||||
{" "}
|
||||
<Sidebar activeKey={0}>
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="梧桐山" />
|
||||
<SidebarItem title="标签名" />
|
||||
<SidebarItem title="标签名" />
|
||||
</Sidebar>
|
||||
<View onClick={()=>{
|
||||
test()
|
||||
}}>
|
||||
{" "}
|
||||
<RichText nodes={state.nodes} />
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
63
src/utils/index.ts
Normal file
63
src/utils/index.ts
Normal file
@@ -0,0 +1,63 @@
|
||||
import Taro from "@tarojs/taro";
|
||||
|
||||
// 数据库环境
|
||||
// const db: any = Taro.cloud.database({
|
||||
// env: "cloud1-5g5xrgza12a0dd6d",
|
||||
// });
|
||||
|
||||
interface Typeint {
|
||||
env?: any;
|
||||
id?:any
|
||||
tableName: any;
|
||||
objData?: any;
|
||||
okFun: any;
|
||||
}
|
||||
|
||||
// 添加数据
|
||||
export const addTable: any = ({ env,tableName, objData, okFun }: Typeint) => {
|
||||
// 数据库环境
|
||||
const db: any = Taro.cloud.database({
|
||||
env: env,
|
||||
});
|
||||
|
||||
let nowtable: any = db?.collection(tableName);
|
||||
nowtable?.add({
|
||||
// data 字段表示需新增的 JSON 数据
|
||||
data: objData,
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
// 获取指定集合数据
|
||||
export const getTable: any = ({ env,tableName, okFun }: Typeint) => {
|
||||
// 数据库环境
|
||||
const db: any = Taro.cloud.database({
|
||||
env: env,
|
||||
});
|
||||
|
||||
let nowtable: any = db?.collection(tableName);
|
||||
nowtable?.get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 获取指定id数据数据
|
||||
export const getTableid: any = ({ env,tableName, id, okFun }: Typeint) => {
|
||||
// 数据库环境
|
||||
const db: any = Taro.cloud.database({
|
||||
env: env,
|
||||
});
|
||||
|
||||
let nowtable: any = db?.collection(tableName);
|
||||
nowtable?.doc(id).get({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user