Jelajahi Sumber

添加首页

lijj 2 tahun lalu
induk
melakukan
873274a9c8

+ 43 - 6
admin/src/main/java/org/springblade/modules/ycwh/controller/wx/WXCollectInfoController.java

@@ -16,6 +16,8 @@
  */
 package org.springblade.modules.ycwh.controller.wx;
 
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -65,18 +67,53 @@ public class WXCollectInfoController extends BladeController {
 	 * 名菜名点名店收藏 分页
 	 */
 	@GetMapping("/list")
-	@ApiOperationSupport(order = 2)
+	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "分页", notes = "传入collectInfo")
 	public R<IPage<CollectInfoVO>> list(@ApiIgnore @RequestParam Map<String, Object> collectInfo, Query query) {
-//		BladeUser user = AuthUtil.getUser();
-//		if (Func.isEmpty(user)) {
-//			return R.fail("未登录");
-//		}
+		BladeUser user = AuthUtil.getUser();
+		if (Func.isEmpty(user)) {
+			return R.fail("未登录");
+		}
 		QueryWrapper<CollectInfoEntity> qw = Condition.getQueryWrapper(collectInfo, CollectInfoEntity.class);
-//		qw.eq("create_user", user.getUserId());
+		qw.eq("create_user", user.getUserId());
 		IPage<CollectInfoEntity> pages = collectInfoService.page(Condition.getPage(query), qw);
 		return R.data(CollectInfoWrapper.build().pageVO(pages));
 	}
 
+	/**
+	 * 名菜名点名店收藏 新增
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "新增", notes = "传入collectInfo")
+	public R save(@Valid @RequestBody CollectInfoEntity collectInfo) {
+		BladeUser user = AuthUtil.getUser();
+		if (Func.isEmpty(user)) {
+			return R.fail("未登录");
+		}
+		if (Func.isEmpty(collectInfo.getCollectId()) || Func.isEmpty(collectInfo.getCollectType())) {
+			return R.fail("收藏内容有误,请重新再试");
+		}
+		collectInfo.setMemberId(user.getUserId());
+		return R.status(collectInfoService.save(collectInfo));
+	}
+
+	/**
+	 * 名菜名点名店收藏 删除
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "逻辑删除", notes = "id, 收藏类型")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam Long id, @ApiParam(value = "收藏类型", required = true) @RequestParam String collectionType) {
+		BladeUser user = AuthUtil.getUser();
+		if (Func.isEmpty(user)) {
+			return R.fail("未登录");
+		}
+		LambdaQueryWrapper<CollectInfoEntity> lqw = new LambdaQueryWrapper();
+		lqw.eq(CollectInfoEntity::getMemberId, user.getUserId());
+		lqw.eq(CollectInfoEntity::getCollectId, id);
+		lqw.eq(CollectInfoEntity::getCollectType, collectionType);
+		return R.status(collectInfoService.remove(lqw));
+	}
 
 }

+ 41 - 0
admin/src/main/java/org/springblade/modules/ycwh/enums/CollectionTypeEnum.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.ycwh.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 系统字典枚举类
+ *
+ * @author Chill
+ */
+@Getter
+@AllArgsConstructor
+public enum CollectionTypeEnum {
+
+	/**
+	 * 性别
+	 */
+	DISH("dish", "名菜"),
+	LOCATION("location", "名点"),
+	RESTAURANT("restaurant", "名店");
+
+	final String key;
+	final String label;
+
+}

+ 19 - 5
miniapp/api/collection.js

@@ -22,19 +22,33 @@ const getCollectionList = (current, size, vo) => {
   })
 }
 
-const getCollectionDetail = (id) => {
+const addCollection = (collectionId, collectionType) => {
   return http.request({
-    url: bizConst.basicPrefix + '/collect_info/detail',
-    method: 'GET',
+    url: bizConst.basicPrefix + '/collect_info/save',
+    method: 'POST',
+    header: {
+      'Tenant-Id': tenantId
+    },
+    params: {
+      collectionId, collectionType
+    },
+  })
+}
+
+const deleteCollection = (collectionId) => {
+  return http.request({
+    url: bizConst.basicPrefix + '/collect_info/remove',
+    method: 'POST',
     header: {
       'Tenant-Id': tenantId
     },
     params: {
-      id
+      id: collectionId
     },
   })
 }
 export default {
   getCollectionList,
-  getCollectionDetail
+  addCollection,
+  deleteCollection
 }

+ 36 - 40
miniapp/pages.json

@@ -11,7 +11,13 @@
         "navigationBarTitleText": "粤菜文化",
         "enablePullDownRefresh": false
       }
-    },{
+    }, {
+      "path": "pages/yuecai/home/index",
+      "style": {
+        "navigationBarTitleText": "首页",
+        "enablePullDownRefresh": false
+      }
+    }, {
       "path": "pages/yuecai/professional_style/index",
       "style": {
         "navigationBarTitleText": "专业风采",
@@ -65,40 +71,40 @@
         "navigationBarTitleText": "我的",
         "enablePullDownRefresh": false
       }
-    },  {
-			"path": "pages/yuecai/usercenter/profile/index",
-			"style": {
-				"navigationBarTitleText": "个人信息",
-				"enablePullDownRefresh": false
-			}
-		},{
+    }, {
+      "path": "pages/yuecai/usercenter/profile/index",
+      "style": {
+        "navigationBarTitleText": "个人信息",
+        "enablePullDownRefresh": false
+      }
+    }, {
       "path": "pages/yuecai/information/detail/index",
       "style": {
         "navigationBarTitleText": "资讯",
         "enablePullDownRefresh": false
       }
     }, {
-			"path": "pages/yuecai/usercenter/protocol/index",
-			"style": {
-				"navigationBarTitleText": "用户协议",
-				"enablePullDownRefresh": false
-			}
-		}, {
-			"path": "pages/yuecai/usercenter/privacy/index",
-			"style": {
-				"navigationBarTitleText": "隐私保护政策",
-				"enablePullDownRefresh": false
-			}
-		}, {
-			"path": "pages/yuecai/collection/index",
-			"style": {
-				"navigationBarTitleText": "我的收藏",
-				"enablePullDownRefresh": false
-			}
-		}
+      "path": "pages/yuecai/usercenter/protocol/index",
+      "style": {
+        "navigationBarTitleText": "用户协议",
+        "enablePullDownRefresh": false
+      }
+    }, {
+      "path": "pages/yuecai/usercenter/privacy/index",
+      "style": {
+        "navigationBarTitleText": "隐私保护政策",
+        "enablePullDownRefresh": false
+      }
+    }, {
+      "path": "pages/yuecai/collection/index",
+      "style": {
+        "navigationBarTitleText": "我的收藏",
+        "enablePullDownRefresh": false
+      }
+    }
   ],
   "globalStyle": {
-    "navigationBarTitleText": "",
+    "navigationBarTitleText": "粤菜文化",
     "navigationBarBackgroundColor": "@navBgColor",
     "navigationBarTextStyle": "@navTxtStyle",
     "backgroundColor": "@bgColor",
@@ -114,23 +120,13 @@
     "list": [{
       "iconPath": "@iconPath1",
       "selectedIconPath": "@selectedIconPath1",
-      "text": "专业风采",
-      "pagePath": "pages/yuecai/professional_style/index"
+      "text": "首页",
+      "pagePath": "pages/yuecai/home/index"
     }, {
       "iconPath": "@iconPath2",
       "selectedIconPath": "@selectedIconPath2",
-      "text": "名菜",
+      "text": "发现",
       "pagePath": "pages/yuecai/dish/index"
-    }, {
-      "iconPath": "@iconPath2",
-      "selectedIconPath": "@selectedIconPath2",
-      "text": "名点",
-      "pagePath": "pages/yuecai/location/index"
-    }, {
-      "iconPath": "@iconPath2",
-      "selectedIconPath": "@selectedIconPath2",
-      "text": "名店",
-      "pagePath": "pages/yuecai/restaurant/index"
     }, {
       "iconPath": "@iconPath2",
       "selectedIconPath": "@selectedIconPath2",

+ 30 - 6
miniapp/pages/yuecai/collection/index.vue

@@ -1,9 +1,9 @@
 <template>
   <view class="width-100 height-100 view-page">
-    <view class="p-10">
+    <!-- <view class="p-10">
       <u-search :clearabled="true" placeholder="请输入搜索关键字" v-model="keyword" :shape="square" search="doRefresh"
         @custom="doRefresh"></u-search>
-    </view>
+    </view> -->
     <u-list @scrolltolower="scrolltolower" height="calc(100% - 180px)" lowerThreshold="10">
       <u-list-item v-for="(item, index) in list" :key="index">
         <u-cell :title="item.name" @click="toDetail(item.id)">
@@ -24,6 +24,7 @@
     data() {
       return {
         page: {
+          loading: false,
           current: 1,
           size: 10,
           total: 0,
@@ -59,7 +60,6 @@
         this.getCollectionList();
       },
       getCollectionList() {
-
         if (this.page.status == 'loading' || this.page.status == 'nomore') {
           // 防止重复下拉
           return;
@@ -67,7 +67,7 @@
         this.page.status = 'loading';
         //
         this.$u.api.getCollectionList(this.page.current, this.page.size, {
-          name: this.keyword || ''
+          collectType: this.collectionType || ''
         }).then(res => {
           if (res.data.records && res.data.records.length > 0) {
             this.list.push(...res.data.records)
@@ -78,11 +78,35 @@
           } else {
             this.page.status = 'loadmore'
           }
+        }).catch(e=> {
+          this.page.status = 'loadmore'
         })
       },
       toDetail(id) {
-        uni.navigateTo({
-          url: "/pages/yuecai/dish/detail/index?id=" + id,
+        if (this.collectionType == 'dish') {
+          uni.navigateTo({
+            url: "/pages/yuecai/dish/detail/index?id=" + id,
+          })
+        } else if (this.collectionType == 'location') {
+          uni.navigateTo({
+            url: "/pages/yuecai/location/detail/index?id=" + id,
+          })
+        } else if (this.collectionType == 'restaurant') {
+          uni.navigateTo({
+            url: "/pages/yuecai/restaurant/detail/index?id=" + id,
+          })
+        }
+      },
+      deleteCollection(id, index) {
+        if (this.loading) {
+          return;
+        }
+        this.loading = true;
+        this.$u.api.deleteCollection(id).then(res => {
+          this.list.splice(index, 1);
+          this.loading = false;
+        }).catch(e => {
+          this.loading = false;
         })
       }
     },

+ 150 - 0
miniapp/pages/yuecai/home/index.vue

@@ -0,0 +1,150 @@
+<template>
+  <view class="width-100 height-100 view-page">
+    <view class="p-10 dis-flex flex-y-center flex-x-between">
+      <view class="icon-circle search-left-btn"></view>
+      <view class="width-100">
+        <u-search :clearabled="true" placeholder="请输入搜索关键字" v-model="keyword" :shape="square" search="doSearch"
+          @custom="doSearch" :showAction="false"></u-search>
+      </view>
+    </view>
+    <u-swiper height="185" :list="bannerList" @click="clickInfo" keyName="cover"></u-swiper>
+    <view class="p-l-r-30 p-t-30 dis-flex flex-x-around nav-btns">
+      <view class="nav-btn">
+        <view class="nav-btn-icon icon-circle"></view>
+        <view class="nav-btn-text">专业风采</view>
+      </view>
+      <view class="nav-btn">
+        <view class="nav-btn-icon icon-circle"></view>
+        <view class="nav-btn-text">名菜</view>
+      </view>
+      <view class="nav-btn">
+        <view class="nav-btn-icon icon-circle"></view>
+        <view class="nav-btn-text">名点</view>
+      </view>
+      <view class="nav-btn">
+        <view class="nav-btn-icon icon-circle"></view>
+        <view class="nav-btn-text">名店</view>
+      </view>
+    </view>
+    <view class="info-list">
+      <view class="dis-flex flex-x-between info-item" v-for="item in 10">
+        <view class="info-pic"></view>
+        <view class="info-view">
+          <view class="info-title">
+            标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题标题
+          </view>
+          <view class="dis-flex info-bottom">
+            <view>10月07日</view>
+            <view>点赞</view>
+            <view>阅读量</view>
+          </view>
+        </view>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script>
+  import themeMixins from '@/pages/yuecai/mixins/themeMixins.js';
+  export default {
+    mixins: [themeMixins],
+    data() {
+      return {
+        keyword: '',
+        bannerList: [],
+        page: {},
+        keyword: '',
+        list: []
+      }
+    },
+    onLoad(options) {},
+    onShow() {
+      this.getBanners()
+    },
+    methods: {
+      getBanners() {
+        this.$u.api.getInformationList(0, 6, {}).then(res => {
+          this.bannerList = res.data.records || []
+        })
+      },
+      clickInfo(index) {
+        if (index < 0) {
+          return;
+        }
+        uni.navigateTo({
+          url: "/pages/yuecai/information/detail/index?id=" + this.bannerList[index].id,
+        })
+      },
+      doSearch() {
+
+      }
+    },
+  }
+</script>
+
+<style scoped lang="scss">
+  .search-left-btn {
+    min-width: 28px;
+    height: 28px;
+    margin-right: 5px;
+    box-sizing: border-box;
+  }
+
+  .icon-circle {
+    border-radius: 50%;
+    border: 1rpx solid #787878;
+  }
+
+  .nav-btns {
+    border-bottom: 1rpx solid #787878;
+    margin-bottom: 20rpx;
+    padding-bottom: 50rpx;
+
+    .nav-btn {
+      width: 150rpx;
+
+      .nav-btn-icon {
+        margin: auto;
+        width: 110rpx;
+        height: 110rpx;
+      }
+
+      .nav-btn-text {
+        width: 100%;
+        text-align: center;
+      }
+    }
+  }
+
+  .info-list {
+    .info-item {
+      padding: 20rpx;
+
+      .info-pic {
+        width: 160rpx;
+        height: 160rpx;
+        background: bisque;
+      }
+
+      .info-view {
+        width: calc(100% - 180rpx);
+
+        .info-title {
+          overflow: hidden;
+          text-overflow: -o-ellipsis-lastline;
+          overflow: hidden;
+          text-overflow: ellipsis;
+          display: -webkit-box;
+          -webkit-line-clamp: 3;
+          line-clamp: 3;
+          -webkit-box-orient: vertical;
+        }
+
+        .info-bottom {
+          color: #787878;
+          margin-top: 10rpx;
+        }
+      }
+    }
+  }
+</style>

+ 1 - 1
miniapp/pages/yuecai/professional_style/index.vue

@@ -89,7 +89,7 @@
       },
       toDetail(id) {
         uni.navigateTo({
-          url: "/pages/yuecai/professional_style/detail/index" + id,
+          url: "/pages/yuecai/professional_style/detail/index?id=" + id,
         })
       }
     },

+ 3 - 3
miniapp/pages/yuecai/usercenter/index.vue

@@ -50,15 +50,15 @@
 					[{
 						icon: '',
 						text: '名菜收藏',
-						url: '/pages/yuecai/collection/index?type=1',
+						url: '/pages/yuecai/collection/index?type=dish',
 					}, {
 						icon: '',
 						text: '名点收藏',
-						url: '/pages/yuecai/collection/index?type=1',
+						url: '/pages/yuecai/collection/index?type=location',
 					}, {
 						icon: '',
 						text: '名店收藏',
-						url: '/pages/yuecai/collection/index?type=1',
+						url: '/pages/yuecai/collection/index?type=restaurant',
 					}],
 					[{
 						icon: '',

+ 1 - 1
miniapp/utils/func.js

@@ -16,7 +16,7 @@ const install = (Vue, vm) => {
 	//跳到首页。所有地方都不要写死这个页面的地址,统一由这个方法管理
 	const toHome = () => {
 		uni.switchTab({
-			url: '/pages/yuecai/professional_style/index'
+			url: '/pages/yuecai/home/index'
 		})
 	}