接口调取完成

static-project
chen 2022-06-02 16:55:16 +08:00
parent c037848d0f
commit 1bd8e6489f
6 changed files with 174 additions and 134 deletions

View File

@ -112,7 +112,6 @@
};
},
mounted() {
// +
const query = wx.createSelectorQuery().in(this)
query.select('.posi-sticky').boundingClientRect((rect) => {
console.log(rect.height);

View File

@ -12,13 +12,13 @@
</view>
</scroll-view>
</view>
<view class="pad-zy20">
<view class="pad-sx20" :style="{width: newWidth+'px'}">
<view class="pad-zy20" style="width: 100%;">
<view class="pad-sx20" :style="{width: newWidth+'px'}" v-if="secendCateList.length>0">
<swiper-tab-jl :list="secendCateList" v-model="activeIndex" @changeEv="clickTab" itemColor="#FFFFFF"></swiper-tab-jl>
</view>
<scroll-view scroll-y="true" @scrolltolower="scrollBottomEv" :style="{height: scrollHeight +'px'}">
<view class=" posir" style="padding-bottom: 220rpx;">
<view class="disac bbt-d9 pad-sx30" @tap="goDetail(index)" v-for="(item,index) in dataList" :key="index">
<view class="disac bbt-d9 pad-sx30" @tap="goDetail(item.id)" v-for="(item,index) in dataList" :key="index">
<image class="radius30 flexs borbot-cc" :src="item.imgsrc" mode="aspectFill" style="width: 240rpx;height: 240rpx;"></image>
<view class="width100 disjb fc mar-z20" style="height: 240rpx;">
<view class="fon30 colb clips2">{{item.title}}</view>
@ -65,44 +65,10 @@
current:0,
scrollHeight:uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50,
newWidth:uni.getSystemInfoSync().windowWidth,
cateList:[
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
// {id:1,title:''},
],
cateList:[], //
activeIndex:0,
secendCateList:[
{title:'标题一'},
{title:'标题二标题二'},
{title:'标题三'},
{title:'标题四'},
{title:'标题五'},
{title:'标题六标题六标题六'},
{title:'标题七'},
{title:'标题八'},
{title:'标题九'},
],
dataList:[
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:199},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
// {imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg', title:'',price:20000},
],
secendCateList:[],
dataList:[], //
page:1,
size:10,
total:0,
@ -126,14 +92,16 @@
methods: {
//
checkShopList(id){
console.log(id,'分类id2')
this.ifLoading = true;
let params = {
page:this.page,// query 1
size:this.size,// query 10
pid:id
category_id:id
}
this.$requst.post('/api/spu/list',params).then(res=>{
if(res.code==0) {
console.log(res,'商品列表')
this.total = res.data.total;
if(this.page==1) this.dataList = [];
if(res.data.list.length) {
@ -152,6 +120,7 @@
this.ifLoading = false;
})
},
//
checkShopCate(){
this.$requst.post('/api/spu/category',{hasChildren:1}).then(res=>{
@ -172,6 +141,7 @@
}
})
},
scrollBottomEv(){
console.log('触底了');
if(this.total!=this.dataList.length) {
@ -179,48 +149,47 @@
this.checkShopList(this.pid);
}
},
//
chooseCate(index,id) {
this.current = index;
this.page = 1;
this.pid = id;
console.log(this.pid,'分类id')
// if(this.activeIndex>this.cateList[index].child.length-1) {
// this.activeIndex = this.cateList[index].child.length-1;
// }
if(this.cateList[index].child) {
this.secendCateList = this.cateList[index].child;
this.activeIndex = 0;
this.pid = this.secendCateList[0].id;
} else {
this.secendCateList = [
{title:'标题一'},
{title:'标题二标题二'},
{title:'标题三'},
{title:'标题四'},
{title:'标题五'},
{title:'标题六标题六标题六'},
{title:'标题七'},
{title:'标题八'},
{title:'标题九'},
]
this.secendCateList = [];
}
this.checkShopList(id);
this.checkShopList(this.pid);
},
goDetail(id) {
uni.navigateTo({
url:'/pagesB/shop-detail/shop-detail'
url:'/pagesB/shop-detail/shop-detail?id='+id
})
},
addCartEv(id) {
this.$requst.post('/api/order/shopping-cart-add',{sku_id:id,num:1}).then(res=>{
if(res.code==0) {
this.$toolAll.tools.showToast('加入购物车成功(*^▽^*)')
this.$toolAll.tools.showToast('加入购物车成功(*^▽^*)');
} else {
this.$toolAll.tools.showToast(res.msg)
}
})
},
// tab
clickTab(index){
this.activeIndex = index;
this.pid = this.secendCateList[this.activeIndex].id;
this.checkShopList(this.pid);
},
}
}

View File

@ -8,34 +8,36 @@
<swiper-tab-jl :list="tagList" v-model="activeIndex" @changeEv="tabTap" itemColor="#FFFFFF"></swiper-tab-jl>
</view>
<swiper :style="{height: swiperHeight + 'px'}" class="fon30" style="background-color: #f4f4f4;" :current="activeIndex" @change="swiperChange">
<swiper-item v-for="(item,index) in dataList.length" :key="index" class="pad-s30">
<swiper-item v-for="(item,index) in dataList" :key="index" class="pad-s30">
<scroll-view scroll-y @scrolltolower="scrollBottomEv" style="height: 100%;">
<!-- 列表数据 -->
<view class="radius20 bacf pad-zy30 mar-x25 mar-zy40" @tap="goDetail" v-for="(item1,index1) in dataList[index]" :key="index1">
<view class="radius20 bacf pad-zy30 mar-x25 mar-zy40" @tap="goDetail(item1.id)" v-for="(item1,index1) in dataList[index]" :key="index1">
<view class="disjbac bbot pad30" style="margin: 0 -30rpx;">
<view class="">订单号2928392832</view>
<view class="" :style="{color: ['#f83030','#f83030','#f83030','#a0a0a0','#a0a0a0'][0]}">{{['已下单','制作中','已发货','已完成','已取消'][0]}}</view>
<view class="">订单号{{item1.coding}}</view>
<view class="" :style="{color: ['#f83030','#f83030','#f83030','#a0a0a0','#a0a0a0'][0]}">{{item1.status_text}}</view>
</view>
<view class="disjb borbot pad-sx30" v-for="(item2,index2) in 2" :key="index2">
<image class="mar-y30 flexs radius40" src="https://s6.jpg.cm/2022/05/06/Lx4T45.jpg" mode="" style="width: 210rpx;height: 210rpx;"></image>
<view class="disjb borbot pad-sx30" v-for="(item2,index2) in item1.skus" :key="index2">
<image class="mar-y30 flexs radius40" :src="item2.spu_cover" mode="" style="width: 210rpx;height: 210rpx;"></image>
<view class="width100 disjb fc" style="height: 210rpx;">
<view class="clips2 fon24">{{item1.title}}</view>
<view class="clips2 fon24">{{item2.spu_name}}</view>
<view class="">
<view class="fon24 mar-x30" style="color: #8c8c9b;">单位{{item1.title}}</view>
<view class="fon24 mar-x30" style="color: #8c8c9b;">单位{{item2.sku_unit}}</view>
<view class="disjbac ">
<view class="textc bold">{{$toolAll.tools.changeNum(item1.price)}}</view>
<view class="fon24" style="color: #8c8c9b;">x1</view>
<view class="textc bold">{{$toolAll.tools.changeNum(item2.price)}}</view>
<view class="fon24" style="color: #8c8c9b;">x{{item2.num}}</view>
</view>
</view>
</view>
</view>
<view class="disjbac tbot pad30" style="margin: 0 -30rpx;">
<view class="bold" style="color: #f83030;">合计2390.00</view>
<!-- <view class="btn" @tap.stop="cancleEv">取消订单</view> -->
<view class="btn csbtn" @tap.stop="buyEv">再次购买</view>
<view class="bold" style="color: #f83030;">合计{{item1.original_price}}</view>
<view class="btn" @tap.stop="cancleEv(item1.coding)" v-if="item1.status == 'order_placed'"></view>
<view class="btn csbtn" @tap.stop="buyEv(index1)" v-if="item1.status == 'completed' || item1.status == 'cancel'"></view>
<view class="btn csbtn" @tap.stop="affirmEv(item1.id)" v-if="item1.status == 'shipped' || item1.status == 'arrived'"></view>
</view>
</view>
<view class="pad-sx40" v-if="total==dataList.length"><pitera textStr="—— 到底啦 ——"></pitera></view>
<view class="pad-sx40" v-if="total==totalAll"><pitera textStr="—— 到底啦 ——"></pitera></view>
</scroll-view>
</swiper-item>
</swiper>
@ -62,51 +64,24 @@
data() {
return {
tagList:[
{title:'全部'},
{title:'已下单'},
{title:'制作中'},
{title:'已发货'},
{title:'已完成'},
{title:'已取消'},
{title:'全部',tag:'all'},
{title:'已下单',tag:'order_placed'},
{title:'制作中',tag:'makeing'},
{title:'已发货',tag:'shipped'},
{title:'已完成',tag:'completed'},
{title:'已取消',tag:'cancel'},
],
activeIndex:0,
dataList:[
[
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
],
[
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
],
[
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
],
[
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
],
[
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
],
[
{title:'标题',content:'描述描述描述描述描述描述描述描述描述描述描述描述',price:199,xiaol:99},
],
],
dataList:[[],[],[],[],[],[]],
flag:true,
swiperHeight:uni.getSystemInfoSync().windowHeight,
newTop:uni.getSystemInfoSync().statusBarHeight + 50,
ifLoading:false,
total:0
total:0,
totalAll:0,
page: 1,
size: 10,
tag: 'all'
}
},
onLoad(op) {
@ -117,34 +92,115 @@
if(op.index) {
this.activeIndex = op.index;
}
this.getOrderList();
},
methods: {
tabTap(e) {
this.activeIndex = e;
this.page = 1;
this.dataList = [[],[],[],[],[],[]];
this.getOrderList();
},
swiperChange(e) {
this.activeIndex = e.detail.current;
},
scrollBottomEv(e) {
this.ifLoading = true;
this.total = 0;
let pageSize = Math.floor(this.totalAll/this.size)
if(this.page < pageSize){
this.page++;
this.getOrderList();
}else if(this.page == pageSize){
this.page++;
this.getOrderList();
this.total = this.totalAll;
}else{
this.ifLoading = false;
return false;
}
setTimeout(()=>{
this.ifLoading = false;
this.total = this.dataList.length;
},2000)
},
//
getOrderList(){
let params = {
page: this.page,
size: this.size,
tag: this.tagList[this.activeIndex].tag
}
this.$requst.get('/api/user/order',params).then(res=>{
if(res.data.length!=0){
this.totalAll = res.data.total;
res.data.list.forEach(item=>{
let dataObj = {
id: item.id, //id
coding: item.coding, //
original_price: item.original_price, //
status: item.status, //
status_text: item.status_text, //
skus: item.skus //
}
this.dataList[this.activeIndex].push(dataObj)
})
console.log(this.dataList[this.activeIndex],'订单列表')
}
})
},
//
goDetail(){
goDetail(id){
uni.navigateTo({
url:'/pagesB/order-detail/order-detail'
url:'/pagesB/order-detail/order-detail?id='+id
})
},
//
cancleEv(){
console.log('取消订单');
cancleEv(coding){
let params = {
order_coding: coding //
}
this.$requst.post('/api/order/cancel',params).then(res=>{
if(res.code==0) {
this.$toolAll.tools.showToast('取消订单成功(*^▽^*)');
this.dataList = [[],[],[],[],[],[]];
this.page = 1;
this.getOrderList();
} else {
this.$toolAll.tools.showToast(res.msg)
}
})
},
//
affirmEv(id){
let params = {
order_id: id //
}
this.$requst.post('/api/order/accepted',params).then(res=>{
if(res.code==0) {
this.$toolAll.tools.showToast('确认收货成功(*^▽^*)');
this.dataList = [[],[],[],[],[],[]];
this.page = 1;
this.getOrderList();
} else {
this.$toolAll.tools.showToast(res.msg)
}
})
},
//
buyEv(){
buyEv(index){
let buyList = [];
let newArr = this.dataList[this.activeIndex][index];
newArr.skus.forEach(item=>{
let obj = {
sku_coding: item.coding,
num: item.num
}
buyList.push(obj);
})
uni.setStorageSync('buyList',buyList);
uni.navigateTo({
url:'/pagesB/settlement/settlement'
})
uni.navigateTo({
url:'/pagesB/settlement/settlement'
})

View File

@ -6,41 +6,41 @@
<view class="bacf radius30 pad-sx30 pad-zy40 fon30 mar-x25">
<view class="disjbac">
<view class="">订单编号</view>
<view class="bold">2928392832</view>
<view class="bold">{{orderDetail.coding}}</view>
</view>
<view class="disjbac mar-sx30">
<view class="">下单时间</view>
<view class="bold">2021-11-30 2330</view>
<view class="bold">{{orderDetail.status_text}}</view>
</view>
<view class="disjbac">
<view class="">订单状态</view>
<view class="bold">已发货</view>
<view class="bold">{{orderDetail.coding}}</view>
</view>
</view>
<view class="bacf radius30 pad-sx30 pad-zy40 fon30 mar-x25">
<view class="">订单信息</view>
<view class="disjb bbot pad-sx30" v-for="(item,index) in 2" :key="index">
<view class="disjb bbot pad-sx30" v-for="(item,index) in orderDetail.skus" :key="index">
<image class="mar-y30 flexs radius30" src="https://s6.jpg.cm/2022/05/06/Lx4T45.jpg" mode="" style="width: 210rpx;height: 210rpx;"></image>
<view class="width100 disjb fc line-h40" style="height: 210rpx;">
<view class="clips2 fon24">于亿年宝藏中臻选1的宝石级钻石每年开采数LOVE100 星座光的原石挑选 </view>
<view class="clips2 fon24">{{item.spu_name}} </view>
<view class="">
<view class="fon24 mar-x30" style="color: #8c8c9b;">单位</view>
<view class="fon24 mar-x30" style="color: #8c8c9b;">单位{{item.sku_unit}}</view>
<view class="disjbac ">
<view class="textc bold">{{$toolAll.tools.changeNum(2000)}}</view>
<view class="fon24" style="color: #8c8c9b;">x1</view>
<view class="textc bold">{{item.price}}</view>
<view class="fon24" style="color: #8c8c9b;">x{{item.num}}</view>
</view>
</view>
</view>
</view>
<view class="disje pad-s30">总计<text class="fon36 bold textc" style="margin-top: -6rpx;">4000</text></view>
<view class="disje pad-s30">总计<text class="fon36 bold textc" style="margin-top: -6rpx;">{{orderDetail.original_price}}</text></view>
</view>
<view class="bacf radius30 pad-sx30 pad-zy40 fon30 mar-x25">
<view class="mar-x30">联系信息</view>
<view class="bold">徐卫 546546515315</view>
<view class="bold">{{orderDetail.contacts}} {{orderDetail.phone}}</view>
<view class="fon24">
<view class="mar-sx10" style="color: #8c8c9b;">四川省成都市双店路奥园广场3期1419号</view>
<view class="" style="color: #8c8c9b;">婚期2022-12-23</view>
<view class="mar-s10" style="color: #8c8c9b;">希望到货时间2022-12-21</view>
<view class="mar-sx10" style="color: #8c8c9b;">{{orderDetail.address}}</view>
<view class="" style="color: #8c8c9b;">婚期{{orderDetail.wedding_date}}</view>
<view class="mar-s10" style="color: #8c8c9b;">希望到货时间{{orderDetail.expected_delivery_date}}</view>
</view>
</view>
<view class="posixzy bacf pad-sx20 pad-zy50" style="box-shadow: 0rpx -2rpx 10rpx rgba(0, 0, 0, 0.06);">
@ -56,7 +56,7 @@
export default {
data() {
return {
orderDetail: []
}
},
onShareAppMessage(res) {
@ -72,9 +72,22 @@
},
methods: {
getDetail(id){
this.$requst.post('/api/spu/detail',{id}).then(res=>{
if(res.code==1) {
this.$requst.post('/api/user/order-detail',{id}).then(res=>{
if(res.code==0) {
let dataObj = {
coding: res.data.coding, //
created_at: res.data.created_at, //
status_text: res.data.status_text, //
expected_delivery_date: res.data.expected_delivery_date, //
wedding_date: res.data.wedding_date, //
original_price: res.data.original_price, //
contacts: res.data.contacts, //
address: res.data.address, //
phone: res.data.phone, //
skus: res.data.skus //
}
this.orderDetail = dataObj;
console.log(this.orderDetail,'订单详情2')
}
})
}

View File

@ -49,7 +49,7 @@
}
},
onLoad() {
console.log(uni.getStorageSync('buyList'),'缓存数组')
},
methods: {
//

View File

@ -61,6 +61,7 @@
this.getDetail(op.id);
},
methods: {
//
getDetail(id){
this.$requst.post('/api/spu/detail',{id}).then(res=>{
@ -81,6 +82,7 @@
}
})
},
//
buyEv(id){
this.$requst.post('/api/order/shopping-cart-add',{sku_id:id,num:1}).then(res=>{
@ -94,6 +96,7 @@
}
})
},
//
addCartEv(id) {
if(this.$toolAll.tools.judgeAuth()) {