Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
singleStore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Max
singleStore
Commits
6cc8edd2
Commit
6cc8edd2
authored
Jun 29, 2021
by
June
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:sku,购物车ui;fixed:分类页面
parent
917b873f
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
429 additions
and
133 deletions
+429
-133
App.vue
App.vue
+4
-6
apis/carts.js
apis/carts.js
+34
-6
components/goods-popup/index.vue
components/goods-popup/index.vue
+101
-19
components/inputNumber/index.vue
components/inputNumber/index.vue
+1
-1
components/price/index.vue
components/price/index.vue
+55
-0
pages.json
pages.json
+3
-2
pages/carts/cart-modules.js
pages/carts/cart-modules.js
+40
-0
pages/carts/index.vue
pages/carts/index.vue
+57
-20
pages/category/index.vue
pages/category/index.vue
+44
-15
pages/goods/detail.vue
pages/goods/detail.vue
+20
-5
pages/home/components/goods-module.vue
pages/home/components/goods-module.vue
+10
-5
pages/home/index.vue
pages/home/index.vue
+9
-19
pages/mine/index.vue
pages/mine/index.vue
+3
-14
readme.md
readme.md
+8
-7
static/images/common/icon-collect_default.png
static/images/common/icon-collect_default.png
+0
-0
store/modules/cart.js
store/modules/cart.js
+8
-12
subPages/storeInfo/index.vue
subPages/storeInfo/index.vue
+10
-2
utils/common.js
utils/common.js
+20
-0
utils/vue_extend.js
utils/vue_extend.js
+2
-0
No files found.
App.vue
View file @
6cc8edd2
...
...
@@ -19,12 +19,10 @@ export default {
// wx.login
login_wx
()
// uni.getExtConfig({
// success: res => {
// console.log(res)
// }
// })
if
(
token
)
{
this
.
setCount
()
}
uni
.
setEnableDebug
({
enableDebug
:
true
})
...
...
apis/carts.js
View file @
6cc8edd2
...
...
@@ -7,35 +7,63 @@ import { baseUrl } from '@/config'
*/
export
function
cartCount
()
{
return
request
({
url
:
`
${
baseUrl
}
/wxxcx/cartCount.htm`
,
url
:
'
zsxcx/cartCount.htm
'
,
method
:
'
post
'
})
}
/**
* @desc 加入购物车
* @param {int | String} goods_id 商品ID
* @param {int} cart_number 加入商品数量
* @param {int | String} sku_id 规格ID
*/
export
function
addCart
(
params
)
{
return
request
({
url
:
'
zsxcx/addcart.htm
'
,
method
:
'
post
'
,
data
:
params
})
}
/**
* @desc 获取购物车列表
*/
export
function
cartsList
()
{
return
request
({
url
:
`
${
baseUrl
}
/a`
url
:
'
zsxcx/cartlist.htm
'
,
method
:
'
post
'
,
needMask
:
true
})
}
/**
* @desc 编辑购物车商品
* @param {int | String} 购物车ID
* @param {int | String} 编辑后的购买数量
*/
export
function
editCart
()
{
export
function
editCart
(
{
cart_id
,
cart_number
}
)
{
return
request
({
url
:
`
${
baseUrl
}
/a`
url
:
'
zsxcx/editcart.htm
'
,
data
:
{
cart_id
,
cart_number
},
method
:
'
post
'
,
needMask
:
true
})
}
/**
* @desc 删除购物车商品
* @param {String} cart_ids // 购物车ids
*/
export
function
delCart
()
{
export
function
delCart
(
cart_ids
)
{
return
request
({
url
:
`
${
baseUrl
}
/a`
url
:
'
zsxcx/delcarts.htm
'
,
data
:
{
cart_ids
},
method
:
'
post
'
,
needMask
:
true
})
}
components/goods-popup/index.vue
View file @
6cc8edd2
...
...
@@ -14,8 +14,9 @@
<view
class=
"font-28 font-bold"
>
{{
goods
.
title
}}
</view>
</view>
<
view
class=
"sku-list
font-28"
>
<
scroll-view
scroll-y
class=
"sku-list w-100
font-28"
>
<view
class=
"sku-item py-2"
v-for=
"(item, index) in skuData"
:key=
"item.sku_id"
>
...
...
@@ -23,30 +24,38 @@
<view
class=
"flex-1"
>
{{
item
.
spec_str
}}
</view>
<view
class=
"step-wrap"
>
<input-number
:defaultVal=
"item.counts"
:index=
"index"
@
change=
"numberChange"
/>
</view>
</view>
<view
class=
"w-100 flex j-between a-center"
>
<view
class=
"flex-1 text-left"
>
¥
{{
item
.
price
}}
</view>
<view
class=
"flex-1 text-center"
>
{{
item
.
inventory
}}
</view>
<view
class=
"payCount text-center"
>
0件起购
</view>
<view
class=
"flex-1 text-left price-txt"
>
<!-- 如果不是阶梯价 ? 价格 === 0 ? 询价 : 固定售价 -->
<text
v-if=
"item.is_tiered === '1'"
>
¥
{{
item
.
tiered_pri
}}
</text>
<text
v-else-if=
"item.is_tiered === '0' && item.price === '0'"
>
询价
</text>
<text
v-else
>
¥
{{
item
.
price
}}
</text>
<text
class=
"originPrice ml-1"
>
¥
{{
item
.
original_price
}}
</text>
</view>
<view
class=
"flex-1 text-center"
>
库存:
{{
item
.
inventory
}}
</view>
<view
class=
"payCount text-center"
>
{{
item
.
origin_number_sku
}}
件起购
</view>
</view>
</view>
</view>
</
scroll-
view>
<view
class=
"flex w-100 a-center flex-column font-28 mt-2"
>
<view
class=
"as-end"
>
共
<text
class=
"btn-theme"
>
M
</text>
件
<text
class=
" ml-2 price btn-theme"
>
¥
9999.44
</text>
共
<text
class=
"btn-theme"
>
{{
totalCounts
}}
</text>
件
<text
class=
" ml-2 price btn-theme"
>
¥
{{
totalPrice
}}
</text>
</view>
</view>
<!-- btn -->
<view
class=
"w-100 btn-wrap text-center font-32"
>
<vi
we
class=
"btn-cart"
>
加入购物车
</viwe
>
<view
class=
"btn-pay"
>
立即购买
</view>
<view
class=
"w-100 btn-wrap
flex j-between a-center
text-center font-32"
>
<vi
ew
class=
"btn-cart flex-1"
@
click.stop=
"handleCart"
>
加入购物车
</view
>
<view
class=
"btn-pay
flex-1"
@
click.stop=
"handlePay
"
>
立即购买
</view>
</view>
</view>
</uni-popup>
...
...
@@ -54,25 +63,45 @@
<
script
>
import
uniPopup
from
'
@/components/uni-popup/index.vue
'
import
price
from
'
@/components/price/index.vue
'
import
inputNumber
from
'
@/components/inputNumber/index.vue
'
import
{
goodsSku
}
from
'
@/apis/good
s.js
'
import
{
addCart
}
from
'
@/apis/cart
s.js
'
import
{
mapActions
}
from
'
vuex
'
export
default
{
name
:
'
goods-popup
'
,
data
()
{
return
{
goods
:
null
,
skuData
:
null
skuData
:
[],
currentSku
:
null
,
// 一次只能提交一个规格到购物车: 0,
totalCounts
:
0
,
totalPrice
:
0
}
},
components
:
{
uniPopup
,
inputNumber
inputNumber
,
price
},
computed
:
{
// 总数
// totalCounts() {
// return this.skuData.reduce((pre, cur) => {
// return pre + cur.counts
// }, 0)
// },
// // 总价
// totalPrice() {
// return 1
// }
},
methods
:
{
...
mapActions
(
'
cart
'
,
[
'
setCount
'
]),
/**
* @param {Object} params
* goodsInfo: {
...
...
@@ -86,6 +115,7 @@ export default {
console
.
log
(
params
)
this
.
goods
=
params
.
goodsInfo
this
.
skuData
=
params
.
skuData
this
.
skuData
.
forEach
(
item
=>
item
.
counts
=
0
)
this
.
$refs
.
goodsPopup
.
open
()
}
catch
(
e
){
console
.
log
(
e
)
...
...
@@ -98,10 +128,53 @@ export default {
this
.
$refs
.
goodsPopup
.
close
()
this
.
showSku
=
false
this
.
detail
=
null
this
.
currentSku
=
null
this
.
skuData
=
[]
this
.
goods
=
null
},
numberChange
(
e
)
{
console
.
log
(
e
)
const
skuData
=
this
.
skuData
const
idx
=
e
.
index
const
value
=
e
.
val
this
.
currentSku
=
{
goods_id
:
skuData
[
idx
].
goods_id
,
cart_number
:
value
,
sku_id
:
skuData
[
idx
].
sku_id
}
this
.
$set
(
this
.
skuData
[
idx
],
'
counts
'
,
value
)
this
.
total
()
},
total
()
{
const
skuData
=
this
.
skuData
this
.
totalCounts
=
skuData
.
reduce
((
pre
,
cur
)
=>
{
return
pre
+
cur
.
counts
},
0
)
this
.
totalPrice
=
skuData
.
reduce
((
pre
,
cur
)
=>
{
return
pre
+
~~
cur
.
price
*
cur
.
counts
},
0
)
},
// 加入购物车
async
handleCart
()
{
console
.
log
(
'
33333333
'
)
try
{
console
.
log
(
'
00003333
'
)
console
.
log
(
this
.
currentSku
)
if
(
!
this
.
currentSku
)
return
const
{
status
,
data
}
=
await
addCart
(
this
.
currentSku
)
if
(
status
)
{
this
.
$toast
({
title
:
'
加入购物车成功
'
,
cb
:
this
.
hide
})
this
.
setCount
()
}
}
catch
(
e
){
console
.
log
(
e
)
this
.
$toast
({
title
:
'
加入购物车失败
'
})
//TODO handle the exception
}
},
// 下单
handlePay
()
{
console
.
log
(
'
00000
'
)
}
}
}
...
...
@@ -120,9 +193,11 @@ export default {
}
.sku-list
{
height
:
372rpx
;
@include
borderBox
(
30rpx
,
20rpx
);
border-bottom
:
1rpx
solid
$line
;
.sku-item
{
border-bottom
:
1rpx
solid
$line
;
}
.step-wrap
{
flex
:
0
0
224rpx
;
width
:
224rpx
;
...
...
@@ -134,6 +209,15 @@ export default {
font-size
:
20rpx
;
color
:
$desc
;
}
.price-txt
{
color
:
$primary
;
.originPrice
{
color
:
$desc
;
text-decoration
:
line-through
;
}
}
}
.btn-wrap
{
...
...
@@ -144,14 +228,12 @@ export default {
z-index
:
2
;
height
:
98rpx
;
.btn-cart
,
.btn-pay
{
display
:
inline-block
;
width
:
50%
;
color
:
#fff
;
font-weight
:
bold
;
line-height
:
98rpx
;
}
.btn-cart
{
background-color
:
red
;
background-color
:
#FFBB33
;
}
.btn-pay
{
background-color
:
$primary
;
...
...
components/inputNumber/index.vue
View file @
6cc8edd2
...
...
@@ -55,7 +55,7 @@ export default {
methods
:
{
subtraction
()
{
const
val
=
this
.
calVal
if
(
val
==
=
this
.
min
)
return
this
.
$toast
({
title
:
`数量不能小于
${
this
.
min
}
`
})
if
(
val
<
=
this
.
min
)
return
this
.
$toast
({
title
:
`数量不能小于
${
this
.
min
}
`
})
this
.
calVal
-=
1
},
add
()
{
...
...
components/price/index.vue
0 → 100644
View file @
6cc8edd2
<
template
>
<view
class=
"price-wrap font-28"
>
<template
v-if=
"is_inquiry === '1'"
>
<text
class=
"mr-1"
>
询价
</text>
</
template
>
<
template
v-else-if=
"is_tiered === '1'"
>
<text
class=
"mr-1"
>
¥
{{
price
}}
</text>
<text
class=
"origin-price"
v-if=
"originPrice"
>
¥
{{
originPrice
}}
</text>
<text
v-if=
"goods_unit"
>
/
{{
goods_unit
}}
</text>
</
template
>
<
template
v-else
>
<text
class=
"mr-1"
>
¥
{{
price
}}
</text>
<text
class=
"origin-price"
v-if=
"originPrice"
>
¥
{{
originPrice
}}
</text>
<text
v-if=
"goods_unit"
>
/
{{
goods_unit
}}
</text>
</
template
>
</view>
</template>
<
script
>
export
default
{
props
:
{
is_inquiry
:
{
// 是否开启询价 1开启 0关闭
type
:
String
,
default
:
'
0
'
},
is_tiered
:
{
// 是否开启阶梯价 1开启 0关闭
type
:
String
,
default
:
'
0
'
},
price
:
{
// 正常显示的价格
type
:
String
|
Number
,
default
:
0
},
originPrice
:{
// 文本穿透线的价格
type
:
String
|
Number
,
default
:
0
},
goods_unit
:
{
type
:
String
,
default
:
''
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.price-wrap
{
color
:
$primary
;
.origin-price
{
font-size
:
20rpx
;
color
:
$desc
;
text-decoration
:
line-through
;
}
}
</
style
>
pages.json
View file @
6cc8edd2
...
...
@@ -5,7 +5,7 @@
"style"
:
{
"navigationBarTitleText"
:
" "
,
"enablePullDownRefresh"
:
true
,
"onReachBottomDistance"
:
10
0
"onReachBottomDistance"
:
5
0
}
},
{
...
...
@@ -18,7 +18,8 @@
"path"
:
"pages/carts/index"
,
"style"
:
{
"navigationBarTitleText"
:
"购物车"
,
"enablePullDownRefresh"
:
true
"enablePullDownRefresh"
:
true
,
"onReachBottomDistance"
:
50
}
},
{
...
...
pages/carts/cart-modules.js
0 → 100644
View file @
6cc8edd2
import
{
cartsList
,
editCart
,
delCart
}
from
"
@/apis/carts.js
"
// 获取购物车列表
async
function
getCartList
()
{
try
{
const
{
status
,
data
}
=
await
cartsList
()
if
(
status
)
{
this
.
cartList
=
data
[
0
].
cart_list2
}
}
catch
(
e
){
this
.
$toast
({
title
:
'
获取购物车失败
'
})
//TODO handle the exception
}
}
// 编辑购物车
async
function
editCartCount
()
{
try
{
}
catch
(
e
){
this
.
$toast
({
title
:
'
编辑购物车失败
'
})
//TODO handle the exception
}
}
// 删除购物车
async
function
deleteCarts
()
{
try
{
}
catch
(
e
){
this
.
$toast
({
title
:
'
删除购物车失败
'
})
//TODO handle the exception
}
}
export
default
{
getCartList
,
editCartCount
,
deleteCarts
}
\ No newline at end of file
pages/carts/index.vue
View file @
6cc8edd2
...
...
@@ -17,26 +17,35 @@
</
template
>
<
template
v-else
>
<view
class=
"list-wrap
W
-100"
>
<view
<view
class=
"list-wrap
w
-100"
>
<view
class=
"list-item"
v-for=
"(item, index) in cartList"
:key=
"i
ndex
"
:key=
"i
tem.goods_id
"
@
click=
"handleCartItem(index, item)"
>
<view>
<view
:class=
"item.checked ? 'cart-seleted' : 'cart-unseleted'"
></view>
<text>
{{
item
.
price
}}
</text>
<view
class=
"w-100 flex j-star a-center"
>
<image
class=
"goods-cover mr-2"
:src=
"baseUrl + '/' + item.goods_thumb"
mode=
"aspectFit"
/>
<view
class=
"goods-title flex flex-column j-between a-start flex-1 font-24"
>
{{
item
.
goods_name
}}
</view>
</view>
<view
v-for=
"cart in item.list"
:key=
"cart.cart_id"
>
<text>
{{
cart
.
specification
}}
</text>
</view>
<view
style=
"width: 240rpx;height: 64rpx;"
>
<
!--
<
view
style=
"width: 240rpx;height: 64rpx;"
>
<input-number
:index=
"index"
:value=
"item.counts"
@
change=
"numberChange"
/>
</view>
</view>
-->
</view>
</view>
...
...
@@ -55,12 +64,14 @@
import
inputNumber
from
'
@/components/inputNumber/index.vue
'
import
{
mapState
}
from
'
vuex
'
import
cartModules
from
'
./cart-modules.js
'
import
{
baseUrl
}
from
'
@/config/index.js
'
export
default
{
data
()
{
return
{
cartList
:
[
1
]
baseUrl
,
cartList
:
[]
}
},
...
...
@@ -71,14 +82,17 @@ export default {
onPullDownRefresh
()
{
console
.
log
(
'
refresh
'
);
setTimeout
(
function
()
{
this
.
getCartList
()
uni
.
stopPullDownRefresh
();
},
1000
);
},
computed
:
{
...
mapState
({
token
:
state
=>
state
.
user
.
token
}),
// 总价
totalPrice
()
{
return
this
.
cartList
.
filter
(
item
=>
item
.
checked
).
reduce
((
pre
,
cur
)
=>
{
...
...
@@ -87,7 +101,13 @@ export default {
}
},
created
()
{
this
.
getCartList
()
},
methods
:
{
...
cartModules
,
handleLogin
()
{
uni
.
navigateTo
({
url
:
'
/pages/login/index
'
...
...
@@ -122,16 +142,33 @@ export default {
background-color
:
$primary
;
}
.list-item
{
position
:
relative
;
.cart-unseleted
{
@include
unSelected
(
28rpx
,
28rpx
);
}
.cart-seleted
{
@include
selected
(
28rpx
,
28rpx
);
.list-wrap
{
margin-top
:
40rpx
;
.list-item
{
@include
borderBox
(
40rpx
,
20rpx
);
width
:
690rpx
;
background-color
:
#fff
;
border-radius
:
16rpx
;
margin
:
0
auto
20rpx
;
.goods-cover
{
flex
:
0
0
160rpx
;
width
:
160rpx
;
height
:
160rpx
;
}
.goods-title
{
height
:
160rpx
;
@include
text-ellipsis
(
3
);
}
.cart-unseleted
{
@include
unSelected
(
28rpx
,
28rpx
);
}
.cart-seleted
{
@include
selected
(
28rpx
,
28rpx
);
}
}
}
.cart_info
{
@include
borderBox
(
0
,
30rpx
);
position
:
fixed
;
...
...
pages/category/index.vue
View file @
6cc8edd2
...
...
@@ -14,7 +14,8 @@
class=
"scroll-left"
scroll-y
:scroll-into-view=
"leftScrollName"
>
>
<!-- 一级分类 -->
<view
class=
"w-100 px-3 py-2"
v-for=
"(cate_1, cate_idx_1) in cate_list"
...
...
@@ -24,11 +25,12 @@
<view
class=
"mb-2"
@
click.stop=
"cateChange(1, cate_1.cat_id)"
@
click.stop=
"cateChange(1, cate_1.cat_id
, cate_idx_1
)"
:class=
"cate1_current === cate_1.cat_id ? 'cate-1_active' : null"
>
{{
cate_1
.
cat_name
}}
</view>
<view
v-show=
"cate1_current === cate_1.cat_id && cate_1.list.length > 0"
>
<!-- 二级分类 -->
<view
class=
"ml-2 mb-2"
v-for=
"(cate_2, cate_idx_2) in cate_1.list"
...
...
@@ -36,7 +38,7 @@
>
<view
:class=
"cate2_current === cate_2.cat_id ? 'cate-2_active' : null"
@
click.stop=
"cateChange(2, cate_2.cat_id)"
@
click.stop=
"cateChange(2, cate_2.cat_id
, cate_idx_1, cate_idx_2
)"
>
{{
cate_2
.
cat_name
}}
</view>
</view>
...
...
@@ -47,6 +49,7 @@
</scroll-view>
<view
class=
"scroll-right flex-1"
>
<view
class=
"cates_title"
>
{{
cate1_name
+
'
-
'
+
cate2_name
}}
</view>
<pull-list
ref=
"pullList"
:refresherEnabled=
"false"
...
...
@@ -81,6 +84,7 @@
</
template
>
<
script
>
// 所有写法需要优化!!!
import
pullList
from
'
@/components/pull-list/index.vue
'
import
{
getCatetories
,
cateGoodsList
}
from
'
@/apis/category.js
'
import
{
searchGoods
}
from
'
@/apis/goods.js
'
...
...
@@ -88,16 +92,18 @@ import { baseUrl } from '@/config/index.js'
let
cat_id
=
0
const
params
=
{
keywords
:
''
,
cat_id
:
0
}
//
const params = {
//
keywords: '',
//
cat_id: 0
//
}
export
default
{
data
()
{
return
{
baseUrl
,
cate1_current
:
'
1
'
,
cate1_current
:
'
1
'
,
// 和cateid对应则未选中状态
cate2_current
:
'
0
'
,
cate1_name
:
''
,
cate2_name
:
''
,
cate_list
:
[],
// 分类列表
goods_list
:
[],
// 分类商品列表
showNoMoreMsg
:
false
...
...
@@ -116,8 +122,11 @@ export default {
if
(
status
)
{
let
cate_list
=
this
.
cate_list
cate_list
=
data
cat_id
=
cate_list
[
0
].
cat_id
cat_id
=
cate_list
[
0
].
list
[
0
].
cat_id
this
.
cate2_current
=
cate_list
[
0
].
list
[
0
].
cat_id
this
.
cate_list
=
cate_list
this
.
cate1_name
=
cate_list
[
0
].
cat_name
this
.
cate2_name
=
cate_list
[
0
].
list
[
0
].
cat_name
this
.
getCateGoods
()
}
}
catch
(
e
){
...
...
@@ -126,16 +135,23 @@ export default {
}
},
// 切换分类 type === 1 分类1 type === 2 分类2
cateChange
(
type
,
cate_id
)
{
// 切换分类 type === 1 分类1 type === 2 分类2, cate1_idx 分类一的下表
cateChange
(
type
,
cate_id
,
cate1_idx
,
cate2_idx
)
{
console
.
log
(
type
,
cate_id
,
cate1_idx
)
if
(
type
===
1
)
{
const
cate_list
=
this
.
cate_list
this
.
cate1_current
=
cate_id
this
.
cate2_current
=
null
this
.
cate2_current
=
cate_list
[
cate1_idx
].
list
[
0
].
cat_id
// params.cat_id = cate_list[cate1_idx].list[0].cat_id
cat_id
=
cate_list
[
cate1_idx
].
list
[
0
].
cat_id
this
.
cate1_name
=
cate_list
[
cate1_idx
].
cat_name
this
.
cate2_name
=
cate_list
[
cate1_idx
].
list
[
0
].
cat_name
}
else
if
(
type
===
2
)
{
this
.
cate2_current
=
cate_id
// params.cat_id = cat_id
cat_id
=
cate_id
this
.
cate2_name
=
cate_list
[
cate1_idx
].
list
[
cate2_idx
].
cat_name
}
params
.
cat_id
=
cate_id
cat_id
=
cate_id
this
.
$refs
.
pullList
.
scroll2Top
()
this
.
getCateGoods
()
},
...
...
@@ -211,7 +227,20 @@ export default {
}
.scroll-right
{
position
:
relative
;
padding-top
:
72rpx
;
background-color
:
#fff
;
.cates_title
{
position
:
absolute
;
left
:
0
;
top
:
0
;
right
:
0
;
z-index
:
2
;
height
:
72rpx
;
line-height
:
72rpx
;
margin-left
:
20rpx
;
background-color
:
#fff
;
}
.empty-text
{
font-size
:
20rpx
;
color
:
$desc
;
...
...
pages/goods/detail.vue
View file @
6cc8edd2
...
...
@@ -29,7 +29,7 @@
</view>
<view
class=
"goods-info mb-2"
>
<
view
class=
"price mb-3"
>
¥
{{
detail
.
is_inquiry
===
'
1
'
?
'
询价
'
:
detail
.
shop_price_range
}}
</view
>
<
price
:is_inquiry=
"detail.is_inquiry"
:price=
"detail.shop_price_range"
/
>
<view
class=
"font-28 font-bold mb-2"
>
{{
detail
.
goods_name
}}
</view>
<view
class=
"counts w-100 flex j-start a-center"
>
<view
class=
"mr-4"
>
现库存:
{{
inventory
}}
</view>
...
...
@@ -97,7 +97,10 @@
<!-- buttons -->
<view
class=
"btns w-100 flex j-between a-center"
>
<view
class=
"flex-1 flex j-around a-center"
>
<view
class=
"flex-1 left-item flex flex-column j-center a-center"
>
<view
class=
"flex-1 left-item flex flex-column j-center a-center"
@
click=
"callPhone"
>
<image
class=
"icon mb-1"
src=
"/static/images/common/btn-phone.png"
mode=
"aspectFit"
/>
<text>
联系老板
</text>
</view>
...
...
@@ -111,7 +114,8 @@
<text>
购物车
</text>
</navigator>
<view
class=
"flex-1 left-item flex flex-column j-center a-center"
@
click=
"handleCollect(detail.is_col)"
>
<image
class=
"icon mb-1"
src=
"/static/images/common/icon-collect_active.png"
mode=
"aspectFit"
/>
<image
v-show=
"detail.is_col === 10"
class=
"icon mb-1"
src=
"/static/images/common/icon-collect_active.png"
mode=
"aspectFit"
/>
<image
v-show=
"detail.is_col === 11"
class=
"icon mb-1"
src=
"/static/images/common/icon-collect_default.png"
mode=
"aspectFit"
/>
<!-- 是否已收藏商品:10已收藏 11未收 -->
<text>
{{
detail
.
is_col
===
10
?
'
已收藏
'
:
'
未收藏
'
}}
...
...
@@ -133,9 +137,11 @@
// import leftMenuButton from './components/left-menuButton.vue'
import
backBtn
from
'
./components/back-btn.vue
'
import
uParse
from
'
@/components/parse/parse.vue
'
import
price
from
'
@/components/price/index.vue
'
import
goodsPopup
from
'
@/components/goods-popup/index.vue
'
import
{
goodDetail
,
goodsSku
,
collectGoods
}
from
'
@/apis/goods.js
'
import
{
baseUrl
}
from
'
@/config/index.js
'
import
{
makePhoneCall
}
from
'
@/utils/common.js
'
let
goods_id
=
null
export
default
{
...
...
@@ -158,6 +164,7 @@ export default {
// leftMenuButton,
backBtn
,
uParse
,
price
,
goodsPopup
},
async
onLoad
(
options
)
{
...
...
@@ -180,7 +187,8 @@ export default {
}
else
{
return
[]
}
}
},
},
methods
:
{
...
...
@@ -251,6 +259,8 @@ export default {
this
.
swiperCurrent
=
e
.
detail
.
current
},
// 切换物流
handleLogistics
(
id
)
{
if
(
id
===
this
.
logistics_cur
)
return
...
...
@@ -261,7 +271,7 @@ export default {
handlePopup
()
{
const
skuData
=
this
.
skuData
const
detail
=
this
.
detail
if
(
!
skuData
)
return
this
.
$toast
({
title
:
'
该商品暂无库存
'
})
if
(
!
skuData
&
skuData
.
length
)
return
this
.
$toast
({
title
:
'
该商品暂无库存
'
})
const
params
=
{
goodsInfo
:
{
cover
:
`
${
this
.
baseUrl
}
/
${
detail
.
goods_thumb
}
`
,
...
...
@@ -270,6 +280,11 @@ export default {
skuData
:
skuData
}
this
.
$refs
.
popup
.
show
(
params
)
},
// 呼叫老板
callPhone
()
{
this
.
$checkLogin
(
makePhoneCall
)
}
}
}
...
...
pages/home/components/goods-module.vue
View file @
6cc8edd2
...
...
@@ -15,8 +15,11 @@
/>
<view
class=
"goods-info flex flex-column j-between"
>
<view
class=
"title font-28 my-1"
>
{{
item
.
goods_name
}}
</view>
<view
class=
"flex j-between a-center mt-1 mb-2"
>
<view
class=
"price font-28"
>
{{
item
.
is_inquiry
===
'
1
'
?
'
询价
'
:
item
.
shop_price
+
'
/
'
+
item
.
goods_unit
}}
</view>
<view
class=
"w-10
</price>
flex j-between a-center mt-1 mb-2">
<price
:is_inquiry=
"item.is_inquiry"
:price=
"item.shop_price"
/>
<image
class=
"cart-btn"
src=
"/static/images/common/icon-cart.png"
...
...
@@ -30,6 +33,7 @@
</
template
>
<
script
>
import
price
from
'
@/components/price/index.vue
'
import
{
baseUrl
}
from
'
@/config/index.js
'
export
default
{
props
:
{
...
...
@@ -43,6 +47,10 @@ export default {
}
},
components
:
{
price
},
data
()
{
return
{
baseUrl
...
...
@@ -84,9 +92,6 @@ export default {
.title
{
@include
text-ellipsis
(
2
)
}
.price
{
color
:
$primary
;
}
.cart-btn
{
width
:
34rpx
;
height
:
32rpx
;
...
...
pages/home/index.vue
View file @
6cc8edd2
...
...
@@ -135,7 +135,10 @@
<view
class=
"goods-info flex flex-column j-between"
>
<view
class=
"title font-28 my-1"
>
{{
good
.
goods_name
}}
</view>
<view
class=
"flex j-between a-center mt-1 mb-2"
>
<view
class=
"price font-28"
>
{{
good
.
is_inquiry
===
'
1
'
?
'
询价
'
:
good
.
shop_price
+
'
/
'
+
good
.
goods_unit
}}
</view>
<price
:is_inquiry=
"good.is_inquiry"
:price=
"good.shop_price"
/>
<image
class=
"cart-btn"
src=
"/static/images/common/icon-cart.png"
...
...
@@ -149,7 +152,7 @@
</view>
</
template
>
</block>
</view>
</template>
...
...
@@ -162,11 +165,12 @@
import
searchBar
from
'
@/components/search-bar/index.vue
'
import
goodsModule
from
'
./components/goods-module.vue
'
import
goodsPopup
from
'
@/components/goods-popup/index.vue
'
import
price
from
'
@/components/price/index.vue
'
import
LoadMore
from
'
@/utils/load-more.js
'
import
{
checkLogin
}
from
'
@/utils/modules/login.js
'
import
indexModule
from
'
./index.js
'
import
{
baseUrl
}
from
'
@/config/index.js
'
import
{
makePhoneCall
}
from
'
@/utils/common.js
'
import
{
mapState
,
mapActions
}
from
'
vuex
'
export
default
{
...
...
@@ -184,6 +188,7 @@ export default {
searchBar
,
goodsModule
,
goodsPopup
,
price
},
computed
:
{
...
...
@@ -249,19 +254,7 @@ export default {
checkLogin
(()
=>
{
switch
(
type
)
{
case
'
contact
'
:
const
storeInfo
=
this
.
storeInfo
if
(
storeInfo
&&
storeInfo
.
shop_tel
)
{
uni
.
showModal
({
content
:
`是否拨打
${
storeInfo
.
shop_tel
}
`
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
uni
.
makePhoneCall
({
phoneNumber
:
storeInfo
.
shop_tel
})
}
}
})
}
makePhoneCall
()
break
;
case
'
collect
'
:
uni
.
navigateTo
({
...
...
@@ -340,9 +333,6 @@ export default {
.title
{
@include
text-ellipsis
(
2
)
}
.price
{
color
:
$primary
;
}
.cart-btn
{
width
:
34rpx
;
height
:
32rpx
;
...
...
pages/mine/index.vue
View file @
6cc8edd2
...
...
@@ -92,7 +92,7 @@
import
{
mapState
,
mapActions
}
from
'
vuex
'
import
{
checkLogin
}
from
'
@/utils/modules/login.js
'
import
{
baseUrl
}
from
'
@/config/index.js
'
import
{
makePhoneCall
}
from
'
@/utils/common.js
'
export
default
{
data
()
{
return
{
...
...
@@ -111,6 +111,7 @@ export default {
}
},
methods
:
{
makePhoneCall
,
...
mapActions
(
'
user
'
,
[
'
setUserInfo
'
]),
nav
(
type
,
arg
)
{
...
...
@@ -151,19 +152,7 @@ export default {
// 拨打电话
phoneCall
()
{
checkLogin
(()
=>
{
const
phone
=
'
100
'
uni
.
showModal
({
content
:
`是否拨打
${
phone
}
`
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
uni
.
makePhoneCall
({
phoneNumber
:
phone
})
}
}
})
})
this
.
$checkLogin
(
makePhoneCall
)
}
}
}
...
...
readme.md
View file @
6cc8edd2
...
...
@@ -26,10 +26,11 @@
-
仅次于小程序原生弹窗 zIndex 100
#### 未完成
+
呼叫老板提取公共方法
+
分类页面选中名称显示
+
一级分类无商品 二级分类却有商品
+
商品弹窗组件封装(根据sku打开购物弹窗组件)
+
商品的价格展示处理
+
购物
+
购物车step组件
+
搜索列表
+
下单
+
支付
+
订单管理
+
订单详情
+
服务过期处理
+
购物车
+
sku阶梯价未处理
static/images/common/icon-collect_default.png
0 → 100644
View file @
6cc8edd2
1.7 KB
store/modules/cart.js
View file @
6cc8edd2
...
...
@@ -13,18 +13,14 @@ const mutations = {
const
actions
=
{
setCount
:
async
({
commit
})
=>
{
const
{
status
,
data
}
=
await
cartCount
()
console
.
log
(
status
,
data
)
const
count
=
res
.
res
.
count
console
.
log
(
'
vuex actions success ==========================================
'
)
// if(res.status && count > 0) {
// commit('SETCOUNT', count)
// uni.setTabBarBadge({
// index: 2,
// text: count > 99 ? '99+' : JSON.stringify(count)
// })
// } else {
// wx.removeTabBarBadge({index: 2})
// }
const
count
=
data
.
count
if
(
status
&&
count
>
0
)
{
commit
(
'
SETCOUNT
'
,
count
)
uni
.
setTabBarBadge
({
index
:
2
,
text
:
count
>
99
?
'
99+
'
:
String
(
count
)
})
}
}
}
...
...
subPages/storeInfo/index.vue
View file @
6cc8edd2
...
...
@@ -20,7 +20,7 @@
</view>
<view
class=
"store-item py-2 font-28"
>
<text
class=
"hd"
>
所在地
</text>
<text
class=
"flex-1"
></text>
<text
class=
"flex-1"
>
{{
storeInfo
.
ap
+
storeInfo
.
ac
+
storeInfo
.
ad
}}
</text>
</view>
<view
class=
"store-item py-2 font-28"
>
<text
class=
"hd"
>
详细地址
</text>
...
...
@@ -34,9 +34,13 @@
<text
class=
"hd"
>
营业时间
</text>
<text
class=
"flex-1"
>
{{
startT
+
'
至
'
+
endT
}}
</text>
</view>
<view
class=
"store-item py-2 font-28"
>
<text
class=
"hd"
>
自提时间
</text>
<text
class=
"flex-1"
>
{{
storeInfo
.
pickup_hours
}}
</text>
</view>
<view
class=
"store-item py-2 font-28"
>
<text
class=
"hd"
>
创建时间
</text>
<text
class=
"flex-1"
></text>
<text
class=
"flex-1"
>
{{
createTime
}}
</text>
</view>
</view>
</view>
...
...
@@ -45,6 +49,7 @@
<
script
>
import
{
mapState
}
from
'
vuex
'
import
{
baseUrl
}
from
'
@/config/index.js
'
import
dayjs
from
'
dayjs
'
const
weeks
=
{
1
:
'
周一
'
,
2
:
'
周二
'
,
...
...
@@ -69,6 +74,9 @@ export default {
},
endT
()
{
return
weeks
[
this
.
storeInfo
.
business_week_end
]
},
createTime
()
{
return
dayjs
(
this
.
storeInfo
.
add_time
*
1000
).
format
(
'
YYYY-MM-DD
'
)
}
}
}
...
...
utils/common.js
View file @
6cc8edd2
...
...
@@ -46,6 +46,26 @@ export function throttle(callback, wait = 3000) {
}
}
/**
* 联系老板
*/
export
function
makePhoneCall
()
{
const
storeInfo
=
store
.
state
.
user
.
storeInfo
if
(
storeInfo
&&
storeInfo
.
shop_tel
)
{
const
phoneNumber
=
storeInfo
.
shop_tel
uni
.
showModal
({
content
:
`是否拨打
${
phoneNumber
}
`
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
uni
.
makePhoneCall
({
phoneNumber
})
}
}
})
}
}
/**
* @微信支付
* @param { Functiom } cb 回调函数
...
...
utils/vue_extend.js
View file @
6cc8edd2
import
Vue
from
"
vue
"
import
{
getStorage
,
setStorage
}
from
"
@/lib/storage/index.js
"
import
Toast
from
"
@/lib/toast/index.js
"
import
{
checkLogin
}
from
'
@/utils/modules/login.js
'
Vue
.
prototype
.
$getStorage
=
getStorage
Vue
.
prototype
.
$setStorage
=
setStorage
Vue
.
prototype
.
$toast
=
Toast
Vue
.
prototype
.
$checkLogin
=
checkLogin
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