diff --git a/config/prod.js b/config/prod.js index 31497d7..30ccf79 100644 --- a/config/prod.js +++ b/config/prod.js @@ -1,3 +1,4 @@ +const path = require('path') module.exports = { env: { NODE_ENV: '"production"' @@ -14,5 +15,11 @@ module.exports = { * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, []) * } */ + }, + alias: { + '@': path.resolve(__dirname, '..', 'src'), + }, + sass: { + resource: path.resolve(__dirname, '..', 'src/styles/common.scss') } } diff --git a/src/app.config.ts b/src/app.config.ts index 487ef1c..28257f6 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -67,7 +67,25 @@ export default { ] }, { - root: "pages/addAddress", + root: "pages/addressAdd", + pages: [ + "index" + ] + }, + { + root: "pages/company", + pages: [ + "index" + ] + }, + { + root: "pages/weightList", + pages: [ + "index" + ] + }, + { + root: "pages/weightListAdd", pages: [ "index" ] diff --git a/src/common/common.ts b/src/common/common.ts index d0266a1..a5a7bc8 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -22,4 +22,68 @@ export const goLink = (path = '', params = {}, type:false|true = false) => { } } -} \ No newline at end of file +} +/** + * 判断对象为空 + * @param object + * @returns + */ +export const isEmptyObject = (object: any)=>{ + if(object==undefined||object==null||Number.isNaN(object)){ + return true; + }else{ + if(object.constructor==Object){ + return Reflect.ownKeys(object).length==0; + }else if(object.constructor==Array){ + return object.length==0; + }else if(object.constructor==String){ + return object==""; + } + } + return false; + } + +/** + * 表单检索 + * @param data + * @param rules + * @param message + * @returns + */ +export const retrieval = (data: any, message: string="请填写完信息", rules?: Object)=>{ + return new Promise((resolve, reject)=>{ + if(rules){ + const keys = Reflect.ownKeys(rules); + const result = keys.some((key:any)=>{ + for(let item of (rules as any)[key]){ + + let _res = false; + if(item.validator){ + if(item.validator(data[key],item)){ + _res=true; + } + }else if(item.regex){ + if(!item.regex.test(data[key])){ + _res=true; + } + }else{ + if(isEmptyObject(data[key])){ + _res=true; + } + } + message = item.message; + return _res; + } + }); + if(result){ + reject(message); + } + }else{ + const keys = Reflect.ownKeys(data); + if(keys.some((key:any)=>isEmptyObject(data[key]))){ + reject(message); + } + } + resolve(null); + }) + } \ No newline at end of file diff --git a/src/components/AddressList/index.scss b/src/components/AddressList/index.scss index 1e94570..78f6d40 100644 --- a/src/components/AddressList/index.scss +++ b/src/components/AddressList/index.scss @@ -16,6 +16,7 @@ padding: 30px; box-sizing: border-box; margin: 18px auto 0; + border: 1px solid #ffffff; } .address-list:hover{ border: 1px solid #68b4ff; @@ -50,8 +51,8 @@ color: #ababab; margin-left: 30px; } - .address-edit{ - font-size: 26px; + .address-edit .icon-bianji{ + font-size: 40px; } .address-list-info{ @@ -75,4 +76,13 @@ position: absolute;bottom: 8%;left: 50%; transform: translateX(-50%); } + .address-no-data{ + font-size: 24px; + font-weight: 400; + text-align: center; + color: #707070; + height: 100%; + padding-top: 40%; + box-sizing: border-box; + } } \ No newline at end of file diff --git a/src/components/AddressList/index.tsx b/src/components/AddressList/index.tsx index bc1b374..1681fbc 100644 --- a/src/components/AddressList/index.tsx +++ b/src/components/AddressList/index.tsx @@ -1,6 +1,6 @@ import { Button, Navigator, ScrollView, Text, View } from "@tarojs/components" -import { useState } from "react" +import { memo, useState } from "react" import "./index.scss" interface Params{ @@ -10,22 +10,23 @@ interface Params{ } // 地址列表 -const AddressList = (props:Params)=>{ +const AddressList = memo((props:Params)=>{ // 处理刷新 const [refreshState, setRefreshState] = useState(false); const handleRefresh = ()=>{ setRefreshState(true); setTimeout(()=>{ setRefreshState(false); - },3000) - + },500) } + const data = Array.from({length:15}); return ( { - Array.from({length:15}).map((item,index)=>{ + data.length>0? + data.map((item,index)=>{ return( props.onSelect&&props.onSelect(item,index)} className="address-list"> @@ -38,16 +39,19 @@ const AddressList = (props:Params)=>{ **省**市**区**街道****仓库 181****9790 - 编辑 + + + ); - }) + }): + 暂未添加地址 } - 添加收货地址 + 添加收货地址 ) -} +}) export default AddressList; \ No newline at end of file diff --git a/src/pages/addAddress/index.scss b/src/components/FromList/index.scss similarity index 80% rename from src/pages/addAddress/index.scss rename to src/components/FromList/index.scss index b77fdba..c59c84e 100644 --- a/src/pages/addAddress/index.scss +++ b/src/components/FromList/index.scss @@ -1,10 +1,8 @@ -.add-address{ +.form-list{ + display: flex; + justify-content: space-between; + margin: 30px 30px 0; - .form-list{ - display: flex; - justify-content: space-between; - margin: 30px 30px 0; - } .form-list-label{ font-size: 28px; font-weight: 700; @@ -13,13 +11,16 @@ } .form-list-right{ width: 506px; - min-height: 80px; - background: #f6f6f6; - border-radius: 20px; - padding: 10px 20px; - box-sizing: border-box; font-size: 26px; font-weight: 400; + } + .form-list-right-meet{ + background: #f6f6f6; + width: 506px; + min-height: 80px; + border-radius: 20px; + box-sizing: border-box; + padding: 10px 20px; display: flex;justify-content: space-between; align-items: center; } @@ -32,6 +33,7 @@ .form-list-right textarea{ height: 186px; border-radius: 10px; + padding: 10px 0; } .form-list-right .phcolor{ color: #ababab; @@ -39,8 +41,8 @@ .form-list-right-placeholder{ color: #ababab; } - .form-list-right-enter{ - + .form-list-right-enter .icon-a-moreback{ + font-size: 28px; } .add-address-default{ display: flex;align-items: center;justify-content: space-between; diff --git a/src/components/FromList/index.tsx b/src/components/FromList/index.tsx new file mode 100644 index 0000000..2d428cf --- /dev/null +++ b/src/components/FromList/index.tsx @@ -0,0 +1,46 @@ + +import { Input, Text, Textarea, View } from "@tarojs/components" +import { memo } from "react" +import "./index.scss" + +interface ListParams{ + label: string, //左边label + onInput?: ()=>any, // 输入框输入 + onClick?:()=>any, //点击列表 + placeholder?:string, // 提示文本 + children?: any, // 插槽 + type?: string // 类型:1.input,2.textarea,3.select + value?: any +} + +// 表单列表 +const FromList = memo((props:ListParams)=>{ + const {type="input",value=""} = props; + + return ( + + {props.label} + + { + props.children?? + + { + type=="input"?: + type=="textarea"?