cmy 3 днів тому
батько
коміт
cbcefd870b
2 змінених файлів з 43 додано та 6 видалено
  1. 10 2
      pages/index/components/news.vue
  2. 33 4
      pages/index/index.vue

+ 10 - 2
pages/index/components/news.vue

@@ -65,8 +65,16 @@
 				direction:this.dataConfig.direction?this.dataConfig.direction.type:0
 			};
 		},
-		created() {},
-		mounted() {},
+		created() {
+		},
+		mounted() {
+			this.$emit('onNews',this.itemNew);
+		},
+		watch: {
+			itemNew(newValue, oldValue) {
+				this.$emit('onNews',newValue)
+			}
+		},
 		methods: {
 			moreTab(url){
 				this.$util.JumpPath(url);

+ 33 - 4
pages/index/index.vue

@@ -8,7 +8,7 @@
 			<view class="index">
 				<!-- #ifdef H5 -->
 				<view v-for="(item, index) in styleConfig" :key="index">
-					<component :is="item.name" :index="index" :dataConfig="item" @changeBarg="changeBarg"
+					<component :is="item.name" :index="index" :dataConfig="item" @changeBarg="changeBarg" @onNews="onNews"
 						@detail="goDetail" :isSortType="isSortType" @bindSortId="bindSortId" @bindHeight="bindHeight"
 						:isFixed="isFixed" :productVideoStatus='product_video_status' :isScrolled="isScrolled">
 					</component>
@@ -52,7 +52,7 @@
 					</liveBroadcast>
 					<menus v-if="item.name == 'menus'" :dataConfig="item" :isSortType="isSortType"></menus>
 					<!-- 实时消息 -->
-					<news v-if="item.name == 'news'" :dataConfig="item" :isSortType="isSortType"></news>
+					<news v-if="item.name == 'news'" @onNews="onNews"   :dataConfig="item" :isSortType="isSortType"></news>
 					<!-- 图片库 -->
 					<pictureCube v-if="item.name == 'pictureCube'" :dataConfig="item" :isSortType="isSortType">
 					</pictureCube>
@@ -183,7 +183,7 @@
 				<view class="btn" @click="reconnect">重新连接</view>
 			</view>
 		</view>
-	</view>
+		</view>
 </template>
 
 <script>
@@ -271,7 +271,9 @@
 	import Loading from '@/components/Loading/index.vue';
 	import recommend from '@/components/recommend';
 	export default {
-		computed: mapGetters(['isLogin', 'uid', 'cartNum']),
+		computed:{ 
+			...mapGetters(['isLogin', 'uid', 'cartNum']),
+		},
 		mixins: [colors],
 		components: {
 			skeletons,
@@ -313,6 +315,7 @@
 		},
 		data() {
 			return {
+				newsd:'',
 				showSkeleton: true, //骨架屏显示隐藏
 				styleConfig: [],
 				loading: false,
@@ -473,6 +476,29 @@
 		onReady() {},
 		methods: {
 			...mapMutations(['SET_AUTOPLAY']),
+			onNews(item){
+				this.newsd ={
+					title:item[0].chiild[0].val,
+					link:item[0].chiild[1].val,
+				} ;
+				let newsId = uni.getStorageSync("news");
+				if(newsId!=this.newsd.title){
+					uni.setStorageSync("news",this.newsd.title);
+					uni.showModal({
+						title: '您有一条消息',
+						content: this.newsd.title,
+						cancelText: '关闭',
+						confirmText: '立即查看',
+						success: res => {
+							uni.navigateTo({
+								url:this.newsd.link
+							})
+						},
+						fail: () => {},
+						complete: () => {}
+					});
+				}
+			},
 			// 授权关闭
 			// authColse: function(e) {
 			//   this.isShowAuth = e
@@ -777,6 +803,7 @@
 			},
 			getDiyData() {
 				getDiy(0).then(res => {
+					console.log(res, '55555555')
 					uni.setStorageSync('diyData', JSON.stringify(res.data));
 					this.setDiyData(res.data);
 				}).catch(error => {
@@ -798,8 +825,10 @@
 			},
 			diyData() {
 				let diyData = uni.getStorageSync('diyData');
+				console.log(JSON.parse(diyData), 'diyData');
 				if (diyData) {
 					getDiyVersion(0).then(res => {
+						console.log(res, '5555555555555')
 						let diyVersion = uni.getStorageSync('diyVersion');
 						if ((res.data.version + '0') === diyVersion) {
 							this.setDiyData(JSON.parse(diyData));