diff --git a/config/pre.js b/config/pre.js index fe4664b..a8791fb 100644 --- a/config/pre.js +++ b/config/pre.js @@ -3,7 +3,6 @@ module.exports = { env: { NODE_ENV: '"pre"', }, - outputRoot: 'pre_dis', defineConstants: {}, mini: { optimizeMainPackage: { @@ -32,16 +31,7 @@ module.exports = { }) }, }, - h5: { - /** - * 如果h5端编译后体积过大,可以使用webpack-bundle-analyzer插件对打包体积进行分析。 - * 参考代码如下: - * webpackChain (chain) { - * chain.plugin('analyzer') - * .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, []) - * } - */ - }, + h5: {}, alias: { '@': path.resolve(__dirname, '..', 'src'), }, diff --git a/package.json b/package.json index 363da3f..07584a4 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "dev:rn": "npm run build:rn -- --watch", "dev:qq": "npm run build:qq -- --watch", "dev:jd": "npm run build:jd -- --watch", - "dev:quickapp": "npm run build:quickapp -- --watch" + "dev:quickapp": "npm run build:quickapp -- --watch", + "build:weapp:pre": "cross-env NODE_ENV=pre taro build --type weapp" }, "browserslist": [ "last 3 versions", @@ -63,6 +64,7 @@ "@typescript-eslint/eslint-plugin": "^4.15.1", "@typescript-eslint/parser": "^4.15.1", "babel-preset-taro": "3.3.10", + "cross-env": "^7.0.3", "eslint": "^6.8.0", "eslint-config-taro": "3.3.10", "eslint-plugin-import": "^2.12.0", diff --git a/src/common/constant.js b/src/common/constant.js index 6f29d7c..dd73ec1 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -1,10 +1,19 @@ -// export const BASE_URL = CURRENT_ENV.includes('development') ? `https://test.zzfzyc.com/lymarket` : `https://www.zzfzyc.com/lymarket` +function BASE_URL_LIST() { + return { + development: `https://test.zzfzyc.com/lymarket`, + production: `https://www.zzfzyc.com/lymarket`, + pre: `https://pre.zzfzyc.com/lymarket`, + }[process.env.NODE_ENV || 'production'] +} + +export const BASE_URL = BASE_URL_LIST() // export const BASE_URL = `http://192.168.0.75:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:50001/lymarket` // export const BASE_URL = `http://10.0.0.5:50001/lymarket` // export const BASE_URL = `http://192.168.0.89:40001/lymarket` // export const BASE_URL = `http://192.168.1.165:40001/lymarket` // 王霞 -export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境 +// export const BASE_URL = `https://test.zzfzyc.com/lymarket` // 测试环境 +// export const BASE_URL = `https://pre.zzfzyc.com/lymarket` // 预发布 // export const BASE_URL = `http://192.168.1.9:40001/lymarket` // 发 // export const BASE_URL = `http://192.168.1.9:50005/lymarket` // 发 // export const BASE_URL = `http://192.168.1.30:50001/lymarket` // 发 @@ -20,12 +29,12 @@ export const GET_UPLOAD_SIGN = `/upyun/getsign` // 请求签名 url export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/` // cdn -// export const IMG_CND_Prefix = CURRENT_ENV.includes('development')? "https://test.cdn.zzfzyc.com":"https://cdn.zzfzyc.com" -export const IMG_CND_Prefix = CURRENT_ENV.includes('development') ? 'https://test.cdn.zzfzyc.com' : 'https://test.cdn.zzfzyc.com' +export const IMG_CND_Prefix = CURRENT_ENV.includes('development') ? 'https://test.cdn.zzfzyc.com' : 'https://cdn.zzfzyc.com' +// export const IMG_CND_Prefix = CURRENT_ENV.includes('development') ? 'https://test.cdn.zzfzyc.com' : 'https://www.cdn.zzfzyc.com' //在线支付图片baseUrl -// export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development')? "https://test.zzfzyc.com":"https://www.zzfzyc.com" -export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development') ? 'https://test.zzfzyc.com' : 'https://test.zzfzyc.com' +export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development') ? 'https://test.zzfzyc.com' : 'https://www.zzfzyc.com' +// export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development') ? 'https://test.zzfzyc.com' : 'https://www.zzfzyc.com' // 上传图片视频 export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}` diff --git a/src/components/banner/index.tsx b/src/components/banner/index.tsx index d356f4d..de6c3be 100644 --- a/src/components/banner/index.tsx +++ b/src/components/banner/index.tsx @@ -1,60 +1,53 @@ -import { Image, Swiper, SwiperItem, View } from "@tarojs/components" -import { goLink } from "@/common/common" -import {GetBannerList} from "@/api/banner" -import styles from './index.module.scss' -import { useEffect, useState } from "react" -import { formatImgUrl } from "@/common/fotmat" +import { Image, Swiper, SwiperItem, View } from '@tarojs/components' +import { goLink } from '@/common/common' +import { GetBannerList } from '@/api/banner' +import styles from './index.module.scss' +import { useEffect, useState } from 'react' +import { formatImgUrl } from '@/common/fotmat' -type item = {title:string, img:string, url:string, id:number} +type item = { title: string; img: string; url: string; id: number } type params = { list?: item[] - swiperOnClick?: (val: item) => void, + swiperOnClick?: (val: item) => void style?: Object } -export default (props:params) => { - let {swiperOnClick, style = {}} = props +export default (props: params) => { + let { swiperOnClick, style = {} } = props - const [list, setList] = useState([]) - const {fetchData, state} = GetBannerList() + const [list, setList] = useState([]) + const { fetchData, state } = GetBannerList() - useEffect(() => { - getData() - }, []) + useEffect(() => { + getData() + }, []) - const getData = async () => { - const res = await fetchData() - setList(res.data?.list) + const getData = async () => { + const res = await fetchData() + setList(res.data?.list) + } + + const skipTo = (item) => { + if (item.jump_type == 2) { + goLink(item.link + '&title=' + item.title) + } else { + goLink(item.link) } + } - const skipTo = (item) => { - if(item.jump_type == 2) { - goLink(item.link + '&title=' + item.title) - } else { - goLink(item.link) - } - } - - return ( - - - { - list?.map(item => { - return - skipTo(item)}> - - - - }) - } - - - ) - -} \ No newline at end of file + return ( + + + {list?.map((item) => { + return ( + + skipTo(item)}> + + + + ) + })} + + + ) +} diff --git a/yarn.lock b/yarn.lock index 0a9a735..9178562 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4659,7 +4659,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-spawn@7.0.3, cross-spawn@^7.0.3: +cross-env@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf" + integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw== + dependencies: + cross-spawn "^7.0.1" + +cross-spawn@7.0.3, cross-spawn@^7.0.1, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==