zhaoxiaohai 2 years ago
parent
commit
509f0b7088

+ 2 - 1
app.json

@@ -8,7 +8,8 @@
       "root": "packageA",
       "pages": [
         "market/index",
-        "market/detail"
+        "market/detail",
+        "shopping/index"
       ]
     }
   ],

+ 3 - 3
components/Yl_Files/index.js

@@ -1,7 +1,7 @@
 const _Http = getApp().globalData.http;
 import {
     fileList
-} from "../../utils/matchingFeilType";
+} from "../../utils/FormatTheAttachment";
 Component({
     properties: {
         files: {
@@ -17,7 +17,7 @@ Component({
         delete: Boolean
     },
     methods: {
-        /* 预览媒体 */
+        /* 预览媒体 */
         viewMedias(e) {
             const {
                 index,
@@ -28,7 +28,7 @@ Component({
                 sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
             })
         },
-        /* 预览文档 */
+        /* 预览文档 */
         viewFlies(e) {
             const {
                 item

+ 72 - 5
packageA/market/detail.js

@@ -1,21 +1,28 @@
 const _Http = getApp().globalData.http;
 
+import {
+  fileList
+} from "../../utils/FormatTheAttachment";
+
 Page({
   data: {
     loading: true
   },
   onLoad(options) {
-    console.log(options)
     if (options.id) this.setData({
-      sa_itemgroupid: options.id
+      sa_itemgroupid: options.id,
+      itemno: 'BM8270 0150000'
     })
     this.getDetail()
   },
+
+  /* 获取详情 */
   getDetail() {
     _Http.basic({
-      "id": "20220926142403",
+      "id": "20221223165503",
       "content": {
-        "sa_itemgroupid": this.data.sa_itemgroupid
+        "sa_itemgroupid": this.data.sa_itemgroupid,
+        itemno: this.data.itemno
       }
     }).then(res => {
       console.log("商品详情", res)
@@ -23,12 +30,72 @@ Page({
         title: res.msg,
         icon: "none"
       })
+      this.handleFiles(res.data.item[0].attinfos)
       this.setData({
-        detail: res.data[0],
+        detail: res.data.item[0],
+        rows: res.data.rows,
         loading: false
       })
     })
   },
+  /* 预览媒体 */
+  viewMedias(e) {
+    const {
+      index,
+      type
+    } = e.currentTarget.dataset;
+    wx.previewMedia({
+      current: index,
+      sources: type == 'image' ? this.data.files.viewImages : this.data.files.viewVideos,
+    })
+  },
+  /* 处理附件 */
+  handleFiles(arr) {
+    let files = {
+        images: [],
+        viewImages: [],
+        videos: [],
+        viewVideos: [],
+        files: []
+      },
+      list = fileList(arr);
+    list.forEach(v => {
+      switch (v.fileType) {
+        case "video":
+          files.videos.push(v)
+          files.viewVideos.push({
+            url: v.url,
+            type: "video",
+            poster: v.subfiles[0].url
+          })
+          break;
+        case "image":
+          files.images.push(v)
+          files.viewImages.push({
+            url: v.url,
+            type: "image"
+          })
+          break;
+        default:
+          files.files.push(v)
+          break;
+      }
+    });
+    this.setData({
+      files
+    })
+  },
+  /* 切换产品 */
+  changeItemno(e) {
+    const {
+      item
+    } = e.currentTarget.dataset;
+    if (item.itemno == this.data.itemno) return;
+    this.setData({
+      itemno: item.itemno
+    });
+    this.getDetail();
+  },
   /* 加入购物车 */
   storage() {
     _Http.basic({

+ 3 - 3
packageA/market/detail.wxml

@@ -3,8 +3,8 @@
 <template is="skeleton" wx:if="{{loading}}" />
 <!-- 轮播图 -->
 <swiper indicator-dots circular indicator-active-color='#333'>
-	<swiper-item wx:for="{{3}}">
-		<van-image width="100vw" height="464rpx" fit="cover" src="https://img.yzcdn.cn/vant/cat.jpeg" use-loading-slot use-error-slot lazy-load>
+	<swiper-item wx:for="{{files.images}}" wx:key="item.attachmentid" data-index="{{index}}" data-type='image' bindtap="viewMedias">
+		<van-image width="100vw" height="464rpx" fit="cover" src="{{item.cover}}" use-loading-slot use-error-slot lazy-load>
 			<van-loading slot="loading" type="spinner" size="20" vertical />
 			<text slot="error">加载失败</text>
 		</van-image>
@@ -37,7 +37,7 @@
 		选择商品
 	</view>
 	<view class="product-box">
-		<navigator url="#" class="product {{index==0?'active':''}}" wx:for="{{5}}">22X1.2mmX2.5{{index}}</navigator>
+		<navigator url="#" class="product {{itemno===item.itemno?'active':''}}" wx:for="{{rows}}" wx:key="item.itemno" bindtap="changeItemno" data-item="{{item}}">{{item.spec}}</navigator>
 	</view>
 </view>
 

+ 11 - 0
packageA/market/index.js

@@ -97,7 +97,18 @@ Page({
 			})
 		})
 	},
+	/* 去购物车 */
+	toShopping() {
+		wx.navigateTo({
+			url: '/packageA/shopping/index',
+		})
+	},
 
+	startFiltration() {
+		/* _Http.basic().then(res => {
+			console.log("获取领域", res)
+		}) */
+	},
 	onReady() {
 		this.setListHeight()
 	},

+ 2 - 2
packageA/market/index.wxml

@@ -9,7 +9,7 @@
 		<navigator wx:if="{{content.where.condition}}" bindtap="onClear" url="#" class="iconfont icon-quxiao" />
 	</view>
 	<navigator url="#" class="but"><text class="iconfont icon-shengxu"></text>排序</navigator>
-	<navigator url="#" class="but"><text class="iconfont icon-shaixuan"></text>筛选</navigator>
+	<navigator url="#" class="but"><text class="iconfont icon-shaixuan" bindtap="startFiltration"></text>筛选</navigator>
 </view>
 
 <!-- 品牌列表 -->
@@ -17,7 +17,7 @@
 <!-- 产品列表 -->
 <Tabs wx:for="{{typeList}}" active="{{item.active}}" wx:key="{{index}}" rowIndex="{{index}}" list="{{item.list}}" bind:onChange="typeChange" name='itemclassname' box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' />
 
-<Yl_FloatingButton useSlot>
+<Yl_FloatingButton useSlot bindtap="toShopping">
 	<view>
 		<text class="corner-mark">99+</text>
 		<image style="width: 160rpx; height: 160rpx; transform: translate(-50%,-50%);" src='/static/image/shopping.png' data-title="新建线索" />

+ 3 - 3
packageA/market/modules/list/index.wxml

@@ -1,4 +1,4 @@
-<navigator class="product" url="/packageA/market/detail?id={{item.sa_itemgroupid}}" wx:for="{{list}}" wx:key="index">
+<navigator class="product" url="/packageA/market/detail?id={{item.sa_itemgroupid}}&itemno={{item.itemno}}" wx:for="{{list}}" wx:key="index">
 	<view class="image-box">
 		<van-image width="100%" wx:if="{{item.attinfos[0]}}" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url}}" use-loading-slot use-error-slot lazy-load>
 			<van-loading slot="loading" type="spinner" size="20" vertical />
@@ -7,8 +7,8 @@
 		<text class="text" wx:else>暂无图片</text>
 	</view>
 	<view class="right-box">
-		<view class="title line-1">{{item.itemname||'--'}}</view>
-		<view class="type line-1">{{item.itemno||'--'}}</view>
+		<view class="title line-1">{{item.groupname||'--'}}</view>
+		<view class="type line-1">{{item.groupnum||'--'}}</view>
 		<view class="tags">
 			<view style="background: #FA8C16;">
 				{{item.brandname}}

+ 16 - 0
packageA/shopping/index.js

@@ -0,0 +1,16 @@
+Page({
+  data: {
+    isAll: true,
+  },
+  onLoad(options) {
+
+  },
+  changeAll() {
+    this.setData({
+      isAll: !this.data.isAll
+    })
+  },
+  onReady() {
+
+  },
+})

+ 5 - 0
packageA/shopping/index.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "van-checkbox": "@vant/weapp/checkbox/index"
+  }
+}

+ 46 - 0
packageA/shopping/index.scss

@@ -0,0 +1,46 @@
+.footer {
+	display: flex;
+	flex-direction: column;
+	align-items: center;
+	position: fixed;
+	bottom: 0;
+	width: 100vw;
+	min-height: 243rpx;
+	background-color: #fff;
+	box-shadow: rgba(0, 0, 0, 0.15) 0px 5rpx 15rpx 0px;
+
+	.view {
+		display: flex;
+		height: 82rpx;
+		width: 690rpx;
+		margin: 20rpx 0 10rpx;
+
+		.left {
+			width: 150rpx;
+			height: 60rpx;
+			font-size: 24rpx;
+			font-family: PingFang SC-Regular, PingFang SC;
+			color: #333333;
+
+			.check {
+				margin-left: -10rpx !important;
+			}
+		}
+
+		.right {
+			flex: 1;
+			background-color: blue;
+		}
+	}
+
+	.but {
+		width: 690rpx;
+		height: 90rpx;
+		background: #3874F6;
+		border-radius: 16rpx;
+		font-size: 28rpx;
+		font-weight: 600;
+		color: #FFFFFF;
+		margin-top: 10rpx;
+	}
+}

+ 18 - 0
packageA/shopping/index.wxml

@@ -0,0 +1,18 @@
+<!--packageA/shopping/index.wxml-->
+<text>packageA/shopping/index.wxml</text>
+
+
+
+<!-- 底部 -->
+<view style="height: 150rpx;" />
+<view class="footer">
+	<view class="view">
+		<view class="left" bindtap="changeAll">
+			<van-checkbox value="{{ isAll }}" label-class='check' shape='square' icon-size='28rpx' checked-color="var(--assist)">{{isAll?'取消全选':'全选'}}</van-checkbox>
+		</view>
+		<view class="right">
+
+		</view>
+	</view>
+	<van-button custom-class='but' bindtap="storage">生成订单</van-button>
+</view>

+ 7 - 0
project.private.config.json

@@ -36,6 +36,13 @@
           "query": "",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "购物车",
+          "pathName": "packageA/shopping/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }

+ 0 - 53
utils/CheckFile.js

@@ -1,53 +0,0 @@
-module.exports.checkFile = (item) => {
-    if (['image', 'video'].includes(item.fileType)) {
-        preViewMedia(item)
-    } else if (['word', 'excel', 'ppt', 'pdf'].includes(item.fileType)) {
-        openDocument(item)
-    } else {
-        wx.setClipboardData({
-            data: item.url,
-            success: function () {
-                wx.showToast({
-                    title: '当前文件类型不支持在线浏览,已将文件下载地址复制到剪切板,您可在浏览器中打开链接下载到本地浏览',
-                    icon: "none",
-                    duration: 5000
-                });
-            }
-        })
-    }
-}
-
-function preViewMedia(item) {
-    wx.previewMedia({
-        sources: [{
-            url: item.url,
-            type: item.fileType,
-        }],
-        current: 0,
-        showmenu: true
-    })
-}
-
-function openDocument(item) {
-    wx.downloadFile({
-        url: item.url,
-        success: function (res) {
-            console.log(res.tempFilePath)
-            wx.openDocument({
-                filePath: res.tempFilePath,
-                fileType: item.postfix,
-                showMenu: true,
-                success: function (res) {
-                    console.log(res)
-                    console.log('打开文档成功')
-                },
-                fail: (err) => {
-                    wx.showToast({
-                        title: '打开失败',
-                        icon: "none"
-                    })
-                }
-            })
-        }
-    })
-}