Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yongxinda-h5
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
yongxinda-h5
Commits
5484b168
提交
5484b168
authored
10月 12, 2022
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
首页80%
上级
a2bab482
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
296 行增加
和
271 行删除
+296
-271
index.ts
src/api/index.ts
+5
-0
index.vue
src/pages/goods/index.vue
+193
-139
index.vue
src/pages/index/index.vue
+43
-116
auth.ts
src/utils/auth.ts
+41
-0
config.ts
src/utils/config.ts
+3
-5
request.ts
src/utils/request.ts
+11
-11
没有找到文件。
src/api/index.ts
0 → 100644
浏览文件 @
5484b168
import
{
request
}
from
'@/utils/request'
;
export
const
homeIndex
=
()
=>
request
(
'/wx/home/index'
,
'GET'
);
export
const
indexDetails
=
(
data
:
any
)
=>
request
(
'/wx/goods/detail'
,
'GET'
,
data
);
src/pages/goods/index.vue
浏览文件 @
5484b168
<
template
>
<view
class=
"goods-detail"
>
<view
class=
"goods-img"
>
<swiper
class=
"swiper"
circular
:indicator-dots=
"indicatorDots"
:autoplay=
"false"
>
<swiper-item
v-for=
"(item, index) in goodsInfo.imgList"
:key=
"index"
>
<view
class=
"swiper-item"
>
<image
class=
"banner"
:src=
"item.img"
/>
</view>
</swiper-item>
</swiper>
</view>
<!-- 轮播图 -->
<view
class=
"wrap"
><u-swiper
:list=
"detailData?.info.gallery"
img-mode=
"scaleToFill"
height=
"700"
></u-swiper></view>
<!-- 商品详情 -->
<view
class=
"goods-info"
>
<uni-row>
<uni-col
:span=
"24"
>
<text
class=
"goods-title"
>
{{
goodsInfo
.
titl
e
}}
</text>
<text
class=
"goods-title"
>
{{
detailData
?.
info
.
nam
e
}}
</text>
</uni-col>
</uni-row>
<uni-row
>
<uni-row
style=
"margin: 4rpx 0 10rpx;"
>
<uni-col
:span=
"24"
>
<text
class=
"goods-sub"
>
{{
detailData
?.
info
.
brief
}}
</text>
</uni-col>
</uni-row>
<uni-row>
<uni-col
:span=
"3"
>
<text
class=
"goods-price"
>
<text
class=
"unit"
>
¥
</text>
<text
class=
"price"
>
{{
goodsInfo
.
price
}}
</text>
<text
class=
"price"
>
{{
detailData
?.
info
.
retailPrice
}}
</text>
</text>
</uni-col>
<uni-col
:span=
"21"
style=
"margin-top: 18rpx;"
>
<text
class=
"goods-cost-price"
>
<text
class=
"unit"
>
¥
</text>
<text
class=
"price"
>
{{
detailData
?.
info
.
counterPrice
}}
</text>
</text>
</uni-col>
</uni-row>
</view>
<u-cell-group
style=
"margin-top: 20rpx;"
>
<u-cell-item
v-if=
"!selectedGoodsItem.specName"
icon=
""
title=
"规格"
value=
"请选择"
:index=
"0"
@
click=
"clickGroup"
></u-cell-item>
<u-cell-item
v-else
icon=
""
:title=
"'已选:' + selectedGoodsItem.specName + '*' + selectedGoodsItem.num"
:arrow=
"false"
:index=
"0"
@
click=
"clickGroup"
></u-cell-item>
<u-cell-item
icon=
""
title=
"属性"
:index=
"1"
@
click=
"clickGroup"
></u-cell-item>
<u-cell-item
icon=
""
title=
"运费"
value=
"满88免邮费"
:arrow=
"false"
:border-bottom=
"false"
></u-cell-item>
</u-cell-group>
<!-- 规格弹窗 -->
<view
class=
"goods-detail-item"
>
<uni-row>
<view>
<view
@
click=
"openPopup"
>
<uni-col
:span=
"24"
>
<text
v-if=
"!selectedGoodsItem.specName"
>
选择规格
</text>
<text
v-else
>
已选:
{{
selectedGoodsItem
.
specName
}}
*
{{
selectedGoodsItem
.
num
}}
</text>
</uni-col>
</view>
<uni-popup
ref=
"popup"
type=
"bottom"
:safe-area=
"true"
background-color=
"#FFFFFF"
>
<view
class=
"popup-selected-spec"
>
<view
class=
"goods-item"
>
<image
class=
"goods-mini-img"
:src=
"selectedGoodsItem.img"
/>
<image
class=
"goods-mini-img"
:src=
"selectedGoodsItem.img"
/>
<view
class=
"goods-text"
>
<text
class=
"goods-price"
>
<text
class=
"unit"
>
¥
</text>
...
...
@@ -48,84 +53,102 @@
</text>
<text
class=
"goods-selected"
>
<text>
已选:
</text>
<text
v-if=
"selectedGoodsItem.specName"
>
{{
selectedGoodsItem
.
specName
}}
*
{{
selectedGoodsItem
.
num
}}
</text>
<text
v-if=
"selectedGoodsItem.specName"
>
{{
selectedGoodsItem
.
specName
}}
*
{{
selectedGoodsItem
.
num
}}
</text>
</text>
</view>
</view>
<uni-section
class=
"mb-10"
title=
"颜色"
>
<view
class=
"goods-spec"
>
<uni-data-checkbox
mode=
"tag"
v-model=
"radioValue"
:localdata=
"goodsInfo.spec"
@
change=
"changeColor"
/>
</view>
<view
class=
"goods-spec"
><uni-data-checkbox
mode=
"tag"
v-model=
"radioValue"
:localdata=
"goodsInfo.spec"
@
change=
"changeColor"
/></view>
</uni-section>
<uni-section
class=
"mb-10"
title=
"数量"
>
<view
class=
"goods-spec"
>
<uni-number-box
:min=
"1"
:max=
"99"
@
change=
"changeBuyNum"
/>
</view>
<view
class=
"goods-spec"
><uni-number-box
:min=
"1"
:max=
"99"
@
change=
"changeBuyNum"
/></view>
</uni-section>
</view>
<view
class=
"popup-bottom-button"
>
<view
v-if=
"showPopupButton === 0"
class=
"add-to-cart"
@
click=
"addToCart"
>
<text>
确定
</text>
</view>
<view
v-else
class=
"buy-now"
@
click=
"buyNow"
>
<text>
购买
</text>
</view>
<view
v-if=
"showPopupButton === 0"
class=
"add-to-cart"
@
click=
"addToCart"
><text>
确定
</text></view>
<view
v-else
class=
"buy-now"
@
click=
"buyNow"
><text>
购买
</text></view>
</view>
</uni-popup>
</view>
</uni-row>
</view>
<view
class=
"shop-info"
>
<view
class=
"shop-logo-box"
>
<image
class=
"shop-logo"
src=
"https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/logo/logo.png"
/>
</view>
<!--
<view
class=
"shop-info"
>
<view
class=
"shop-logo-box"
><image
class=
"shop-logo"
src=
"https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/logo/logo.png"
/></view>
<view
class=
"shop-desc"
>
<view
class=
"shop-name"
>
<text>
Apple官方旗舰店
</text>
</view>
</view>
<view
class=
"shop-enter-button"
>
<text>
进店逛逛
</text>
</view>
<view
class=
"shop-name"
><text>
Apple官方旗舰店
</text></view>
</view>
<view
class=
"shop-enter-button"
><text>
进店逛逛
</text></view>
</view>
-->
<view
class=
"goods-intro"
>
<!--
<scroll-view
scroll-y=
"
{{
true
}}
" style="width:100%;height:
{{
sysheight
}}
px;">-->
<!--
<view
class=
"img-size"
>
-->
<!--
<image
src=
"/static/img/goods/detail.png"
mode=
"widthFix"
class=
"liucheng-img"
></image>
-->
<!--
</view>
-->
<!--
</scroll-view>
-->
<uni-segmented-control
:current=
"current"
:values=
"tabButtons"
@
clickItem=
"onClickItem"
styleType=
"text"
activeColor=
"#e43d33"
></uni-segmented-control>
<view
class=
"content"
>
<view
v-show=
"current === 0"
>
<rich-text
:nodes=
"goodsInfo.detail"
/
>
<view
v-show=
"current === 0"
><u-parse
:html=
"detailData?.info.detail"
:show-with-animation=
"true"
lazy-load
style=
"font-size: 0"
/></view
>
<view
v-show=
"current === 1"
>
选项卡2的内容
</view
>
</view>
<view
v-show=
"current === 1"
>
选项卡2的内容
</view>
<!-- 提交订单栏 -->
<view
class=
"bottom-bar"
><uni-goods-nav
:fill=
"true"
:options=
"options"
:button-group=
"buttonGroup"
@
click=
"onClick"
@
buttonClick=
"buttonClick"
/></view>
<!-- 属性弹窗 -->
<u-popup
v-model=
"attrPopup"
mode=
"bottom"
height=
"50%"
closeable
>
<view
class=
"attr-content"
>
<view
class=
"title"
>
商品属性
</view>
<view
v-for=
"(item, index) in detailData?.attribute"
:key=
"item.id"
class=
"details"
>
<text
class=
"left"
>
{{
item
.
attribute
}}
</text>
<text
class=
"right"
>
{{
item
.
value
}}
</text>
<u-line
v-show=
"detailData?.attribute.length-1 !== index"
/>
</view>
</view>
<view
class=
"bottom-bar"
>
<uni-goods-nav
:fill=
"true"
:options=
"options"
:button-group=
"buttonGroup"
@
click=
"onClick"
@
buttonClick=
"buttonClick"
/>
</view>
</u-popup>
</view>
</
template
>
<
script
lang=
"ts"
setup
>
import
{
ref
}
from
"vue"
;
import
{
GoodsItem
}
from
"@/types/goods"
;
import
{
ref
}
from
'vue'
;
import
{
onLoad
}
from
'@dcloudio/uni-app'
;
import
{
indexDetails
}
from
'@/api/index'
;
const
attrPopup
=
ref
(
false
);
const
detailData
=
ref
();
onLoad
((
options
:
any
)
=>
{
console
.
log
(
options
.
id
);
indexDetails
({
id
:
options
.
id
}).
then
((
res
:
any
)
=>
{
if
(
res
.
data
.
code
===
200
)
{
}
for
(
let
s
in
res
.
data
.
data
?.
attribute
)
{
const
value
=
res
.
data
.
data
?.
attribute
[
s
].
value
.
split
(
'
\
n'
)
if
(
value
.
length
>
1
)
{
let
str
:
string
=
''
value
.
forEach
((
item
:
string
)
=>
{
str
+=
' '
+
item
})
res
.
data
.
data
!
.
attribute
[
s
].
value
=
str
}
}
detailData
.
value
=
res
.
data
.
data
;
console
.
log
(
detailData
.
value
,
'商品详情数据'
);
});
});
const
clickGroup
=
(
index
:
number
)
=>
{
switch
(
index
)
{
case
0
:
popup
.
value
.
open
(
'bottom'
);
resetSelected
();
break
;
case
1
:
attrPopup
.
value
=
true
;
}
};
const
indicatorDots
=
ref
(
true
);
const
popup
=
ref
();
const
tabButtons
=
ref
([
'
详情'
,
'评论'
])
let
current
=
ref
(
0
)
const
tabButtons
=
ref
([
'
商品详情'
]);
let
current
=
ref
(
0
)
;
const
goodsInfo
=
ref
({
id
:
1
,
...
...
@@ -137,10 +160,12 @@ const goodsInfo = ref({
{
id
:
1
,
img
:
`https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_1.jpg`
},
{
},
{
id
:
2
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_2.jpg'
},
{
},
{
id
:
3
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_3.jpg'
}
...
...
@@ -151,18 +176,19 @@ const goodsInfo = ref({
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_1.jpg'
,
text
:
'石墨色'
,
price
:
'5000.00'
},
{
},
{
value
:
2
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_2.jpg'
,
text
:
'远峰蓝'
,
price
:
'5100.00'
},
{
},
{
value
:
3
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_3.jpg'
,
text
:
'银色'
,
price
:
'5099.00'
}
]
});
...
...
@@ -172,18 +198,20 @@ const selectedGoodsItem = ref({
img
:
''
,
price
:
''
,
num
:
1
})
})
;
const
radioValue
=
ref
(
selectedGoodsItem
.
value
.
id
)
const
radioValue
=
ref
(
selectedGoodsItem
.
value
.
id
)
;
const
options
=
ref
([
{
icon
:
'chat'
,
text
:
'客服'
},
{
},
{
icon
:
'shop'
,
text
:
'店铺'
},
{
},
{
icon
:
goodsInfo
.
value
.
star
?
'star-filled'
:
'star'
,
text
:
'收藏'
}
...
...
@@ -204,64 +232,60 @@ const buttonGroup = ref([
const
onClick
=
(
e
:
any
)
=>
{
if
(
e
.
index
===
0
)
{
console
.
log
(
'客服'
)
console
.
log
(
'客服'
);
}
if
(
e
.
index
===
1
)
{
console
.
log
(
'店铺'
)
console
.
log
(
'店铺'
);
}
if
(
e
.
index
===
2
)
{
console
.
log
(
'收藏'
)
goodsInfo
.
value
.
star
=
!
goodsInfo
.
value
.
star
e
.
content
.
icon
=
goodsInfo
.
value
.
star
?
'star-filled'
:
'star'
let
text
=
''
text
=
goodsInfo
.
value
.
star
?
'已收藏'
:
'已取消收藏'
console
.
log
(
'收藏'
);
goodsInfo
.
value
.
star
=
!
goodsInfo
.
value
.
star
;
e
.
content
.
icon
=
goodsInfo
.
value
.
star
?
'star-filled'
:
'star'
;
let
text
=
''
;
text
=
goodsInfo
.
value
.
star
?
'已收藏'
:
'已取消收藏'
;
uni
.
showToast
({
title
:
text
,
icon
:
"none"
})
icon
:
'none'
});
}
}
};
/**
* popup中按钮展示状态
*/
const
showPopupButton
=
ref
(
0
)
const
showPopupButton
=
ref
(
0
)
;
const
buttonClick
=
(
e
:
any
)
=>
{
if
(
e
.
index
===
0
)
{
console
.
log
(
'加入购物车'
)
showPopupButton
.
value
=
0
console
.
log
(
'加入购物车'
);
showPopupButton
.
value
=
0
;
}
if
(
e
.
index
===
1
)
{
console
.
log
(
'立即购买'
)
showPopupButton
.
value
=
1
console
.
log
(
'立即购买'
);
showPopupButton
.
value
=
1
;
}
openPopup
()
}
openPopup
();
}
;
const
openPopup
=
()
=>
{
console
.
log
(
'打开popup'
,
popup
)
popup
.
value
.
open
(
'bottom'
)
popup
.
value
.
open
(
'bottom'
);
resetSelected
()
}
resetSelected
();
};
const
addToCart
=
()
=>
{
console
.
log
(
'添加至购物车'
,
selectedGoodsItem
.
value
)
popup
.
value
.
close
()
console
.
log
(
'添加至购物车'
,
selectedGoodsItem
.
value
);
popup
.
value
.
close
();
uni
.
showToast
({
title
:
'已添加至购物车'
,
icon
:
"success"
})
}
icon
:
'success'
});
}
;
const
buyNow
=
()
=>
{
console
.
log
(
'立即购买'
,
selectedGoodsItem
.
value
)
popup
.
value
.
close
()
}
console
.
log
(
'立即购买'
,
selectedGoodsItem
.
value
);
popup
.
value
.
close
();
}
;
const
resetSelected
=
()
=>
{
selectedGoodsItem
.
value
.
id
=
goodsInfo
.
value
.
id
;
...
...
@@ -270,28 +294,26 @@ const resetSelected = () => {
selectedGoodsItem
.
value
.
specName
=
''
;
selectedGoodsItem
.
value
.
num
=
1
;
radioValue
.
value
=
''
;
}
}
;
const
changeColor
=
(
e
:
any
)
=>
{
console
.
log
(
e
)
const
selected
=
e
.
detail
.
data
selectedGoodsItem
.
value
.
id
=
selected
.
id
selectedGoodsItem
.
value
.
img
=
selected
.
img
selectedGoodsItem
.
value
.
price
=
selected
.
price
selectedGoodsItem
.
value
.
specName
=
selected
.
text
}
console
.
log
(
e
);
const
selected
=
e
.
detail
.
data
;
selectedGoodsItem
.
value
.
id
=
selected
.
id
;
selectedGoodsItem
.
value
.
img
=
selected
.
img
;
selectedGoodsItem
.
value
.
price
=
selected
.
price
;
selectedGoodsItem
.
value
.
specName
=
selected
.
text
;
};
const
changeBuyNum
=
(
value
:
number
)
=>
{
selectedGoodsItem
.
value
.
num
=
value
}
selectedGoodsItem
.
value
.
num
=
value
;
}
;
const
onClickItem
=
(
e
:
any
)
=>
{
if
(
current
.
value
!=
e
.
currentIndex
)
{
current
.
value
=
e
.
currentIndex
;
}
}
};
</
script
>
<
style
lang=
"scss"
scoped
>
...
...
@@ -319,7 +341,7 @@ const onClickItem = (e: any) => {
.goods-info
{
//height: 200rpx;
background-color
:
#FFFFFF
;
background-color
:
#ffffff
;
padding
:
20rpx
30rpx
;
font-family
:
arial
,
sans-serif
;
border-bottom-left-radius
:
30rpx
;
...
...
@@ -335,33 +357,50 @@ const onClickItem = (e: any) => {
-webkit-box-orient
:
vertical
;
-webkit-line-clamp
:
2
;
}
.goods-sub
{
font-size
:
12px
;
color
:
#ccc
;
display
:
-
webkit-box
;
word-break
:
break-all
;
text-overflow
:
ellipsis
;
overflow
:
hidden
;
-webkit-box-orient
:
vertical
;
-webkit-line-clamp
:
2
;
}
.goods-price
{
color
:
#dd524d
;
margin-top
:
10rpx
;
//position: absolute;
font-size
:
40rpx
;
display
:
flex
;
.unit
{
font-size
:
10px
;
//
font-size: 10px;
}
.price
{
font-size
:
16px
;
font-weight
:
bold
//
font-size: 16px;
font-weight
:
bold
;
}
}
.goods-cost-price
{
color
:
#ccc
;
text-decoration
:
line-through
;
font-size
:
24rpx
;
margin-left
:
10rpx
;
}
}
.cell-group
{
margin-top
:
20rpx
;
border-radius
:
30rpx
;
}
.goods-detail-item
{
margin-top
:
20rpx
;
background-color
:
#FFFFFF
;
padding
:
20rpx
30rpx
;
background-color
:
#ffffff
;
//
padding: 20rpx 30rpx;
font-size
:
30rpx
;
font-family
:
arial
,
sans-serif
;
color
:
rgb
(
192
,
192
,
192
);
border-radius
:
30rpx
;
//
border-radius: 30rpx;
.popup-selected-spec
{
height
:
800rpx
;
...
...
@@ -390,7 +429,7 @@ const onClickItem = (e: any) => {
}
.price
{
font-size
:
16px
;
font-weight
:
bold
font-weight
:
bold
;
}
}
.goods-selected
{
...
...
@@ -428,13 +467,12 @@ const onClickItem = (e: any) => {
border-radius
:
50rpx
;
background
:
linear-gradient
(
90deg
,
rgb
(
254
,
96
,
53
)
,
rgb
(
239
,
18
,
36
));
}
}
}
.shop-info
{
height
:
160rpx
;
background-color
:
#FFFFFF
;
background-color
:
#ffffff
;
margin-top
:
20rpx
;
border-radius
:
30rpx
;
display
:
flex
;
...
...
@@ -458,7 +496,6 @@ const onClickItem = (e: any) => {
font-family
:
'Helvetica Neue'
,
Helvetica
,
sans-serif
;
line-height
:
160rpx
;
}
}
.shop-enter-button
{
line-height
:
160rpx
;
...
...
@@ -471,11 +508,10 @@ const onClickItem = (e: any) => {
border-radius
:
10rpx
;
}
}
}
.goods-intro
{
//height: 160rpx;
background-color
:
#FFFFFF
;
background-color
:
#ffffff
;
margin-top
:
20rpx
;
border-radius
:
30rpx
;
...
...
@@ -494,10 +530,28 @@ const onClickItem = (e: any) => {
right
:
var
(
--
window-right
);
bottom
:
0
;
padding-bottom
:
constant
(
safe-area-inset-bottom
);
background-color
:
#FFFFFF
;
background-color
:
#ffffff
;
padding-bottom
:
env
(
safe-area-inset-bottom
);
}
}
.attr-content
{
padding
:
32rpx
40rpx
;
.title
{
text-align
:
center
;
margin-bottom
:
100rpx
;
}
.details
{
width
:
100%
;
font-size
:
14px
;
.left
{
display
:
inline-block
;
width
:
40%
;
padding
:
20rpx
0
;
}
.right
{
padding
:
20rpx
0
;
}
}
}
</
style
>
src/pages/index/index.vue
浏览文件 @
5484b168
<
template
>
<!-- 搜索 -->
<view><uni-search-bar
placeholder=
"输入搜索商品"
bgColor=
"#EEEEEE"
clearButton=
"auto"
cancelButton=
"none"
@
blur=
"blur"
@
focus=
"focus"
@
confirm=
"search"
/></view>
<view>
<swiper
class=
"swiper"
circular
:indicator-dots=
"indicatorDots"
:autoplay=
"autoplay"
:interval=
"interval"
:duration=
"duration"
>
<swiper-item
v-for=
"(item, index) in bannerList"
:key=
"index"
>
<view
class=
"swiper-item"
><image
class=
"banner"
:src=
"item.img"
/></view>
</swiper-item>
</swiper>
</view>
<view>
<uni-grid
:column=
"4"
:showBorder=
"false"
>
<uni-grid-item
v-for=
"(item, index) in gridList"
:key=
"index"
>
<uni-icons
:type=
"item.icon"
:size=
"30"
color=
"#777"
/>
<text
class=
"text"
>
{{
item
.
text
}}
</text>
</uni-grid-item>
</uni-grid>
</view>
<!-- 轮播图 -->
<view
class=
"wrap"
><u-swiper
:list=
"indexData?.banner"
name=
"url"
height=
"400"
></u-swiper></view>
<!-- 宫格布局 -->
<u-grid
:col=
"4"
class=
"grid"
@
click=
"clickGrid"
>
<u-grid-item
v-for=
"(item, index) in indexData?.channel"
:key=
"item.id"
:index=
"item.id"
>
<u-icon
:name=
"item.iconUrl"
:size=
"46"
></u-icon>
<view
class=
"grid-text"
>
{{
item
.
name
}}
</view>
</u-grid-item>
</u-grid>
<view
class=
"goods"
>
<uni-row>
<uni-col
:span=
"12"
v-for=
"(item, index) in
goodsList"
:key=
"index
"
>
<uni-col
:span=
"12"
v-for=
"(item, index) in
indexData?.newGoodsList"
:key=
"item.id
"
>
<view
class=
"goods-item"
@
click=
"viewGoods(item)"
>
<image
class=
"goods-img"
:src=
"item.
img
"
></image>
<image
class=
"goods-img"
:src=
"item.
picUrl
"
></image>
<view
class=
"goods-infos"
>
<uni-row>
<uni-col
:span=
"24"
>
<text
class=
"goods-title"
>
{{
item
.
titl
e
}}
</text>
<text
class=
"goods-title"
>
{{
item
.
nam
e
}}
</text>
</uni-col>
<uni-col>
<uni-row>
<uni-col
:span=
"
12
"
>
<uni-col
:span=
"
24
"
>
<text
class=
"goods-price"
>
<text
class=
"unit"
>
¥
</text>
<text
class=
"price"
>
{{
item
.
p
rice
}}
</text>
<text
class=
"price"
>
{{
item
.
counterP
rice
}}
</text>
</text>
</uni-col>
<uni-col
:span=
"12"
>
<
!--
<
uni-col
:span=
"12"
>
<text
class=
"goods-sales-count"
>
<text>
销量
</text>
<text>
{{
item
.
sales
}}
</text>
</text>
</uni-col>
</uni-col>
-->
</uni-row>
</uni-col>
</uni-row>
...
...
@@ -54,90 +47,34 @@
<
script
setup
lang=
"ts"
>
import
{
ref
}
from
'vue'
;
import
{
GoodsItem
}
from
'@/types/goods'
;
import
{
homeIndex
}
from
'@/api/index'
;
// import { GoodsItem } from '@/types/goods';
const
indicatorDots
=
ref
(
true
);
const
autoplay
=
ref
(
true
);
const
interval
=
ref
(
3000
);
const
duration
=
ref
(
1500
);
const
indexData
=
ref
();
const
bannerList
=
ref
([
{
id
:
1
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/banner/banner1.jpg'
},
{
id
:
2
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/banner/banner2.jpg'
},
{
id
:
3
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/banner/banner3.jpg'
}
]);
const
gridList
=
ref
([
{
icon
:
'phone-filled'
,
text
:
'手机'
},
{
icon
:
'phone'
,
text
:
'电脑'
},
{
icon
:
'phone'
,
text
:
'家电'
},
{
icon
:
'phone'
,
text
:
'更多'
}
]);
const
clickGrid
=
(
index
:
any
)
=>
{
console
.
log
(
index
);
};
const
goodsList
=
ref
([
{
id
:
1
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_1.jpg'
,
title
:
'Iphone 13 Pro Max 256G 全网通 国行正品'
,
price
:
'5000.00'
,
sales
:
1000
},
{
id
:
2
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_2.jpg'
,
title
:
'Iphone 13 Pro Max'
,
price
:
'5000.00'
,
sales
:
1000
},
{
id
:
3
,
img
:
'https://bytelibs-dev.oss-cn-beijing.aliyuncs.com/image/goods/goods_3.jpg'
,
title
:
'Iphone 13 Pro Max'
,
price
:
'5000.00'
,
sales
:
1000
}
]);
const
viewGoods
=
(
row
:
any
)
=>
{
uni
.
navigateTo
({
url
:
'/pages/goods/index?id='
+
row
.
id
});
};
const
viewGoods
=
(
row
:
GoodsItem
)
=>
{
console
.
log
(
'查看商品'
,
row
.
id
);
uni
.
navigateTo
({
url
:
'/pages/goods/index?goodsId='
+
row
.
id
});
const
initIndex
=
()
=>
{
homeIndex
().
then
((
res
:
any
)
=>
{
// console.log(res);
// if (res.data.code === 200) {
indexData
.
value
=
res
.
data
.
data
;
console
.
log
(
res
,
'首页数据'
);
// }
});
};
initIndex
();
</
script
>
<
style
lang=
"scss"
>
.swiper
{
height
:
300rpx
;
.swiper-item
{
display
:
block
;
height
:
300rpx
;
line-height
:
300rpx
;
text-align
:
center
;
.banner
{
width
:
100%
;
height
:
100%
;
}
}
.grid
{
padding
:
16rpx
;
}
.text
{
...
...
@@ -160,7 +97,7 @@ const viewGoods = (row: GoodsItem) => {
overflow
:
hidden
;
.goods-img
{
width
:
100%
;
height
:
3
5
0rpx
;
height
:
3
0
0rpx
;
}
.goods-infos
{
margin
:
6rpx
10rpx
;
...
...
@@ -171,17 +108,19 @@ const viewGoods = (row: GoodsItem) => {
word-break
:
break-all
;
text-overflow
:
ellipsis
;
overflow
:
hidden
;
margin-bottom
:
30rpx
;
-webkit-box-orient
:
vertical
;
-webkit-line-clamp
:
1
;
}
.goods-price
{
color
:
#dd524d
;
font-family
:
arial
,
sans-serif
;
.unit
{
display
:
flex
;
justify-content
:
flex-end
;
font-size
:
10px
;
}
.price
{
font-size
:
14px
;
margin
:
40rpx
20rpx
0
0
;
font-size
:
16px
;
font-weight
:
bold
;
}
}
...
...
@@ -193,16 +132,4 @@ const viewGoods = (row: GoodsItem) => {
}
}
}
//.grid-item-box {
// flex: 1;
// // position: relative;
// /* #ifndef APP-NVUE */
// display: flex;
// /* #endif */
// flex-direction: column;
// align-items: center !important;
// justify-content: center !important;
// padding: 15px 0;
//}
</
style
>
src/utils/auth.ts
0 → 100644
浏览文件 @
5484b168
export
const
TokenKey
:
string
=
'X-Litemall-Admin-Token'
// 获取指定缓存
export
const
getCache
=
(
key
:
string
)
=>
{
uni
.
getStorage
({
key
:
key
,
success
:
(
res
:
any
)
=>
{
return
res
.
data
}
})
}
// 获取缓存信息
export
const
getAllCache
=
()
=>
{
uni
.
getStorageInfo
({
success
:
(
res
:
any
)
=>
{
return
res
}
})
}
// 修改指定缓存
export
const
setCache
=
(
key
:
string
,
data
:
any
)
=>
{
uni
.
setStorage
({
key
:
key
,
data
})
}
// 移除制定缓存
export
const
renoveCache
=
(
key
:
any
)
=>
{
uni
.
removeStorage
({
key
})
}
// 清除本地缓存
export
const
clearCache
=
()
=>
{
uni
.
clearStorage
()
}
\ No newline at end of file
src/utils/config.ts
浏览文件 @
5484b168
const
CONFIG
:
any
=
{
// 开发环境配置
development
:
{
assetsPath
:
'http
s://m.siccat.com/public/static/images/
'
,
// 静态资源路径
baseUrl
:
'http
s://api.test.siccat.com/api/graphql
'
,
// 后台接口请求地址
hostUrl
:
'http://
m.test.siccat.com/
'
,
// H5地址(前端运行地址)
assetsPath
:
'http
://192.168.2.210:8080
'
,
// 静态资源路径
baseUrl
:
'http
://193.112.67.73:81
'
,
// 后台接口请求地址
hostUrl
:
'http://
192.168.2.210:8080
'
,
// H5地址(前端运行地址)
websocketUrl
:
''
,
// websocket服务端地址
weixinAppId
:
'wx47469e48cd51018c'
// 微信公众号appid
},
// 生产环境配置
production
:
{
...
...
@@ -14,7 +13,6 @@ const CONFIG: any = {
// baseUrl: 'https://api.test.siccat.com/api/graphql',
hostUrl
:
'https://m.siccat.com/'
,
// H5地址(前端运行地址)
websocketUrl
:
''
,
// websocket服务端地址
weixinAppId
:
'wx47469e48cd51018c'
// 微信公众号appid
}
};
...
...
src/utils/request.ts
浏览文件 @
5484b168
...
...
@@ -13,17 +13,17 @@ function request(url: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', data?:
}
else
{
let
pages
=
getCurrentPages
();
let
curRoute
=
pages
[
pages
.
length
-
1
].
route
;
if
(
curRoute
!=
'pages/login/login'
)
{
uni
.
showToast
({
icon
:
'none'
,
title
:
'请重新登录'
,
success
()
{
uni
.
navigateTo
({
url
:
'/pages/login/login'
});
}
});
}
//
if (curRoute != 'pages/login/login') {
//
uni.showToast({
//
icon: 'none',
//
title: '请重新登录',
//
success() {
//
uni.navigateTo({
//
url: '/pages/login/login'
//
});
//
}
//
});
//
}
}
uni
.
request
({
url
:
baseUrl
+
url
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论