【新增】新增仿点餐模块

This commit is contained in:
大灰灰
2022-09-18 22:44:02 +08:00
parent 1b2a299d0a
commit 8682701c66
15 changed files with 820 additions and 122 deletions

View File

@@ -23,5 +23,12 @@ namespace CoreCms.Net.IRepository
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<int> GetCountAsync(int userId); Task<int> GetCountAsync(int userId);
/// <summary>
/// 获取购物车商品总价格
/// </summary>
/// <returns></returns>
Task<decimal> GetMoneyAsync(int userId);
} }
} }

View File

@@ -127,6 +127,11 @@ namespace CoreCms.Net.IServices
/// <returns></returns> /// <returns></returns>
Task<int> GetCountAsync(int userId); Task<int> GetCountAsync(int userId);
/// <summary>
/// 获取购物车商品总价格
/// </summary>
/// <returns></returns>
Task<decimal> GetMoneyAsync(int userId);
/// <summary> /// <summary>
/// 根据提交的数据判断哪些购物券可以使用 /// 根据提交的数据判断哪些购物券可以使用

View File

@@ -35,19 +35,45 @@ namespace CoreCms.Net.Repository
/// <returns></returns> /// <returns></returns>
public async Task<int> GetCountAsync(int userId) public async Task<int> GetCountAsync(int userId)
{ {
var count = DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) => var count = await DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) =>
new object[] new object[]
{ {
JoinType.Inner, cart.productId == products.id, JoinType.Inner, cart.productId == products.id,
JoinType.Inner, products.goodsId == goods.id JoinType.Inner, products.goodsId == goods.id
}) })
.Where((cart, products, goods) => cart.type == (int) GlobalEnumVars.OrderType.Common) .Where((cart, products, goods) => cart.type == (int)GlobalEnumVars.OrderType.Common)
.Select((cart, products, goods) => new {cart.id, cart.userId, goodId = goods.id}) .Select((cart, products, goods) => new { cart.id, cart.userId, goodId = goods.id })
.MergeTable() .MergeTable()
.CountAsync(p => p.userId == userId); .CountAsync(p => p.userId == userId);
return await count; return count;
} }
#endregion #endregion
#region
/// <summary>
/// 获取购物车商品总价格
/// </summary>
/// <returns></returns>
public async Task<decimal> GetMoneyAsync(int userId)
{
var count = await DbClient.Queryable<CoreCmsCart, CoreCmsProducts, CoreCmsGoods>((cart, products, goods) =>
new object[]
{
JoinType.Inner, cart.productId == products.id,
JoinType.Inner, products.goodsId == goods.id
})
.Where((cart, products, goods) => cart.type == (int)GlobalEnumVars.OrderType.Common && cart.userId == userId)
.Select((cart, products, goods) => new { cart.nums, products.price, sunMoney = cart.nums * products.price })
.MergeTable()
.SumAsync(p => p.sunMoney);
return count;
}
#endregion
} }
} }

View File

@@ -854,6 +854,18 @@ namespace CoreCms.Net.Services
#endregion #endregion
#region
/// <summary>
/// 获取购物车商品总价格
/// </summary>
/// <returns></returns>
public async Task<decimal> GetMoneyAsync(int userId)
{
return await _dal.GetMoneyAsync(userId);
}
#endregion
#region 使 #region 使
/// <summary> /// <summary>
/// 根据提交的数据判断哪些购物券可以使用 /// 根据提交的数据判断哪些购物券可以使用

View File

@@ -16,6 +16,10 @@
<None Remove="CoreShop\**" /> <None Remove="CoreShop\**" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="CoreShopProfessional-UniApp\pages\template\" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions> <ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project> </Project>

View File

@@ -71,6 +71,8 @@ const install = (Vue, vm) => {
let setCartNum = (params, config = {}) => http.post('/Api/Cart/SetCartNum', params, { custom: { methodName: 'cart.setnums', needToken: true } }); let setCartNum = (params, config = {}) => http.post('/Api/Cart/SetCartNum', params, { custom: { methodName: 'cart.setnums', needToken: true } });
// 获取购物车数量 // 获取购物车数量
let getCartNum = (params, config = {}) => http.post('/Api/User/GetCartNumber', params, { custom: { methodName: 'cart.getnumber', needToken: true } }); let getCartNum = (params, config = {}) => http.post('/Api/User/GetCartNumber', params, { custom: { methodName: 'cart.getnumber', needToken: true } });
// 获取购物车数量和商品总价格
let getCartNumAndMoney = (params, config = {}) => http.post('/Api/User/GetCartNumberAndMoney', params, { custom: { methodName: 'cart.getnumber', needToken: true } });
// 根据购物车已有数据获取能够使用的优惠券 // 根据购物车已有数据获取能够使用的优惠券
let getCartCoupon = (params, config = {}) => http.post('/Api/Cart/GetCartAvailableCoupon', params, { custom: { methodName: 'cart.getCartCoupon', needToken: true } }); let getCartCoupon = (params, config = {}) => http.post('/Api/Cart/GetCartAvailableCoupon', params, { custom: { methodName: 'cart.getCartCoupon', needToken: true } });
@@ -443,6 +445,7 @@ const install = (Vue, vm) => {
cartList, cartList,
setCartNum, setCartNum,
getCartNum, getCartNum,
getCartNumAndMoney,
getCartCoupon, getCartCoupon,
userShip, userShip,
userDefaultShip, userDefaultShip,

View File

@@ -56,10 +56,10 @@
"name": "template", "name": "template",
"pages": [ "pages": [
{ {
"path": "empty/empty", "path": "index/index",
"style": { "style": {
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "模板架构页" "navigationBarTitleText": "模板页"
} }
}, },
{ {
@@ -68,6 +68,20 @@
"navigationBarTextStyle": "black", "navigationBarTextStyle": "black",
"navigationBarTitleText": "助农农产品首页" "navigationBarTitleText": "助农农产品首页"
} }
},
{
"path": "diancan/index/index",
"style": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "点餐首页"
}
},
{
"path": "diancan/list/list",
"style": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "点餐列表"
}
} }
] ]
}, },
@@ -251,19 +265,6 @@
} }
] ]
}, },
{
"root": "pages/reward",
"name": "reward",
"pages": [
{
"path": "reward",
"style": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "打赏"
}
}
]
},
{ {
"root": "pages/storeMap", "root": "pages/storeMap",
"name": "storeMap", "name": "storeMap",
@@ -892,7 +893,6 @@
}, },
{ {
"pagePath": "pages/index/member/member", "pagePath": "pages/index/member/member",
//"pagePath": "pages/login/loginByAccount/loginByAccount",
"text": "我的", "text": "我的",
"iconPath": "static/images/indexMenus/index04.png", "iconPath": "static/images/indexMenus/index04.png",
"selectedIconPath": "static/images/indexMenus/index04_1.png" "selectedIconPath": "static/images/indexMenus/index04_1.png"

View File

@@ -90,7 +90,7 @@
imgTap() { imgTap() {
this.modalShow = false; this.modalShow = false;
uni.navigateTo({ uni.navigateTo({
url: "/pages/reward/reward" url: "/pages/template/index/index"
}); });
}, },
closeTap() { closeTap() {

View File

@@ -1,38 +0,0 @@
<template>
<view>
<u-navbar title="打赏" safeAreaInsetTop fixed placeholder>
<view class="coreshop-navbar-left-slot" slot="left">
<u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
<u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
<u-icon name="home" size="22" @click="goHome"></u-icon>
</view>
<view slot="right">
</view>
</u-navbar>
<view class="coreshop-padding-15 coreshop-bg-white">
<image :src="$globalConstVars.apiFilesUrl+'/static/images/reward/wx.png'" mode="widthFix" />
<image :src="$globalConstVars.apiFilesUrl+'/static/images/reward/zfb.jpg'" mode="widthFix" />
</view>
<!-- 登录提示 -->
<coreshop-login-modal></coreshop-login-modal>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style lang="scss" scoped>
image { width: 100%; }
</style>

View File

@@ -0,0 +1,190 @@
<template>
<view class="container">
<swiper class="banner-swiper" circular autoplay :interval="5000" :duration="1000">
<swiper-item class="banner-swiper-item" v-for="(item, index) in swipers" :key="index">
<image :src="item" mode="widthFix"></image>
</swiper-item>
</swiper>
<view class="content">
<!-- section-1 begin -->
<view class="section-1" @tap="goDianCanCategory">
<navigator class="item" open-type="switchTab" url="/pages/index/index" hover-class="none">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/home_icon_ziqu1.png" mode="widthFix"></image>
<view class="wenyue-font">门店自取</view>
<view class="text-color-assist">下单免排队</view>
</navigator>
<navigator class="item" open-type="navigate" url="/pages/addresses/addresses" hover-class="none">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/home_icon_waimai1.png" mode="widthFix"></image>
<view class="wenyue-font">外卖</view>
<view class="text-color-assist">无需接触 送喜到家</view>
</navigator>
</view>
<!-- section-2 end -->
<!-- section-2 begin -->
<view class="section-2" @tap="goDianCanCategory">
<navigator class="item" open-type="switchTab" url="/pages/mart/mart" hover-class="none">
<view class="title">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/home_icon_baihuo1.png"></image>
<view>喜茶百货</view>
</view>
<view class="tips">灵感商品 立即选购</view>
</navigator>
<navigator class="item" open-type="navigate" url="/pages/home/group-dinner" hover-class="none">
<view class="title">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/home_icon_qiye1.png"></image>
<view>企业团餐</view>
</view>
<view class="tips">50份起送</view>
</navigator>
</view>
<!-- section-2 end -->
<view class="section-3" @tap="goDianCanCategory">
<navigator class="my-integral" open-type="navigate" url="/pages/integrals/mall" hover-class="none">
<view class="integrals">
<view>我的积分</view>
<view class="neutra-font">63</view>
</view>
<view class="tips">
可兑换喜茶劵和丰富灵感周边
</view>
</navigator>
<navigator class="my-code" open-type="navigate" url="/pages/my/code" hover-class="none">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/home_icon_erweima.png"></image>
<view>会员码</view>
</navigator>
</view>
<view class="section-4" @tap="goDianCanCategory">
<view class="left">
<view class="grid coreshop-flex-direction coreshop-justify-center">
<view class="coreshop-flex coreshop-align-center">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/csc.png" class="mark-img"></image>
<view class="font-size-sm text-color-base">奈雪的茶商城</view>
</view>
<view class="text-color-assist" style="margin-left: 40rpx; font-size: 20rpx;">优质茶礼盒网红零食</view>
</view>
<view class="grid justify-content-end align-items-end">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/yzclh.png" class="yzclh-img" mode="heightFix"></image>
</view>
</view>
<view class="right">
<view class="tea-activity">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/mcsb.png" class="mark-img"></image>
<view>买茶送包</view>
<view class="right-img">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/mcsb_bg.png" mode="widthFix"></image>
</view>
</view>
<view class="member-gifts">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/hyjb.png" class="mark-img"></image>
<view>会员劵包</view>
<view class="right-img">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/hyjb_bg.png" mode="widthFix"></image>
</view>
</view>
</view>
</view>
<view class="section-5" @tap="goDianCanCategory">
<view class="header">
<view class="title">会员新鲜事</view>
<view class="iconfont iconRightbutton"></view>
</view>
<view class="list">
<view class="item">
<image src="https://img-shop.qmimg.cn/s23107/2020/04/27/0039bf41c9ebd50a2c.jpg"></image>
<view class="title">"梅"你不行 | 霸气杨梅清爽回归</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
swipers: [
"https://files.cdn.coreshop.cn/static/template/diancan/images/1.jpg",
"https://files.cdn.coreshop.cn/static/template/diancan/images/2.jpg",
"https://files.cdn.coreshop.cn/static/template/diancan/images/3.jpg",
"https://files.cdn.coreshop.cn/static/template/diancan/images/4.jpg",
"https://files.cdn.coreshop.cn/static/template/diancan/images/5.jpg",
]
}
},
methods: {
goDianCanCategory() {
this.$u.route({ url: '/pages/template/diancan/list/list', });
}
}
}
</script>
<style lang="scss" scoped>
page { max-height: 100%; }
.banner-swiper { width: 100%; height: 600rpx;
.banner-swiper-item {
image { width: 100%; }
}
}
.content { width: 100%; padding: 0 30rpx; position: relative; }
.section-1 { position: relative; background-color: #ffffff; margin-top: -60rpx; border-radius: 12rpx; padding: 60rpx 0; display: flex; margin-bottom: 30rpx; box-shadow: 0 20rpx 20rpx -20rpx rgba($color: #333, $alpha: 0.1);
.item { flex: 1; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; position: relative;
&:nth-child(1):after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 2rpx; background-color: #c8c7cc; }
image { width: 100rpx; margin-bottom: 20rpx; }
.wenyue-font { font-size: 48rpx; margin-bottom: 10rpx; }
}
}
.section-2 { display: flex; justify-content: space-between; margin-bottom: 30rpx;
.item { width: 335rpx; background-color: #EAEBEC; padding: 30rpx 0; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 12rpx;
.title { width: 100%; display: flex; align-items: center; justify-content: center; font-size: 32rpx;
image { width: 60rpx; height: 60rpx; margin-right: 10rpx; }
}
.tips { color: #999; font-size: 26rpx; }
}
}
.section-3 { margin-bottom: 30rpx; display: flex; justify-content: space-between; align-items: center; font-size: 26rpx; color: #999; width: 100%; margin-bottom: 20rpx; border-radius: 10rpx; background-color: #ffffff; box-shadow: 0 20rpx 20rpx -20rpx rgba($color: #333, $alpha: 0.1); padding: 20rpx; display: flex;
.my-integral { flex: 1; display: flex; flex-direction: column;
.integrals { display: flex; align-items: center; font-size: 32rpx; color: #343434; margin-bottom: 10rpx;
.neutra-font { margin-left: 10rpx; font-size: 42rpx; }
}
}
.my-code { display: flex; flex-direction: column; align-items: center; padding: 0 30rpx; position: relative;
image { width: 60rpx; height: 60rpx; margin-bottom: 10rpx; }
&:before { content: " "; position: absolute; left: 0; top: 0; bottom: 0; border-left: 1rpx solid rgba($color: #c8c7cc, $alpha: 0.6); }
}
}
.section-4 { width: 100%; margin-bottom: 20rpx; border-radius: 10rpx; background-color: #ffffff; box-shadow: 0 20rpx 20rpx -20rpx rgba($color: #333, $alpha: 0.1); padding: 20rpx; display: flex; align-items: stretch;
.left { width: 340rpx; margin-right: 20rpx; display: flex; padding: 0 20rpx; flex-direction: column; font-size: 24rpx; color: #5A5B5C; background-color: #F2F2E6;
.grid { height: 50%; display: flex; }
}
.right { width: 290rpx; display: flex; flex-direction: column;
.tea-activity, .member-gifts { width: 100%; display: flex; padding: 20rpx; font-size: 24rpx; color: #5A5B5C; align-items: center; position: relative; }
.tea-activity { background-color: #FDF3F2; margin-bottom: 20rpx; }
.member-gifts { background-color: #FCF6D4; }
.right-img { flex: 1; position: relative; margin-left: 20rpx; margin-right: -20rpx; margin-bottom: -20rpx; display: flex; align-items: flex-end;
image { width: 100%; }
}
}
.mark-img { width: 30rpx; height: 30rpx; margin-right: 10rpx; }
.yzclh-img { height: 122.96rpx; width: 214.86rpx; }
}
.section-5 { width: 100%; margin-bottom: 30rpx;
.header { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 0;
.title { font-size: 32rpx; font-weight: bold; }
.iconfont { font-size: 52rpx; color: #919293; }
}
.list { width: 100%; display: flex; flex-direction: column;
.item { width: 100%; height: 240rpx; position: relative;
image { width: 100%; height: 100%; border-radius: 8rpx; }
.title { position: relative; font-size: 32rpx; font-weight: 500; width: 100%; top: -70rpx; left: 16rpx; color: #ffffff; }
}
}
}
</style>

View File

@@ -0,0 +1,90 @@
.main { width: 100%; height: 100%; /*position: relative;*/ display: flex; flex-direction: column; }
.nav { width: 100%; height: 212rpx; flex-shrink: 0; display: flex; flex-direction: column;
.header { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 20rpx; background-color: #ffffff; height: 140rpx;
.left { flex: 1; display: flex; flex-direction: column;
.store-name { display: flex; justify-content: flex-start; align-items: center; font-size: 32rpx; margin-bottom: 10rpx;
.iconfont { margin-left: 10rpx; line-height: 100%; }
}
.store-location { display: flex; justify-content: flex-start; align-items: center; color: #919293; font-size: 24rpx;
.iconfont { vertical-align: middle; display: table-cell; color: #ADB838; line-height: 100%; }
}
}
.right { background-color: #F5F5F5; border-radius: 38rpx; display: flex; align-items: center; font-size: 24rpx; padding: 0 38rpx; color: #919293;
.dinein, .takeout { position: relative; display: flex; align-items: center;
&.active { padding: 14rpx 38rpx; color: #ffffff; background-color: #E8EACF; border-radius: 38rpx; }
}
.takeout { margin-left: 20rpx; height: 100%; flex: 1; padding: 14rpx 0; }
.dinein.active { margin-left: -38rpx; }
.takeout.active { margin-right: -38rpx; }
}
}
.coupon { flex: 1; width: 100%; background-color: #E8EACF; font-size: 28rpx; color: #ADB838; padding: 0 20rpx; display: flex; align-items: center; overflow: hidden;
.title { flex: 1; margin-left: 10rpx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.iconfont { line-height: 100%; }
}
}
.content { flex: 1; overflow: hidden; width: 100%; display: flex;
.menus { width: 200rpx; height: 100%; overflow: hidden; background-color: #F5F5F5;
.wrapper { width: 100%; height: 100%;
.menu { display: flex; align-items: center; justify-content: flex-start; padding: 30rpx 20rpx; font-size: 26rpx; color: #919293; position: relative;
&:nth-last-child(1) { margin-bottom: 130rpx; }
&.current { background-color: #ffffff; color: #5A5B5C; }
.dot { position: absolute; width: 34rpx; height: 34rpx; line-height: 34rpx; font-size: 22rpx; background-color: #ADB838; color: #ffffff; top: 16rpx; right: 10rpx; border-radius: 100%; text-align: center; }
}
}
}
.goods { flex: 1; height: 100%; overflow: hidden; background-color: #ffffff;
.wrapper { width: 100%; height: 100%; padding: 20rpx;
.ads { height: calc(300 / 550 * 510rpx);
image { width: 100%; height: 100%; border-radius: 8rpx; }
}
.list { width: 100%; font-size: 28rpx; padding-bottom: 30rpx;
.category { width: 100%;
.title { padding: 30rpx 0; display: flex; align-items: center; color: #5A5B5C;
.icon { width: 38rpx; height: 38rpx; margin-left: 10rpx; }
}
}
.items { display: flex; flex-direction: column; padding-bottom: -30rpx;
.good { display: flex; align-items: center; margin-bottom: 30rpx;
.image { width: 160rpx; height: 160rpx; margin-right: 20rpx; border-radius: 8rpx; }
.right { flex: 1; height: 160rpx; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding-right: 14rpx;
.name { font-size: 28rpx; margin-bottom: 10rpx; }
.tips { width: 100%; height: 40rpx; line-height: 40rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 24rpx; color: #919293; margin-bottom: 10rpx; }
.price_and_action { width: 100%; display: flex; justify-content: space-between; align-items: center;
.price { font-size: 28rpx; font-weight: 600; }
.btn-group { display: flex; justify-content: space-between; align-items: center; position: relative;
.btn { padding: 0 20rpx; box-sizing: border-box; font-size: 24rpx; height: 44rpx; line-height: 44rpx;
&.property_btn { border-radius: 24rpx; }
&.add_btn,
&.reduce_btn { padding: 0; width: 44rpx; border-radius: 44rpx; }
}
.dot { position: absolute; background-color: #ffffff; border: 1px solid #ADB838; color: #ADB838; font-size: 24rpx; width: 36rpx; height: 36rpx; line-height: 36rpx; text-align: center; border-radius: 100%; right: -12rpx; top: -10rpx; }
.number { width: 44rpx; height: 44rpx; line-height: 44rpx; text-align: center; }
}
}
}
}
}
}
}
}
}
.cart-box { position: absolute; bottom: 30rpx; left: 30rpx; right: 30rpx; height: 96rpx; border-radius: 48rpx; box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.2); background-color: #FFFFFF; display: flex; align-items: center; justify-content: space-between; z-index: 10;
.cart-img { width: 96rpx; height: 96rpx; position: relative; margin-top: -48rpx; }
.pay-btn { height: 100%; padding: 0 30rpx; color: #FFFFFF; border-radius: 0 50rpx 50rpx 0; display: flex; align-items: center; font-size: 28rpx; }
.mark { padding-left: 46rpx; margin-right: 30rpx; position: relative;
.tag { background-color: #FAB714; color: #ffffff; display: flex; justify-content: center; align-items: center; font-size: 24rpx; position: absolute; right: -10rpx; top: -50rpx; border-radius: 100%; padding: 4rpx; width: 40rpx; height: 40rpx; opacity: .9; }
}
.price { flex: 1; color: #5A5B5C; }
}
.text-color-base { color: #5A5B5C; }
text-color-assist { color: #919293; }
.overflow-hidden { overflow: hidden !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

View File

@@ -0,0 +1,387 @@
<template>
<view>
<u-toast ref="uToast" /><u-no-network></u-no-network>
<u-navbar title="在线点餐" safeAreaInsetTop fixed placeholder @leftClick="goNavigateBack"></u-navbar>
<view class="main">
<view class="nav">
<view class="header">
<view class="left" v-if="orderType == 'takein'">
<view class="store-name">
<text>南山田舍</text>
<view class="iconfont iconarrow-right"></view>
</view>
<view class="store-location">
<image src='https://files.cdn.coreshop.cn/static/template/diancan/images/location.png' style="width: 30rpx; height: 30rpx;" class="mr-10"></image>
<text>距离您 100千米</text>
</view>
</view>
<view class="left overflow-hidden" v-else>
<view class="coreshop-flex coreshop-align-center overflow-hidden">
<image src='https://files.cdn.coreshop.cn/static/template/diancan/images/location.png' style="width: 30rpx; height: 30rpx;" class="mr-10"></image>
<view class="coreshop-font-20 text-color-base coreshop-font-weight-bold text-truncate">
南山田舍生鲜平台
</view>
</view>
<view class="font-size-sm text-color-assist overflow-hidden text-truncate">
<text class="text-color-base" style="margin: 0 10rpx">宇宙联盟银河系加里敦联合配送中心</text>配送
</view>
</view>
<view class="right">
<view class="dinein active">
<text>自取</text>
</view>
<view class="takeout">
<text>外卖</text>
</view>
</view>
</view>
<view class="coupon">
<text class="title">"霸气mini卡"超级购券活动赶紧去购买</text>
<view class="iconfont iconarrow-right"></view>
</view>
</view>
<view class="content">
<scroll-view class="menus" :scroll-into-view="menuScrollIntoView" scroll-with-animation scroll-y>
<view class="wrapper">
<view class="menu" :id="`menu-${item.id}`" :class="{'current': item.id === currentCateId}" v-for="(item, index) in menus"
:key="index" @tap="handleMenuTap(item.id)">
<text>{{ item.name }}</text>
<!--<view class="dot" v-show="menuCartNum(item.id)">{{ menuCartNum(item.id) }}</view>-->
</view>
</view>
</scroll-view>
<!-- goods list begin -->
<scroll-view class="goods" scroll-with-animation scroll-y :scroll-top="cateScrollTop" @scroll="handleGoodsScroll">
<view class="wrapper">
<view class="list">
<!-- category begin -->
<view class="category" v-for="(good, key) in goodsList" :key="key" :id="`cate-${item.id}`">
<view class="items">
<!-- 商品 begin -->
<view class="good">
<image :src="good.images" class="image" @tap="goGoodsDetail(item.id)"></image>
<view class="right">
<text class="name u-line-1">{{ good.name }}</text>
<text class="tips u-line-1">{{ good.brief }}</text>
<view class="price_and_action">
<text class="price">{{ good.price }}</text>
<view class="btn-group">
<button type="primary" class="btn property_btn" hover-class="none" size="mini" @tap="showGoodSkuModal(good)">
选规格
</button>
<!--<view class="dot">111</view>-->
</view>
</view>
</view>
</view>
<!-- 商品 end -->
</view>
</view>
<!-- category end -->
<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" margin-top="20" margin-bottom="20" />
</view>
</view>
</scroll-view>
<!-- goods list end -->
</view>
<!-- 购物车栏 begin -->
<view class="cart-box">
<view class="mark">
<image src="https://files.cdn.coreshop.cn/static/template/diancan/images/cart.png" class="cart-img"></image>
<view class="tag">{{cartNums}}</view>
</view>
<view class="price">{{cartMoney}}</view>
<button type="primary" class="pay-btn" @tap="redirectCart" :disabled="cartNums<=0">去结算</button>
</view>
<!-- 购物车栏 end -->
</view>
<vk-data-goods-sku-popup ref="skuPopup"
v-model="skuKey"
border-radius="20"
:amount-type="0"
:localdata="goodsSkuInfo"
:mode="skuMode"
@open="onOpenSkuPopup"
@close="onCloseSkuPopup"
@add-cart="addCart"
@buy-now="buyNow"></vk-data-goods-sku-popup>
<!-- 登录提示 -->
<coreshop-login-modal></coreshop-login-modal>
</view>
</template>
<script>
import { mapMutations, mapActions, mapState } from 'vuex';
export default {
data() {
return {
cartNums: 0, // 购物车数量
cartMoney: 0, // 购物车数量
menus: [],//所有分类
goodsList: [], //所有商品
menuScrollIntoView: '',
good: {},
currentCateId: 0,//默认分类
scrollTop: 0,
loadStatus: 'loadmore',
loadIconType: 'flower',
loadText: {
loadmore: '轻轻上拉',
loading: '努力加载中',
nomore: '实在没有了'
},
type: 2, // 1加入购物车 2购买
cartType: this.$globalConstVars.paymentType.common,
page: 1,
limit: 10,
// 是否打开SKU弹窗
skuKey: false,
// SKU弹窗模式
skuMode: 1,
// 后端返回的商品信息
goodsSkuInfo: {},
}
},
computed: {
...mapState({
hasLogin: state => state.hasLogin,
userInfo: state => state.userInfo,
}),
hasLogin: {
get() {
return this.$store.state.hasLogin;
},
set(val) {
this.$store.commit('hasLogin', val);
}
},
userInfo: {
get() {
return this.$store.state.userInfo;
},
set(val) {
this.$store.commit('userInfo', val);
}
},
},
onShow() {
this.categories();
// 获取购物车数量
this.getCartNums();
},
onReachBottom() {
if (this.loadStatus != 'nomore') {
this.getGoods();
}
},
methods: {
// 打开sku弹出
openSkuPopup() {
this.skuKey = true;
},
closeSkuPopup() {
this.skuKey = false;
},
// sku组件监听
onOpenSkuPopup() {
//console.log("监听 - 打开sku组件");
},
onCloseSkuPopup() {
//console.log("监听 - 关闭sku组件");
},
showGoodSkuModal(item) {
console.log(item);
if (item.id) {
this.getGoodsDetail(item.id);
}
},
// 获取商品详情
getGoodsDetail(goodsId) {
uni.showLoading({
title: '加载中'
});
let _this = this;
let data = {
id: goodsId,
data: true
}
// 如果用户已经登录 要传用户token
let userToken = this.$db.get("userToken");
if (userToken) {
this.$u.api.goodsDetailByToken(data).then(res => {
if (res.status == true) {
_this.goodsSkuInfo = res.data.skuList;
_this.openSkuPopup();
uni.hideLoading();
} else {
_this.$refs.uToast.show({
message: res.msg, type: 'error', complete: function () {
uni.navigateBack({
delta: 1
});
}
})
uni.hideLoading();
}
})
} else {
this.$u.api.goodsDetail(data).then(res => {
if (res.status == true) {
_this.goodsSkuInfo = res.data.skuList;
_this.openSkuPopup();
uni.hideLoading();
} else {
_this.$refs.uToast.show({
message: res.msg, type: 'error', complete: function () {
uni.navigateBack({
delta: 1
});
}
})
uni.hideLoading();
}
})
}
},
// 加入购物车按钮
addCart(selectShop) {
//console.log("监听 - 加入购物车");
//console.log(selectShop);
var that = this;
uni.showLoading({
title: '加载中'
});
if (!this.hasLogin) {
uni.hideLoading();
this.$store.commit('showLoginTip', true);
return false;
}
if (selectShop.buy_num > 0) {
let data = {
productId: selectShop._id,
nums: selectShop.buy_num,
type: 1,
}
this.$u.api.addCart(data).then(res => {
if (res.status) {
uni.hideLoading();
that.getCartNums(); // 获取购物车数量
that.$refs.uToast.show({ message: res.msg, type: 'success' });
} else {
that.$u.toast(res.msg);
uni.hideLoading();
}
});
}
that.closeSkuPopup();
},
// 立即购买
buyNow(selectShop) {
//console.log("监听 - 立即购买");
//console.log(selectShop);
var that = this;
uni.showLoading({
title: '加载中'
});
if (!this.hasLogin) {
uni.hideLoading();
this.$store.commit('showLoginTip', true);
return false;
}
if (selectShop.buy_num > 0) {
let data = {
productId: selectShop._id,
nums: selectShop.buy_num,
type: 2,
cartType: this.cartType
}
this.$u.api.addCart(data).then(res => {
if (res.status) {
let cartIds = res.data;
that.$u.route('/pages/placeOrder/index/index?cartIds=' + JSON.stringify(cartIds));
uni.hideLoading();
} else {
this.$u.toast(res.msg);
uni.hideLoading();
}
});
}
that.closeSkuPopup();
},
handleMenuTap(id) {
this.currentCateId = id
this.page = 1;
this.goodsList = [];
this.getGoods();
//this.$nextTick(() => this.cateScrollTop = this.goods.find(item => item.id == id).top)
},
categories() {
this.$u.api.categories().then(res => {
if (res.status) {
this.menus = res.data;
if (res.data.length > 0) {
this.currentCateId = res.data[0].id;
}
this.getGoods();
}
});
},
//取得商品数据
getGoods: function () {
uni.showLoading({
title: '加载中'
});
var _this = this;
let data = {
page: this.page,
limit: this.limit,
};
var where = {
catId: this.currentCateId,
};
data.where = JSON.stringify(where);
_this.$u.api.goodsList(data).then(res => {
if (res.status) {
const _list = res.data.list;
_this.goodsList = [..._this.goodsList, ..._list];
if (res.data.totalCount > _this.goodsList.length) {
_this.loadStatus = 'loadmore';
_this.page++;
} else {
// 数据已加载完毕
_this.loadStatus = 'nomore';
}
uni.hideLoading();
} else {
// 接口请求出错了
uni.hideLoading();
this.$u.toast(res.msg);
}
});
},
// 获取购物车数量
getCartNums() {
let userToken = this.$db.get("userToken");
if (userToken && userToken != '') {
// 获取购物车数量
this.$u.api.getCartNumAndMoney().then(res => {
if (res.status) {
this.cartNums = res.data.count;
this.cartMoney = res.data.money;
}
})
}
},
}
}
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped>
@import 'list.scss';
</style>

View File

@@ -1,62 +0,0 @@
<template>
<view>
<u-navbar title="模板" safeAreaInsetTop fixed placeholder @leftClick="goNavigateBack"></u-navbar>
<view class="content">
<image class="logo" src="/static/images/logo/logo.png"></image>
<view class="text-area">
<text class="title">
CoreShop - Net开源商城系统
</text>
</view>
<view class="button-demo">
<u-button>按钮组件演示</u-button>
</view>
<view class="link-demo">
<u-link :color="$u.color['primary']" :under-line="true" href="http://www.coreshop.cn">跳转coreshop官网www.coreshop.cn</u-link>
</view>
</view>
<view class="coreshop-bg-white coreshop-card-hight-box" />
<!--底部-->
<view class="coreshop-foot-hight-view" />
<view class="coreshop-bg-white coreshop-footer-fixed coreshop-foot-padding-bottom coreshop-text-center coreshop-padding-10">
<u-button class='coreshop-bg-red' type="success" size="default" @click="">确认</u-button>
</view>
<!--按钮-->
<view class="coreshop-bg-white coreshop-footer-fixed coreshop-foot-padding-bottom">
<u-button type="error" size="normal" @click="submitHandler" :disabled='submitStatus' :loading='submitStatus'>保存</u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.content { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.logo { height: 100px; width: 100px; margin-top: 50px; margin-left: auto; margin-right: auto; margin-bottom: 25px; }
.text-area { display: flex; justify-content: center; }
.title { font-size: 14px; color: $u-content-color; }
.button-demo { margin-top: 40px; }
.link-demo { margin-top: 40px; }
</style>

View File

@@ -0,0 +1,48 @@
<template>
<view>
<u-navbar title="模板站" safeAreaInsetTop fixed placeholder @leftClick="goNavigateBack"></u-navbar>
<view class="content">
<image class="logo" src="/static/images/logo/logo.png"></image>
<view class="text-area">
<text class="title">
此分包模块用于展示不同的首页模板将持续增加
</text>
</view>
<view class="button-demo">
<u-button @click="gozhunong">农产品助农平台</u-button>
</view>
<view class="button-demo">
<u-button @click="goDianCan">仿点餐模块</u-button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
methods: {
gozhunong() {
this.$u.route({ url: '/pages/template/zhunong/zhunong', });
},
goDianCan() {
this.$u.route({ url: '/pages/template/diancan/index/index', });
},
}
}
</script>
<style lang="scss" scoped>
.content { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.logo { height: 100px; width: 100px; margin-top: 50px; margin-left: auto; margin-right: auto; margin-bottom: 25px; }
.text-area { display: flex; justify-content: center; }
.title { font-size: 14px; color: $u-content-color; }
.button-demo { margin-top: 40px; }
.link-demo { margin-top: 40px; }
</style>

View File

@@ -37,6 +37,7 @@ using CoreCms.Net.WeChat.Service.Models;
using CoreCms.Net.WeChat.Service.Options; using CoreCms.Net.WeChat.Service.Options;
using CoreCms.Net.WeChat.Service.Utilities; using CoreCms.Net.WeChat.Service.Utilities;
using DotLiquid.Util; using DotLiquid.Util;
using Essensoft.Paylink.Alipay.Domain;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@@ -273,7 +274,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
{ {
jm.msg = "当前请求太频繁_请稍后再试"; jm.msg = "当前请求太频繁_请稍后再试";
} }
return jm; return jm;
} }
#endregion #endregion
@@ -888,6 +889,31 @@ namespace CoreCms.Net.Web.WebApi.Controllers
} }
#endregion #endregion
#region
/// <summary>
/// 获取购物车商品数量
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<WebApiCallBack> GetCartNumberAndMoney()
{
var jm = new WebApiCallBack();
var count = await _cartServices.GetCountAsync(_user.ID);
var money = await _cartServices.GetMoneyAsync(_user.ID);
jm.status = true;
jm.msg = jm.status ? GlobalConstVars.GetDataSuccess : GlobalConstVars.GetDataFailure;
jm.data = new
{
count,
money
};
return jm;
}
#endregion
#region / #region /
/// <summary> /// <summary>
/// 商品取消/添加收藏 /// 商品取消/添加收藏