作者 lihongjuan

1

{
"pages": [
"pages/homepage/homepage",
"pages/goodtail/goodtail",
"pages/login/login",
"pages/cart/cart",
"pages/orderbox/orderbox",
... ... @@ -9,7 +11,7 @@
"pages/dizhibox/dizhibox",
"pages/message/message",
"pages/mine/mine",
"pages/goodtail/goodtail",
"pages/orderdetail/orderdetail",
"pages/sureorder/sureorder",
"pages/searchbox/searchbox",
... ...
... ... @@ -55,6 +55,9 @@
</view>
<view class="goodname">{{item.goods_name}}</view>
</view>
<view class="attr" wx:for="{{goods_standard}}" wx:key=''>
<view class="goodbottomright attritem">{{item}}</view>
</view>
</view>
<view class="songk">
<image src="/img/send.png"></image>
... ... @@ -69,6 +72,9 @@
</view>
<view class="goodname">{{item.gift.goods_name}}</view>
</view>
<view class="attr" wx:for="{{goods_standard}}" wx:key=''>
<view class="goodbottomright attritem">{{item}}</view>
</view>
</view>
</view>
... ... @@ -120,4 +126,6 @@
</view>
<view class="cartbottomright" bindtap="jiesuan">结算</view>
</view>
\ No newline at end of file
</view>
... ...
... ... @@ -262,4 +262,8 @@ page {
color:#FF5A4E;
font-size: 30rpx;
font-weight: bold;
}
image{
width:100%;
height:100%;
}
\ No newline at end of file
... ...
... ... @@ -25,10 +25,11 @@ Page({
totalping: 0,
giftstandard: '请选择规格',
standard: '请选择规格',
standardarr:[],
giftstandardarr:[],
buynum:1
standardarr: [],
giftstandardarr: [],
buynum: 1,
buytype: '', //1 加入购物车 2立即购买
attrshow: false
},
/**
... ... @@ -71,7 +72,7 @@ Page({
})
},
// 获取商品详情
getgoodtail() {
let that = this;
var url = 'goods/get_one';
... ... @@ -94,7 +95,7 @@ Page({
that.data.goodtail.gift.standard.forEach(function(value, index, array) {
value.selindex = -1,
value.selname = ''
value.selname = ''
})
that.setData({
goodtail: that.data.goodtail
... ... @@ -104,33 +105,38 @@ Page({
})
},
reducenum(){
this.data.buynum=this.data.buynum-1;
if(this.data.buynum==1){
reducenum() {
this.data.buynum = this.data.buynum - 1;
if (this.data.buynum == 1) {
this.setData({
buynum:this.data.buynum
buynum: this.data.buynum
})
}
},
addnum(){
this.data.buynum = this.data.buynum +1;
addnum() {
this.data.buynum = this.data.buynum + 1;
this.setData({
buynum: this.data.buynum
})
},
uniq(array) {
return temp;
},
// 选择属性
selattr(e) {
let that = this;
console.log(e)
let index = e.currentTarget.dataset.index;
let attrindex = e.currentTarget.dataset.bindex;
let name=e.currentTarget.dataset.name
let name = e.currentTarget.dataset.name
console.log(index);
console.log(attrindex)
that.data.standardarr.push(name)
that.data.goodtail.standard[attrindex].selindex = index;
that.data.goodtail.standard[attrindex].selname = name;
that.setData({
goodtail: that.data.goodtail,
standardarr: that.data.standardarr
... ... @@ -138,7 +144,7 @@ Page({
console.log(that.data.goodtail)
console.log(that.data.standardarr)
},
selgiftattr(e){
selgiftattr(e) {
let that = this;
console.log(e)
let index = e.currentTarget.dataset.index;
... ... @@ -159,13 +165,22 @@ Page({
},
//加入购物车
addcart() {
let that = this;
this.setData({
buytype: 1,
attrshow: true
})
},
addcartk() {
let that = this
var url = 'car/update_car';
var params = {
goods_id: that.data.goodid,
type: 1,
goods_standard:that.data.standardarr.join(","),
give_standard: that.data.giftstandardarr.join(",")
goods_standard: that.data.standardarr.join(","),
give_standard: that.data.giftstandardarr.join(","),
number: that.data.buynum
}
app.post(url, params).then((res) => {
... ... @@ -174,6 +189,12 @@ Page({
title: '添加购物车成功',
icon: 'none'
})
setTimeout(function(){
that.setData({
attrshow:false
})
},1500)
that.getqipao()
... ... @@ -246,13 +267,22 @@ Page({
//立即抢购
lijiqiang() {
this.setData({
buytype: 2,
attrshow: true
})
},
lijiqiangk() {
let that = this;
var url = 'order/confirm_order';
var params = {
goods_ids: that.data.goodtail.id,
take_id: '',
type: 1
type: 1,
goods_standard: that.data.standardarr.join(","),
give_standard: that.data.giftstandardarr.join(","),
number: that.data.buynum
}
app.post(url, params).then((res) => {
console.log(res);
... ... @@ -266,15 +296,16 @@ Page({
let freight = res.freight;
let price = res.price;
let total = res.total;
let give_standard = res.give_standard
let goods_standard = res.goods_standard
console.log(give_standard);
console.log(goods_standard)
app.globalData.give_standard = give_standard;
console.log(freight);
console.log(price);
console.log(total);
console.log(orderarr);
app.globalData.goods_standard = goods_standard;
wx.navigateTo({
url: '/pages/sureorder/sureorder?orderarr=' + neworderarr + '&freight=' + freight + '&price=' + price + '&total=' + total + '&type=' + 1,
url: '/pages/sureorder/sureorder?orderarr=' + neworderarr + '&freight=' + freight + '&price=' + price + '&total=' + total + '&type=' + 1
})
... ... @@ -285,6 +316,83 @@ Page({
})
})
},
//确定购买或加入购物车
surebuy() {
let that = this;
console.log(that.data.goodtail)
var arr = [];
var giftarr = [];
that.data.goodtail.standard.forEach(function(value, index, array) {
console.log(value);
console.log(value.selname)
if (value.selname != "") {
arr.push(value.selname);
}
})
var temp = []; //一个新的临时数组 去掉多选的商品属性
for (var i = 0; i < arr.length; i++) {
if (temp.indexOf(arr[i]) == -1) {
temp.push(arr[i]);
}
}
that.data.goodtail.gift.standard.forEach(function(value, index, array) {
console.log(value);
console.log(value.selname)
if (value.selname != "") {
giftarr.push(value.selname);
}
})
var gifttemp = []; //一个新的临时数组 去掉多选的商品属性
for (var i = 0; i < giftarr.length; i++) {
if (gifttemp.indexOf(giftarr[i]) == -1) {
gifttemp.push(giftarr[i]);
}
}
that.setData({
standardarr: temp,
giftstandardarr: gifttemp
})
if (that.data.standardarr.length != that.data.goodtail.standard.length) {
wx.showToast({
title: '请选择商品属性',
icon: 'none'
})
} else if (that.data.giftstandardarr.length != that.data.goodtail.gift.standard.length) {
wx.showToast({
title: '请选择赠品属性',
icon: 'none'
})
} else {
if (that.data.buytype == 1) {
that.addcartk()
} else {
that.lijiqiangk()
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
... ... @@ -149,7 +149,7 @@
</view>
<!-- 选择商品属性 -->
<view class="registerk">
<view class="registerk" wx:if="{{attrshow}}">
<view class="naturewrap">
<view class="naturebox">
<view class="naturetop flexone">
... ... @@ -212,8 +212,8 @@
</view>
<view class="cartbottom boxcartbot">
<view class="cartbottomleft" bindtap="gocart">
<view class="cartbottom boxcartbot surebot">
<!-- <view class="cartbottomleft" bindtap="gocart">
<view class="cartbototmtopimg">
<image src="/img/shop.png"></image>
<view class="cartnum">{{count}}</view>
... ... @@ -222,11 +222,12 @@
<view class="gouwucart">购物车</view>
</view>
</view> -->
<view class="cartright">
<view class="cartleftname" bindtap="addcart">加入购物车</view>
<view class="qianggou" bindtap="lijiqiang">立即抢购</view>
<!-- <view class="cartleftname" bindtap="addcart">加入购物车</view> -->
<!-- <view class="qianggou" bindtap="surebuy">确定</view> -->
<view class="surebuy" bindtap="surebuy">确定</view>
</view>
</view>
... ...
... ... @@ -349,6 +349,23 @@
line-height: 77rpx;
border-radius: 4rpx 20rpx 20rpx 4rpx;
}
.surebot{
display:flex;
justify-content: center;
align-items: center
}
.surebuy{
width:500rpx;
height:77rpx;
background: rgba(255, 90, 78, 1);
color:#fff;
font-size: 28rpx;
text-align: center;
line-height: 77rpx;
border-radius: 44rpx;
margin:0 auto;
}
.cartright {
display: flex;
... ...
... ... @@ -15,7 +15,9 @@ Page({
type:'',
goodsid:[],
remark:'',
order_id:''
order_id:'',
goods_standard:[],
give_standard:[]
},
/**
... ... @@ -33,8 +35,13 @@ Page({
orderarr: JSON.parse(options.orderarr),
freight: options.freight,
type:options.type,
give_standard: app.globalData.give_standard,
goods_standard: app.globalData.goods_standard
})
console.log(this.data.give_standard)
console.log(this.data.goods_standard)
let neworderarr=this.data.orderarr;
let newgoodsid=this.data.goodsid;
for(var obj of neworderarr){
... ...
... ... @@ -28,18 +28,21 @@
<image src="{{item.image}}"></image>
</view>
<view class="xiename">
<view class="xiek">
<view class="xienameleft">
<image src="/img/good.png"></image>
</view>
<view class="goodname">{{item.goods_name}}</view>
<view class="goodname">x{{item.number}}</view>
<view class="goodname">x{{item.number}}</view>
</view>
<view class="goodbottom">
<view class="goodbottomleft">¥{{item.price}}</view>
<view class="goodbottomright" wx:if="{{item.freight==0.00}}">运费:免运费</view>
<view class="goodbottomright" wx:else>运费:{{item.freight}}元</view>
<view class="goodbottomright" wx:else>运费:{{item.freight}}元</view>
</view>
<view class="attr" wx:for="{{goods_standard}}" wx:key=''>
<view class="goodbottomright attritem">{{item}}</view>
</view>
</view>
... ... @@ -64,6 +67,9 @@
<view class="goodbottomright" wx:if='{{item.gift.freight==0.00}}'>运费:免运费</view>
<view class="goodbottomright" wx:else>运费:{{item.gift.freight}}元</view>
</view>
<view class="attr" wx:for="{{give_standard}}" wx:key=''>
<view class="goodbottomright attritem">{{item}}</view>
</view>
</view>
</view>
... ... @@ -82,7 +88,7 @@
</view>
<view class="beizhuenter">
<input placeholder='请填写订单备注' placeholder-class='entermark' bindinput="entertext"/>
<input placeholder='请填写订单备注' placeholder-class='entermark' bindinput="entertext" />
</view>
</view>
... ...
... ... @@ -122,3 +122,19 @@
line-height: 88rpx;
margin-top:80rpx;
}
.attr{
display:flex;
align-items: center;
margin-top:10rpx;
flex-wrap: wrap;
}
.attritem{
margin-right:8rpx
}
.xiek{
display: flex;
margin-top: 24rpx;
}
\ No newline at end of file
... ...
... ... @@ -4,13 +4,23 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"coverView": true,
"autoAudits": false,
"checkInvalidKey": true
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"compileType": "miniprogram",
"libVersion": "2.9.2",
... ...