Browse Source

feat: 🚀 会员、活动、学院接口

pull/2/head
liyongle 3 years ago
parent
commit
4ef2dee4b3
  1. 138
      public/static/offline/JSON/getArtList.json
  2. 5
      src/components/Carousel/Carousel.vue
  3. 27
      src/composables/useActivityNav.ts
  4. 35
      src/composables/useInitConfigAndMallInfo.ts
  5. 12
      src/enums/index.ts
  6. 10
      src/http/api/activity/index.ts
  7. 4
      src/http/api/base/index.ts
  8. 3
      src/http/api/member/index.ts
  9. 5
      src/store/root/actions.ts
  10. 5
      src/store/root/state.ts
  11. 8
      src/types/activity.d.ts
  12. 16
      src/views/Activity/Activity.vue
  13. 47
      src/views/Member/Member.vue
  14. 16
      src/views/School/School.vue

138
public/static/offline/JSON/getArtList.json

@ -0,0 +1,138 @@
{
"code": 200,
"msg": "操作成功",
"data": [
{
"fileCode": "U7L-31evFSZcHT-Cx_afU",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/U7L-31evFSZcHT-Cx_afU.jpg",
"flag": 2,
"artType": 2
},
{
"fileCode": "8eaU9Xr1gng_VA_J93wY4",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/8eaU9Xr1gng_VA_J93wY4.jpg",
"flag": 2,
"artType": 2
},
{
"fileCode": "waeW0L9rBMK2cgKfYq9p6",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/waeW0L9rBMK2cgKfYq9p6.jpg",
"flag": 2,
"artType": 2
},
{
"fileCode": "XWzK3bNnd4G7ZqvP3jKVC",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/XWzK3bNnd4G7ZqvP3jKVC.png",
"flag": 1,
"artType": 2
},
{
"fileCode": "wmDoGzz91VdkWXk21w3vc",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/wmDoGzz91VdkWXk21w3vc.png",
"flag": 1,
"artType": 2
},
{
"fileCode": "Tbbv6-r31zJ-nb_IwuCni",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/Tbbv6-r31zJ-nb_IwuCni.png",
"flag": 2,
"artType": 4
},
{
"fileCode": "rKqs6tfSx-YE9mVRs6jRH",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/rKqs6tfSx-YE9mVRs6jRH.png",
"flag": 1,
"artType": 4
},
{
"fileCode": "WeRFpcfjtc6se7VVlulv9",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/WeRFpcfjtc6se7VVlulv9.png",
"flag": 1,
"artType": 4
},
{
"fileCode": "9BB20uH7LsAUCs9G5bLn1",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/9BB20uH7LsAUCs9G5bLn1.jpeg",
"flag": 1,
"artType": 1
},
{
"fileCode": "xyU-DUq-t_RrrDIuzsVaA",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/xyU-DUq-t_RrrDIuzsVaA.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "sp9psNqTdHdvB_Hrjkoi_",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/sp9psNqTdHdvB_Hrjkoi_.png",
"flag": 1,
"artType": 1
},
{
"fileCode": "PDUU-eWClnBaf75GvkLtl",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230505/PDUU-eWClnBaf75GvkLtl.png",
"flag": 1,
"artType": 3
},
{
"fileCode": "Gb1NiXqSAxQkdd2izaPJO",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/Gb1NiXqSAxQkdd2izaPJO.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "Fmk6kcf07YcAJp7sw2ZQb",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/Fmk6kcf07YcAJp7sw2ZQb.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "4oeWRq44Yib1ZLJv--7XX",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/4oeWRq44Yib1ZLJv--7XX.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "WO3JKVPWJ_y82uNR-p2nA",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/WO3JKVPWJ_y82uNR-p2nA.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "MRSnm9ILLTcU5R_ILNipY",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/MRSnm9ILLTcU5R_ILNipY.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "KtAw80_3z8nCffxts0eGB",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/KtAw80_3z8nCffxts0eGB.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "Z-KsfCiytrn3_5cj__5KY",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/Z-KsfCiytrn3_5cj__5KY.png",
"flag": 2,
"artType": 1
},
{
"fileCode": "Hve3AxoPDuLx42ObwtW76",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/Hve3AxoPDuLx42ObwtW76.png",
"flag": 2,
"artType": 2
},
{
"fileCode": "u-LrcbOriATjX4QeX2FJq",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/u-LrcbOriATjX4QeX2FJq.png",
"flag": 1,
"artType": 2
},
{
"fileCode": "PMUBs8-cvNM9FqzO1Ozyx",
"fileUrl": "/iotFile/project-bffju2pfalsylhcfcuzgaa/20230506/PMUBs8-cvNM9FqzO1Ozyx.png",
"flag": 1,
"artType": 2
}
]
}

