xiaohaizhao vor 2 Jahren
Ursprung
Commit
e839a64d08

+ 32 - 35
packageA/market/detail.js

@@ -8,33 +8,29 @@ import currency from "../../utils/currency";
 
 Page({
   data: {
-    loading: true
+    loading: true,
+    content: {
+      sa_itemgroupid: null,
+      spec: "", //规格
+      color: "", //颜色
+      material: "", //材质
+      cheek: "", //边框
+    }
   },
   onLoad(options) {
-    if (options.id) this.setData({
-      sa_itemgroupid: options.id,
-      itemno: options.itemno
-    })
-    sa_brandid = options.sa_brandid;
+    let data = JSON.parse(options.params);
+    sa_brandid = data.sa_brandid;
+    if (wx.getStorageSync('userrole') == '业务员') sys_enterpriseid = data.sys_enterpriseid
+    this.data.content.sa_itemgroupid = data.sa_itemgroupid;
     this.setData({
       userrole: wx.getStorageSync('userrole')
     })
-
-    if (wx.getStorageSync('userrole') == '业务员') sys_enterpriseid = options.sys_enterpriseid
     this.getDetail();
   },
   /* 获取详情 */
   getDetail() {
-    let content = {
-      "sa_itemgroupid": this.data.sa_itemgroupid,
-      pageSize: 999 ,
-      // "itemno": "80409006",
-      "spec": "",
-      "color": "",
-      "material": ""
-    }
+    let content = this.data.content;
     if (sys_enterpriseid) content.sys_enterpriseid = sys_enterpriseid;
-    console.log(sys_enterpriseid)
     _Http.basic({
       "id": "20221223165503",
       content
@@ -44,7 +40,7 @@ Page({
         title: res.msg,
         icon: "none"
       })
-      if (res.data.length == 0) {
+      if (res.data.item.length == 0) {
         wx.showToast({
           title: '未查询到商品',
           icon: "none",
@@ -55,19 +51,20 @@ Page({
         }, 500)
         return;
       }
-      this.handleFiles(res.data[0].attinfos)
+      this.handleFiles(res.data.item[0].attinfos)
       const CNY = sum => currency(sum, {
         symbol: "¥",
         precision: 2
       }).format();
-
+      res.data.item[0].gradeprice = CNY(res.data.item[0].gradeprice);
+      res.data.item[0].marketprice = CNY(res.data.item[0].marketprice);
       this.setData({
-        detail: res.data[0],
-        rows: res.data.map(v => {
-          v.gradeprice = CNY(v.gradeprice);
-          v.marketprice = CNY(v.marketprice);
-          return v
-        }),
+        detail: res.data.item[0],
+        content: Object.assign(this.data.content, res.data.rows[0]),
+        specRows: res.data.specRows,
+        cheekRows: res.data.cheekRows,
+        materialRows: res.data.materialRows,
+        colorRows: res.data.colorRows,
         loading: false
       })
     })
@@ -121,15 +118,15 @@ Page({
   },
   /* 切换产品 */
   changeItemno(e) {
+    console.log("切换产品", e.currentTarget.dataset)
     const {
-      item
-    } = e.currentTarget.dataset;
-    if (item.itemno == this.data.itemno) return;
-    this.handleFiles(item.attinfos)
-    this.setData({
-      detail: item,
-      itemno: item.itemno
-    })
+      value,
+      valuename
+    } = e.currentTarget.dataset,
+      content = this.data.content;
+    if (content[valuename] == value) return;
+    content[valuename] = value;
+    this.getDetail()
   },
   clickBut() {
     this.data.detail.tradefield.length >= 2 ? wx.showToast({
@@ -192,7 +189,7 @@ Page({
         sa_brandid,
         "itemid": detail.itemid, //货品id
         "qty": detail.orderminqty, //数量
-        "itemno": this.data.itemno, //货品编号
+        itemno: detail.itemno, //货品编号
         tradefield: detail.tradefield[index].tradefield
       },
     }).then(res => {

+ 8 - 3
packageA/market/detail.scss

@@ -5,6 +5,7 @@ swiper {
   width: 100vw;
   height: 464rpx;
   background-color: #fff;
+
   swiper-item {
     width: 100%;
     height: 100%;
@@ -86,13 +87,13 @@ swiper {
 .model {
   width: 100vw;
   background-color: #fff;
-  padding: 0 0 20rpx 30rpx;
+  padding-left: 30rpx;
   box-sizing: border-box;
   margin-top: 20rpx;
 
   .label {
-    height: 90rpx;
-    line-height: 90rpx;
+    height: 70rpx;
+    line-height: 70rpx;
     font-size: 28rpx;
     font-weight: 600;
     color: #333333;
@@ -121,6 +122,10 @@ swiper {
     }
   }
 
+  .product-box:last-child {
+    padding-bottom: 20rpx;
+  }
+
 }
 
 .tabs {

+ 41 - 8
packageA/market/detail.wxml

@@ -31,15 +31,48 @@
     <text>库存:{{userrole=='经销商'?detail.stockstatus:detail.cansaleqty}}</text>
   </view>
 </view>
-<!-- 选择型号 -->
-<view class="model" wx:if="{{rows.length}}">
-  <view class="label">
-    选择商品
-  </view>
-  <view class="product-box">
-    <navigator url="#" class="product {{itemno===item.itemno?'active':''}}" wx:for="{{rows}}" wx:key="itemno" bindtap="changeItemno" data-item="{{item}}">{{item.spec}}</navigator>
-  </view>
+<!-- 选择规格 -->
+<view class="model">
+  <block wx:if="{{specRows.length}}">
+    <view class="label">
+      规格
+    </view>
+    <view class="product-box">
+      <navigator url="#" class="product {{content.spec===item?'active':''}}" wx:for="{{specRows}}" wx:key="index" bindtap="changeItemno" data-valuename="spec" data-value="{{item}}">{{item}}</navigator>
+    </view>
+  </block>
+
+  <block wx:if="{{colorRows.length}}">
+    <view class="label">
+      颜色
+    </view>
+    <view class="product-box">
+      <navigator url="#" class="product {{content.color===item?'active':''}}" wx:for="{{colorRows}}" wx:key="index" bindtap="changeItemno" data-valuename="color" data-value="{{item}}">{{item}}</navigator>
+    </view>
+  </block>
+
+  <block wx:if="{{materialRows.length}}">
+    <view class="label">
+      材质
+    </view>
+    <view class="product-box">
+      <navigator url="#" class="product {{content.material===item?'active':''}}" wx:for="{{materialRows}}" wx:key="index" bindtap="changeItemno" data-valuename="material" data-value="{{item}}">{{item}}</navigator>
+    </view>
+  </block>
+
+  <block wx:if="{{cheekRows.length}}">
+    <view class="label">
+      边框
+    </view>
+    <view class="product-box">
+      <navigator url="#" class="product {{content.cheek===item?'active':''}}" wx:for="{{cheekRows}}" wx:key="index" bindtap="changeItemno" data-valuename="cheek" data-value="{{item}}">{{item}}</navigator>
+    </view>
+  </block>
+
 </view>
+
+
+
 <van-tabs custom-class='tabs' title-active-color='var(--assist)' color='var(--assist)'>
   <van-tab title="商品简介">
     <view class="tab-box">

+ 1 - 1
packageA/market/index.wxml

@@ -14,7 +14,7 @@
 <!-- 品牌列表 -->
 <!-- <Tabs list="{{brandList}}" wx:if="{{brandList.length>1}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' bind:onChange="brandChange" /> -->
 <!-- 产品列表 -->
-<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' />
+<Tabs wx:for="{{typeList}}" wx:if="{{typeList.length>1}}" 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' />
 <view class="division" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
 	<List list="{{list}}" sys_enterpriseid='{{sys_enterpriseid}}' />

+ 14 - 0
packageA/market/modules/list/index.js

@@ -2,5 +2,19 @@ Component({
   properties: {
     list: Array,
     sys_enterpriseid: String
+  },
+  methods: {
+    toDetail(e) {
+      const {
+        item
+      } = e.currentTarget.dataset;
+      wx.navigateTo({
+        url: `/packageA/market/detail?params=${JSON.stringify({
+          sa_itemgroupid:item.sa_itemgroupid,
+          sa_brandid:item.sa_brandid,
+          sys_enterpriseid:this.data.sys_enterpriseid
+        })}`,
+      })
+    }
   }
 })

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

@@ -1,4 +1,4 @@
-<navigator class="product" url="/packageA/market/detail?id={{item.sa_itemgroupid}}&itemno={{item.itemno}}&sa_brandid={{item.sa_brandid}}&sys_enterpriseid={{sys_enterpriseid}}" wx:for="{{list}}" wx:key="index">
+<navigator class="product" bindtap="toDetail" data-item="{{item}}" url="#" wx:for="{{list}}" wx:key="index">
 	<view class="image-box">
 		<van-image width="100%" wx:if="{{item.attinfos[0]||item.cover}}" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||item.attinfos[0].url||item.cover}}" use-loading-slot use-error-slot lazy-load>
 			<van-loading slot="loading" type="spinner" size="20" vertical />