| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- // 店铺相关接口
- import { get, post } from '@/core/http/http-client'
- import { buildRestPath } from '@/core/config/api-paths'
- import { buildOssUrl } from '@/core/media/oss-url'
- /**
- * 店铺详情
- * 对接 88live 的 /wanlshop/shop/getShopInfo 接口
- */
- export async function pullMallShopInfo(id) {
- const { data } = await get(buildRestPath('shop/getShopInfo'), { id })
- if (data.avatar) data.avatar = buildOssUrl(data.avatar)
- if (data.find_user && data.find_user.avatar) data.find_user.avatar = buildOssUrl(data.find_user.avatar)
- if (Array.isArray(data.category)) {
- data.category.forEach(item => {
- if (item.image) item.image = buildOssUrl(item.image)
- if (Array.isArray(item.childlist)) {
- item.childlist.forEach(child => {
- if (child.image) child.image = buildOssUrl(child.image)
- if (Array.isArray(child.childlist)) {
- child.childlist.forEach(sub => {
- if (sub.image) sub.image = buildOssUrl(sub.image)
- })
- }
- })
- }
- })
- }
- return data
- }
- /**
- * 店铺发现动态列表
- * 对接 88live 的 /wanlshop/find/find/getFindList 接口
- */
- export async function pullMallShopFindList({ user_no, page = 1 } = {}) {
- const { data } = await get(buildRestPath('find/find/getFindList'), { user_no, page })
- const list = data && data.data ? data.data : []
- if (Array.isArray(list)) {
- list.forEach(item => {
- if (Array.isArray(item.images)) {
- item.images = item.images.map(img => buildOssUrl(img))
- }
- })
- }
- return {
- list: list,
- total: data && data.total ? data.total : 0,
- currentPage: data && data.current_page ? data.current_page : 1,
- lastPage: data && data.last_page ? data.last_page : 1
- }
- }
- /**
- * 关注/取消关注店铺
- * 对接 88live 的 /wanlshop/find/user/setFindUser 接口
- */
- export async function postShopFollow(user_no) {
- const { data } = await post(buildRestPath('find/user/setFindUser'), {
- id: user_no,
- type: 'follow'
- })
- return data
- }
- /**
- * 获取通知列表
- * 对接 88live 的 /wanlshop/notice/getNoticeList 接口
- */
- export async function pullNoticeList({ type, page = 1 } = {}) {
- const { data } = await get(buildRestPath('notice/getNoticeList'), { type, page })
- return {
- data: data && data.data ? data.data : [],
- total: data && data.total ? data.total : 0,
- current_page: data && data.current_page ? data.current_page : 1,
- last_page: data && data.last_page ? data.last_page : 1
- }
- }
- /**
- * 获取收藏列表
- * 对接 88live 的 /wanlshop/product/collect 接口
- */
- export async function pullCollectList({ type, page = 1 } = {}) {
- const { data } = await get(buildRestPath('product/collect'), { type, page })
- return {
- data: data && data.data ? data.data : [],
- current_page: data && data.current_page ? data.current_page : 1,
- last_page: data && data.last_page ? data.last_page : 1
- }
- }
- /**
- * 收藏/取消收藏商品
- * 对接 88live 的 /wanlshop/product/follow 接口
- */
- export async function postCollectFollow({ type, id } = {}) {
- const apiUrl = type === 'groups' ? 'groups/product/follow' : 'product/follow'
- return await post(buildRestPath(apiUrl), { id })
- }
- /**
- * 获取关注店铺列表
- * 对接 88live 的 /wanlshop/find/user/getShopList 接口
- */
- export async function pullFollowShopList({ page = 1 } = {}) {
- const { data } = await post(buildRestPath('find/user/getShopList'), { page })
- return {
- data: data && data.data ? data.data : [],
- current_page: data && data.current_page ? data.current_page : 1,
- last_page: data && data.last_page ? data.last_page : 1,
- total: data && data.total ? data.total : 0
- }
- }
- /**
- * 关注/取消关注店铺
- * 对接 88live 的 /wanlshop/find/user/setFindUser 接口
- */
- export async function postFollowShop({ id, type = 'follow' } = {}) {
- const { data } = await post(buildRestPath('find/user/setFindUser'), { id, type })
- return { data: data && data.data !== undefined ? data.data : null }
- }
- /**
- * 获取我的足跡列表
- * 对接 88live 的 /wanlshop/product/footprint 接口
- */
- export async function pullFootprintList({ type, page = 1 } = {}) {
- const { data } = await get(buildRestPath('product/footprint'), { type, page })
- return {
- data: data && data.data ? data.data : [],
- current_page: data && data.current_page ? data.current_page : 1,
- last_page: data && data.last_page ? data.last_page : 1
- }
- }
|