Commit f1f78282 by 李嘉林

优化

parent 4be4b1ce
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"
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;
......
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({
......
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`;
......
......@@ -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;
......
......@@ -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)
......
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