diff --git a/src/app.tsx b/src/app.tsx index f61a81d..afe1300 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,8 +4,7 @@ import { Provider } from 'react-redux' import configStore from './store' import './app.scss' import Taro, { useDidShow} from '@tarojs/taro' -import { analysisShortCodeApi } from './common/shortCode' -import { IMG_CND_Prefix } from './common/constant' +import { shareShop } from './common/util' const store = configStore() const App:FC = (params) => { @@ -14,38 +13,8 @@ const App:FC = (params) => { withShareTicket: true }) - useDidShow(() => { - console.log('params:',params) - }) - - const page = Taro.getCurrentInstance().page - console.log('res:::', page) - if(page && page.onShareAppMessage) { - //当有分享参数时,绑定上下级 - if(page.options?.share) { - analysisShortCodeApi(page.options.share) - } - page.onShareAppMessage = (res) => { - let path = '' - let title = '' - let imageUrl = '' - let sortCode = Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):'' - if(res.from === 'button') { - path = `/pages/details/index?share=${sortCode.shareShortDetail.code}` - title = sortCode.shareShortDetail.title - imageUrl = sortCode.shareShortDetail.img - } else { - path = `/pages/index/index?share=${sortCode.shareShortPage.code}` - title = sortCode.shareShortPage.title - imageUrl = sortCode.shareShortPage.img - } - return { - title, - path, - imageUrl, - } - } - } + //分享 + shareShop() return ( diff --git a/src/common/common.ts b/src/common/common.ts index 0c814aa..9adb0d3 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -109,16 +109,24 @@ export const retrieval = (data: any, rules?: Object, message: string="请填写 title,icon: "error" }) }, - loading(title: string){ + loading(title: string, mask: true|false = false){ Taro.showToast({ - title,icon: "loading" + title,icon: "loading", + mask }) }, none(title: string){ Taro.showToast({ title,icon: "none" }) + }, + showLoading(title: string, mask: true|false = true) { + Taro.showLoading({title, mask}) + }, + hideLoading() { + Taro.hideLoading() + } } // 金额千位分割符 diff --git a/src/common/constant.js b/src/common/constant.js index c9a028c..4512c59 100644 --- a/src/common/constant.js +++ b/src/common/constant.js @@ -4,7 +4,7 @@ // 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 = `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` // 发 @@ -12,7 +12,7 @@ // export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境 // export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞 // export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添 -export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰 +// export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰 // CDN // 生成密钥 diff --git a/src/common/user.js b/src/common/user.js deleted file mode 100644 index aabdbfc..0000000 --- a/src/common/user.js +++ /dev/null @@ -1,36 +0,0 @@ -import Taro from "@tarojs/taro"; -import { useStore } from "vuex"; -import { computed } from "@vue/runtime-core"; - -/** - * - * @param {String} token - */ -export const setToken = (token) => { - Taro.setStorageSync('token', token) -} -/** - * - * @param {Object} userinfo - */ -export const setUserInfo = (userinfo) => { - Taro.setStorageSync('userInfo', userinfo) -} - - -/** - * 检查登录 - */ -export const checkLogin = () => { - const store = useStore() - const token = computed(() => store.state.token) - console.log('checklogin token', token); - - // 本地调试屏蔽 - if (token == '') { - Taro.redirectTo({ - url: '/pages/login/index', - }) - } - -} \ No newline at end of file diff --git a/src/common/util.ts b/src/common/util.ts index 4bb0803..b7a7f0c 100644 --- a/src/common/util.ts +++ b/src/common/util.ts @@ -1,3 +1,7 @@ +import { formatImgUrl } from "./fotmat"; +import { analysisShortCodeApi } from "./shortCode"; +import Taro from '@tarojs/taro' + /** * 防抖 * @param {*} fn @@ -102,4 +106,36 @@ export const throttle = (fn, delay) => { } else { return 3 } - } \ No newline at end of file + } + + //全局分享监听 + export const shareShop = () => { + const page = Taro.getCurrentInstance().page + //当有分享参数时,绑定上下级 + if(page && page.options?.share) { + analysisShortCodeApi(page.options.share) + } + if(page && page.onShareAppMessage) { + page.onShareAppMessage = (res) => { + let path = '' + let title = '' + let imageUrl = '' + let sortCode = Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):'' + let pageInfo:any = page + if(res.from === 'button') { + path = `/pages/details/index?share=${sortCode.shareShortDetail.code}` + title = sortCode.shareShortDetail.title + imageUrl = sortCode.shareShortDetail.img + } else { + path = `/pages/index/index?share=${sortCode.shareShortPage.code}` + title = sortCode.shareShortPage.title + imageUrl = (pageInfo.route === 'pages/user/index')?formatImgUrl('/mall/share_img_02.png') : sortCode.shareShortPage.img + } + return { + title, + path, + imageUrl, + } + } + } +} \ No newline at end of file diff --git a/src/components/filterV2/index copy.tsx b/src/components/filterV2/index copy.tsx deleted file mode 100644 index 06f2ff3..0000000 --- a/src/components/filterV2/index copy.tsx +++ /dev/null @@ -1,130 +0,0 @@ -import { GetProductKindListApi } from "@/api/material"; -import Popup, {Params as PopuParams} from "@/components/popup" -import { Input, ScrollView, Text, Textarea, View } from "@tarojs/components" -import { useDidShow } from "@tarojs/taro"; -import classnames from "classnames"; -import { useEffect, useState } from "react"; -import styles from './index.module.scss' - -type params = { - onFiltr?: (val:object) => void -} & PopuParams -export default ({onClose, onFiltr, show = false}:params) => { - - //搜索条件 - const [filterObj, setFilterObj] = useState({ - seriesId: '', - minWidth: '', - maxWidth: '', - minWeight: '', - maxWeight: '', - element: '' - }) - - //获取系列 - const {fetchData: kindFetchData} = GetProductKindListApi() - const [kindList, setKindList] = useState([]) - const getCategoryList = async () => { - let {data} = await kindFetchData() - setKindList(data.list) - } - - useEffect(() => { - show&&getCategoryList() - }, [show]) - - //切换系列 - const changeKind = (e) => { - setFilterObj({...filterObj, seriesId:e.id}) - } - - const onCloseEven = () => { - onClose?.() - } - const onRest = () => { - console.log('12123') - setFilterObj({ - seriesId: '', - minWidth: '', - maxWidth: '', - minWeight: '', - maxWeight: '', - element: '' - }) - } - useEffect(() => { - console.log(filterObj) - }, [filterObj]) - - const onVerify = () => { - console.log(filterObj) - onFiltr?.(filterObj) - } - - const setNumber = (e, field) => { - console.log(e) - let num = parseFloat(e.detail.value) - if(isNaN(num)) { - filterObj[field] = null - } else { - filterObj[field] = parseFloat(num.toFixed(2)) - } - setFilterObj({...filterObj}) - } - - const setElement = (e) => { - let res = e.detail.value - setFilterObj({...filterObj, element:res}) - } - return ( - - onCloseEven()} showIconButton={true}> - - 全部筛选 - - - - 系列 - - {kindList.map(item => changeKind(item)} className={classnames(styles.btn_item, (filterObj.seriesId == item.id)&&styles.select_btn_item)}>{item.name})} - - - - 幅宽 - - setNumber(e,'minWidth')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/> - - setNumber(e,'maxWidth')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/> - cm - - - - 克重 - - setNumber(e,'minWeight')} placeholder="自定义最低值" placeholderStyle="font-size: 26rpx"/> - - setNumber(e,'maxWeight')} placeholder="自定义最高值" placeholderStyle="font-size: 26rpx"/> - g - - - - 成分 - -