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
0b1d1345
Commit
0b1d1345
authored
Feb 03, 2021
by
程智春
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nativehome_tst' of
http://code.mayi888.com/chengmo/mayi-mp-shop
into nativehome_tst
parents
a7da4ee4
e3ca81ae
Show 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 @
0b1d1345
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 @
0b1d1345
...
@@ -7,7 +7,7 @@ import orderApi from "./api/order"
...
@@ -7,7 +7,7 @@ import orderApi from "./api/order"
import
promoteApi
from
"./api/promote"
;
import
promoteApi
from
"./api/promote"
;
import
indexApi
from
'./api/index'
import
indexApi
from
'./api/index'
import
{
DFSImg
}
from
"@/utils/index"
;
import
{
DFSImg
}
from
"@/utils/index"
;
import
{
$themeToLink
}
from
"@/utils/mayi"
import
{
$themeToLink
,
$themeAddToCard
}
from
"@/utils/mayi"
;
import
shop
from
"./api/shop"
;
import
shop
from
"./api/shop"
;
Vue
.
config
.
productionTip
=
false
Vue
.
config
.
productionTip
=
false
...
@@ -46,7 +46,8 @@ mpApp.themeColorCallBack = function () {};
...
@@ -46,7 +46,8 @@ mpApp.themeColorCallBack = function () {};
console
.
log
(
'3555555'
,
wx
)
console
.
log
(
'3555555'
,
wx
)
// 全局跳转 data为link对象
// 全局跳转 data为link对象
mpApp
.
$themeToLink
=
$themeToLink
mpApp
.
$themeToLink
=
$themeToLink
// 全局加入购物车
mpApp
.
$themeAddToCard
=
$themeAddToCard
// api
// api
mpApp
.
goodsApi
=
goodsApi
;
mpApp
.
goodsApi
=
goodsApi
;
mpApp
.
orderApi
=
orderApi
;
mpApp
.
orderApi
=
orderApi
;
...
...
src/utils/mayi.js
View file @
0b1d1345
import
cart
from
"@/api/cart"
// 主题色
// 主题色
export
let
themeColor
=
{
export
let
themeColor
=
{
"--main-color"
:
"#ffffff"
,
"--main-color"
:
"#ffffff"
,
...
@@ -95,6 +96,35 @@ export function $themeToLink(data, option) {
...
@@ -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
=
""
)
{
function
toPage
(
backPath
,
backParams
=
""
)
{
wx
.
navigateTo
({
wx
.
navigateTo
({
...
...
static/nativeComponents/GoodsList/GoodsItem/index.js
View file @
0b1d1345
const
app
=
getApp
();
const
app
=
getApp
();
const
{
goodsApi
,
DFSImg
,
$themeToLink
}
=
app
;
const
{
goodsApi
,
DFSImg
,
$themeToLink
,
$themeAddToCard
}
=
app
;
const
componentOptions
=
{
const
componentOptions
=
{
// 组件选项
// 组件选项
options
:
{
options
:
{
...
@@ -86,7 +86,7 @@ const componentOptions = {
...
@@ -86,7 +86,7 @@ const componentOptions = {
if
(
btnType
<
6
)
{
if
(
btnType
<
6
)
{
// 加入购物车
// 加入购物车
console
.
log
(
"加入购物车"
);
console
.
log
(
"加入购物车"
);
// this.$themeAddToCard(item
);
$themeAddToCard
(
this
.
data
.
items
);
}
else
{
}
else
{
// 进入确认订单
// 进入确认订单
linkVal
=
`/order/orderConfirm?productGoodsMixId=
${
minProductGoodsMixid
}
&productGoodsId=
${
minProductGoodsId
}
&goodsId=
${
minGoodsId
}
&qty=1&goodsString=null&source=3`
;
linkVal
=
`/order/orderConfirm?productGoodsMixId=
${
minProductGoodsMixid
}
&productGoodsId=
${
minProductGoodsId
}
&goodsId=
${
minGoodsId
}
&qty=1&goodsString=null&source=3`
;
...
...
static/nativeComponents/GoodsList/GoodsItem/index.wxss
View file @
0b1d1345
...
@@ -250,6 +250,9 @@ align-items: flex-start;
...
@@ -250,6 +250,9 @@ align-items: flex-start;
.Sold text{
.Sold text{
font-size: 24rpx;
font-size: 24rpx;
}
}
.buy-now-icon{
color: var(--main-color);
}
.buy-now {
.buy-now {
color: #ffffff;
color: #ffffff;
position: absolute;
position: absolute;
...
...
static/nativeComponents/GoodsList/index.js
View file @
0b1d1345
...
@@ -226,7 +226,7 @@ const componentOptions = {
...
@@ -226,7 +226,7 @@ const componentOptions = {
item
.
productImgUrl
=
DFSImg
(
item
.
productImgUrl
,
400
,
400
,
1
);
item
.
productImgUrl
=
DFSImg
(
item
.
productImgUrl
,
400
,
400
,
1
);
item
.
minPrice
=
Number
(
item
.
minPrice
).
toFixed
(
2
);
item
.
minPrice
=
Number
(
item
.
minPrice
).
toFixed
(
2
);
item
.
qty
=
Number
(
item
.
qty
);
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
.
totalCollectionCount
=
Number
(
item
.
totalCollectionCount
)
||
0
;
item
.
minPriceAfterRecommendedCardPriceTable
=
item
.
minPriceAfterRecommendedCardPriceTable
item
.
minPriceAfterRecommendedCardPriceTable
=
item
.
minPriceAfterRecommendedCardPriceTable
?
Number
(
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