添加域名、新增商城分类接口、列表查询接口
							parent
							
								
									a13bd2cca8
								
							
						
					
					
						commit
						a1a3edb942
					
				
							
								
								
									
										2
									
								
								App.vue
								
								
								
								
							
							
						
						
									
										2
									
								
								App.vue
								
								
								
								
							| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
			projectname:'', // 项目名称
 | 
			
		||||
			lat:'', // 公司地址维度
 | 
			
		||||
			lng:''  ,// 公司地址经度
 | 
			
		||||
			hostapi:'请配置域名' // 域名配置
 | 
			
		||||
			hostapi:'https://chuanwujia.scdxtc.cn' // 域名配置
 | 
			
		||||
		},
 | 
			
		||||
		// 优先于show方法
 | 
			
		||||
		onLaunch: ()=> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,15 +1,15 @@
 | 
			
		|||
<template>
 | 
			
		||||
	<view class="disjbac fw">
 | 
			
		||||
		<view @tap="goDetail(index)" class="radius8 bacf pad12 boxshow1 width48_6 mar-s20 flexs" v-for="(item,index) in 2" :key="index">
 | 
			
		||||
			<image src="https://s6.jpg.cm/2022/02/14/L4oDhy.jpg" style="height: 226rpx;" mode="aspectFill" class="width100" lazy-load></image>
 | 
			
		||||
		<view @tap="goDetail(item.id)" class="radius8 bacf pad12 boxshow1 width48_6 mar-s20 flexs" v-for="(item,index) in list" :key="index">
 | 
			
		||||
			<image :src="item.cover" style="height: 226rpx;" mode="aspectFill" class="width100" lazy-load></image>
 | 
			
		||||
			<view class="fon24 pad-zy8 disjb fc" style="color: #262626;">
 | 
			
		||||
				<view class="clips2 mar-sx10" style="height: 64rpx;">动作教学动作教学动作教学动作教学Jj</view>
 | 
			
		||||
				<view class="clips2 mar-sx10" style="height: 64rpx;">{{item.name}}</view>
 | 
			
		||||
				<view class="disjbac ae pad-x10">
 | 
			
		||||
					<view class="">
 | 
			
		||||
						<span class="bold colf8">¥199.00</span>
 | 
			
		||||
						<span class="fon20 mar-z10 tline-through" style="color: #969696;">¥220.00</span>
 | 
			
		||||
						<span class="bold colf8">¥{{item.price}}</span>
 | 
			
		||||
						<span class="fon20 mar-z10 tline-through" style="color: #969696;">¥{{item.original_price}}</span>
 | 
			
		||||
					</view>
 | 
			
		||||
					<view v-if="index%2==0" class="radius18 pad-zy12 disjcac flexs fon20" style="color: #f37617;border: 2rpx solid #f37617;">购买</view>
 | 
			
		||||
					<view v-if="!ifCourse" class="radius18 pad-zy12 disjcac flexs fon20" style="color: #f37617;border: 2rpx solid #f37617;">购买</view>
 | 
			
		||||
					<view v-else class="radius16 pad-zy10 disjcac colf flexs fon20" style="border: 2rpx solid #f37617;background-color: #f37617;">去学习</view>
 | 
			
		||||
				</view>
 | 
			
		||||
			</view>
 | 
			
		||||
| 
						 | 
				
			
			@ -20,9 +20,15 @@
 | 
			
		|||
