first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
652d4c58-8f92-4f48-a0e8-f71e13b66f51

View File

@@ -0,0 +1,77 @@
// mall/index/index.js
const app = getApp();
const regeneratorRuntime = app.loadAsync()
const model = app.loadModel("index")
const http = app.loadHttp()
const util = app.loadUtils("util")
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
system: app.globalData.system, //设备相关信息
pageTitle: "商城", //头部标题
isBack: false,//显示返回
titleColor: { //头部背景和文字颜色
bColor: "#1dbf53",
tColor: "#ffffff"
},
TabCur: 0,
scrollLeft: 0,
category: [],// 商品大分类
product: [],//大分类下的商品
},
created() {
this.storeCategory()
},
/**
* 组件的方法列表
*/
methods: {
// tab
tabSelect(e) {
this.setData({
TabCur: e.currentTarget.dataset.id,
scrollLeft: (e.currentTarget.dataset.id - 1) * 60,
product: []
})
this.storeProduct()
},
// 获取商城分类获取
async storeCategory() {
let res = await http.http.request1({ url: `${http.api.storeCategory}`, method: "GET" })
this.setData({
category: res.data.data,
TabCur: res.data.data[0].id
})
this.storeProduct()
},
// 获取分类下商品
async storeProduct() {
let res = await http.http.request1({ url: `${http.api.storeProduct}/${this.data.TabCur}`, method: "GET" })
this.setData({
product: res.data.data
})
},
// 添加商品到购物车
async addCart(e) {
let item = e.currentTarget.dataset.item
item.num = 0
item.attr = []
model.shopCart.setCart(item)
},
// 去详情
goInfo(e) {
wx.navigateTo({
url: "/mall/index/shopInfo/shopInfo?id=" + e.currentTarget.dataset.id
})
}
}
})

View File

