From 159bf2aed488d8158cdca03f68bec39f8b9940ee Mon Sep 17 00:00:00 2001 From: sunlizhou <296190577@qq.com> Date: Sat, 19 Aug 2023 18:21:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=93=81=E7=89=8C=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 2 +- .gitignore | 1 + src/api/brand.ts | 8 +- src/app.config.ts | 1 + src/app.scss | 8 + src/pages/brand/info/info.config.ts | 4 + src/pages/brand/info/info.module.scss | 31 +++ src/pages/brand/info/info.tsx | 57 ++++++ .../brand/list/components/BrandView.config.ts | 3 - src/pages/brand/list/components/BrandView.tsx | 176 ------------------ src/pages/brand/list/list.module.scss | 60 +++--- src/pages/brand/list/list.tsx | 64 ++----- 12 files changed, 150 insertions(+), 265 deletions(-) create mode 100644 src/pages/brand/info/info.config.ts create mode 100644 src/pages/brand/info/info.module.scss create mode 100644 src/pages/brand/info/info.tsx delete mode 100644 src/pages/brand/list/components/BrandView.config.ts delete mode 100644 src/pages/brand/list/components/BrandView.tsx diff --git a/.env b/.env index 1eee7ad..f96406d 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -TARO_APP_API=https://yjx.dev.yaojiankang.top +TARO_APP_API=https://shopfix.yaojiankang.top #TARO_APP_API=https://playedu.yaojiankang.top TARO_APP_LGOIN=true diff --git a/.gitignore b/.gitignore index b7dd2d1..35f7392 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ deploy_versions/ node_modules/ .DS_Store .swc +.env diff --git a/src/api/brand.ts b/src/api/brand.ts index d33b2e1..705706c 100644 --- a/src/api/brand.ts +++ b/src/api/brand.ts @@ -1,6 +1,7 @@ import {request} from "@/api/request"; export type BrandRecord = { + name: string; id: number introductory_video: string[] brand_album: string[] @@ -9,14 +10,15 @@ export type BrandRecord = { } export const brandApi = { + /** 品牌列表 */ list(page: number , page_size: number) { return request<{ data: BrandRecord[], total: number - }>(`/api/v1/department/index?page=${page}&page_size=${page_size}` , "GET") + }>(`/home/v1/brand/list?page=${page}&page_size=${page_size}` , "GET") }, - /** 学习记录 */ + /** 品牌详情 */ info(id: number) { - return request(`/api/v1/user/record/${id}`, "GET") + return request(`/home/v1/brand/${id}`, "GET") }, } diff --git a/src/app.config.ts b/src/app.config.ts index 9c0163b..540429a 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -80,6 +80,7 @@ export default defineAppConfig({ root: 'pages/brand', pages: [ 'list/list', + 'info/info', ] } ], diff --git a/src/app.scss b/src/app.scss index 6df0891..5fc0794 100644 --- a/src/app.scss +++ b/src/app.scss @@ -325,4 +325,12 @@ .border-none{border: none} +.text-row1 { + display: -webkit-box; + text-overflow: ellipsis; + overflow: hidden; + -webkit-box-orient:vertical; + -webkit-line-clamp:1; +} + diff --git a/src/pages/brand/info/info.config.ts b/src/pages/brand/info/info.config.ts new file mode 100644 index 0000000..2a0a86b --- /dev/null +++ b/src/pages/brand/info/info.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '', + onReachBottomDistance: 30 +}) diff --git a/src/pages/brand/info/info.module.scss b/src/pages/brand/info/info.module.scss new file mode 100644 index 0000000..f13b13d --- /dev/null +++ b/src/pages/brand/info/info.module.scss @@ -0,0 +1,31 @@ +.box { + display: flex; + margin-bottom: 20rpx; + background-color: #fff; + border-radius: 16rpx; + padding: 24rpx; + box-sizing: border-box; +} +.image{ + width: 128rpx; + height:128rpx; + background-color: pink; + border-radius: 8rpx; +} +.rightBox{ + padding-left: 24rpx; + box-sizing: border-box; + flex: 1; +} +.desc{ + font-size: 24rpx; + font-weight: 500; + color: #909795; + line-height: 34rpx; + display: -webkit-box; + text-overflow: ellipsis; + overflow: hidden; + -webkit-box-orient:vertical; + -webkit-line-clamp:2; +} + diff --git a/src/pages/brand/info/info.tsx b/src/pages/brand/info/info.tsx new file mode 100644 index 0000000..395ec1c --- /dev/null +++ b/src/pages/brand/info/info.tsx @@ -0,0 +1,57 @@ +import {FC, useCallback, useEffect, useState} from "react"; +import {Image, Swiper, SwiperItem, View} from "@tarojs/components"; +import {brandApi, BrandRecord} from "@/api"; +import Taro, {useRouter} from "@tarojs/taro"; + +type Params = { + id: number +} +const MeetingsConfig: FC = () => { + const {id} = useRouter().params as unknown as Params + const [brandInfo, setBrandInfo] = useState() + + useEffect(() => { + getData() + }, [id]) + + const getData = async () => { + try { + const data = await brandApi.info(id) + Taro.setNavigationBarTitle({title:data.name}) + setBrandInfo(data) + } catch (e) { + } + } + + + return ( + + { + // brands.length ? brands.map((d) => + // jumpInfo(d.id)} className={styles.box} key={d.id}> + // + // + // {d.name} + // {d.graphic_introduction.repeat(30)} + // + // ) + // : + + { brandInfo?.brand_album?.length + && brandInfo?.brand_album.map((d) => + + + ) + } + + } + + ); +} + +export default MeetingsConfig diff --git a/src/pages/brand/list/components/BrandView.config.ts b/src/pages/brand/list/components/BrandView.config.ts deleted file mode 100644 index 67241a3..0000000 --- a/src/pages/brand/list/components/BrandView.config.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText: '登记', -}) diff --git a/src/pages/brand/list/components/BrandView.tsx b/src/pages/brand/list/components/BrandView.tsx deleted file mode 100644 index 16c8e89..0000000 --- a/src/pages/brand/list/components/BrandView.tsx +++ /dev/null @@ -1,176 +0,0 @@ -import {FC, useCallback, useEffect, useState} from "react"; -import {Form, Input, View} from "@tarojs/components"; -import Taro, {useRouter} from "@tarojs/taro"; -import {userApi, loginApi, LoginParams, meetingAPi, Meeting} from "@/api"; -import {Profile} from '@/store' -import {regexTel} from "@/utils/regu"; -import MyButton from "@/components/button/MyButton"; - -interface Params { - meeting_id: string - phone_number?: string - user_name?: string -} - -const MeetingLogin: FC = () => { - const {setUser, setToken, setCompany} = Profile.useContainer() - const [codeTime, setCodeTime] = useState(0) - const [phone_number, setPhone_number] = useState() - const [userName, setUserName] = useState('') - const [code, setCode] = useState('') - const [h5params, setH5Params] = useState(null) - const [meeting, setMeeting] = useState(null) - const params = useRouter().params as unknown as Params - - useEffect(() => { - loginApi.getMeetingParams().then((res) => { - setH5Params(res) - }) - if (params.user_name && params.phone_number) { - setPhone_number(Number(params.phone_number)) - setUserName(params.user_name) - Taro.showToast({title: '验证码错误', icon: 'error'}) - } - }, []) - - - useEffect(() => { - if (codeTime > 0) { - setTimeout(() => { - setCodeTime(codeTime - 1) - }, 1000) - } - }, [codeTime]) - - Taro.useLoad(() => { - meetingAPi.meetingInfo(params.meeting_id).then(res => { - if (res.type !== 1) { - Taro.showModal({ - title: res.type === 0 ? '暂未开始' : '二维码已过期', - success() { - Taro.reLaunch({url: '/pages/login/login'}) - } - }) - return - } - setMeeting(res.data) - }) - }) - - function submit(e) { - const value = e.detail.value - if (!value.user_name) { - Taro.showToast({title: '请写用户名', icon: "error"}) - return - } - - if (!regexTel.exec(value.phone_number)) { - Taro.showToast({title: '手机号错误', icon: 'error'}) - return - } - - if (!value.phone_code) { - Taro.showToast({title: '请获取手机验证码', icon: 'error'}) - return; - } - - if (process.env.TARO_ENV === 'h5') { - if (h5params == null) { - Taro.showToast({title: '页面参数错误,请刷新页面!', icon: 'error'}) - return; - } - location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?" + - "appid=" + h5params!.appid + - "&redirect_uri=" + - encodeURIComponent( - h5params!.route + - `?dep_id=${meeting?.dep_id}&company_id=${meeting?.companyId}&phone_number=${value.phone_number}&user_name=${value.user_name}&meeting_id=${params.meeting_id}&phone_code=${value.phone_code}` - ) + - "&response_type=code" + - "&scope=snsapi_userinfo" + - "#wechat_redirect"; - } else { - Taro.login({ - success: async (res) => { - const data = await userApi.meetingSave({ - ...value, - code: res.code, - meeting_id: params.meeting_id - }) - setCompany(data.company) - setUser(data.user) - setToken(data.token) - Taro.switchTab({url: '/pages/index/index'}) - }, - fail: () => { - Taro.showToast({title: '获取微信登录失败', icon: "error"}) - } - }) - } - } - - const getCode = useCallback(async () => { - if (codeTime > 0) return; - if (!phone_number || !regexTel.exec(String(phone_number))) { - Taro.showToast({title: '请输入正确的手机号', icon: 'error'}) - return - } - - try { - await userApi.getCode(phone_number) - Taro.showToast({title: '请注意查收', icon: "none"}) - setCodeTime(60) - } catch (e) { - Taro.showToast({title: '获取短信验证码失败', icon: "error"}) - } - }, [codeTime, phone_number]) - - return ( - -
- - - 用户名 - setUserName(e.detail.value)}/> - - - - 手机号 - setPhone_number(Number(e.detail.value))}/> - - - - - 验证码 - - setCode(e.detail.value)} - placeholder='输入验证码'/> - - {codeTime > 0 ? `${codeTime}` : '获取验证码'} - - - - - 登记 -
-
- ) -} - - -export default MeetingLogin diff --git a/src/pages/brand/list/list.module.scss b/src/pages/brand/list/list.module.scss index 075fb8b..f13b13d 100644 --- a/src/pages/brand/list/list.module.scss +++ b/src/pages/brand/list/list.module.scss @@ -1,43 +1,31 @@ -.meeting { +.box { display: flex; - justify-content: space-between; margin-bottom: 20rpx; + background-color: #fff; + border-radius: 16rpx; + padding: 24rpx; + box-sizing: border-box; } - -.title { - position: relative; - flex: 1; - width: 70%; - background: #fff; - padding: 20rpx; - border-radius: 10rpx; - overflow: hidden; +.image{ + width: 128rpx; + height:128rpx; + background-color: pink; + border-radius: 8rpx; +} +.rightBox{ + padding-left: 24rpx; box-sizing: border-box; + flex: 1; } - - -.overdue { - position: absolute; - top: 0; - bottom: 0; - right: 0; - left: 0; - text-align: center; - color: #fff; - display: flex; - justify-content: center; - align-items: center; - background: rgba(#000, .8); +.desc{ + font-size: 24rpx; + font-weight: 500; + color: #909795; + line-height: 34rpx; + display: -webkit-box; + text-overflow: ellipsis; + overflow: hidden; + -webkit-box-orient:vertical; + -webkit-line-clamp:2; } - -.del { - border-radius: 10rpx; - background: #FF3A2F; - display: flex; - align-items: center; - color: #fff; - width: 100rpx; - justify-content: center; - margin-left: 20rpx; -} diff --git a/src/pages/brand/list/list.tsx b/src/pages/brand/list/list.tsx index c7d5a9a..cc1b746 100644 --- a/src/pages/brand/list/list.tsx +++ b/src/pages/brand/list/list.tsx @@ -1,11 +1,9 @@ import {FC, useCallback, useEffect, useState} from "react"; -import {View} from "@tarojs/components"; -import {brandApi, BrandRecord, Meeting} from "@/api"; +import {Image, View} from "@tarojs/components"; +import {brandApi, BrandRecord} from "@/api"; import styles from './list.module.scss' import Taro, {useReachBottom} from "@tarojs/taro"; import Empty from "@/components/empty/empty"; -import {formatDate} from "@/utils/time"; -import brandView from "@/pages/brand/list/components/BrandView"; const MeetingsConfig: FC = () => { const [page, setPage] = useState(1) @@ -18,38 +16,18 @@ const MeetingsConfig: FC = () => { const getData = useCallback( async () => { try { - // const res = await brandApi.list(1, 10) - // setTotal(res.total) - // setBrands([ - // ...res.data - // ]) + const res = await brandApi.list(1, 10) + setTotal(res.total) + setBrands([ + ...res.data + ]) } catch (e) { } }, [page]) - function del(id: number, index: number) { - try { - Taro.showModal({ - title: '确定删除', - async success({confirm}) { - if (confirm) { - await meetingAPi.del(id) - const oldMeeting: Meeting[] = JSON.parse(JSON.stringify(brandView)) - oldMeeting.splice(index, 1) - setBrands(oldMeeting) - } - } - }) - } catch (e) { - } - } - - function jumpInfo(item: Meeting) { - if (Date.now() > item.estimate_end_time || item.status > 0) { - return - } - Taro.navigateTo({url: `/pages/manage/spotMeeting/spotMeeting?id=${item.id}`}) + function jumpInfo(id: number) { + Taro.navigateTo({url: `/pages/brand/info/info?id=${id}`}) } useReachBottom(useCallback(() => { @@ -62,22 +40,16 @@ const MeetingsConfig: FC = () => { return ( - { - brands.length ? - brands.map((d, index) => - jumpInfo(d)}> - {d.name} - {formatDate(new Date(d.estimate_start_time), "MM-dd")} 至 {formatDate(new Date(d.estimate_start_time), "MM-dd")} - { - (Date.now() > d.estimate_end_time || d.status > 1) && - {d.status > 1 ? '已结束' : "已过期"} - - } - - del(d.id, index)}>删除 - ) - : + brands.length ? brands.map((d) => + jumpInfo(d.id)} className={styles.box} key={d.id}> + + + {d.name} + {d.graphic_introduction.repeat(30)} + + ) + : } )