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({
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

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

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

@ -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;
}
}
}
.decorate {
width: 9rpx;
height: 102rpx;
background-color: #3fb66e;
}
}

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

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

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

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

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){
text += `/${i}/${urldata[i]}`
if(urldata[i] == undefined){
text += `/${i}`
}else{
text += `/${i}/${urldata[i]}`
}
}
url+=text
// if(method == "POST" || method == "post"){