pplok #29

Manually merged
theluyuan merged 5 commits from pplok into master 2019-12-20 14:17:19 +08:00
15 changed files with 338 additions and 202 deletions

View File

@ -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
})
}
}

View File

@ -28,6 +28,17 @@
margin-left: 40rpx;
display: flex;
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;

View File

@ -1,5 +1,17 @@
<scroll-view class="list" scroll-y="{{true}}" >
<view class="commodity" bindtap="todetail">
<view class="commodity" bindtap="todetail" wx:for="{{list}}" wx:for-index="j" wx:key="{{j}}" data-id="{{item.goods_id}}">
<view class="content">
<image class="imgthumb " src="{{item.image}}"></image>
<view class="introduce">
<text class="towline">{{item.goods_name}}</text>
<view>
<text>¥{{item.shop_price}}</text>
<text>加入购物车</text>
</view>
</view>
</view>
</view>
<!-- <view class="commodity" bindtap="todetail">
<view class="content">
<image class="imgthumb "></image>
<view class="introduce">
@ -22,17 +34,5 @@
</view>
</view>
</view>
</view>
<view class="commodity" bindtap="todetail">
<view class="content">
<image class="imgthumb "></image>
<view class="introduce">
<text>产品名称产品名称产品名称产品名称产品名称产品</text>
<view>
<text>¥657</text>
<text>加入购物车</text>
</view>
</view>
</view>
</view>
</view> -->
</scroll-view>

View File

@ -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}

View File

@ -12,6 +12,7 @@ Component({
this.setData({
id: a.target.dataset.id
})
this.triggerEvent("select",{id:a.target.dataset.id})
}
}
})

View File

@ -40,7 +40,6 @@
align-items: center;
justify-content: space-between;
> text:first-child {
font-size: 30rpx;
color: #dec499;
}

View File

@ -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})
}
}

View File

@ -1,5 +1,5 @@
<view class="shoppingitem">
<view class="select"></view>
<view class="select {{select ? 'selects':''}}" bind:tap="sel"></view>
<view class="pic">
<image src="{{pic}}"></image>
</view>

View File

@ -12,7 +12,9 @@
border-radius: 50%;
margin: auto 0;
}
.selects{
background-color: #45C778;
}
.pic {
/* width: 222rpx;
height: 222rpx; */

View File

@ -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
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/

View File

@ -1,4 +1,4 @@
<view class="box">
<navigation types="{{type}}"></navigation>
<list ></list>
<navigation bindselect="select" types="{{type}}"></navigation>
<list list="{{list}}"></list>
</view>

View File

@ -7,7 +7,16 @@ Page({
*/
data: {
list: [],
userid:0
select: [],
userid: 0,
price: "0.00"
},
sel(a) {
console.log(a)
this.setData({
[`select[${a.detail.index}]`]: !a.detail.select
})
this.num();
},
/**
@ -24,6 +33,8 @@ Page({
this.setData({
list: res.data.result
})
this.num()
})
},
onLoad: function (options) {
@ -35,6 +46,7 @@ Page({
userid: res.data.data.user_id
})
this.getlist()
})
},
sub() {
@ -53,7 +65,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.onLoad()
},
/**
@ -89,5 +101,78 @@ Page({
*/
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()
})
}
}
}
})

View File

@ -1,6 +1,6 @@
<view class="shopping">
<view class="item" wx:for="{{list}}" wx:for-index="j" wx:key="{{j}}">
<shopping-item shopname="{{item.goods_name}}" shopdesc="{{item.spec_key_name||'默认规格'}}" price="{{item.goods_price}}" pic="{{item.image}}" num="{{item.goods_num}}" gid="{{item.id}}"></shopping-item>
<shopping-item shopname="{{item.goods_name}}" shopdesc="{{item.spec_key_name||'默认规格'}}" price="{{item.goods_price}}" pic="{{item.image}}" num="{{item.goods_num}}" gid="{{item.id}}" index="{{j}}" select="{{select[j]}}" bindsel="sel"></shopping-item>
</view>
<!-- <view class="item">
<shopping-item shopname="J`adore - Dior" shopdesc="30支 1.30kg" price="61.78"></shopping-item>
@ -13,12 +13,12 @@
</view> -->
<view class="bottom">
<view class="left">
<view class="select"></view>
<text class="selectall">全选</text>
<text class="pri">$0.00</text>
<view bind:tap="call" class="select {{all ? 'selects':''}}"></view>
<text bind:tap="call" class="selectall">全选</text>
<text class="pri">${{price}}</text>
</view>
<view class="right">
<text class="del">删除</text>
<text class="del" bind:tap="del">删除</text>
<text class="sub" bindtap="sub">结算</text>
</view>
</view>

View File

@ -33,19 +33,22 @@
margin-left: 46rpx;
margin-right: 24rpx;
}
.selects{
background-color: #4cc97d;
}
.pri {
color: #E0C79D;
color: #e0c79d;
font-size: 26rpx;
margin-left: 19rpx;
}
.right {
color: #BBBBBB;
color: #bbbbbb;
margin-right: 31rpx;
}
.sub {
margin-left: 30rpx;
color: #4CC97D;
color: #4cc97d;
}

View File

@ -14,7 +14,13 @@ let request = function (obj){
url="http://daigou.sdbairui.com/index.php/WXAPI/" + url
let text = ""
for(let i in urldata){
if(urldata[i] == undefined){
text += `/${i}`
}else{
text += `/${i}/${urldata[i]}`
}
}
url+=text
// if(method == "POST" || method == "post"){