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..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 }, /** @@ -25,9 +27,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 +42,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,10 +58,11 @@ Component({ num:this.data.num + 1 } }).then((res)=>{ - this.setData({ - num: this.data.num + 1 - }) + }) + }, + 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/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 diff --git a/pages/shopping/shopping.js b/pages/shopping/shopping.js index 02f0f12..66d90fa 100644 --- a/pages/shopping/shopping.js +++ b/pages/shopping/shopping.js @@ -1,40 +1,52 @@ // pages/shopping/shopping.js -import {request} from "../../utils/bin" +import { request } from "../../utils/bin" Page({ /** * 页面的初始数据 */ data: { - list:[], - userid:0 + list: [], + select: [], + userid: 0, + price: "0.00" + }, + sel(a) { + console.log(a) + this.setData({ + [`select[${a.detail.index}]`]: !a.detail.select + }) + this.num(); }, /** * 生命周期函数--监听页面加载 */ - 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() { @@ -45,49 +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() { + let num = 0; + let sel = 0; + 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 (sel == this.data.list.length && this.data.list.length != 0) { + this.setData({ + all: true + }) + } else { + this.setData({ + all: false + }) + } + this.setData({ + price: num / 100 + }) + }, + call() { + let sel = 0; + let select = [] + 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 { + select[i] = true + } + } + if (sel == this.data.list.length) { + this.setData({ + all: false, + select: [] + }) + } else { + this.setData({ + 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 563d88f..58f0a24 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; +} diff --git a/utils/bin.js b/utils/bin.js index ebc1f15..f5daf4f 100644 --- a/utils/bin.js +++ b/utils/bin.js @@ -14,7 +14,13 @@ let request = function (obj){ url="http://daigou.sdbairui.com/index.php/WXAPI/" + url let text = "" for(let i in urldata){ - text += `/${i}/${urldata[i]}` + if(urldata[i] == undefined){ + text += `/${i}` + + }else{ + text += `/${i}/${urldata[i]}` + + } } url+=text // if(method == "POST" || method == "post"){