Browse Source

修复商品详情多个规格错误问题,对接购物车选择、删除、提交、修改商品数量

master
ltlzx 3 years ago
parent
commit
188cf09051
  1. 13
      pages/account/myOrders.vue
  2. 14
      pages/productDetails/index.vue
  3. 163
      pages/shippingCart/index.vue

13
pages/account/myOrders.vue

@ -299,6 +299,7 @@
</template>
<script>
import {defaultRequest2} from '../../api/index.js'
export default {
data() {
return {
@ -308,9 +309,21 @@
}
},
methods:{
getList(){
let data={_action:'getuserorders',page_index:1,page_size:10,payingstatus:'0,1',status:'0'}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
}
})
},
scrollChange(index){
this.scroll_active=index
},
},
onLoad() {
this.getList()
}
}
</script>

14
pages/productDetails/index.vue

@ -78,7 +78,7 @@
<view class="variations_title_left">Variations</view>
<text>{{colorNum}}color</text>
</view>
<view class="variations_select">
<view >
<view v-for="(item,index) in goodsDate.attr_list" :key="index" class="variations_select">
<!-- <view class="variations_select_varieties" >
<view class="select_varieties_image" v-for="(item,index) in 3" :key="index"></view>
@ -284,7 +284,7 @@
</view>
</view>
<view class="addCard" v-show="isCart">
<image src="/static/img/close1.png" mode="" class="addCard_close"></image>
<image src="/static/img/close1.png" mode="" class="addCard_close" @click="isCart=false"></image>
<scroll-view class="spike1 " scroll-x="true" :show-scrollbar="false">
<image :src="item.img_url" mode="" class="addCard_scroll" v-for="(item,index) in goodsDate.gallery_list" :key="index" @click="clickImg(index)"></image>
</scroll-view>
@ -353,15 +353,14 @@
],
gallery_list:[
{content:''}
]
],
},
user_info:{},
addressDate:{},
colorNum:0,
//
goods_attr_list:[
{goods_attr_id:''}
],
goods_attr_list:[],
//
catQuery:{
_action:'getgoods',
@ -451,7 +450,6 @@
//
selectAttr(attr_id,goods_attr_id,index){
let data={attr_id:attr_id,goods_attr_id:goods_attr_id}
if(this.goods_attr_list[0].goods_attr_id=='')this.goods_attr_list=[]
if(this.goods_attr_list.length==0){
this.goods_attr_list.push(data)
}else{
@ -533,10 +531,12 @@
this.info.push(item.img_url)
})
if(this.goodsDate.attr_list){
let data={goods_attr_id:''}
this.goodsDate.attr_list.map(item=>{
if(item.attr_name=="Color"){
this.colorNum=item.goods_attrs.length
}
this.goods_attr_list.push(data)
})
}else{
this.goods_attr_list=[]

163
pages/shippingCart/index.vue

@ -3,16 +3,16 @@
<uni-nav-bar :statusBar="true" left-icon="left" title="Shipping Cart" color="#000000" :fixed="true" @clickLeft="back">
<block slot="right">
<view class="nav_right">
<image src="../../static/img/delete1.png" mode=""></image>
<image src="../../static/img/delete1.png" mode="" @click="deleteCart"></image>
</view>
</block>
</uni-nav-bar>
<view class="empty" v-if="isEmpty">
<view class="empty" v-if="goods_list.length==0">
<image src="/static/img/cart3.png" mode=""></image>
<text>Your cart is empty</text>
<button>Shop Now</button>
</view>
<template v-if="!isEmpty">
<template v-else>
<view class="cart_info">
<image src="/static/img/Shipped.png" mode=""></image>
<view class="cart_title_content">Buy US$32.00 more to enjoy FREE STANDARD SHIPPING!</view>
@ -20,9 +20,9 @@
</view>
<view class="cart">
<view class="cart_content">
<view class="good_info" v-for="(item,index) in goods_list " :key="item.rec_id">
<image src="../../static/img/select1.png" mode="" class="cart_select" v-show="is_check==1"></image>
<image src="../../static/img/select2.png" mode="" class="cart_select" v-show="is_check==0"></image>
<view class="good_info" v-for="(item,index) in goods_list" :key="item.rec_id">
<image src="../../static/img/select1.png" mode="" class="cart_select" v-show="item.is_check==1" @click="cartCheck(1,0,item.rec_id,index)"></image>
<image src="../../static/img/select2.png" mode="" class="cart_select" v-show="item.is_check==0" @click="cartCheck(1,1,item.rec_id,index)"></image>
<view class="good_info_left ">
<view class="good_info_image">
<image :src="item.goods_thumb" mode=""></image>
@ -37,7 +37,7 @@
</view>
<view class="info_price">
<text>US${{item.goods_price}}</text>
<uni-number-box background="#FFFFFF">{{item.goods_number}}</uni-number-box>
<uni-number-box background="#FFFFFF" :min="1" :value="item.goods_number" @change="updateCart($event,item.rec_id)"></uni-number-box>
</view>
</view>
@ -91,20 +91,24 @@
<view class="footer">
<view class="footer_left">
<image src="../../static/img/select2.png" mode=""></image>
<image src="../../static/img/select1.png" mode="" v-if="all_allno==1 && goods_list.length>0" @click="cartCheck(0,0)"></image>
<image src="../../static/img/select2.png" mode="" v-else @click="cartCheck(0,1)"></image>
<text>All</text>
</view>
<view class="footer_right">
<text>US$314.00</text>
<button>CHECKOUT(2)</button>
<text>US${{total.goods_price}}</text>
<button @click="cartCheckOut">CHECKOUT({{total.goods_count}})</button>
</view>
</view>
<uni-popup ref="alertDialog" type="dialog">
<uni-popup-dialog type="error" cancelText="Close" confirmText="Delete" title="Tips" content="Whether to delete goods?"
@confirm="dialogConfirm" ></uni-popup-dialog>
</uni-popup>
</view>
</template>
<script>
import {defaultRequest2} from '../../api/index.js'
import {defaultRequest2,defaultRequest4} from '../../api/index.js'
export default {
data() {
return {
@ -114,23 +118,142 @@
//
goods_list:[],
// 1-2-3-
all_allno:2
all_allno:2,
deleteQuery:{
_action:'removecart'
}
}
},
methods:{
//
updateCart(e,id){
let data={_action:'updatecart',rec_id:id,goods_number:e}
defaultRequest4(data).then(res=>{
console.info(res)
if(res.error==0){
this.getList()
}
})
},
//
cartCheckOut(){
if(this.goods_list.length==0) return
if(this.all_allno==2){
uni.showToast({
icon:'none',
title:'Please select the product'
})
return
}
let data={_action:'cartcheckout',is_new:1,direct_shopping:0,consignee:''}
defaultRequest2(data).then(res=>{
console.info(res)
if(res.error==0){
// uni.navigateTo({
// url:''
// })
}
})
},
//
deleteCart(){
if(this.goods_list.length==0) return
if(this.all_allno==2){
uni.showToast({
icon:'none',
title:'Please select the product to delete'
})
return
}else if(this.all_allno==3){
let selectNum=0,
rec_id=''
this.goods_list.map(item=>{
if(item.is_check==1){
rec_id=item.rec_id
selectNum++
}
})
if(selectNum>1){
uni.showToast({
icon:'none',
title:'Only one or all items can be deleted'
})
return
}else{
this.deleteQuery.rec_id=rec_id
}
}else{
// this.deleteQuery._action='clearcart'
}
this.$refs.alertDialog.open()
},
dialogConfirm(){
defaultRequest2(this.deleteQuery).then(res=>{
console.info(res)
if(res.error==0){
uni.showToast({
icon:'none',
title:'Successfully deleted!'
})
this.getList()
}
})
},
// -- type: 1 0
cartCheck(type,is_check,id,index){
if(this.goods_list.length==0) return
let data={}
if(type==1){
data={_action:'cartcheck',rec_id:id,is_check:is_check}
}else{
data={_action:'cartcheckall',is_check:is_check}
}
defaultRequest4(data).then(res=>{
console.info(res)
if(res.error==0){
this.getList()
// Object.assign(this.total,res.data)
// this.total.goods_price=res.data.price
// this.all_allno=res.data.all_allno
// if(type==1){
// if(is_check==0){
// this.goods_list[index].is_check=0
// }else{
// this.goods_list[index].is_check=1
// }
// }else{
// this.goods_list.map(item=>{
// if(is_check==0){
// item.is_check=0
// }else{
// item.is_check=1
// }
// })
// }
}
})
},
getList(){
let data={_action:'getcartgoods'}
defaultRequest2(data).then(res=>{
defaultRequest4(data).then(res=>{
console.info(res)
if(res.error==0){
this.total=res.data.total
this.all_allno=res.data.all_allno
res.data.goods_list.map(item=>{
item.goods_attr=item.goods_attr.replace(/\n/,"");
console.info(item.goods_attr)
})
this.goods_list=res.data.goods_list
if(res.data.goods_list){
res.data.goods_list.map(item=>{
item.goods_attr=item.goods_attr.replace(/\s\n/g,';');
})
this.goods_list=res.data.goods_list
}else{
this.goods_list=[]
}
}
})

Loading…
Cancel
Save