5
src/components/Carousel/Carousel.vue

@ -12,7 +12,7 @@
:dynamic-bullets="true"
class="myswiper"
>
<swiper-slide v-for="(item, index) in acList" :key="index">
<swiper-slide v-for="item in acList" :key="item.fileCode">
<img :src="item.fileUrl" class="img" />
</swiper-slide>
</swiper>
@ -25,8 +25,9 @@ import { Swiper, SwiperSlide } from 'swiper/vue'
import { Autoplay, Pagination } from 'swiper'
import 'swiper/css'
import 'swiper/css/pagination'
import type { Picture } from '@/types/activity'
type AcType = {
acList: any
acList: Picture[]
}
defineProps<AcType>()
const modules = ref([Autoplay, Pagination])

27
src/composables/useActivityNav.ts

@ -1,27 +0,0 @@
import { useRouter } from 'vue-router'
import { storeToRefs } from 'pinia'
import { useRootStore } from '@/store/root'
import Brand from '@/utils/Class/Brand'
export const useActivityNav = () => {
const router = useRouter()
const store = useRootStore()
const { shopList } = storeToRefs(store)
function nav(activity: Activity) {
let shop
if (activity.shopCode.length) {
shop = shopList.value.find(item => item.shopCode === activity?.shopCode)
} else if (activity.point > -1) {
const { activityName, floorOrder, floor, point, fileUrl, activityId } = activity
shop = new Brand({ shopName: activityName, floorOrder, floor, logoUrl: fileUrl, yaxis: point, shopCode: activityId })
}
if (!shop) {
return
}
store.SET_SHOP(shop)
router.push('/nav')
}
return { nav }
}

35
src/composables/useInitConfigAndMallInfo.ts