@@ -0,0 +1,5 @@
{
"navigationBarTextStyle":"white",
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,34 @@
<!-- 头部 -->
<nav-bar isBack="{{isBack}}" pageTitle="{{pageTitle}}" system="{{system}}" titleColor="{{titleColor}}"></nav-bar>
<!-- mall/index/index.wxml -->
<view class="index">
<view class="index_tab">
<scroll-view scroll-x class="bg-white nav" scroll-with-animation scroll-left="{{scrollLeft}}">
<view wx:for="{{category}}" wx:key class="cu-item {{item.id==TabCur?'text-green cur':''}}" bindtap="tabSelect" data-id="{{item.id}}">
{{item.name}}
</view>
</scroll-view>
</view>
<scroll-view class="index_cen">
<view catchtap="goInfo" class="shop_list" wx:for="{{ product }}" wx:key="{{index}}" data-id="{{ item.id }}" >
<view class="shop_img">
<image lazy-load src="{{item.image}}" />
</view>
<view class="shop_cen">
<view class="shop_title">{{item.name}}</view>
<view class="shop_info">
<view class="shop_info_l">
<view class="opri">原价¥{{item.original_price}}</view>
<view class="ppri"><span>¥</span>{{item.price}}</view>
</view>
<view class="shop_info_r">
<image data-item="{{item}}" catchtap="addCart" lazy-load src="/static/img/icon/jrgwc.png" />
</view>
</view>
</view>
</view>
<view class="clear"></view>
</scroll-view>
</view>
<!-- toasta提示 -->
<i-toast id="toast" />

View File

@@ -0,0 +1,126 @@
/* mall/index/index.wxss */
@import "../../extend/ColorUI/css/main.wxss";
.bg-white {
background-color: #1dbf53 !important;
color: #beffd4 !important;
font-size: 30rpx !important;
}
.nav .cu-item {
padding: 0 40rpx !important;
}
.nav .cu-item.cur {
border-bottom: 0 !important;
}
.cur {
position: relative;
}
.nav .cu-item.cur::before {
position: absolute;
content: "";
width: 30rpx;
height: 6rpx;
background-color: #beffd4;
border-radius: 3rpx;
bottom: 15rpx;
left: 50%;
margin-left: -15rpx;
}
.text-green {
font-size: 32rpx !important;
color: #fff !important;
}
.index_cen {
margin-top: 20rpx;
padding: 0 20rpx 150rpx;
}
.shop_list {
width: 348rpx;
height: 536rpx;
background-color: #fff;
border-radius: 2%;
float: left;
}
.shop_list:nth-child(2n) {
margin-left: 14rpx;
}
.shop_list:nth-child(n+3) {
margin-top: 14rpx;
}
.clear {
clear: both;
}
.shop_img {
width: 100%;
height: 310rpx;
}
.shop_img image {
height: 100%;
width: 100%;
}
.shop_cen {
padding: 0 25rpx;
}
.shop_title {
height: 80rpx;
margin-top: 10rpx;
font-weight: 600;
font-size: 30rpx;
color: #333;
display: -webkit-box !important;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.shop_info {
display: flex;
margin-top: 39rpx;
}
.shop_info_l {
flex: 2;
}
.shop_info_r {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
}
.shop_info_r image {
width: 50rpx;
height: 50rpx;
}
.opri {
font-size: 22rpx;
color: #999;
text-decoration: line-through;
}
.ppri {
margin-top: 19rpx;
font-size: 32rpx;
color: #333;
}
.ppri span {
font-size: 22rpx;
color: #333;
}

View File

@@ -0,0 +1 @@
c84c7f07-94d2-432b-96a8-31cc08bbc571

View File

@@ -0,0 +1,220 @@
// mall/index/shopInfo/shopInfo.js
const app = getApp();
const regeneratorRuntime = app.loadAsync()
const model = app.loadModel("index")
const http = app.loadHttp()
const util = app.loadUtils("util")
Page({
/**
* 页面的初始数据
*/
data: {
system: app.globalData.system, //设备相关信息
pageTitle: "详情", //头部标题
isBack: true,//显示返回
imgUrls: [
'https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1564218168&di=f9df8e6bc2e9d02f6f1b7fc73247d927&src=http://ac-r.static.booking.cn/images/hotel/max1024x768/987/98767654.jpg',
'https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1564218168&di=f9df8e6bc2e9d02f6f1b7fc73247d927&src=http://ac-r.static.booking.cn/images/hotel/max1024x768/987/98767654.jpg',
'https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1564218168&di=f9df8e6bc2e9d02f6f1b7fc73247d927&src=http://ac-r.static.booking.cn/images/hotel/max1024x768/987/98767654.jpg'
],
indicatorDots: false,
autoplay: true,
interval: 3000,
duration: 1000,
current: 0,
visible: false,
cartNum: 0,//角标
id: "",//商品id
shopInfo: {},//商品的详情信息
shopAttr: [],//商品的属性
attr: [],//勾选了的属性
type: null,//0购物车 1购买
num: 1,//商品的数量
},
// 轮播图下表
currentChange(e) {
this.setData({
current: e.detail.current
})
},
//弹出层开启关闭
onClose(e) {
let type = e.currentTarget.dataset.type
this.setData({
visible: !this.data.visible,
type: type
})
},
// 打开弹出层
onOpen() {
this.setData({
visible: true
})
},
// 选择数量
numChang(e) {
this.setData({
num: e.detail.value
})
},
// 选择完确定
async sure() {
let shopInfo = this.data.shopInfo
let data = {
id: shopInfo.id,
name: shopInfo.name,
image: shopInfo.top_img,
original_price: shopInfo.original_price,
price: shopInfo.price,
num: this.data.num,
attr: this.data.attr
}
this.setData({
visible: false
})
if (this.data.type == 0) {
model.shopCart.setCart(data)
return
}
let isLogin = await util.isLoginJump()
if (isLogin == 1) return;
app.globalData.temCart = {
total: (data.num * data.price).toFixed(2),
allCart: [data]
}
wx.navigateTo({
url: "/mall/placeOrder/placeOrder"
})
},
// 获取商品的详情
async getShopInfo() {
let res = await http.http.request1({ url: `${http.api.storeProductDetails}/${this.data.id}`, method: "GET" })
this.setData({
shopInfo: res.data.data
})
this.getAttr()
},
// 获取商品属性
async getAttr() {
let res = await http.http.request1({ url: `${http.api.storeProductAttr}/${this.data.id}`, method: "GET" })
res.data.data.map((v, i) => {
res.data.data[i].index = i
})
this.setData({
shopAttr: res.data.data
})
},
// 实时更新购物车角标
async realUpdateCarker() {
var that = this
app.setWatching('cartNum', (v) => {
that.setData({
cartNum: v
});
});
},
// 去往购物车
goCart() {
wx.navigateTo({
url: "/mall/shopcart/shopcart"
})
},
// 选择商品属性
selectAttr(e) {
let { i1, i2 } = e.currentTarget.dataset
let shopAttr = this.data.shopAttr
let attr = this.data.attr //选中的商品属性
let isShow = [] //当前选中或者移除的所有isShow字段
shopAttr[i1].attr_vals.map((v, i) => {
if (i2 == i) {
shopAttr[i1].attr_vals[i].isShow = !shopAttr[i1].attr_vals[i].isShow
} else {
shopAttr[i1].attr_vals[i].isShow = false
}
isShow.push(v.isShow)
})
// 获取当前商品属性选中的下表然后插入对应下表的method_value到attr
let is = isShow.indexOf(true)
if (is != -1) {
attr[i1] = shopAttr[i1].attr_vals[is].method_value
} else {
attr[i1] = ""
}
this.setData({
shopAttr: shopAttr,
attr: attr
})
},
// 商品详情查看大图
bigShopImg(e) {
let imgI = e.currentTarget.dataset.url, imgsArr = this.data.shopInfo.imgs, news = [];
imgsArr.map((v, i) => {
news.push(v.detail_img)
})
wx.previewImage({
current: imgI, // 当前显示图片的http链接
urls: news // 需要预览的图片http链接列表
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.realUpdateCarker()
// 接收商品id
this.setData({
id: options.id
})
this.getShopInfo()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@@ -0,0 +1,7 @@
{
"navigationBarTextStyle": "black",
"usingComponents": {
"wux-popup":"../../../extend/wux/dist/popup/index",
"wux-input-number": "../../../extend/wux/dist/input-number/index"
}
}

View File

@@ -0,0 +1,100 @@
<!-- 头部 -->
<nav-bar isBack="{{isBack}}" pageTitle="{{pageTitle}}" system="{{system}}"></nav-bar>
<!-- mall/index/shopInfo/shopInfo.wxml -->
<view class="shopInfo">
<view class="shopInfo_title">
<view class="shopInfo_img">
<!-- <swiper bindchange="currentChange" indicator-dots="{{indicatorDots}}" circular autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block wx:for="{{shopInfo.imgs}}" wx:key="{{index}}">
<swiper-item> -->
<image src="{{shopInfo.top_img}}" class="slide-image" />
<!-- </swiper-item>
</block>
</swiper>
<view class="slide-image_item">{{current+1}}/{{shopInfo.imgs.length}}</view> -->
</view>
<view class="shopInfo_title_cen">
<view class="shop_title">{{shopInfo.name}}</view>
<view class="shop_info">
<view class="shop_info_l">
<view class="opri">原价¥{{shopInfo.original_price}}</view>
<view class="ppri">
<span>¥</span>
{{shopInfo.price}}
</view>
</view>
<view class="shop_info_r">
<view class="flex-con1">
<span>{{shopInfo.sales+shopInfo.invent_sales}}</span>
<view>人已购买</view>
</view>
</view>
</view>
</view>
</view>
<!-- <view class="shop_text mt20">
<view class="shop_text_title">商品详情</view>
<view class="mt40">
<rich-text nodes="{{shopInfo.summary}}"></rich-text>
</view>
<view class="shop_text_p">规格5KG/袋</view>
<view class="shop_text_p">包装:普装</view>
<view class="shop_text_p">保质期24个月</view>
</view> -->
<view wx:if="{{shopInfo.imgs.length > 0}}" class="shop_introduce">
<view class="shop_text_title">商品详情</view>
<image mode="widthFix" wx:for="{{shopInfo.imgs}}" wx:key="{{ index }}" src="{{item.detail_img}}" data-url="{{item.detail_img}}" bind:tap="bigShopImg" />
</view>
</view>
<view class="shop_go">
<view class="shop_cart flex-con3" bind:tap="goCart">
<view class="shop_cart_img">
<image src="/static/img/icon/gwcs.png" />
<span>{{cartNum}}</span>
</view>
</view>
<view data-type="0" class="add_cart" bind:tap="onClose">加入购物车</view>
<view data-type="1" class="buy" bind:tap="onClose">立即购买</view>
</view>
<!-- 购物车弹出 -->
<wux-popup position="bottom" visible="{{ visible }}" catchtap="onClose">
<view class="cart" catchtap="onOpen">
<view class="pd30">
<view class="cart_title">
<view class="cart_title_img">
<image src="{{shopInfo.top_img}}" />
</view>
<view class="cart_title_info">
<view>
<view class="cart_title_info_name">{{shopInfo.name}}</view>
<view class="cart_title_info_mon">
<span>¥</span>
{{shopInfo.price}}
</view>
</view>
</view>
<view class="cart_title_close" catchtap="onClose">
<image src="/static/img/icon/dasdasd_05.png" />
</view>
</view>
<view class="cart_spe mt10" wx:for="{{shopAttr}}" wx:key="i">
<view class="cart_spe_title mt40">{{item.method_name}}</view>
<view class="cart_spe_cen">
<view wx:for="{{item.attr_vals}}" wx:for-item="list" wx:key="{{index}}" data-i1="{{item.index}}" data-i2="{{index}}" class="cart_spe_row mt30 fl mr20 {{ list.isShow ?'spe_row_active':'' }}" bind:tap="selectAttr">
{{list.method_value}}
</view>
<view class="clear"></view>
</view>
</view>
<view class="shop_num">
<view class="shop_numl">数量</view>
<view class="shop_numr">
<wux-input-number wux-sub-class="wux_sub" wux-input-class="wux_input" wux-add-class="wux_add" min="1" default-value="1" slot="footer" bindchange="numChang" />
</view>
</view>
</view>
<view class="cart_sub" catchtap="sure">确定</view>
</view>
</wux-popup>
<!-- toasta提示 -->
<i-toast id="toast" />

View File

@@ -0,0 +1,331 @@
/* mall/index/shopInfo/shopInfo.wxss */
.shopInfo {
margin-bottom: 120rpx;
}
.shopInfo_title {
background: #fff;
}
.slide-image {
width: 100%;
height: 600rpx;
background-color: #fff;
}
swiper {
height: 600rpx !important;
}
.shopInfo_img {
position: relative;
}
.slide-image_item {
position: absolute;
bottom: 20rpx;
right: 20rpx;
width: 80rpx;
height: 40rpx;
background-color: rgba(0, 0, 0, 0.4);
border-radius: 20rpx;
text-align: center;
line-height: 40rpx;
font-size: 26rpx;
color: #fff;
}
.shopInfo_title_cen {
padding: 0 30rpx 40rpx 30rpx;
}
.shop_title {
margin-top: 32rpx;
font-size: 36rpx;
color: #333;
font-weight: 500;
}
.shopInfo_title_info {
display: flex;
}
.shop_info {
display: flex;
margin-top: 39rpx;
}
.shop_info_l {
flex: 2;
}
.shop_info_r {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
font-size: 22rpx;
color: #999;
}
.shop_info_r span {
font-size: 22rpx;
color: #333;
line-height: 32rpx;
}
.opri {
font-size: 26rpx;
color: #999;
text-decoration: line-through;
}
.ppri {
margin-top: 20rpx;
font-size: 40rpx;
color: #ff4737;
}
.ppri span {
font-size: 28rpx;
}
.shop_text {
padding: 45rpx 30rpx;
background-color: #fff;
}
.shop_text_title {
margin-top: 35rpx;
font-size: 36rpx;
color: #333;
font-weight: 500;
padding-bottom: 20rpx;
position: relative;
text-align: center;
}
.shop_text_title::before {
position: absolute;
content: "";
left: 50%;
bottom: 0;
width: 40rpx;
height: 4rpx;
margin-left: -20rpx;
background-color: #333;
}
.shop_text_p {
margin-top: 20rpx;
font-size: 28rpx;
color: #999;
}
.shop_introduce {
margin-top: 20rpx;
padding: 35rpx 20rpx;
background-color: #fff;
text-align: center;
}
.shop_introduce image {
/* height: auto; */
max-width: 100%;
}
.shop_go {
position: fixed;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100rpx;
background-color: #fff;
box-shadow: 0px -8px 20px 0px rgba(14, 5, 9, 0.06);
display: flex;
}
.shop_cart {
flex: 1;
}
.add_cart, .buy {
width: 296rpx;
height: 100rpx;
line-height: 100rpx;
text-align: center;
display: inline-block;
font-size: 32rpx;
color: #fff;
}
.add_cart {
background-color: #323332;
}
.buy {
background-color: #1dbf53;
}
.shop_cart_img {
position: relative;
}
.shop_cart_img span {
position: absolute;
right: -10rpx;
top: -15rpx;
width: 30rpx;
height: 30rpx;
line-height: 30rpx;
text-align: center;
border-radius: 50%;
background-color: #ff4838;
font-size: 20rpx;
color: #fff;
}
.shop_cart_img image {
height: 40rpx;
width: 40rpx;
}
.cart {
padding: 30rpx 0 230rpx 0;
position: relative;
min-height: 500rpx;
}
.cart_title {
display: flex;
}
.cart_title_img, .cart_title_close {
display: inline-block;
}
.cart_title_close image {
width: 30rpx;
height: 30rpx;
}
.cart_title_img image {
width: 190rpx;
height: 190rpx;
}
.cart_title_info {
flex: 1;
padding-left: 27rpx;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
}
.cart_title_info view {
text-align: left;
}
.cart_title_info_name {
font-size: 36rpx;
font-weight: 500;
color: #333;
}
.cart_title_info_mon {
margin-top: 20rpx;
font-size: 40rpx;
font-weight: 500;
color: #ff4737;
}
.cart_title_info_mon span {
font-size: 28rpx;
}
.cart_sub {
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100rpx;
background-image: linear-gradient(#1dbf53, #1dbf53), linear-gradient(#2fd152, #2fd152);
background-blend-mode: normal, normal;
text-align: center;
line-height: 100rpx;
font-size: 38rpx;
font-weight: 500;
color: #fff;
}
.cart_spe_title {
text-align: left;
font-size: 28rpx;
color: #666;
}
.cart_spe_row {
padding: 19rpx 49rpx;
background-color: #f7f7f7;
border-radius: 30rpx;
font-size: 28rpx;
color: #666;
display: inline-block;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
border: solid 2rpx #f7f7f7;
}
.spe_row_active {
border: solid 2rpx #1dbf53;
color: #1dbf53;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.shop_num {
display: flex;
margin-top: 42rpx;
}
.shop_numl, .shop_numr {
flex: 1;
}
.shop_numl {
text-align: left;
font-size: 28rpx;
color: #666;
}
.shop_numr {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row-reverse;
flex-direction: row-reverse;
}
.wux_sub {
border: 0 !important;
color: #272727 !important;
}
.wux_input {
border: 0 !important;
background-color: #f5f5f5 !important;
}
.wux_add {
border: 0 !important;
color: #272727 !important;
}
.clear {
clear: both;
}