소스 검색

feat: 首页分享、商品分享

Moss 1 년 전
부모
커밋
b8a37e1b47
4개의 변경된 파일106개의 추가작업 그리고 49개의 파일을 삭제
  1. 57 41
      src/pages/goods/detail.vue
  2. 7 5
      src/pages/goods/list.vue
  3. 41 2
      src/pages/index/index.vue
  4. 1 1
      src/pages/mine/myIssue/list.vue

+ 57 - 41
src/pages/goods/detail.vue

@@ -1,5 +1,4 @@
 <template>
-  <!-- #ifdef H5 -->
   <view>
     <Loading
     	:type="3"
@@ -21,7 +20,7 @@
           </view>
         </view>
         <view class="btns">
-          <u-button type="warning" text="分享好友" class="share"></u-button>
+          <u-button type="warning" text="分享好友" class="share" open-type="share"></u-button>
           <u-button type="error" text="立即联系" class="contact" @click="toContact" v-if="!isMine"></u-button>
           <u-button type="primary" text="立即购买" class="buy" @click="toBuy" v-if="!isMine && detail.amount" :disabled="detail.status === 4"></u-button>
         </view>
@@ -84,8 +83,12 @@
             <view class="left">{{item.message}}</view>
             <view class="right" @tap="handelReply(item)"><text class="iconfont icon-bianji"></text><text>回复</text></view>
           </view>
-          <view class="reply">
-            <view class="it" v-for="(it, idx) in item.goodsMessageList" :key="idx" @tap="handelReply(it)">{{it.userName}}回复{{it.replyNickName}}:{{it.message}}</view>
+          <view class="reply" v-if="item.goodsMessageList && item.goodsMessageList.length > 0">
+            <view class="it" v-for="(it, idx) in item.goodsMessageList" :key="idx" @tap="handelReply(it)">
+              <text class="name">{{it.userName}}</text>
+              <text class="text">回复</text>
+              <text class="name">{{it.replyNickName}}</text>:{{it.message}}
+            </view>
           </view>
         </view>
       </view>
@@ -132,14 +135,10 @@
       </view>
     </zj-dialog-box>
   </view>
-  <!-- #endif -->
-  <!-- #ifndef H5 -->
-  <web-view :src="webViewHref('/pages/goods/detail', pam)"></web-view>
-  <!-- #endif -->
+
 </template>
 
 <script>
-  // #ifdef H5
 	import zjDialogBox from "@/components/zj-dialog/zj-dialog-box.vue";
 	import zjDialogRemark from '@/components/zj-dialog/zj-dialog-remark.vue';
   import zjUpload from '@/components/zj-upload/index.vue'
@@ -180,10 +179,36 @@
 
     computed: {
       isMine() {
-        return this.$store.state.user.userId === this.detail.userId;
+        if(this.detail) {
+          return this.$store.state.user.userId === this.detail.userId;
+        }
+        else {
+          return false;
+        }
       }
     },
 
+    onShareAppMessage(options) {
+    	if (options && options.from == 'button') {
+    		// 来自页面内的转发按钮
+    	} else {
+    		// 点击微信右上角的分享按钮
+    	}
+    	return {
+    		title: '分享商品「' + this.detail.title + '」',
+    		imageUrl: this.imageUrl + this.detail.goodsFiles[0].imgUrl,
+    		path: '/pages/goods/detail?id=' + this.id,
+    		query: {
+    			// id: this.goodsId,
+    		},
+    		success: function(res) {
+    			if(res.errMsg == 'shareAppMessage:ok'){
+    				this.$successToast('分享完成');
+    			}
+    		}
+    	}
+    },
+
     onLoad({id}) {
       this.id = id;
       this.getDetail();
@@ -322,42 +347,18 @@
         else if(e.value === 3) {
           this.$navToPage({
             url: `/pages/issue/index?goodsId=${this.id}&type=1`
-          })
+          }, 'switchTab')
         }
         // 编辑
         else if(e.value === 4) {
           this.$navToPage({
             url: `/pages/issue/index?goodsId=${this.id}&type=2`
-          })
+          }, 'switchTab')
         }
       }
     }
 
   }
-  // #endif
-  // #ifndef H5
-  import zjDialogBox from "@/components/zj-dialog/zj-dialog-box.vue";
-  import zjDialogRemark from '@/components/zj-dialog/zj-dialog-remark.vue';
-  import zjUpload from '@/components/zj-upload/index.vue'
-
-  export default {
-    components: {
-      zjDialogBox,
-      zjDialogRemark,
-      zjUpload
-    },
-
-    data() {
-      return {
-        pam: {},
-      }
-    },
-
-    onLoad(pam) {
-      this.pam = pam;
-    },
-  }
-  // #endif
 </script>
 
 <style lang="scss" scoped>
