Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
f1f78282
Commit
f1f78282
authored
Feb 03, 2021
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
4be4b1ce
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
5 deletions
+47
-5
src/api/cart.js
+8
-0
src/main.js
+3
-2
src/utils/mayi.js
+30
-0
static/nativeComponents/GoodsList/GoodsItem/index.js
+2
-2
static/nativeComponents/GoodsList/GoodsItem/index.wxss
+3
-0
static/nativeComponents/GoodsList/index.js
+1
-1
No files found.
src/api/cart.js
0 → 100644
View file @
f1f78282
import
{
requestPOST
,
requestGET
}
from
"@/utils/request.js"
;
// 添加商品
export
default
{
addCart
(
data
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/cart/add_item`
,
data
);
},
}
\ No newline at end of file
src/main.js
View file @
f1f78282
...
...
@@ -7,7 +7,7 @@ import orderApi from "./api/order"
import
promoteApi
from
"./api/promote"
;
import
indexApi
from
'./api/index'
import
{
DFSImg
}
from
"@/utils/index"
;
import
{
$themeToLink
}
from
"@/utils/mayi"
import
{
$themeToLink
,
$themeAddToCard
}
from
"@/utils/mayi"
;
Vue
.
config
.
productionTip
=
false
App
.
mpType
=
'app'
...
...
@@ -45,7 +45,8 @@ mpApp.themeColorCallBack = function () {};
console
.
log
(
'3555555'
,
wx
)
// 全局跳转 data为link对象
mpApp
.
$themeToLink
=
$themeToLink
// 全局加入购物车
mpApp
.
$themeAddToCard
=
$themeAddToCard
// api
mpApp
.
goodsApi
=
goodsApi
;
mpApp
.
orderApi
=
orderApi
;
...
...
src/utils/mayi.js
View file @
f1f78282
import
cart
from
"@/api/cart"
// 主题色
export
let
themeColor
=
{
"--main-color"
:
"#ffffff"
,
...
...
@@ -95,6 +96,35 @@ export function $themeToLink(data, option) {
}
}
}
export
function
$themeAddToCard
(
item
,
callback
)
{
let
app
=
getApp
();
let
errorMsg
=
""
;
if
(
item
.
productNature
==
5
)
{
errorMsg
=
"电子卡券不可加入购物车"
;
}
if
(
item
.
productNature
==
3
)
{
errorMsg
=
"会员卡不可加入购物车"
;
}
if
(
item
.
productNature
==
2
)
{
errorMsg
=
"虚拟商品不可加入购物车"
;
}
if
(
errorMsg
)
{
wx
.
showToast
({
title
:
errorMsg
,
icon
:
'none'
,
});
}
cart
.
addCart
([
{
productGoodsId
:
item
.
minProductGoodsId
,
qty
:
item
.
saleQty
}
])
.
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
wx
.
showToast
({
title
:
"加入购物车成功"
,
icon
:
"none"
});
}
callback
();
});
}
function
toPage
(
backPath
,
backParams
=
""
)
{
wx
.
navigateTo
({
...
...
static/nativeComponents/GoodsList/GoodsItem/index.js
View file @
f1f78282
const
app
=
getApp
();
const
{
goodsApi
,
DFSImg
,
$themeToLink
}
=
app
;
const
{
goodsApi
,
DFSImg
,
$themeToLink
,
$themeAddToCard
}
=
app
;
const
componentOptions
=
{
// 组件选项
options
:
{
...
...
@@ -86,7 +86,7 @@ const componentOptions = {
if
(
btnType
<
6
)
{
// 加入购物车
console
.
log
(
"加入购物车"
);
// this.$themeAddToCard(item
);
$themeAddToCard
(
this
.
data
.
items
);
}
else
{
// 进入确认订单
linkVal
=
`/order/orderConfirm?productGoodsMixId=
${
minProductGoodsMixid
}
&productGoodsId=
${
minProductGoodsId
}
&goodsId=
${
minGoodsId
}
&qty=1&goodsString=null&source=3`
;
...
...
static/nativeComponents/GoodsList/GoodsItem/index.wxss
View file @
f1f78282
...
...
@@ -250,6 +250,9 @@ align-items: flex-start;
.Sold text{
font-size: 24rpx;
}
.buy-now-icon{
color: var(--main-color);
}
.buy-now {
color: #ffffff;
position: absolute;
...
...
static/nativeComponents/GoodsList/index.js
View file @
f1f78282
...
...
@@ -226,7 +226,7 @@ const componentOptions = {
item
.
productImgUrl
=
DFSImg
(
item
.
productImgUrl
,
400
,
400
,
1
);
item
.
minPrice
=
Number
(
item
.
minPrice
).
toFixed
(
2
);
item
.
qty
=
Number
(
item
.
qty
);
item
.
saleQty
=
Number
(
item
.
saleQty
)
;
item
.
saleQty
=
item
.
saleQty
?
Number
(
item
.
saleQty
):
1
;
item
.
totalCollectionCount
=
Number
(
item
.
totalCollectionCount
)
||
0
;
item
.
minPriceAfterRecommendedCardPriceTable
=
item
.
minPriceAfterRecommendedCardPriceTable
?
Number
(
item
.
minPriceAfterRecommendedCardPriceTable
)
...
...
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