From edc898385379962e451301c04d9bdf4333325088 Mon Sep 17 00:00:00 2001
From: pplokijuhyg <1162963624@qq.com>
Date: Thu, 19 Dec 2019 17:22:23 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=AE=8C=E5=96=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/classify/list/index.js | 7 +-
components/classify/list/index.scss | 101 ++++++++++--------
components/classify/list/index.wxml | 28 ++---
components/classify/list/index.wxss | 2 +-
components/classify/navigation/index.js | 1 +
components/index/list/commodity/index.scss | 99 +++++++++--------
.../shopping/shoppingitem/shoppingitem.js | 16 +--
pages/classify/classify.js | 23 +++-
pages/classify/classify.wxml | 4 +-
9 files changed, 158 insertions(+), 123 deletions(-)
diff --git a/components/classify/list/index.js b/components/classify/list/index.js
index 1f2a3b5..f4ed197 100644
--- a/components/classify/list/index.js
+++ b/components/classify/list/index.js
@@ -1,12 +1,13 @@
Component({
properties: {
-
+ list:Array
},
data: {},
methods: {
- todetail() {
+ todetail(a) {
+ console.log(a)
wx.navigateTo({
- url: "/pages/product/product"
+ url: "/pages/product/product?shopid=" + a.currentTarget.dataset.id
})
}
}
diff --git a/components/classify/list/index.scss b/components/classify/list/index.scss
index 8b6dac9..7e93e1b 100644
--- a/components/classify/list/index.scss
+++ b/components/classify/list/index.scss
@@ -1,52 +1,63 @@
-.list{
- padding-left: 20rpx;
- width: 572rpx;
- box-sizing: border-box;
- height: 100vh;
- .commodity {
- width: 552rpx;
- // height: 143rpx;
- // margin-top: 32rpx;
+.list {
+ padding-left: 20rpx;
+ width: 572rpx;
+ box-sizing: border-box;
+ height: 100vh;
+ .commodity {
+ width: 552rpx;
+ // height: 143rpx;
+ // margin-top: 32rpx;
+ display: flex;
+ align-items: center;
+ .content {
+ width: 552rpx;
+ height: 100%;
+ display: flex;
+ align-items: center;
+ // box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4);
+ border-bottom: 2rpx solid #eaeaea;
+ padding: 30rpx 0;
+ .imgthumb {
+ width: 105rpx;
+ height: 105rpx;
+ margin-left: 40rpx;
+ background-color: #333;
+ }
+ .introduce {
+ width: 336rpx;
+ margin-left: 40rpx;
display: flex;
- align-items: center;
- .content {
- width: 552rpx;
- height: 100%;
+ flex-direction: column;
+ .towline {
+ overflow: hidden;
+
+ text-overflow: ellipsis;
+
+ display: -webkit-box;
+
+ -webkit-box-orient: vertical;
+
+ -webkit-line-clamp: 2;
+ }
+ > text {
+ font-size: 22rpx;
+ color: #333;
+ margin-bottom: 22rpx;
+ }
+ > view {
display: flex;
align-items: center;
- // box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4);
- border-bottom: 2rpx solid #eaeaea;
- padding: 30rpx 0;
- .imgthumb {
- width: 105rpx;
- height: 105rpx;
- margin-left: 40rpx;
- background-color: #333;
+ justify-content: space-between;
+ > text:first-child {
+ font-size: 30rpx;
+ color: #dec499;
}
- .introduce {
- width: 336rpx;
- margin-left: 40rpx;
- display: flex;
- flex-direction: column;
- > text {
- font-size: 22rpx;
- color: #333;
- margin-bottom: 22rpx;
- }
- > view {
- display: flex;
- align-items: center;
- justify-content: space-between;
- > text:first-child {
- font-size: 30rpx;
- color: #dec499;
- }
- > text:last-child {
- font-size: 22rpx;
- color: #999;
- }
- }
+ > text:last-child {
+ font-size: 22rpx;
+ color: #999;
}
}
}
-}
\ No newline at end of file
+ }
+ }
+}
diff --git a/components/classify/list/index.wxml b/components/classify/list/index.wxml
index 68eb4f4..7e4a67b 100644
--- a/components/classify/list/index.wxml
+++ b/components/classify/list/index.wxml
@@ -1,5 +1,17 @@
-
+
+
+
+
+ {{item.goods_name}}
+
+ ¥{{item.shop_price}}
+ 加入购物车
+
+
+
+
+
\ No newline at end of file
diff --git a/components/classify/list/index.wxss b/components/classify/list/index.wxss
index 9546d04..895235c 100644
--- a/components/classify/list/index.wxss
+++ b/components/classify/list/index.wxss
@@ -1 +1 @@
-.list{padding-left:20rpx;width:572rpx;box-sizing:border-box;height:100vh}.list .commodity{width:552rpx;display:flex;align-items:center}.list .commodity .content{width:552rpx;height:100%;display:flex;align-items:center;border-bottom:2rpx solid #eaeaea;padding:30rpx 0}.list .commodity .content .imgthumb{width:105rpx;height:105rpx;margin-left:40rpx;background-color:#333}.list .commodity .content .introduce{width:336rpx;margin-left:40rpx;display:flex;flex-direction:column}.list .commodity .content .introduce>text{font-size:22rpx;color:#333;margin-bottom:22rpx}.list .commodity .content .introduce>view{display:flex;align-items:center;justify-content:space-between}.list .commodity .content .introduce>view>text:first-child{font-size:30rpx;color:#dec499}.list .commodity .content .introduce>view>text:last-child{font-size:22rpx;color:#999}
+.list{padding-left:20rpx;width:572rpx;box-sizing:border-box;height:100vh}.list .commodity{width:552rpx;display:flex;align-items:center}.list .commodity .content{width:552rpx;height:100%;display:flex;align-items:center;border-bottom:2rpx solid #eaeaea;padding:30rpx 0}.list .commodity .content .imgthumb{width:105rpx;height:105rpx;margin-left:40rpx;background-color:#333}.list .commodity .content .introduce{width:336rpx;margin-left:40rpx;display:flex;flex-direction:column}.list .commodity .content .introduce .towline{overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.list .commodity .content .introduce>text{font-size:22rpx;color:#333;margin-bottom:22rpx}.list .commodity .content .introduce>view{display:flex;align-items:center;justify-content:space-between}.list .commodity .content .introduce>view>text:first-child{font-size:30rpx;color:#dec499}.list .commodity .content .introduce>view>text:last-child{font-size:22rpx;color:#999}
diff --git a/components/classify/navigation/index.js b/components/classify/navigation/index.js
index ef1630d..e036c8f 100644
--- a/components/classify/navigation/index.js
+++ b/components/classify/navigation/index.js
@@ -12,6 +12,7 @@ Component({
this.setData({
id: a.target.dataset.id
})
+ this.triggerEvent("select",{id:a.target.dataset.id})
}
}
})
\ No newline at end of file
diff --git a/components/index/list/commodity/index.scss b/components/index/list/commodity/index.scss
index 1eb6e9d..6c82ae4 100644
--- a/components/index/list/commodity/index.scss
+++ b/components/index/list/commodity/index.scss
@@ -1,59 +1,58 @@
.commodity {
- width: 623rpx;
- height: 143rpx;
- margin-top: 32rpx;
+ width: 623rpx;
+ height: 143rpx;
+ margin-top: 32rpx;
+ display: flex;
+ align-items: center;
+ .content {
+ width: 614rpx;
+ height: 100%;
display: flex;
align-items: center;
- .content {
- width: 614rpx;
- height: 100%;
+ box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4);
+ .imgthumb {
+ width: 105rpx;
+ height: 105rpx;
+ margin-left: 40rpx;
+ background-color: #333;
+ }
+ .introduce {
+ width: 410rpx;
+ margin-left: 40rpx;
display: flex;
- align-items: center;
- box-shadow: 0 0 24rpx 0 rgba(227, 227, 227, 0.4);
- .imgthumb {
- width: 105rpx;
- height: 105rpx;
- margin-left: 40rpx;
- background-color: #333;
- }
- .introduce {
- width: 410rpx;
- margin-left: 40rpx;
- display: flex;
- flex-direction: column;
- > text {
- font-size: 26rpx;
- color: #333;
- margin-bottom: 22rpx;
- overflow: hidden;
+ flex-direction: column;
+ > text {
+ font-size: 26rpx;
+ color: #333;
+ margin-bottom: 22rpx;
+ overflow: hidden;
- text-overflow: ellipsis;
-
- display: -webkit-box;
-
- -webkit-box-orient: vertical;
-
- -webkit-line-clamp: 2;
+ text-overflow: ellipsis;
+
+ display: -webkit-box;
+
+ -webkit-box-orient: vertical;
+
+ -webkit-line-clamp: 2;
+ }
+ > view {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ > text:first-child {
+ font-size: 30rpx;
+ color: #dec499;
}
- > view {
- display: flex;
- align-items: center;
- justify-content: space-between;
- > text:first-child {
-
- font-size: 30rpx;
- color: #dec499;
- }
- > text:last-child {
- font-size: 22rpx;
- color: #999;
- }
+ > text:last-child {
+ font-size: 22rpx;
+ color: #999;
}
}
}
- .decorate {
- width: 9rpx;
- height: 102rpx;
- background-color: #3fb66e;
- }
- }
\ No newline at end of file
+ }
+ .decorate {
+ width: 9rpx;
+ height: 102rpx;
+ background-color: #3fb66e;
+ }
+}
diff --git a/components/shopping/shoppingitem/shoppingitem.js b/components/shopping/shoppingitem/shoppingitem.js
index 388acca..6943c1b 100644
--- a/components/shopping/shoppingitem/shoppingitem.js
+++ b/components/shopping/shoppingitem/shoppingitem.js
@@ -25,9 +25,14 @@ Component({
*/
methods: {
rm() {
+
if (this.data.num == 0) {
+
return
} else {
+ this.setData({
+ num: this.data.num - 1
+ })
request({
url:"Cart/updateNum",
urldata:{
@@ -35,14 +40,15 @@ Component({
num:this.data.num - 1
}
}).then((res)=>{
- this.setData({
- num: this.data.num - 1
- })
+
})
}
},
add() {
+ this.setData({
+ num: this.data.num + 1
+ })
request({
url:"Cart/updateNum",
urldata:{
@@ -50,9 +56,7 @@ Component({
num:this.data.num + 1
}
}).then((res)=>{
- this.setData({
- num: this.data.num + 1
- })
+
})
}
diff --git a/pages/classify/classify.js b/pages/classify/classify.js
index 494d2e2..20abaf0 100644
--- a/pages/classify/classify.js
+++ b/pages/classify/classify.js
@@ -6,7 +6,8 @@ Page({
* 页面的初始数据
*/
data: {
- type: []
+ type: [],
+ list:[]
},
/**
@@ -23,11 +24,29 @@ Page({
this.setData({
type: res.data.result
})
+ this.select({detail:{id:res.data.result[0].id}})
console.log(this.data.type, 150)
})
},
-
+ select(a){
+ // console.log(a)
+ // a.detail.id
+ request({
+ url:'Goods/goodsList',
+ urldata:{
+ id:a.detail.id,
+ sort:'shop_price',
+ sort_asc:'desc',
+ p:0
+ }
+ }).then((res)=>{
+ console.log(res)
+ this.setData({
+ list:res.data.result.goods_list
+ })
+ })
+ },
/**
* 生命周期函数--监听页面初次渲染完成
*/
diff --git a/pages/classify/classify.wxml b/pages/classify/classify.wxml
index fda1a98..9f392af 100644
--- a/pages/classify/classify.wxml
+++ b/pages/classify/classify.wxml
@@ -1,4 +1,4 @@
-
-
+
+
\ No newline at end of file
--
2.39.5
From 3cf388faedcf42afed349b68c4297f8e456ef452 Mon Sep 17 00:00:00 2001
From: pplokijuhyg <1162963624@qq.com>
Date: Fri, 20 Dec 2019 09:51:28 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E9=80=89=E6=8B=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/shopping/shoppingitem/shoppingitem.js | 7 ++++++-
components/shopping/shoppingitem/shoppingitem.wxml | 2 +-
components/shopping/shoppingitem/shoppingitem.wxss | 4 +++-
pages/shopping/shopping.js | 14 +++++++++++++-
pages/shopping/shopping.wxml | 2 +-
utils/bin.js | 8 +++++++-
6 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/components/shopping/shoppingitem/shoppingitem.js b/components/shopping/shoppingitem/shoppingitem.js
index 6943c1b..a04744f 100644
--- a/components/shopping/shoppingitem/shoppingitem.js
+++ b/components/shopping/shoppingitem/shoppingitem.js
@@ -10,7 +10,9 @@ Component({
price: Number,
pic: String,
gid:Number,
- num:Number
+ num:Number,
+ select:Boolean,
+ index:Number
},
/**
@@ -58,6 +60,9 @@ Component({
}).then((res)=>{
})
+ },
+ sel(){
+ this.triggerEvent('sel', {index:this.data.index,select:this.data.select})
}
}
diff --git a/components/shopping/shoppingitem/shoppingitem.wxml b/components/shopping/shoppingitem/shoppingitem.wxml
index 2753d2d..2003d55 100644
--- a/components/shopping/shoppingitem/shoppingitem.wxml
+++ b/components/shopping/shoppingitem/shoppingitem.wxml
@@ -1,5 +1,5 @@
-
+
diff --git a/components/shopping/shoppingitem/shoppingitem.wxss b/components/shopping/shoppingitem/shoppingitem.wxss
index a24b12e..ca6a41f 100644
--- a/components/shopping/shoppingitem/shoppingitem.wxss
+++ b/components/shopping/shoppingitem/shoppingitem.wxss
@@ -12,7 +12,9 @@
border-radius: 50%;
margin: auto 0;
}
-
+.selects{
+ background-color: #45C778;
+}
.pic {
/* width: 222rpx;
height: 222rpx; */
diff --git a/pages/shopping/shopping.js b/pages/shopping/shopping.js
index 02f0f12..17b9664 100644
--- a/pages/shopping/shopping.js
+++ b/pages/shopping/shopping.js
@@ -7,8 +7,15 @@ Page({
*/
data: {
list:[],
+ select:[],
userid:0
},
+ sel(a){
+ console.log(a)
+ this.setData({
+ [`select[${a.detail.index}]`]:!a.detail.select
+ })
+ },
/**
* 生命周期函数--监听页面加载
@@ -53,7 +60,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
-
+ this.onLoad()
},
/**
@@ -89,5 +96,10 @@ Page({
*/
onShareAppMessage: function() {
+ },
+ num(){
+ for(let i in this.data.select){
+
+ }
}
})
\ No newline at end of file
diff --git a/pages/shopping/shopping.wxml b/pages/shopping/shopping.wxml
index 563d88f..4db3529 100644
--- a/pages/shopping/shopping.wxml
+++ b/pages/shopping/shopping.wxml
@@ -1,6 +1,6 @@
-
+
-
- 全选
- $0.00
+
+ 全选
+ ${{price}}
删除
diff --git a/pages/shopping/shopping.wxss b/pages/shopping/shopping.wxss
index 7379c93..ace9498 100644
--- a/pages/shopping/shopping.wxss
+++ b/pages/shopping/shopping.wxss
@@ -1,51 +1,54 @@
-.shopping{
- padding-bottom: 128rpx;
+.shopping {
+ padding-bottom: 128rpx;
}
.item {
- height: 186rpx;
- margin-left: 46rpx;
- margin-top: 59rpx;
- }
-
- .bottom {
- width: 100%;
- height: 98rpx;
- position: fixed;
- bottom: 0;
- background: linear-gradient(2deg, rgba(250, 250, 250, 0.94), rgba(255, 255, 255, 0.94));
- display: flex;
- justify-content: space-between;
- font-size: 28rpx;
- line-height: 98rpx;
- }
-
- .left {
- display: flex;
- /* line-height: 26rpx; */
- }
-
- .select {
- width: 26rpx;
- height: 26rpx;
- background: rgba(234, 234, 234, 1);
- border-radius: 50%;
- margin: auto 0;
- margin-left: 46rpx;
- margin-right: 24rpx;
- }
-
- .pri {
- color: #E0C79D;
- font-size: 26rpx;
- margin-left: 19rpx;
- }
-
- .right {
- color: #BBBBBB;
- margin-right: 31rpx;
- }
-
- .sub {
- margin-left: 30rpx;
- color: #4CC97D;
- }
\ No newline at end of file
+ height: 186rpx;
+ margin-left: 46rpx;
+ margin-top: 59rpx;
+}
+
+.bottom {
+ width: 100%;
+ height: 98rpx;
+ position: fixed;
+ bottom: 0;
+ background: linear-gradient(2deg, rgba(250, 250, 250, 0.94), rgba(255, 255, 255, 0.94));
+ display: flex;
+ justify-content: space-between;
+ font-size: 28rpx;
+ line-height: 98rpx;
+}
+
+.left {
+ display: flex;
+ /* line-height: 26rpx; */
+}
+
+.select {
+ width: 26rpx;
+ height: 26rpx;
+ background: rgba(234, 234, 234, 1);
+ border-radius: 50%;
+ margin: auto 0;
+ margin-left: 46rpx;
+ margin-right: 24rpx;
+}
+.selects{
+ background-color: #4cc97d;
+}
+
+.pri {
+ color: #e0c79d;
+ font-size: 26rpx;
+ margin-left: 19rpx;
+}
+
+.right {
+ color: #bbbbbb;
+ margin-right: 31rpx;
+}
+
+.sub {
+ margin-left: 30rpx;
+ color: #4cc97d;
+}
--
2.39.5
From 487fee5b045f7989f1d28b9bc962d27ef8cb755a Mon Sep 17 00:00:00 2001
From: pplokijuhyg <1162963624@qq.com>
Date: Fri, 20 Dec 2019 14:16:06 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/shopping/shopping.js | 117 +++++++++++++++++++++--------------
pages/shopping/shopping.wxml | 2 +-
2 files changed, 73 insertions(+), 46 deletions(-)
diff --git a/pages/shopping/shopping.js b/pages/shopping/shopping.js
index f071d4f..66d90fa 100644
--- a/pages/shopping/shopping.js
+++ b/pages/shopping/shopping.js
@@ -1,20 +1,20 @@
// pages/shopping/shopping.js
-import {request} from "../../utils/bin"
+import { request } from "../../utils/bin"
Page({
/**
* 页面的初始数据
*/
data: {
- list:[],
- select:[],
- userid:0,
- price:"0.00"
+ list: [],
+ select: [],
+ userid: 0,
+ price: "0.00"
},
- sel(a){
+ sel(a) {
console.log(a)
this.setData({
- [`select[${a.detail.index}]`]:!a.detail.select
+ [`select[${a.detail.index}]`]: !a.detail.select
})
this.num();
},
@@ -22,28 +22,31 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
- getlist(){
+ getlist() {
request({
- url:"Cart/cartList/session_id/" + wx.getStorageSync('openid'),
- data:{
- user_id:this.data.userid
+ url: "Cart/cartList/session_id/" + wx.getStorageSync('openid'),
+ data: {
+ user_id: this.data.userid
}
- }).then((res)=>{
+ }).then((res) => {
console.log(res)
this.setData({
- list:res.data.result
+ list: res.data.result
})
+ this.num()
+
})
},
- onLoad: function(options) {
+ onLoad: function (options) {
request({
- url:"User/validateOpenid"
- }).then((res)=>{
+ url: "User/validateOpenid"
+ }).then((res) => {
console.log(res)
this.setData({
- userid:res.data.data.user_id
+ userid: res.data.data.user_id
})
this.getlist()
+
})
},
sub() {
@@ -54,98 +57,122 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
- onReady: function() {
+ onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
- onShow: function() {
+ onShow: function () {
this.onLoad()
},
/**
* 生命周期函数--监听页面隐藏
*/
- onHide: function() {
+ onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
- onUnload: function() {
+ onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
- onPullDownRefresh: function() {
+ onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
- onReachBottom: function() {
+ onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
- onShareAppMessage: function() {
+ onShareAppMessage: function () {
},
- num(){
+ num() {
let num = 0;
let sel = 0;
- for(let i in this.data.select){
+ for (let i in this.data.select) {
console.log(i)
- if(this.data.select[i]){
- num += parseFloat(this.data.list[i].goods_price)*100
- sel++
+ if (this.data.select[i]) {
+ num += parseFloat(this.data.list[i].goods_price) * 100
+ sel++
}
}
- if(sel == this.data.list.length){
+ if (sel == this.data.list.length && this.data.list.length != 0) {
this.setData({
- all:true
+ all: true
})
- }else{
+ } else {
this.setData({
- all:false
+ all: false
})
}
this.setData({
- price:num/100
+ price: num / 100
})
},
- call(){
+ call() {
let sel = 0;
let select = []
- for(let i in this.data.list){
+ for (let i in this.data.list) {
console.log(i)
- if(this.data.select[i]){
- // num += parseFloat(this.data.list[i].goods_price)*100
- sel++
- }else{
+ if (this.data.select[i]) {
+ // num += parseFloat(this.data.list[i].goods_price)*100
+ sel++
+ } else {
select[i] = true
}
}
- if(sel == this.data.list.length){
+ if (sel == this.data.list.length) {
this.setData({
- all:false,
- select:[]
+ all: false,
+ select: []
})
- }else{
+ } else {
this.setData({
- all:true,
+ all: true,
select
})
}
this.num()
+ },
+ del() {
+ for (let i in this.data.list) {
+ // console.log(i)
+ if (this.data.select[i]) {
+ // num += parseFloat(this.data.list[i].goods_price)*100
+ // sel++
+ request({
+ url: "Cart/delCart",
+ urldata: {
+ id: this.data.list[i].id
+ }
+ }).then((res) => {
+ console.log('删除成功')
+ this.setData({
+ list: [],
+ select: [],
+ userid: 0,
+ price: "0.00"
+ })
+ this.onLoad()
+ })
+ }
+ }
}
})
\ No newline at end of file
diff --git a/pages/shopping/shopping.wxml b/pages/shopping/shopping.wxml
index b8a8e69..58f0a24 100644
--- a/pages/shopping/shopping.wxml
+++ b/pages/shopping/shopping.wxml
@@ -18,7 +18,7 @@
${{price}}
- 删除
+ 删除
结算
--
2.39.5