Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
groupPurchase-miniapp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭佳妮(贵阳日报)
groupPurchase-miniapp
Commits
1486b429
Commit
1486b429
authored
Jul 30, 2024
by
陈宗胤(贵阳日报)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api
parent
b75c85a3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
31 deletions
+120
-31
App.vue
src/App.vue
+12
-0
index.js
src/api/index.js
+25
-0
foodClassification.vue
src/pages/index/foodClassification.vue
+17
-0
index.vue
src/pages/index/index.vue
+64
-29
domain.js
src/utils/domain.js
+2
-2
No files found.
src/App.vue
View file @
1486b429
<
script
setup
>
import
{
getTokenUser
}
from
'./api/index'
;
import
testJson
from
'./static/json/test.json'
;
import
{
getToken
}
from
'./utils/auth'
;
onLaunch
(()
=>
{
if
(
!
getToken
())
signIn
();
console
.
log
(
'App Launch'
);
});
...
...
@@ -10,6 +14,14 @@ onShow(() => {
onHide
(()
=>
{
console
.
log
(
'App Hide'
);
});
// 登录
const
signIn
=
()
=>
{
getTokenUser
(
testJson
).
then
((
res
)
=>
{
const
token
=
res
.
data
.
access_token
;
xma
.
setStorageSync
(
'Authorization'
,
token
);
console
.
log
(
'登录...'
);
});
};
</
script
>
<
style
>
.multi-line
{
...
...
src/api/index.js
View file @
1486b429
...
...
@@ -16,3 +16,28 @@ export function groupBuyList() {
method
:
'GET'
,
});
}
// 根据父级分类id查询子分类列表
export
function
getByParentId
(
id
)
{
return
request
({
url
:
`/sgyrdd/category/getByParentId?parentId=
${
id
}
`
,
method
:
'GET'
,
});
}
// 获取团购专区主页轮播图
export
function
groupImgList
()
{
return
request
({
url
:
`/sgyrdd/carousel/groupBuyList`
,
method
:
'GET'
,
});
}
// 附近人气美食分页
export
function
popularityPage
(
data
)
{
return
request
({
url
:
`/sgyrdd/shop/popularityPage`
,
method
:
'POST'
,
data
,
});
}
src/pages/index/foodClassification.vue
View file @
1486b429
...
...
@@ -87,12 +87,29 @@ import Search from '../../components/index/Search.vue';
import
Classification
from
'../../components/index/Classification.vue'
;
import
Position
from
'../../components/index/Position.vue'
;
import
Sort
from
'../../components/index/Sort.vue'
;
import
{
getByParentId
}
from
'../../api/index'
;
const
business
=
reactive
([
'优选商家'
,
'超值半价'
,
'今日可订'
,
'经典单人'
]);
const
active
=
ref
(
null
);
const
rotate
=
ref
(
false
);
const
rotate2
=
ref
(
false
);
const
rotate3
=
ref
(
false
);
onLoad
((
option
)
=>
{
const
{
parentId
}
=
option
;
query
(
parentId
);
});
// 根据父级分类id查询子分类列表
const
query
=
(
parentId
)
=>
{
getByParentId
(
parentId
).
then
((
res
)
=>
{
console
.
log
(
'打印res'
,
res
);
});
};
// onLoad(option) {
// //option为object类型,会序列化上个页面传递的参数
// console.log(option.id); //打印出上个页面传递的参数。
// console.log(option.name); //打印出上个页面传递的参数。
// },
const
choice
=
(
index
)
=>
{
active
.
value
=
index
;
};
...
...
src/pages/index/index.vue
View file @
1486b429
...
...
@@ -9,24 +9,24 @@
<view
class=
"classification"
>
<view
class=
"classification-top"
>
<view
@
tap=
"jingang(i
ndex
)"
@
tap=
"jingang(i
tem.categoryId
)"
class=
"choice"
v-for=
"(item, index) in classificationT"
:key=
"index"
>
<image
class=
"imgs"
:src=
"
'../../static/index/' + item.img + '.png'
"
mode=
"widthFix"
/>
<text
class=
"introduce"
>
{{
item
.
text
}}
</text>
<image
class=
"imgs"
:src=
"
item.icon
"
mode=
"widthFix"
/>
<text
class=
"introduce"
>
{{
item
.
categoryName
}}
</text>
</view>
</view>
<view
class=
"classification-bottom"
>
<view
@
tap=
"jingang(i
ndex
)"
@
tap=
"jingang(i
tem.categoryId
)"
class=
"choice"
v-for=
"(item, index) in classificationB"
:key=
"index"
>
<image
class=
"imgs"
:src=
"
'../../static/index/' + item.img + '.png'
"
mode=
"widthFix"
/>
<text
class=
"introduce"
>
{{
item
.
text
}}
</text>
<image
class=
"imgs"
:src=
"
item.icon
"
mode=
"widthFix"
/>
<text
class=
"introduce"
>
{{
item
.
categoryName
}}
</text>
</view>
</view>
</view>
...
...
@@ -128,15 +128,17 @@ import FoodDetails from '../../components/index/FoodDetails.vue';
import
ShopCard
from
'../../components/index/ShopCard.vue'
;
import
Marketing
from
'../../components/index/Marketing.vue'
;
import
Position
from
'../../components/index/Position.vue'
;
import
{
g
etTokenUser
,
groupBuyList
}
from
'../../api/index'
;
import
testJson
from
'../../static/json/test.json'
;
import
{
getToken
}
from
'../../utils/auth'
;
import
{
g
roupBuyList
,
groupImgList
,
popularityPage
}
from
'../../api/index'
;
//
import testJson from '../../static/json/test.json';
//
import { getToken } from '../../utils/auth';
const
title
=
ref
(
'小程序平台'
);
const
{
countInfo
,
addCount
}
=
useCountStore
();
onMounted
(
async
()
=>
{
if
(
!
getToken
())
await
signIn
();
// 轮播图数据
let
lunboData
;
onMounted
(()
=>
{
getClassification
();
rotatingBroadcast
();
nearbyFood
();
// test(testJson).then((res) => {
// console.log('打印', res);
// });
...
...
@@ -153,19 +155,49 @@ const signIn = () => {
// 获取分类
const
getClassification
=
()
=>
{
groupBuyList
().
then
((
res
)
=>
{
console
.
log
(
'res'
,
res
);
res
.
data
.
forEach
((
item
)
=>
{
item
.
icon
=
import
.
meta
.
env
.
VITE_APP_IMG_URL
+
item
.
icon
;
item
.
pic
=
import
.
meta
.
env
.
VITE_APP_IMG_URL
+
item
.
pic
;
});
classificationT
.
value
=
res
.
data
.
slice
(
0
,
4
);
classificationB
.
value
=
res
.
data
.
slice
(
4
);
});
};
// 附近人气美食分页
const
nearbyFood
=
()
=>
{
console
.
log
(
'位置名称:'
);
xma
.
getLocation
({
isHighAccuracy
:
true
,
success
:
function
(
res
)
{
console
.
log
(
'位置名称:'
,
res
);
},
fail
:
function
(
err
)
{
console
.
log
(
'获取位置失败:'
,
err
);
},
});
};
// 轮播图
const
rotatingBroadcast
=
()
=>
{
groupImgList
().
then
((
res
)
=>
{
console
.
log
(
'lunbo'
,
res
);
res
.
data
.
forEach
((
item
)
=>
{
item
.
imgUrl
=
import
.
meta
.
env
.
VITE_APP_IMG_URL
+
item
.
imgUrl
;
});
lunboData
=
res
.
data
;
swiperList
.
value
=
res
.
data
.
map
((
item
)
=>
{
return
item
.
imgUrl
;
});
});
};
const
light
=
ref
(
0
);
const
rotate
=
ref
(
false
);
const
classificationT
=
re
active
([
const
classificationT
=
re
f
([
{
img
:
'hotPot'
,
text
:
'火锅'
},
{
img
:
'barbecue'
,
text
:
'烧烤烤肉'
},
{
img
:
'stirFriedDishes'
,
text
:
'地方菜系'
},
{
img
:
'hamburg'
,
text
:
'小吃快餐'
},
]);
const
classificationB
=
re
active
([
const
classificationB
=
re
f
([
{
img
:
'seafood'
,
text
:
'鱼鲜海鲜'
},
{
img
:
'foreignLand'
,
text
:
'异域风味'
},
{
img
:
'selfHelp'
,
text
:
'自助餐'
},
...
...
@@ -189,19 +221,22 @@ const choice = (index) => {
light
.
value
=
index
;
};
// 金刚区分类选择
const
jingang
=
(
index
)
=>
{
switch
(
index
)
{
case
0
:
xma
.
navigateTo
({
url
:
'/pages/index/foodClassification'
,
});
break
;
case
1
:
xma
.
navigateTo
({});
break
;
case
2
:
xma
.
navigateTo
({});
}
const
jingang
=
(
id
)
=>
{
// switch (index) {
// case 0:
// xma.navigateTo({
// url: '/pages/index/foodClassification',
// });
// break;
// case 1:
// xma.navigateTo({});
// break;
// case 2:
// xma.navigateTo({});
// }
xma
.
navigateTo
({
url
:
'/pages/index/foodClassification?parentId='
+
id
,
});
};
const
locationFiltering
=
()
=>
{
rotate
.
value
=
!
rotate
.
value
;
...
...
src/utils/domain.js
View file @
1486b429
...
...
@@ -3,12 +3,12 @@ let domain = {};
if
(
env
===
'dev'
)
{
domain
=
{
apiPrefix
:
'/api'
,
// imgPrefix: 'https://gdlxy-images.wjzpgz.com/
',
imgPrefix
:
'http://file.rhhzkj.com:8080
'
,
};
}
else
{
domain
=
{
apiPrefix
:
'https://api.rddyz.com'
,
// imgPrefix: 'https://gdlxy-images.wjzpgz.com/
',
imgPrefix
:
'https://file.rddyz.com
'
,
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment