vuex
This commit is contained in:
		
						commit
						46da0894b4
					
				@ -1,6 +1,14 @@
 | 
			
		||||
export default {
 | 
			
		||||
    init(vm){
 | 
			
		||||
        return {
 | 
			
		||||
			// 获取首页轮播
 | 
			
		||||
			getIndexSwiper() {
 | 
			
		||||
				return vm.$u.post('adv/indexadv');
 | 
			
		||||
			},
 | 
			
		||||
			// 获取首页轮播
 | 
			
		||||
			getZhiBoSwiper() {
 | 
			
		||||
				return vm.$u.post('adv/divebroadcastxadv');
 | 
			
		||||
			},
 | 
			
		||||
			// 发现列表
 | 
			
		||||
			getArticlelist({ page, value, store_id, member_id, is_video_img }){
 | 
			
		||||
                return vm.$u.post('article/articlelist', {
 | 
			
		||||
@ -29,6 +37,12 @@ export default {
 | 
			
		||||
					article_id: article_id,
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			// 直播列表
 | 
			
		||||
			// getZhiboList() {
 | 
			
		||||
			// 	return vm.$u.post('article/articleCollect', {
 | 
			
		||||
			// 		article_id: article_id,
 | 
			
		||||
			// 	});
 | 
			
		||||
			// },
 | 
			
		||||
			// 屏蔽用户
 | 
			
		||||
			articleAddShield({ article_id, member_id }) {
 | 
			
		||||
				return vm.$u.post('article/articleAddShield', {
 | 
			
		||||
@ -129,8 +143,14 @@ export default {
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			// 商品详情
 | 
			
		||||
			// getGoodsDetails({ id }) {
 | 
			
		||||
			// 	return vm.$u.post('Goods/goodDetails', {
 | 
			
		||||
			// 		goods_id: id
 | 
			
		||||
			// 	});
 | 
			
		||||
			// },
 | 
			
		||||
			// 商品详情
 | 
			
		||||
			getGoodsDetails({ id }) {
 | 
			
		||||
				return vm.$u.post('Goods/goodDetails', {
 | 
			
		||||
				return vm.$u.post('goods/goodsInfo', {
 | 
			
		||||
					goods_id: id
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
@ -149,7 +169,23 @@ export default {
 | 
			
		||||
				return vm.$u.post('goods/goodsInfo', {
 | 
			
		||||
					goods_id: id
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
			},
 | 
			
		||||
			// 秒杀推荐
 | 
			
		||||
			recommendedSpike() {
 | 
			
		||||
				return vm.$u.post('Spike/recommendedSpike');
 | 
			
		||||
			},
 | 
			
		||||
			// 秒杀详情
 | 
			
		||||
			getSpikeInfo({ id }) {
 | 
			
		||||
				return vm.$u.post('Spike/spikeInfo', {
 | 
			
		||||
					groupbuy_id: id
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
			// 秒杀列表
 | 
			
		||||
			getSpikeList({ page }) {
 | 
			
		||||
				return vm.$u.post('spike/spikeList', {
 | 
			
		||||
					page: page
 | 
			
		||||
				});
 | 
			
		||||
			},
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
@ -302,9 +302,19 @@ export default {
 | 
			
		||||
			delMessage({ type }) {
 | 
			
		||||
				return vm.$u.post('/message/readMessage', { type });
 | 
			
		||||
			},
 | 
			
		||||
<<<<<<< HEAD
 | 
			
		||||
			// 已读消息
 | 
			
		||||
			refreshToken({  }) {
 | 
			
		||||
				return vm.$u.post('/Auth/refreshToken', { });
 | 
			
		||||
=======
 | 
			
		||||
			// 屏蔽列表
 | 
			
		||||
			articlShieldList() {
 | 
			
		||||
				return vm.$u.post('/Article/articlShieldList');
 | 
			
		||||
			},
 | 
			
		||||
			// 取消屏蔽
 | 
			
		||||
			articleDelShield({ id }) {
 | 
			
		||||
				return vm.$u.post('article/articleDelShield', { member_id: id });
 | 
			
		||||
>>>>>>> 76a0e7e8bdfc42e7e46cc74d2cfb43fc4f544e7b
 | 
			
		||||
			},
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										41
									
								
								common/store/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								common/store/index.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
			
		||||
// 商品相关
 | 
			
		||||
const moduleA = {
 | 
			
		||||
	state: () => ({
 | 
			
		||||
		count: 0
 | 
			
		||||
	}),
 | 
			
		||||
	mutations: {
 | 
			
		||||
		increment (state) {
 | 
			
		||||
			// 这里的 `state` 对象是模块的局部状态
 | 
			
		||||
			state.count++
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	getters: {
 | 
			
		||||
		doubleCount (state) {
 | 
			
		||||
			return state.count * 2
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
// 用户相关
 | 
			
		||||
const moduleB = {
 | 
			
		||||
	state: () => ({
 | 
			
		||||
		count: 0
 | 
			
		||||
	}),
 | 
			
		||||
	mutations: {
 | 
			
		||||
		increment (state) {
 | 
			
		||||
			// 这里的 `state` 对象是模块的局部状态
 | 
			
		||||
			state.count++
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	getters: {
 | 
			
		||||
		doubleCount (state) {
 | 
			
		||||
			return state.count * 2
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
  
 | 
			
		||||
const store = new Vuex.Store({
 | 
			
		||||
	modules: {
 | 
			
		||||
		shop: moduleA,
 | 
			
		||||
		user: moduleB
 | 
			
		||||
	}
 | 
			
		||||
})
 | 
			
		||||
@ -5,25 +5,35 @@
 | 
			
		||||
            <text>点击查看更多></text>
 | 
			
		||||
        </view>
 | 
			
		||||
        <view class="connect">
 | 
			
		||||
            <view class="time">
 | 
			
		||||
                <image></image>
 | 
			
		||||
                <text>12:00</text>
 | 
			
		||||
            <view class="time" v-if="type=='spike'">
 | 
			
		||||
                <image src="/static/image/common/15.png"></image>
 | 
			
		||||
                <text>{{ info.groupbuy_starttime_histime }}</text>
 | 
			
		||||
            </view>
 | 
			
		||||
            <view class="info">
 | 
			
		||||
                <text>修身套头上衣</text>
 | 
			
		||||
                <text class="u-line-2">珂莱蒂尔雪纺衫2020春装新简约百搭V领蕾丝九分... </text>
 | 
			
		||||
                <text class="u-line-1">{{ info.groupbuy_name }}</text>
 | 
			
		||||
                <text class="u-line-2">{{ info.goods_name }}</text>
 | 
			
		||||
                <view>
 | 
			
		||||
                    <text>¥99</text>
 | 
			
		||||
                    <text>¥299</text>
 | 
			
		||||
                    <text>¥{{ info.groupbuy_price }}</text>
 | 
			
		||||
                    <text>¥{{ info.goods_price }}</text>
 | 
			
		||||
                </view>
 | 
			
		||||
            </view>
 | 
			
		||||
            <image class="img"></image>
 | 
			
		||||
            <image class="img" :src="info.groupbuy_image1"></image>
 | 
			
		||||
        </view>
 | 
			
		||||
    </view>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
    name:"recommend"
 | 
			
		||||
	name:"recommend",
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			info: {}
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	props: ['recommendData', 'type'],
 | 
			
		||||
	created() {
 | 
			
		||||
		this.info = this.recommendData;
 | 
			
		||||
		console.log(this.recommendData);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
@ -48,7 +58,7 @@ export default {
 | 
			
		||||
            display: flex;
 | 
			
		||||
            flex-direction: column;
 | 
			
		||||
            align-items: center;
 | 
			
		||||
            margin-right: 18rpx;
 | 
			
		||||
            margin-right: 28rpx;
 | 
			
		||||
            justify-content: center;
 | 
			
		||||
            >image{
 | 
			
		||||
                width: 90rpx;
 | 
			
		||||
@ -62,6 +72,7 @@ export default {
 | 
			
		||||
            flex-shrink: 0;
 | 
			
		||||
        }
 | 
			
		||||
        .info{
 | 
			
		||||
			width: 340rpx;
 | 
			
		||||
            display: flex;
 | 
			
		||||
            flex-direction: column;
 | 
			
		||||
            >text:nth-child(1){
 | 
			
		||||
@ -87,6 +98,7 @@ export default {
 | 
			
		||||
                    font-size: 24rpx;
 | 
			
		||||
                    color: #999;
 | 
			
		||||
                    margin-left: 33rpx;
 | 
			
		||||
					text-decoration: line-through;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										7
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.js
									
									
									
									
									
								
							@ -1,12 +1,17 @@
 | 
			
		||||
import Vue from 'vue'
 | 
			
		||||
import App from './App'
 | 
			
		||||
import uView from "uview-ui";
 | 
			
		||||
// import Vuex from 'vuex'
 | 
			
		||||
Vue.config.productionTip = false
 | 
			
		||||
Vue.use(uView);
 | 
			
		||||
// Vue.use(Vuex);
 | 
			
		||||
App.mpType = 'app'
 | 
			
		||||
 | 
			
		||||
// import store from '@/common/store/index.js'
 | 
			
		||||
 | 
			
		||||
const app = new Vue({
 | 
			
		||||
    ...App
 | 
			
		||||
	...App,
 | 
			
		||||
	// store
 | 
			
		||||
})
 | 
			
		||||
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
 | 
			
		||||
import httpInterceptor from '@/common/http.interceptor.js'
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,11 @@
 | 
			
		||||
  "author": "",
 | 
			
		||||
  "license": "ISC",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
<<<<<<< HEAD
 | 
			
		||||
    "uview-ui": "^1.5.0",
 | 
			
		||||
    "vuex": "^3.5.1"
 | 
			
		||||
=======
 | 
			
		||||
	"uview-ui": "^1.5.0"
 | 
			
		||||
>>>>>>> 76a0e7e8bdfc42e7e46cc74d2cfb43fc4f544e7b
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -67,15 +67,16 @@ export default {
 | 
			
		||||
            this.id = id;
 | 
			
		||||
			this.$u.api.getGoodsDetails({ id: id }).then((res)=>{
 | 
			
		||||
				if (res.errCode == 0) {
 | 
			
		||||
					this.goodsInfo = res.data;
 | 
			
		||||
					this.goodsInfo.goods_image_mobile.forEach(item => {
 | 
			
		||||
					this.goodsInfo = res.data.goods;
 | 
			
		||||
					let list = [];
 | 
			
		||||
					res.data.goods_image[0].forEach(item => {
 | 
			
		||||
						let temp = {
 | 
			
		||||
							image: item
 | 
			
		||||
						}
 | 
			
		||||
						this.list.push(temp);
 | 
			
		||||
						list.push(temp);
 | 
			
		||||
					})
 | 
			
		||||
					this.list = list;
 | 
			
		||||
					// console.log(this.goodsInfo.mobile_body);
 | 
			
		||||
					
 | 
			
		||||
				}
 | 
			
		||||
            })
 | 
			
		||||
            this.$u.api.goodsInfo({id}).then((res)=>{
 | 
			
		||||
 | 
			
		||||
@ -1,19 +1,37 @@
 | 
			
		||||
<template>
 | 
			
		||||
	<view class="shield">
 | 
			
		||||
		<view class="shield-list" v-for="(item, index) in 5" :key="index">
 | 
			
		||||
		<view class="shield-list" v-for="(item, index) in userList" :key="index">
 | 
			
		||||
			<view class="infomation">
 | 
			
		||||
				<u-avatar :src="src" size="80"></u-avatar>
 | 
			
		||||
				<view class="nickname u-line-1">神的温柔</view>
 | 
			
		||||
				<u-avatar :src="item.member_avatar" size="80"></u-avatar>
 | 
			
		||||
				<view class="nickname u-line-1">{{ item.member_nickname }}</view>
 | 
			
		||||
			</view>
 | 
			
		||||
			<view class="btn">取消屏蔽</view>
 | 
			
		||||
			<view class="btn" @click="cancelArticleShield(item.member_id)">取消屏蔽</view>
 | 
			
		||||
		</view>
 | 
			
		||||
		<u-empty text="暂无屏蔽用户" mode="list" v-if="!userList.length" margin-top="280" color="#333"></u-empty>
 | 
			
		||||
	</view>
 | 
			
		||||
</template>
 | 
			
		||||
<script>
 | 
			
		||||
export default {
 | 
			
		||||
	data() {
 | 
			
		||||
		return {
 | 
			
		||||
			src: 'https://dmmall.sdbairui.com/uploads/home/avatar/avatar_19.jpg'
 | 
			
		||||
			src: 'https://dmmall.sdbairui.com/uploads/home/avatar/avatar_19.jpg',
 | 
			
		||||
			userList: [],
 | 
			
		||||
		}
 | 
			
		||||
	},
 | 
			
		||||
	onShow() {
 | 
			
		||||
		this.articlShieldList();
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
		articlShieldList() {
 | 
			
		||||
			this.$u.api.articlShieldList().then(res => {
 | 
			
		||||
				this.userList = res.data;
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 取消屏蔽
 | 
			
		||||
		cancelArticleShield(id) {
 | 
			
		||||
			this.$u.api.articleDelShield({ id: id }).then(res => {
 | 
			
		||||
				this.articlShieldList();
 | 
			
		||||
			})
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,8 @@
 | 
			
		||||
            <swiper-item>
 | 
			
		||||
                <scroll-view style="width:100%;height:100%" scroll-y="true">
 | 
			
		||||
                    <view class="box">
 | 
			
		||||
                        <indexad style="width:690rpx"></indexad>
 | 
			
		||||
                        <!-- <indexad style="width:690rpx"></indexad> -->
 | 
			
		||||
						<u-swiper mode="dot" :list="indexImageSwiper" name="adv_code"></u-swiper>
 | 
			
		||||
                        <view class="list">
 | 
			
		||||
                            <view >
 | 
			
		||||
                                <videoItem v-for="item in articleList.filter((_, index) => !(index&1))" :key="item.article_id" :item="item" @getArticlelist="getArticlelist"></videoItem>
 | 
			
		||||
@ -35,7 +36,7 @@
 | 
			
		||||
            <swiper-item>
 | 
			
		||||
                <scroll-view style="width:100%;height:100%" scroll-y="true">
 | 
			
		||||
                    <view class="box">
 | 
			
		||||
                        <indexad style="width:690rpx"></indexad>
 | 
			
		||||
                        <u-swiper mode="dot" :list="zhiboImageSwiper" name="adv_code"></u-swiper>
 | 
			
		||||
                        <view class="list">
 | 
			
		||||
                            <view >
 | 
			
		||||
                                <zhiboItem v-for="item in 10"></zhiboItem>
 | 
			
		||||
@ -185,6 +186,8 @@ export default {
 | 
			
		||||
			page: 0, // 0即第一页
 | 
			
		||||
			articleList: [],
 | 
			
		||||
			recommendList: [], // 推荐达人
 | 
			
		||||
			indexImageSwiper: [],
 | 
			
		||||
			zhiboImageSwiper: [],
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    components:{
 | 
			
		||||
@ -196,8 +199,24 @@ export default {
 | 
			
		||||
    onShow(){
 | 
			
		||||
	   this.getArticlelist();
 | 
			
		||||
	   this.getRecommendList();
 | 
			
		||||
	   this.getSwiper();
 | 
			
		||||
	   this.getZhiBoSwiper();
 | 
			
		||||
    },
 | 
			
		||||
    methods:{
 | 
			
		||||
		getSwiper() {
 | 
			
		||||
			this.$u.api.getIndexSwiper().then(res => {
 | 
			
		||||
				if(res.errCode == 0) {
 | 
			
		||||
					this.indexImageSwiper = res.data;
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		getZhiBoSwiper() {
 | 
			
		||||
			this.$u.api.getZhiBoSwiper().then(res => {
 | 
			
		||||
				if(res.errCode == 0) {
 | 
			
		||||
					this.zhiboImageSwiper = res.data;
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
        dianji(a){
 | 
			
		||||
            // console.log(a)
 | 
			
		||||
            if(typeof a == "object"){
 | 
			
		||||
 | 
			
		||||
@ -37,12 +37,12 @@
 | 
			
		||||
            <shopitem v-for="item in goodsClassify" :key="item.gc_id" :info="item" class="item"></shopitem>
 | 
			
		||||
        </view>
 | 
			
		||||
        <view class="hr" style="margin-top:80rpx"></view>
 | 
			
		||||
        <recommend></recommend>
 | 
			
		||||
        <view class="hr" style="margin-top:40rpx"></view>
 | 
			
		||||
        <seckill></seckill>
 | 
			
		||||
        <view class="hr" style="margin-top:40rpx"></view>
 | 
			
		||||
        <recommend></recommend>
 | 
			
		||||
        <recommend v-if="JSON.stringify(recommendedSpike) != '{}'" :recommendData="recommendedSpike" type="spike"></recommend>
 | 
			
		||||
        <view class="hr" style="margin-top:40rpx"></view>
 | 
			
		||||
        <seckill v-if="spikeList.length"></seckill>
 | 
			
		||||
        <view v-if="spikeList.length" class="hr" style="margin-top:40rpx"></view>
 | 
			
		||||
        <!-- <recommend></recommend> -->
 | 
			
		||||
        <!-- <view class="hr" style="margin-top:40rpx"></view> -->
 | 
			
		||||
        <group></group>
 | 
			
		||||
        <image class="lingquan"></image>
 | 
			
		||||
        <youhq></youhq>
 | 
			
		||||
@ -85,13 +85,20 @@ export default {
 | 
			
		||||
			list:[],
 | 
			
		||||
			goodsClassify: [], // 商品分类
 | 
			
		||||
			classifyList: [],
 | 
			
		||||
			goodsList: []
 | 
			
		||||
			goodsList: [],
 | 
			
		||||
			recommendedSpike: {}, // 秒杀推荐
 | 
			
		||||
			spikeList: [], // 全部秒杀列表
 | 
			
		||||
        }
 | 
			
		||||
	},
 | 
			
		||||
	onLoad() {
 | 
			
		||||
		this.getShopTopList();
 | 
			
		||||
		this.getGoodsRecommend();
 | 
			
		||||
	},
 | 
			
		||||
	onShow() {
 | 
			
		||||
		// console.log(this.$store.shop.state.count);
 | 
			
		||||
		this.getRecommendedSpike();
 | 
			
		||||
		this.getSpikeList();
 | 
			
		||||
	},
 | 
			
		||||
	methods: {
 | 
			
		||||
        sousuo(){
 | 
			
		||||
            // console.log(123)
 | 
			
		||||
@ -115,6 +122,18 @@ export default {
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		getRecommendedSpike() {
 | 
			
		||||
			this.$u.api.recommendedSpike().then(res => {
 | 
			
		||||
				if(res.errCode == 0) this.recommendedSpike = res.data;
 | 
			
		||||
				console.log(this.recommendedSpike);
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		// 全部秒杀
 | 
			
		||||
		getSpikeList() {
 | 
			
		||||
			this.$u.api.getSpikeList({ page: 0 }).then(res => {
 | 
			
		||||
				if(res.errCode == 0) this.spikeList = res.data;
 | 
			
		||||
			})
 | 
			
		||||
		},
 | 
			
		||||
		getGoodsRecommend() {
 | 
			
		||||
			this.$u.api.getGoodsRecommend({
 | 
			
		||||
				page: 1,
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								static/image/common/15.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/image/common/15.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 14 KiB  | 
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user