@@ -567,6 +568,8 @@
       align-items: center;
       .left {
         font-size: 28rpx;
+        word-break: break-all;
+        line-height: 36rpx;
       }
       .right {
         flex-shrink: 0;
@@ -584,12 +587,24 @@
       }
     }
     .reply {
+      background: #f5f5f5;
+      border-radius: 8rpx;
+      padding: 16rpx 20rpx;
+      margin-top: 20rpx;
       .it {
-        margin-top: 20rpx;
+        margin-top: 16rpx;
         font-size: 24rpx;
-        color: $sec-font;
-        border-left: 4rpx solid $theme-color;
-        padding-left: 8rpx;
+        line-height: 30rpx;
+        word-break: break-all;
+        &:first-child {
+          margin-top: 0;
+        }
+        .name {
+          color: $theme-color;
+        }
+        .text {
+          color: $sec-font;
+        }
       }
     }
   }
@@ -611,11 +626,12 @@
   display: flex;
   align-items: center;
   justify-content: flex-end;
-  .u-button {
+  ::v-deep .u-button {
     width: auto;
     height: 60rpx;
     margin: 0;
     margin-left: 20rpx;
+    padding: 0 30rpx;
   }
 }
 </style>

+ 7 - 5
src/pages/goods/list.vue

@@ -114,8 +114,6 @@
     },
 
     async onLoad({categoryId, keyword}) {
-      console.log(categoryId);
-      console.log(keyword);
       this.categoryId = categoryId;
       this.keyword = keyword;
       await this.getCategory();
@@ -137,12 +135,16 @@
       //获取列表数据
       async getList() {
         let params = {};
-        if(this.tabCurrent === 1) {
+        if (this.tabCurrent === 0) {
+          params.status = '1,2,4';
+        }if (this.tabCurrent === 1) {
           params.status = '1';
-        }else if(this.tabCurrent === 2) {
+        } else if (this.tabCurrent === 2) {
+          params.status = '1,2,4';
           params.lng = this.lng;
           params.lat = this.lat;
-        }else if(this.tabCurrent === 3) {
+        } else if (this.tabCurrent === 3) {
+          params.status = '1,2,4';
           params.visitOrderBy = 'YES';
         }
 

+ 41 - 2
src/pages/index/index.vue

@@ -78,11 +78,12 @@
   </view>
   <!-- #endif -->
   <!-- #ifndef H5 -->
-  <web-view :src="webViewHref('/pages/index/index')"></web-view>
+  <web-view :src="webViewHref('/pages/index/index', pam)"></web-view>
   <!-- #endif -->
 </template>
 
 <script>
+  // #ifdef H5
   export default {
     data() {
       return {
@@ -174,12 +175,16 @@
       //获取列表数据
       async getList() {
         let params = {};
-        if (this.tabCurrent === 1) {
+        if (this.tabCurrent === 0) {
+          params.status = '1,2,4';
+        }if (this.tabCurrent === 1) {
           params.status = '1';
         } else if (this.tabCurrent === 2) {
+          params.status = '1,2,4';
           params.lng = this.lng;
           params.lat = this.lat;
         } else if (this.tabCurrent === 3) {
+          params.status = '1,2,4';
           params.visitOrderBy = 'YES';
         }
 
@@ -248,6 +253,40 @@
 
     }
   }
+  // #endif
+  // #ifndef H5
+  export default {
+    data() {
+      return {
+        pam: {},
+      }
+    },
+
+    onLoad(pam) {
+      this.pam = pam;
+    },
+
+    onShareAppMessage(options) {
+    	if (options && options.from == 'button') {
+    		// 来自页面内的转发按钮
+    	} else {
+    		// 点击微信右上角的分享按钮
+    	}
+    	return {
+    		title: '分享小程序',
+    		path: '/pages/index/index',
+    		query: {
+    			// id: this.goodsId,
+    		},
+    		success: function(res) {
+    			if(res.errMsg == 'shareAppMessage:ok'){
+    				this.$successToast('分享完成');
+    			}
+    		}
+    	}
+    },
+  }
+  // #endif
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
src/pages/mine/myIssue/list.vue

@@ -128,7 +128,7 @@
       //获取列表数据
       async getList() {
         const statusMap = {
-          0: 1,
+          0: '',
           1: 4,
           2: 0
         }