<script>
 | 
			
		||||
	export default {
 | 
			
		||||
		name:"list",
 | 
			
		||||
		props:{
 | 
			
		||||
			ifCourse:{
 | 
			
		||||
				type:Boolean,
 | 
			
		||||
				default:false
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		data() {
 | 
			
		||||
			return {
 | 
			
		||||
				
 | 
			
		||||
				list:[]
 | 
			
		||||
			};
 | 
			
		||||
		},
 | 
			
		||||
		methods:{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,7 @@
 | 
			
		|||
					<swiper-tab id="tab" :ifBetween="false" :list="dataList" v-model="current" @changeEv="clickTab" :itemColor="'#e42417'" :lineColor="'#e42417'"></swiper-tab>
 | 
			
		||||
				</view>
 | 
			
		||||
				<view class="pad-zy20">
 | 
			
		||||
					<list @goDetail="goDetail"></list>
 | 
			
		||||
					<list @goDetail="goDetail"></list>
 | 
			
		||||
					<list @goDetail="goDetail"></list>
 | 
			
		||||
					<list @goDetail="goDetail"></list>
 | 
			
		||||
					<list ref="refproduct" @goDetail="goDetail"></list>
 | 
			
		||||
					<pitera textStr="上滑加载更多/到底了~~" textColor="#b0aaa9" paddingStr="40rpx 0 20rpx 0"></pitera>
 | 
			
		||||
				</view>
 | 
			
		||||
			</view>
 | 
			
		||||
| 
						 | 
				
			
			@ -35,19 +32,57 @@
 | 
			
		|||
		data() {
 | 
			
		||||
			return {
 | 
			
		||||
				newtop:uni.getSystemInfoSync().statusBarHeight + 42,
 | 
			
		||||
				current:0,
 | 
			
		||||
				dataList:[
 | 
			
		||||
					{title:'全部'},
 | 
			
		||||
					{title:'机械'},
 | 
			
		||||
					{title:'书籍'},
 | 
			
		||||
					{title:'鞋子'},
 | 
			
		||||
				],
 | 
			
		||||
				current:0,//当前分类索引
 | 
			
		||||
				dataList:[],//分类列表
 | 
			
		||||
				classId:'',//分类id
 | 
			
		||||
				page:1,
 | 
			
		||||
				size:20,
 | 
			
		||||
				total:0,
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		onLoad() {
 | 
			
		||||
			// 调用获取分类列表
 | 
			
		||||
			this.getHomeCate();
 | 
			
		||||
		},
 | 
			
		||||
		methods: {
 | 
			
		||||
			// tab点击事件
 | 
			
		||||
			clickTab(index){
 | 
			
		||||
				this.current = index;
 | 
			
		||||
				// 设置分类id
 | 
			
		||||
				this.classId = this.dataList[index].id;
 | 
			
		||||
				// 调用获取商品产品列表
 | 
			
		||||
				this.getProductList();
 | 
			
		||||
			},
 | 
			
		||||
			// 获取首页分类
 | 
			
		||||
			getHomeCate(){
 | 
			
		||||
				this.$requst.get('/api/spu/category').then(res=>{
 | 
			
		||||
					// 设置分类列表
 | 
			
		||||
					this.dataList = res.data;
 | 
			
		||||
					// 如果分类列表不为空
 | 
			
		||||
					if(this.dataList.length){
 | 
			
		||||
						// 设置分类id
 | 
			
		||||
						this.classId = this.dataList[0].id;
 | 
			
		||||
						// 调用获取商品产品列表
 | 
			
		||||
						this.getProductList();
 | 
			
		||||
					}
 | 
			
		||||
				})
 | 
			
		||||
			},
 | 
			
		||||
			// 获取商品产品列表
 | 
			
		||||
			getProductList(){
 | 
			
		||||
				let params = {
 | 
			
		||||
					category_id:this.classId,
 | 
			
		||||
					page:this.page,
 | 
			
		||||
					size:this.size
 | 
			
		||||
				}
 | 
			
		||||
				this.$requst.post('/api/spu/list',params).then(res=>{
 | 
			
		||||
					if(res.code==0){
 | 
			
		||||
						// 设置总数
 | 
			
		||||
						this.total = res.data.total;
 | 
			
		||||
						if(this.page==1){this.$refs.refproduct.list=[];}
 | 
			
		||||
						// 设置产品列表
 | 
			
		||||
						this.$refs.refproduct.list = [...this.$refs.refproduct.list,...res.data.list];
 | 
			
		||||
					}
 | 
			
		||||
				})
 | 
			
		||||
			},
 | 
			
		||||
			// 去商品详情
 | 
			
		||||
			goDetail(id){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue