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 @@
6c03b6c4-280c-4ee9-a45b-b5e3a0df45e7

View File

@@ -0,0 +1,444 @@
// pages/laundry/laundry.js
const app = getApp();
const regeneratorRuntime = app.loadAsync()
const model = app.loadModel("index")
const util = app.loadUtils("util")
const http = app.loadHttp()
Page({
/**
* 页面的初始数据
*/
data: {
system: app.globalData.system, //设备相关信息
pageTitle: "洗衣", //头部标题
isAccount: false, // 公众号
isBack: true,//显示返回
visible: false,//购物弹窗
isTips: true,//顶部小提示
laundryBig: [
{
id: null,
name: ""
}
],//洗衣大分类
bigSelect: null,//大分类的选中
laundrySom: [],//洗衣小分类
cart: [],//购物车数据
allPrice: 0,//全部价格
page: 1,//分页
isPage: false,
group_type: 0,//团体id
type: 1,//如果是1则是普洗2是工服
},
// 获取大分类列表
async getLaundryBig() {
let data = {
group_type: this.data.group_type,
type: this.data.type
}
let res = await http.http.request2({ url: `${http.api.shopCategory}`, method: "GET", data: data })
this.setData({
laundryBig: res.data.data,
bigSelect: this.data.bigSelect != null ? this.data.bigSelect : res.data.data[0].id
})
this.getLaundrySom()
},
// 获取小分类列表
async getLaundrySom() {
if (this.data.isPage) {
wx.showToast({
title: '已经到底了哦!',
icon: 'none',
duration: 2000
})
return
}
wx.showLoading({
title: '加载中',
})
let res = await http.http.request1({ url: `${http.api.shopProduct}/${this.data.bigSelect}`, method: "GET", data: { page: this.data.page, limit: 10 } })
let som = res.data.data.list
let laundrySom = this.data.laundrySom
if (som.length <= 0) {
wx.hideLoading()
wx.showToast({
title: '暂无数据',
icon: 'none',
duration: 2000
})
return
}
if (som.length < 10) {
this.setData({
isPage: true
})
}
som.map((v, i) => {
som[i].num = 0
})
this.setData({
laundrySom: [...laundrySom, ...som],
})
this.getCart()
wx.hideLoading()
},
// scroll-view 触底
bindscrolltolower() {
this.setData({
page: ++this.data.page
})
this.getLaundrySom()
},
//弹出层开启关闭
onClose() {
this.setData({
visible: !this.data.visible
})
},
// 打开弹出层
onOpen() {
this.setData({
visible: true
})
},
// 大分类选中
bigType(e) {
this.setData({
bigSelect: e.currentTarget.dataset.id,
page: 1,
isPage: false,
laundrySom: []
})
this.getLaundrySom()
},
// 把最新的购物车数据set到本地缓存
async setCart() {
model.storage.setStorage("cart", this.data.cart)
},
// 获取缓存中的购物车数据
async getCart() {
let cartStorage = await model.storage.getSetting("cart") || []
let laundrySom = this.data.laundrySom
laundrySom.map((v, i) => {
let m = cartStorage.filter(n => {
return v.id == n.id
})
if (m.length > 0) {
laundrySom[i] = m[0]
}
})
this.setData({
laundrySom: laundrySom,
cart: cartStorage
})
this.calComPri()
},
// 加商品方法
plusShop(e) {
let item = e.currentTarget.dataset.item //当前要添加的商品
let cart = this.data.cart //购物车
let Som = this.data.laundrySom // 商品列表
let num = ++item.num
if (cart.length == 0) {
item.num = num
this.setData({
cart: [item]
})
} else {
// 如果cart循环完还没有重复项则把item push进去
for (let i = 0; i < cart.length; i++) {
// 点击的时候判断购物车是否有窗帘套餐
if (cart[i].id == 17018 || cart[i].id == 17019 || cart[i].id == 17020) {
if (item.id == 17018 || item.id == 17019 || item.id == 17020) {
console.log("允许继续添加跟多的窗帘商品")
} else {
model.msg.dataMsg({
content: "预售套餐不与其他衣物同时下单哦",
type: "warning"
});
Som.map((v, i) => {
Som[i].num = 0
})
this.setData({
cart: [],
laundrySom: Som
})
this.setCart()
this.calComPri()
return
}
// 如果购物车都是普通套餐
} else {
// 之后你在普通套餐的购物车中添加了窗帘淘宝
if (item.id == 17018 || item.id == 17019 || item.id == 17020) {
model.msg.dataMsg({
content: "预售套餐不与其他衣物同时下单哦",
type: "warning"
});
Som.map((v, i) => {
Som[i].num = 0
})
this.setData({
cart: [],
laundrySom: Som
})
this.setCart()
this.calComPri()
return
}
}
if (cart[i].id == item.id) {
cart[i].num = num
break;
}
if (cart.length - 1 == i) {
cart.push(item)
}
}
this.setData({
cart: cart
})
}
Som.map((v, i) => {
if (v.id == item.id) {
Som[i].num = num
}
})
this.setData({
laundrySom: Som
})
// 每当修改购物车时把最近数据放到本地缓存
this.setCart()
this.calComPri()
},
// 减商品的方法
reduceShop(e) {
let that = this
let item = e.currentTarget.dataset.item //当前要添加的商品
let cart = that.data.cart //购物车
let Som = that.data.laundrySom // 商品列表
let num = --item.num
cart.map((v, i) => {
if (v.id == item.id) {
cart[i].num = num
if (cart[i].num <= 0) {
cart.splice(i, 1)
}
}
})
Som.map((v, i) => {
if (v.id == item.id) {
Som[i].num = num
}
})
// 判断如果num减少到0时提示是否删除
if (num == 0) {
wx.showModal({
title: '删除商品',
content: '点击确定删除',
confirmText: "确认",
cancelText: "取消",
success(res) {
if (res.confirm) {
that.setData({
laundrySom: Som,
cart: cart
})
// 每当修改购物车时把最近数据放到本地缓存
that.setCart()
that.calComPri()
}
}
})
} else {
that.setData({
laundrySom: Som,
cart: cart
})
// 每当修改购物车时把最近数据放到本地缓存
that.setCart()
this.calComPri()
}
},
// 清空购物车
emptyCart() {
let laundrySom = this.data.laundrySom
let that = this
if (this.data.cart.length <= 0) {
model.msg.dataMsg({
content: "暂无商品",
type: "warning"
})
return
}
wx.showModal({
title: '清空购物车',
content: '点击确定清空',
confirmText: "确认",
cancelText: "取消",
success(res) {
if (res.confirm) {
laundrySom.map((v, i) => {
laundrySom[i].num = 0
})
that.setData({
cart: [],
laundrySom: laundrySom
})
that.setCart()
that.onClose()
that.calComPri()
// 删除成功提示用户
model.msg.dataMsg({
content: "删除成功",
type: "success"
})
}
}
})
},
// 点击确定
async _sure() {
let isCurtains = 0; // 0 没有窗帘, 1 有窗帘
let laundrySom = this.data.laundrySom
let userInfo = app.globalData.userInfo
let cart = this.data.cart
let that = this
if (cart.length > 0) {
// 只要购物车中第一条商品是窗帘其中一个
if(cart[0].id == 17018 || cart[0].id == 17019 || cart[0].id == 17020 ) {
isCurtains = 1
} else {
isCurtains = 0
}
let isLogin = await util.isLoginJump()
if (isLogin == 1) return;
} else if (cart.length <= 0) {
return
}
// if (userInfo.cupboard_num != -1) {
// wx.navigateTo({
// url: "/user/wardrobe/wardrobe"
// })
// } else {
wx.navigateTo({
url: "/user/appointment/appointment?shopCart=" + JSON.stringify(cart) + '&type=' + this.data.type + '&group_type=' + this.data.group_type + '&isCurtains=' + isCurtains
})
// }
// laundrySom.map((v, i) => {
// laundrySom[i].num = 0
// })
// that.setData({
// cart: [],
// laundrySom: laundrySom
// })
// that.setCart()
},
// 计算商品价格
calComPri() {
let cart = this.data.cart
let all = 0
cart.map((v, i) => {
all += v.num * v.price
})
this.setData({
allPrice: all.toFixed(2)
})
},
// 关闭顶部小提示
closeTips() {
this.setData({
isTips: false
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (options.id == "36") {
console.log("36")
// true 从公众号进入
this.setData({
isAccount: true
})
}
// 进入页面清除缓存中的购物车数据
model.storage.setStorage("cart", [])
// 如果有group_type说明是团体用户
if (!!options.group_type) {
this.setData({
group_type: options.group_type,
type: options.type
})
}
if (!!options.id) {
this.setData({
bigSelect: options.id
})
} else {
this.setData({
bigSelect: this.data.laundryBig[0].id
})
}
this.getLaundryBig()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.calComPri()
// TODO 不需要重复请求
if (this.data.isAccount) {
this.getLaundryBig()
}
// this.getLaundryBig()
},
/**
* 生命周期函数--监听页面隐藏
*/
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"
},
"disableScroll": true
}

View File

@@ -0,0 +1,150 @@
<!-- 头部导航 -->
<nav-bar isBack="{{isBack}}" pageTitle="{{pageTitle}}" system="{{system}}" />
<!-- pages/laundry/laundry.wxml -->
<view class="laundry">
<view class="laundry" wx:if="{{type == 1}}">
<view class="laundry_l fl">
<view class="laundry_big">
<view
wx:for="{{ laundryBig }}"
wx:key="index"
data-id="{{item.id}}"
class="big_row {{bigSelect == item.id ? 'big_active' : ''}}"
bind:tap="bigType"
>
<span class="big_row_p">
{{item.name}}
<!-- <span class="corner">21</span> -->
</span>
</view>
</view>
</view>
<!-- 开始 -->
<view class="laundry_r fl dis-flex1">
<!-- <view class="laundry_title mt30" wx:if="{{isTips}}">
<view class="laundry_title_l flex-con3">
<image class="mr10" src="/static/img/icon/ts.png" />
衣物含可拆卸毛领的,毛领单独计费哦~
</view>
<view class="laundry_title_r" bind:tap="closeTips">
<image src="/static/img/icon/tsclose.png" />
</view>
</view> -->
<!-- 小分类的标题 -->
<!-- <view class="laundry_name mt35 ml10 mb20"></view> -->
<!-- <view class="flex1"> -->
<!-- <scroll-view scroll-y style="height: auto;"> -->
<view class="scroll_view_f">
<scroll-view bindscrolltolower="bindscrolltolower" scroll-y="{{true}}" class="laundry_shop flex1">
<view class="laundry_shop_row mb50" wx:for="{{ laundrySom }}" wx:key="index" data-item="{{item}}" bind:tap="plusShop">
<view class="laundry_shop_row_l">
<view class="laundry_shop_img fl">
<image src="{{item.image}}" lazy-load />
</view>
<view class="laundry_shop_info fl ml10">
<view class="laundry_shop_name">{{item.name}}</view>
<view class="laundry_shop_pri mt20">
<span>¥</span>
{{item.price}}
</view>
</view>
</view>
<view class="laundry_shop_num">
<view class="shop_num_cen flex-con5">
<!-- 这是加 -->
<view class="num_img">
<image src="/static/img/icon/j2.png" />
</view>
<!-- <view wx:if="{{ item.num > 0 }}" class="num_c">{{ item.num }}</view> -->
<!-- 这是减 -->
<!-- <view bind:tap="reduceShop" data-item="{{item}}" wx:if="{{ item.num > 0 }}" class="num_img">
<image src="/static/img/icon/j1.png" />
</view> -->
</view>
</view>
</view>
</scroll-view>
</view>
<view style="height:{{system.statusHeight+system.titleHeight+'px'}};" />
<view style="height:100rpx;" />
</view>
<!-- 结束 -->
</view>
<!-- 工服排版 -->
<view class='work dis-flex' wx:if="{{type == 2}}" style="padding-bottom:{{system.statusHeight+system.titleHeight+'px'}}">
<scroll-view scroll-y="{{true}}" class='work_list flex1'>
<view
class='work_list_li'
wx:for="{{laundrySom}}"
wx:key="index"
bind:tap="plusShop"
data-item="{{item}}"
>
<view class='work_list_li_row'>
<view class='work_img'>
<image src="{{item.image}}" lazy-load />
</view>
<view class='work_title mt10'>{{item.name}}</view>
<view class='dis-flex work_cen mt10'>
<view class='flex2 flex-con2'>¥{{item.price}}/件</view>
<view class='work_add flex1'>
<image src="/static/img/icon/xyl2.png" />
</view>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="shopCart">
<view class="shopCart_cen">
<view class="shopCart_img">
<view class="shopCart_imgs" bind:tap="onClose">
<image src="{{cart <= 0 ? '/static/img/icon/xyl1.png': '/static/img/icon/xyl2.png'}}" />
<span>{{cart.length}}</span>
</view>
</view>
<span class="cartAllPrice" wx:if="{{ allPrice > 0 }}">¥{{allPrice}}</span>
<span wx:else>洗衣篮是空的哦</span>
</view>
<view class="shopCart_sub {{ cart.length >0 ?'shopCart_sub_active':'' }}" bind:tap="_sure">
确认下单
</view>
</view>
</view>
<!-- 购物车弹出 -->
<wux-popup position="bottom" visible="{{ visible }}" catchtap="onClose">
<view class="cart" catchtap="onOpen">
<view class="cart_title" bind:tap="emptyCart">
<view class="cart_title_l">已选商品</view>
<view class="cart_title_r flex-con5">
清空
<image class="mr10" src="/static/img/icon/sc.png" />
</view>
</view>
<view class="cart_cen">
<view class="cart_shop_row" wx:for="{{ cart }}" wx:key="index">
<view class="cart_shop_info">
<view class="cart_shop_info_l">{{item.name}}</view>
<view class="cart_shop_info_r">
<span>¥</span>
{{item.price}}
</view>
</view>
<view class="cart_shop_num">
<view class="cart_shop_num1 flex-con5">
<view data-item="{{item}}" bind:tap="plusShop" class="cart_shop_img">
<image src="/static/img/icon/j2.png" />
</view>
<view class="cart_shop_c">{{ item.num }}</view>
<view data-item="{{item}}" bind:tap="reduceShop" class="cart_shop_img">
<image src="/static/img/icon/j1.png" />
</view>
</view>
</view>
</view>
</view>
</view>
</wux-popup>
<!-- toasta提示 -->
<i-toast id="toast" />

View File

@@ -0,0 +1,420 @@
/* pages/laundry/laundry.wxss */
page {
height: 100%;
}
.laundry {
height: 100%;
width: 100%;
border-top: 2rpx solid #ebebeb;
}
.laundry_l {
height: 100%;
width: 25%;
}
.laundry_r {
padding: 0 29rpx 0 11rpx;
height: 100%;
width: 75%;
background-color: #fff;
}
.scroll_view_f{
flex: 1;
position: relative;
margin-top: 10rpx;
}
.big_row {
width: 100%;
height: 135rpx;
text-align: center;
line-height: 135rpx;
position: relative;
font-size: 28rpx;
color: #333;
}
.big_active {
background-color: #fff;
font-size: 32rpx;
font-weight: 600;
color: #000;
}
.big_active::after {
content: "";
position: absolute;
left: 0;
top: 50%;
margin-top: -18rpx;
width: 8rpx;
height: 36rpx;
background-image: linear-gradient(#1dbf53, #1dbf53), linear-gradient(#13bf3e, #13bf3e);
background-blend-mode: normal, normal;
border-radius: 2rpx;
}
.big_row_p {
position: relative;
}
.corner {
position: absolute;
right: -9rpx;
top: -13rpx;
width: 30rpx;
height: 30rpx;
background-color: #ff4838;
font-size: 20rpx;
color: #fff;
border-radius: 50%;
overflow: hidden;
text-align: center;
line-height: 30rpx;
}
.laundry_title {
padding: 20rpx 21rpx 20rpx 29rpx;
display: flex;
background-color: #f5f5f5;
border-radius: 10rpx;
}
.laundry_title view {
display: block;
}
.laundry_title_l {
flex: 1;
font-size: 20rpx;
color: #999;
}
.laundry_title_l image {
width: 22rpx;
height: 23rpx;
vertical-align: middle;
}
.laundry_title_r image {
width: 18rpx;
height: 18rpx;
}
.laundry_name {
font-size: 22rpx;
color: #666;
}
.laundry_shop {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
.laundry_shop_row {
height: 140rpx;
display: flex;
padding-left: 17rpx;
padding-right: 8rpx;
}
.laundry_shop_row_l {
flex: 1;
display: flex;
}
.laundry_shop_img image {
height: 140rpx;
width: 140rpx;
}
.laundry_shop_info {
flex: 1;
}
.laundry_shop_name {
font-size: 28rpx;
color: #333;
}
.laundry_shop_pri span {
font-size: 20rpx;
color: #ff4838;
}
.laundry_shop_pri {
font-size: 28rpx;
color: #ff4838;
}
.laundry_shop_num {
width: 60rpx;
height: 100%;
display: inline-block;
position: relative;
}
.shop_num_cen {
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
}
.num_c {
text-align: center;
flex: 1;
height: 45rpx;
line-height: 45rpx;
font-weight: 500;
font-size: 28rpx;
color: #333;
}
.num_img {
display: inline-block;
width: 45rpx;
height: 45rpx;
border-radius: 50%;
}
.num_img image {
height: 100%;
width: 100%;
}
.bot {
height: 100rpx;
width: 100%;
}
.shopCart {
width: 100%;
background-color: #fff;
box-shadow: 0px -8rpx 20rpx 0rpx rgba(14, 5, 9, 0.06);
position: fixed;
bottom: 0;
left: 0;
display: flex;
z-index: 99999;
padding-bottom: calc(env(safe-area-inset-bottom) / 2);
height: calc(100rpx + env(safe-area-inset-bottom) / 2);
}
.shopCart_cen {
flex: 1;
padding-left: 150rpx;
position: relative;
line-height: 100rpx;
}
.shopCart_cen span {
font-size: 28rpx;
color: #999;
}
.shopCart_sub {
display: inline-block;
width: 220rpx;
height: 100rpx;
background-color: #ccc;
text-align: center;
line-height: 100rpx;
font-size: 32rpx;
color: #fff;
}
.shopCart_cen .shopCart_img {
position: absolute;
left: 30rpx;
bottom: 20rpx;
width: 100rpx;
height: 100rpx;
display: flex;
border-radius: 50%;
/* overflow: hidden; */
}
.shopCart_imgs {
flex: 1;
position: relative;
}
.shopCart_imgs image {
height: 100%;
width: 100%;
}
.shopCart_imgs span {
position: absolute;
right: -2rpx;
top: -2rpx;
width: 30rpx;
height: 30rpx;
font-size: 20rpx;
color: #fff;
text-align: center;
line-height: 30rpx;
background-color: #ff4838;
border-radius: 50%;
}
.cart {
height: 370rpx;
width: 100%;
margin-bottom: 100rpx;
}
.cart_cen {
height: 290rpx;
width: 100%;
overflow-y: scroll;
}
.cart_title {
height: 80rpx;
line-height: 80rpx;
background-color: #f5f5f4;
display: flex;
padding: 0 30rpx;
}
.cart_title_l {
flex: 5;
font-size: 32rpx;
color: #999;
text-align: left;
}
.cart_title_r {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #999;
}
.cart_title_r image {
width: 28rpx;
height: 28rpx;
/* vertical-align: middle; */
}
.cart_shop_row {
height: 45rpx;
display: flex;
line-height: 45rpx;
padding: 0 30rpx;
margin-top: 25rpx;
}
.cart_shop_info {
flex: 1;
display: flex;
}
.cart_shop_info_l {
flex: 3;
text-align: left;
font-weight: 500;
font-size: 32rpx;
color: #333;
}
.cart_shop_info_r {
flex: 2;
text-align: right;
padding-right: 20rpx;
font-size: 32rpx;
color: #ff4838;
}
.cart_shop_info_r span {
font-size: 22rpx;
color: #ff4838;
}
.cart_shop_num {
display: inline-block;
width: 160rpx;
}
.cart_shop_num1 {
display: flex;
}
.cart_shop_c {
flex: 1;
text-align: center;
}
.cart_shop_img {
display: inline-block;
}
.cart_shop_img image {
height: 45rpx;
width: 45rpx;
}
.cartAllPrice {
font-family: PingFang-SC-Bold;
font-size: 36rpx !important;
color: #ff4838 !important;
font-weight: 600;
}
.shopCart_sub_active {
background: #1dbf53;
color: #fff;
}
/* 工服列表样式 */
.work{
margin-top: 10rpx;
padding: 0 10rpx;
height: 100%;
}
.work_list{
padding-bottom: 100rpx;
}
.work_list_li{
width: 33.33%;
padding: 10rpx;
display: inline-block;
}
.work_list_li_row{
background-color: #ffffff;
}
.work_title{
text-align: center;
font-size:24rpx;
font-weight:400;
color:rgba(52,52,52,1);
}
.work_img image{
width: 100%;
height: 230rpx;
}
.work_cen{
padding: 0 10rpx;
}
.work_cen view{
font-size: 26rpx;
font-weight: 500;
color: rgba(255,51,51,1);
}
.work_add{
text-align: right;
}
.work_add image{
height: 50rpx;
width: 50rpx;
}