Merge branch 'pplok' of pplokijuhyg/deguodaigou into master

This commit is contained in:
pplokijuhyg 2019-12-20 14:17:19 +08:00
commit 2688882a3e
15 changed files with 338 additions and 202 deletions

View File

@ -1,12 +1,13 @@
Component({ Component({
properties: { properties: {
list:Array
}, },
data: {}, data: {},
methods: { methods: {
todetail() { todetail(a) {
console.log(a)
wx.navigateTo({ wx.navigateTo({
url: "/pages/product/product" url: "/pages/product/product?shopid=" + a.currentTarget.dataset.id
}) })
} }
} }

View File

@ -1,4 +1,4 @@
.list{ .list {
padding-left: 20rpx; padding-left: 20rpx;
width: 572rpx; width: 572rpx;
box-sizing: border-box; box-sizing: border-box;
@ -28,6 +28,17 @@
margin-left: 40rpx; margin-left: 40rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.towline {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
> text { > text {
font-size: 22rpx; font-size: 22rpx;
color: #333; color: #333;

View File

@ -1,5 +1,17 @@
<scroll-view class="list" scroll-y="{{true}}" > <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"> <view class="content">
<image class="imgthumb "></image> <image class="imgthumb "></image>
<view class="introduce"> <view class="introduce">
@ -22,17 +34,5 @@
</view> </view>
</view> </view>
</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>
</scroll-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({ this.setData({
id: a.target.dataset.id id: a.target.dataset.id
}) })
this.triggerEvent("select",{id:a.target.dataset.id})
} }
} }
}) })

View File

@ -40,7 +40,6 @@
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
> text:first-child { > text:first-child {
font-size: 30rpx; font-size: 30rpx;
color: #dec499; color: #dec499;
} }
@ -56,4 +55,4 @@
height: 102rpx; height: 102rpx;
background-color: #3fb66e; background-color: #3fb66e;
} }
} }

View File

@ -10,7 +10,9 @@ Component({
price: Number, price: Number,
pic: String, pic: String,
gid:Number, gid:Number,
num:Number num:Number,
select:Boolean,
index:Number
}, },
/** /**
@ -25,9 +27,14 @@ Component({
*/ */
methods: { methods: {
rm() { rm() {
if (this.data.num == 0) { if (this.data.num == 0) {
return return
} else { } else {
this.setData({
num: this.data.num - 1
})
request({ request({
url:"Cart/updateNum", url:"Cart/updateNum",
urldata:{ urldata:{
@ -35,14 +42,15 @@ Component({
num:this.data.num - 1 num:this.data.num - 1
} }
}).then((res)=>{ }).then((res)=>{
this.setData({
num: this.data.num - 1
})
}) })
} }
}, },
add() { add() {
this.setData({
num: this.data.num + 1
})
request({ request({
url:"Cart/updateNum", url:"Cart/updateNum",
urldata:{ urldata:{
@ -50,10 +58,11 @@ Component({
num:this.data.num + 1 num:this.data.num + 1
} }
}).then((res)=>{ }).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="shoppingitem">
<view class="select"></view> <view class="select {{select ? 'selects':''}}" bind:tap="sel"></view>
<view class="pic"> <view class="pic">
<image src="{{pic}}"></image> <image src="{{pic}}"></image>
</view> </view>

View File

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

View File

@ -6,7 +6,8 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
type: [] type: [],
list:[]
}, },
/** /**
@ -23,11 +24,29 @@ Page({
this.setData({ this.setData({
type: res.data.result type: res.data.result
}) })
this.select({detail:{id:res.data.result[0].id}})
console.log(this.data.type, 150) 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"> <view class="box">
<navigation types="{{type}}"></navigation> <navigation bindselect="select" types="{{type}}"></navigation>
<list ></list> <list list="{{list}}"></list>
</view> </view>

View File

@ -1,40 +1,52 @@
// pages/shopping/shopping.js // pages/shopping/shopping.js
import {request} from "../../utils/bin" import { request } from "../../utils/bin"
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
list:[], 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();
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
getlist(){ getlist() {
request({ request({
url:"Cart/cartList/session_id/" + wx.getStorageSync('openid'), url: "Cart/cartList/session_id/" + wx.getStorageSync('openid'),
data:{ data: {
user_id:this.data.userid user_id: this.data.userid
} }
}).then((res)=>{ }).then((res) => {
console.log(res) console.log(res)
this.setData({ this.setData({
list:res.data.result list: res.data.result
}) })
this.num()
}) })
}, },
onLoad: function(options) { onLoad: function (options) {
request({ request({
url:"User/validateOpenid" url: "User/validateOpenid"
}).then((res)=>{ }).then((res) => {
console.log(res) console.log(res)
this.setData({ this.setData({
userid:res.data.data.user_id userid: res.data.data.user_id
}) })
this.getlist() this.getlist()
}) })
}, },
sub() { 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()
})
}
}
} }
}) })

View File

@ -1,6 +1,6 @@
<view class="shopping"> <view class="shopping">
<view class="item" wx:for="{{list}}" wx:for-index="j" wx:key="{{j}}"> <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>
<!-- <view class="item"> <!-- <view class="item">
<shopping-item shopname="J`adore - Dior" shopdesc="30支 1.30kg" price="61.78"></shopping-item> <shopping-item shopname="J`adore - Dior" shopdesc="30支 1.30kg" price="61.78"></shopping-item>
@ -13,12 +13,12 @@
</view> --> </view> -->
<view class="bottom"> <view class="bottom">
<view class="left"> <view class="left">
<view class="select"></view> <view bind:tap="call" class="select {{all ? 'selects':''}}"></view>
<text class="selectall">全选</text> <text bind:tap="call" class="selectall">全选</text>
<text class="pri">$0.00</text> <text class="pri">${{price}}</text>
</view> </view>
<view class="right"> <view class="right">
<text class="del">删除</text> <text class="del" bind:tap="del">删除</text>
<text class="sub" bindtap="sub">结算</text> <text class="sub" bindtap="sub">结算</text>
</view> </view>
</view> </view>

View File

@ -1,13 +1,13 @@
.shopping{ .shopping {
padding-bottom: 128rpx; padding-bottom: 128rpx;
} }
.item { .item {
height: 186rpx; height: 186rpx;
margin-left: 46rpx; margin-left: 46rpx;
margin-top: 59rpx; margin-top: 59rpx;
} }
.bottom { .bottom {
width: 100%; width: 100%;
height: 98rpx; height: 98rpx;
position: fixed; position: fixed;
@ -17,14 +17,14 @@
justify-content: space-between; justify-content: space-between;
font-size: 28rpx; font-size: 28rpx;
line-height: 98rpx; line-height: 98rpx;
} }
.left { .left {
display: flex; display: flex;
/* line-height: 26rpx; */ /* line-height: 26rpx; */
} }
.select { .select {
width: 26rpx; width: 26rpx;
height: 26rpx; height: 26rpx;
background: rgba(234, 234, 234, 1); background: rgba(234, 234, 234, 1);
@ -32,20 +32,23 @@
margin: auto 0; margin: auto 0;
margin-left: 46rpx; margin-left: 46rpx;
margin-right: 24rpx; margin-right: 24rpx;
} }
.selects{
background-color: #4cc97d;
}
.pri { .pri {
color: #E0C79D; color: #e0c79d;
font-size: 26rpx; font-size: 26rpx;
margin-left: 19rpx; margin-left: 19rpx;
} }
.right { .right {
color: #BBBBBB; color: #bbbbbb;
margin-right: 31rpx; margin-right: 31rpx;
} }
.sub { .sub {
margin-left: 30rpx; 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 url="http://daigou.sdbairui.com/index.php/WXAPI/" + url
let text = "" let text = ""
for(let i in urldata){ for(let i in urldata){
if(urldata[i] == undefined){
text += `/${i}`
}else{
text += `/${i}/${urldata[i]}` text += `/${i}/${urldata[i]}`
}
} }
url+=text url+=text
// if(method == "POST" || method == "post"){ // if(method == "POST" || method == "post"){