@ -1,5 +1,5 @@
import { useRootStore } from '@/store/root'
import { getConfig, getFacilitiesList, getWeather } from '@/http/api/base'
import { getConfig, getFacilitiesList, getWeather, getArtList } from '@/http/api/base'
import { getShopAndBuildingList } from '@/http/api/shop'
import { getDeviceInfo } from '@/http/api/building'
import { getShopListByFloor, getShopListByIndustry, getBrandInfo } from '@/http/api/brand'
@ -12,17 +12,27 @@ export const useInitConfigAndMallInfo = async () => {
const store = useRootStore()
store.SET_CONFIG(_config.data)
const [_DeviceInfo, _shopAndBuilding, _facilityList, _weather, _shopListByFloor, _shopListByIndustry, _brandInfo, _menuList] =
await Promise.all([
getDeviceInfo(),
getShopAndBuildingList(),
getFacilitiesList(),
getWeather(),
getShopListByFloor(),
getShopListByIndustry(),
getBrandInfo(),
getModuleList()
])
const [
_DeviceInfo,
_shopAndBuilding,
_facilityList,
_weather,
_shopListByFloor,
_shopListByIndustry,
_brandInfo,
_menuList,
_pictureList
] = await Promise.all([
getDeviceInfo(),
getShopAndBuildingList(),
getFacilitiesList(),
getWeather(),
getShopListByFloor(),
getShopListByIndustry(),
getBrandInfo(),
getModuleList(),
getArtList()
])
const { shopList, buildingList } = _shopAndBuilding.data
store.SET_DEVICE(_DeviceInfo.data)
@ -34,6 +44,7 @@ export const useInitConfigAndMallInfo = async () => {
store.SET_FACILITY_LIST(_facilityList.data)
store.SET_WEATHER(_weather.data)
store.SET_MENU_LIST(_menuList.data)
store.SET_PICTURE_LIST(_pictureList.data)
} catch (error) {
Message({ text: '初始化数据失败', type: 'success' })
}

12
src/enums/index.ts

@ -25,3 +25,15 @@ export enum HTTP_CODE {
ERR_NULL = 401, //未识别到语音
ERR_DISCERNING = 201 //语音识别中
}
export enum PictureStatus {
SCHOOL = 1, // 文化学院
GOLD = 2, // 金卡会员
BLACK = 3, // 黑卡会员
ACTIVITY = 4 // 活动
}
export enum PictureType {
H = 1, // 横版图片
V = 2 // 竖版图片
}

10
src/http/api/activity/index.ts

@ -1,10 +0,0 @@
import { request } from '@/http/http'
type AcType = {
activityList: Activity[]
}
//获取商场活动
export const getMallActivity = () => request<AcType>({ url: `/JSON/getActivityList1.json` })
//获取店铺活动
export const getShopActivity = () => request({ url: `/JSON/getActivityList2.json` })

4
src/http/api/base/index.ts

@ -1,4 +1,5 @@
import { request } from '@/http/http'
import type { Picture } from '@/types/activity'
import type { WrittenQuery } from './types'
//获取配置项
@ -21,3 +22,6 @@ export const getHandWriting = (data: WrittenQuery) => request<string[]>({ url: '
// 获取首页数据
export const getIndexJson = () => request({ url: `/JSON/index.json` })
// 获取活动、会员卡等
export const getArtList = () => request<Picture[]>({ url: `/JSON/getArtList.json` })

3
src/http/api/member/index.ts

@ -1,3 +0,0 @@
import { request } from '../../http'
// 获取会员信息
export const getMemberInfo = () => request<MemberInfo>({ url: `/JSON/getMemberInterests.json` })

5
src/store/root/actions.ts

@ -3,6 +3,7 @@ import type { State } from './state'
import type { Root } from '../key'
import type { CreateActions } from '../types'
import { BrandRes, GroupList } from '@/http/api/brand/types'
import { Picture } from '@/types/activity'
export interface Actions {
SET_SHOP_LIST_BY_INDUSTRY(list: GroupList): void
@ -20,6 +21,7 @@ export interface Actions {
SET_SHOW_DETAIL(flag: boolean): void
SET_SHOW_SEARCH(flag: boolean): void
SET_MENU_LIST(list: MenuType[]): void
SET_PICTURE_LIST(list: Picture[]): void
}
export type GenActions = CreateActions<Root, State, Actions>
@ -72,5 +74,8 @@ export const actions: GenActions = {
},
SET_MENU_LIST(list) {
this.menuList = list
},
SET_PICTURE_LIST(list) {
this.pictureList = list
}
}

5
src/store/root/state.ts

@ -1,4 +1,5 @@
import type { GroupList, BrandRes } from '@/http/api/brand/types'
import { Picture } from '@/types/activity'
export interface State {
shopList: Readonly<Shop[]> //店铺列表
@ -16,6 +17,7 @@ export interface State {
device: Device //当前设备信息
shop: Shop //店铺信息
menuList: MenuType[] // 菜单信息
pictureList: Picture[] // 图片列表
}
export const state = (): State => ({
@ -33,5 +35,6 @@ export const state = (): State => ({
mapStatus: false,
device: {} as Device,
shop: {} as Shop,
menuList: []
menuList: [],
pictureList: []
})

8
src/types/activity.d.ts

@ -1,3 +1,4 @@
import { PictureStatus, PictureType } from '@/enums'
declare interface Activity {
activityAddress: string //活动地址
activityAddressEn: string //活动地址英文
@ -20,3 +21,10 @@ declare interface Activity {
point: number // 导航点
shopCode: string //关联店铺code
}
declare interface Picture {
fileCode: string // 图片编码
fileUrl: string // 图片地址
flag: PictureType // 图片横竖
artType: PictureStatus // 图片类型
}

16
src/views/Activity/Activity.vue

@ -8,12 +8,18 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { getMallActivity } from '@/http/api/activity'
import { ref, toRefs } from 'vue'
import type { Picture } from '@/types/activity'
import { useRootStore } from '@/store/root'
import { PictureStatus, PictureType } from '@/enums'
import Carousel from '@/components/Carousel/Carousel.vue'
const aclist = ref<Activity[]>([])
getMallActivity().then(({ data }) => {
aclist.value = data.activityList
const aclist = ref<Picture[]>([])
const store = useRootStore()
const { pictureList } = toRefs(store)
pictureList.value.forEach(item => {
if (item.artType === PictureStatus.ACTIVITY && item.flag === PictureType.H) {
aclist.value.push(item)
}
})
</script>

47
src/views/Member/Member.vue

@ -1,15 +1,20 @@
<template>
<typeBtnGroup class="top" :list="list" />
<typeBtnGroup class="top" :list="list" @change-type="change" />
<transition appear enter-active-class="animate__animated animate__fadeIn" leave-active-class="animate__animated animate__zoomOut">
<div class="carousel">
<Carousel :ac-list="memberInfo" />
<div v-if="current === 0" class="carousel">
<Carousel :ac-list="goldMemberInfo" />
</div>
<div v-else class="carousel">
<Carousel :ac-list="blackMemberInfo" />
</div>
</transition>
</template>
<script setup lang="ts">
import { shallowRef } from 'vue'
import { getMemberInfo } from '@/http/api/member/index'
import { ref, shallowRef, toRefs } from 'vue'
import type { Picture } from '@/types/activity'
import { useRootStore } from '@/store/root'
import { PictureStatus, PictureType } from '@/enums'
import Carousel from '@/components/Carousel/Carousel.vue'
import typeBtnGroup from '@/components/TypeBtnList/TypeBtnList.vue'
const list = [
@ -22,16 +27,34 @@ const list = [
titleEn: 'Black Card Member'
}
]
const memberInfo = shallowRef<fileList[]>([])
getMemberInfo().then(({ data }) => {
if (data.fileList) {
memberInfo.value = data.fileList?.map(item => {
return {
fileUrl: item
const store = useRootStore()
const { pictureList } = toRefs(store)
const goldMemberInfo = shallowRef<Picture[]>([])
const blackMemberInfo = shallowRef<Picture[]>([])
const current = ref(0)
function getInfo(status: PictureStatus) {
if (status === PictureStatus.GOLD) {
goldMemberInfo.value = []
pictureList.value.forEach(item => {
if (item.artType === status && item.flag === PictureType.H) {
goldMemberInfo.value.push(item)
}
})
} else {
blackMemberInfo.value = []
pictureList.value.forEach(item => {
if (item.artType === status && item.flag === PictureType.H) {
blackMemberInfo.value.push(item)
}
})
}
})
}
getInfo(PictureStatus.GOLD)
function change(params: any) {
current.value = params.order
params.order === 0 ? getInfo(PictureStatus.GOLD) : getInfo(PictureStatus.BLACK)
}
</script>
<style lang="scss" scoped>

16
src/views/School/School.vue

@ -8,12 +8,18 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { getMallActivity } from '@/http/api/activity'
import { ref, toRefs } from 'vue'
import type { Picture } from '@/types/activity'
import { useRootStore } from '@/store/root'
import { PictureStatus, PictureType } from '@/enums'
import Carousel from '@/components/Carousel/Carousel.vue'
const aclist = ref<Activity[]>([])
getMallActivity().then(({ data }) => {
aclist.value = data.activityList
const aclist = ref<Picture[]>([])
const store = useRootStore()
const { pictureList } = toRefs(store)
pictureList.value.forEach(item => {
if (item.artType === PictureStatus.SCHOOL && item.flag === PictureType.H) {
aclist.value.push(item)
}
})
</script>

Loading…
Cancel
Save