Commit 0b1d1345 by 程智春

Merge branch 'nativehome_tst' of http://code.mayi888.com/chengmo/mayi-mp-shop into nativehome_tst

parents a7da4ee4 e3ca81ae
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
...@@ -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;
......
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({
......
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`;
......
...@@ -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;
......
...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment