Explorar el Código

修复用户主页的bug,浏览图片大图

nnkwrik hace 6 años
padre
commit
09c8aa81f0

+ 1 - 1
goods-service/src/main/java/io/github/nnkwrik/goodsservice/controller/UserController.java

@@ -120,7 +120,7 @@ public class UserController {
 
         Integer soldCount = goodsService.getSellerHistory(userId);
         LinkedHashMap<String, List<Goods>> userHistory = userService.getUserHistoryList(userId, page, size);
-        UserPageVo vo = new UserPageVo(user, userHistory,soldCount);
+        UserPageVo vo = new UserPageVo(user, userHistory, soldCount);
         log.info("浏览用户id=[{}],昵称=[{}]的首页,搜索到{}天的记录", user.getOpenId(), user.getNickName(), userHistory.size());
 
         return Response.ok(vo);

+ 1 - 0
goods-service/src/main/java/io/github/nnkwrik/goodsservice/service/impl/UserServiceImpl.java

@@ -88,6 +88,7 @@ public class UserServiceImpl implements UserService {
     public LinkedHashMap<String, List<Goods>> getUserHistoryList(String userId, int page, int size) {
         PageHelper.startPage(page, size);
         List<GoodsExample> userHistoryList = userMapper.getUserHistoryList(userId);
+        if (userHistoryList.size() < 1) return new LinkedHashMap<>();
 
         LinkedHashMap<String, List<Goods>> result = new LinkedHashMap<>();
 

+ 11 - 197
wx-front/pages/goods/goods.js

@@ -9,12 +9,7 @@ Page({
     id: 0,
     goods: {},
     gallery: [],
-    // attribute: [],
-    // issueList: [],
     comment: [],
-    // brand: {},
-    // specificationList: [],
-    // productList: [],
     isSeller:false,
     seller: {},
     sellerDates: 0,
@@ -22,9 +17,7 @@ Page({
     relatedGoods: [],
     cartGoodsCount: 0,
     userHasCollect: 0,
-    number: 1,
-    checkedSpecText: '请选择规格数量',
-    openAttr: false,
+
     openComment: false,
     openDelete:false,
     replyId: '',
@@ -125,114 +118,7 @@ Page({
     });
 
   },
-  // clickSkuValue: function (event) {
-  //   let that = this;
-  //   let specNameId = event.currentTarget.dataset.nameId;
-  //   let specValueId = event.currentTarget.dataset.valueId;
-
-  //   //判断是否可以点击
-
-  //   //TODO 性能优化,可在wx:for中添加index,可以直接获取点击的属性名和属性值,不用循环
-  //   let _specificationList = this.data.specificationList;
-  //   for (let i = 0; i < _specificationList.length; i++) {
-  //     if (_specificationList[i].specification_id == specNameId) {
-  //       for (let j = 0; j < _specificationList[i].valueList.length; j++) {
-  //         if (_specificationList[i].valueList[j].id == specValueId) {
-  //           //如果已经选中,则反选
-  //           if (_specificationList[i].valueList[j].checked) {
-  //             _specificationList[i].valueList[j].checked = false;
-  //           } else {
-  //             _specificationList[i].valueList[j].checked = true;
-  //           }
-  //         } else {
-  //           _specificationList[i].valueList[j].checked = false;
-  //         }
-  //       }
-  //     }
-  //   }
-  //   this.setData({
-  //     'specificationList': _specificationList
-  //   });
-  //   //重新计算spec改变后的信息
-  //   this.changeSpecInfo();
-
-  //   //重新计算哪些值不可以点击
-  // },
-
-  //获取选中的规格信息
-  // getCheckedSpecValue: function () {
-  //   let checkedValues = [];
-  //   let _specificationList = this.data.specificationList;
-  //   for (let i = 0; i < _specificationList.length; i++) {
-  //     let _checkedObj = {
-  //       nameId: _specificationList[i].specification_id,
-  //       valueId: 0,
-  //       valueText: ''
-  //     };
-  //     for (let j = 0; j < _specificationList[i].valueList.length; j++) {
-  //       if (_specificationList[i].valueList[j].checked) {
-  //         _checkedObj.valueId = _specificationList[i].valueList[j].id;
-  //         _checkedObj.valueText = _specificationList[i].valueList[j].value;
-  //       }
-  //     }
-  //     checkedValues.push(_checkedObj);
-  //   }
-
-  //   return checkedValues;
-
-  // },
-  // //根据已选的值,计算其它值的状态
-  // setSpecValueStatus: function () {
-
-  // },
-  // //判断规格是否选择完整
-  // isCheckedAllSpec: function () {
-  //   return !this.getCheckedSpecValue().some(function (v) {
-  //     if (v.valueId == 0) {
-  //       return true;
-  //     }
-  //   });
-  // },
-  // getCheckedSpecKey: function () {
-  //   let checkedValue = this.getCheckedSpecValue().map(function (v) {
-  //     return v.valueId;
-  //   });
-
-  //   return checkedValue.join('_');
-  // },
-  // changeSpecInfo: function () {
-  //   let checkedNameValue = this.getCheckedSpecValue();
-
-  //   //设置选择的信息
-  //   let checkedValue = checkedNameValue.filter(function (v) {
-  //     if (v.valueId != 0) {
-  //       return true;
-  //     } else {
-  //       return false;
-  //     }
-  //   }).map(function (v) {
-  //     return v.valueText;
-  //   });
-  //   if (checkedValue.length > 0) {
-  //     this.setData({
-  //       'checkedSpecText': checkedValue.join(' ')
-  //     });
-  //   } else {
-  //     this.setData({
-  //       'checkedSpecText': '请选择规格数量'
-  //     });
-  //   }
-
-  // },
-  // getCheckedProductItem: function (key) {
-  //   return this.data.productList.filter(function (v) {
-  //     if (v.goods_specification_ids == key) {
-  //       return true;
-  //     } else {
-  //       return false;
-  //     }
-  //   });
-  // },
+
   onLoad: function(options) {
     // 页面初始化 options为页面跳转所带来的参数
     this.setData({
@@ -389,87 +275,15 @@ Page({
         });
     })
   },
-  // openCartPage: function () {
-  //   wx.switchTab({
-  //     url: '/pages/cart/cart',
-  //   });
-  // },
-  // addToCart: function () {
-  //   var that = this;
-  //   if (this.data.openAttr === false) {
-  //     //打开规格选择窗口
-  //     this.setData({
-  //       openAttr: !this.data.openAttr
-  //     });
-  //   } else {
-
-  //     //提示选择完整规格
-  //     if (!this.isCheckedAllSpec()) {
-  //       wx.showToast({
-  //         image: '/static/images/icon_error.png',
-  //         title: '请选择规格',
-  //         mask: true
-  //       });
-  //       return false;
-  //     }
-
-  //     //根据选中的规格,判断是否有对应的sku信息
-  //     let checkedProduct = this.getCheckedProductItem(this.getCheckedSpecKey());
-  //     if (!checkedProduct || checkedProduct.length <= 0) {
-  //       //找不到对应的product信息,提示没有库存
-  //       wx.showToast({
-  //         image: '/static/images/icon_error.png',
-  //         title: '库存不足',
-  //         mask: true
-  //       });
-  //       return false;
-  //     }
-
-  //     //验证库存
-  //     if (checkedProduct.goods_number < this.data.number) {
-  //       //找不到对应的product信息,提示没有库存
-  //       wx.showToast({
-  //         image: '/static/images/icon_error.png',
-  //         title: '库存不足',
-  //         mask: true
-  //       });
-  //       return false;
-  //     }
-
-  //     //添加到购物车
-  //     util.request(api.CartAdd, { goodsId: this.data.goods.id, number: this.data.number, productId: checkedProduct[0].id }, "POST")
-  //       .then(function (res) {
-  //         let _res = res;
-  //         if (_res.errno == 0) {
-  //           wx.showToast({
-  //             title: '添加成功'
-  //           });
-  //           that.setData({
-  //             openAttr: !that.data.openAttr,
-  //             cartGoodsCount: _res.data.cartTotal.goodsCount
-  //           });
-  //         } else {
-  //           wx.showToast({
-  //             image: '/static/images/icon_error.png',
-  //             title: _res.errmsg,
-  //             mask: true
-  //           });
-  //         }
-
-  //       });
-  //   }
-
-  // },
-  // cutNumber: function () {
-  //   this.setData({
-  //     number: (this.data.number - 1 > 1) ? this.data.number - 1 : 1
-  //   });
-  // },
-  // addNumber: function () {
-  //   this.setData({
-  //     number: this.data.number + 1
-  //   });
-  // }
+  preview: function (event) {
+    let url = event.currentTarget.dataset.url
+
+    wx.previewImage({
+      urls: [url] // 需要预览的图片http链接列表
+    })
+    console.log(url)
+  },
+
   onReachBottom: function() {
     console.log("拉到底")
     this.setData({

+ 2 - 2
wx-front/pages/goods/goods.wxml

@@ -1,7 +1,7 @@
 <view class="container">
   <swiper class="goodsimgs" indicator-dots="true" autoplay="true" interval="3000" duration="1000">
     <swiper-item wx:for="{{gallery}}" wx:key="{{item.id}}">
-      <image src="{{item.imgUrl}}" background-size="cover"></image>
+      <image bindtap='preview' data-url="{{item.imgUrl}}" src="{{item.imgUrl}}" background-size="cover"></image>
     </swiper-item>
   </swiper>
   <view class="location-time">
@@ -123,7 +123,7 @@
           <view wx:for="{{item.replyList}}" wx:for-index="iindex" wx:for-item="iitem" wx:key="{{iitem.id}}">
             <view class="reply-info">
               <view class="reply-user">
-                <navigator class='navimg-reply' url="/pages/user/user?userId={{iitem.simpleUser.openId}}" wx: style="background-image: url('{{item.simpleUser.avatarUrl}}')"></navigator>
+                <navigator class='navimg-reply' url="/pages/user/user?userId={{iitem.simpleUser.openId}}" wx: style="background-image: url('{{iitem.simpleUser.avatarUrl}}')"></navigator>
 
                 <text>{{iitem.simpleUser.nickName}}</text>
               </view>

+ 10 - 0
wx-front/pages/user/user.js

@@ -61,6 +61,16 @@ Page({
     });
   },
 
+  preview: function(event){
+    let url = event.currentTarget.dataset.url
+    url = url.slice(0,-3)+0 //浏览头像大图
+    
+    wx.previewImage({
+      urls: [url] // 需要预览的图片http链接列表
+    })
+    console.log(url)
+  },
+
 
   /**
    * 生命周期函数--监听页面加载

+ 3 - 3
wx-front/pages/user/user.wxml

@@ -1,9 +1,9 @@
 <view class="container">
 <view class='top'>
-  <view class='bg' style="background-image: url('https://i.postimg.cc/8z1C1k82/2144.jpg')">   </view>
+  <view class='bg' style="background-image: url('https://i.postimg.cc/bwmqpKjL/watercolour-1336856-640.jpg)">   </view>
     <view class="profile-info">
       <view class='img'>
-        <image class="avatar" src="{{userInfo.avatarUrl}}"></image>
+        <image bindtap='preview' data-url="{{userInfo.avatarUrl}}" class="avatar" src="{{userInfo.avatarUrl}}"></image>
       </view>
       <view class="info">
       <text class="name">{{userInfo.nickName}}</text>
@@ -13,7 +13,7 @@
   </view>
   </view>
 
-  <view class="userhis" wx:if='{{historyList}}'>
+  <view class="userhis" wx:if='{{historyList.lenght}}'>
     <view class="day-item" wx:for="{{historyList}}" wx:key="{{index}}">
       <view class="day-hd">{{index}}</view>
       <view class="day-list">

+ 12 - 10
wx-front/pages/user/user.wxss

@@ -14,7 +14,7 @@ page {
 }
 
 .bg {
-  /* filter: blur(7px) brightness(90%) contrast(70%); */
+  filter: blur(2px) ;
   width: 100%;
   height: 345rpx;
   position: absolute;
@@ -40,12 +40,15 @@ page {
 }
 
 .profile-info .avatar {
-  display: block;
-  height: 148rpx;
-  width: 148rpx;
-  border-radius: 50%;
-  margin-left: auto;
-  margin-right: auto;
+display:block;
+height:150rpx;
+width:150rpx;
+border-radius:50%;
+margin-left:auto;
+margin-right:auto;
+border:5rpx solid #fff;
+
+  
 }
 
 .profile-info .info {
@@ -58,9 +61,8 @@ page {
   display: block;
   height: 45rpx;
   line-height: 45rpx;
-  color: #555;
+  /* color: #555; */
   font-size: 37.5rpx;
-  /* margin-bottom: 10rpx; */
   margin-top: 20rpx;
 }
 
@@ -169,7 +171,7 @@ page {
 .result-empty {
   width: 100%;
   height: 100%;
-  padding-top: 300rpx;
+  padding-top:200rpx;
 }
 
 .result-empty .icon {