Переглянути джерело

地区多选、商品数据结构变化、商品列表默认展开

xiaomei 10 місяців тому
батько
коміт
67a406885a

+ 11 - 6
src/views/index/index.vue

@@ -31,21 +31,25 @@
             <van-icon name="arrow" color="#7f7f7f" size="14px" />
           </div>
         </div>
-        <div class="goods_list" v-for="(item, index) in product_list" :key="index" @click="navigatorToPage('GoodsDetail', item.id)">
-          <van-image class="goods_list_img" radius="10" :src="item.img_url" />
+        <div class="goods_list" v-for="(item, index) in product_list" :key="index" @click="navigatorToPage('GoodsDetail', item.id, item.product_id)">
+          <van-image class="goods_list_img" radius="10" :src="item.products_list.thum" />
           <div class="right">
-            <span class="ellipsis">{{ item.name }}</span>
+            <span class="ellipsis" v-if="$i18n.locale == 'en'">{{ item.products_list.en_name }}</span>
+            <span class="ellipsis" v-else>{{ item.products_list.zh_name }}</span>
             <div class="cen">
               <span class="money"
                 >{{ item.price }}<span class="ssm">{{ $t('lang174') }}</span></span
               >
-              <div class="yel">
+              <div class="yel" v-if="item.status == 1">
                 <van-count-down
                   class="count"
                   :time="item.end_time * 1000 - new Date().getTime()"
                   :format="`${$t('lang8')} DD ${$t('lang9')} HH ${$t('lang10')} mm ${$t('lang11')} ss ${$t('lang12')}`"
                 />
               </div>
+              <div class="yel" style="background-color: #f1f1f1;" v-else-if="item.status == 0">
+                <span class="count" style="color: #aaa;">{{ $t('lang72') }}</span>
+              </div>
             </div>
             <span class="time_text">{{ $t('lang6') }} {{ item.cost_price }}{{ $t('lang174') }}</span>
             <div class="progress">
@@ -274,8 +278,8 @@ export default {
     navigatorTo(name) {
       this.$router.push({ name });
     },
-    navigatorToPage(name, id) {
-      this.$router.push({ name, query: { id: id } });
+    navigatorToPage(name, id, product_id) {
+      this.$router.push({ name, query: { id: id, product_id: product_id } });
     },
     getIndexBaseInfo() {
       homeApi.getIndexBaseInfo().then(res => {
@@ -482,6 +486,7 @@ export default {
         padding: 0px 8px;
         border-radius: 16px;
         white-space: nowrap;
+        line-height: 100%;
         .count {
           color: #f7c35d;
           font-size: 9px;

+ 1 - 1
src/views/mine/TransferDetail.vue

@@ -195,7 +195,7 @@ export default {
   methods: {
     statusFn(status) {
       let result = '';
-      switch (status) {
+      switch (status) {//0未开始 1进行中 2已结束
         case 0:
           result = this.$t('lang72');
           break;

+ 12 - 11
src/views/trade/detail.vue

@@ -27,7 +27,7 @@
             <span>{{ product.info.num }}{{ $t('lang52') }}</span>
           </div>
         </div>
-        <div class="countdown" v-if="product.info.end_time * 1000 - new Date().getTime() > 0">
+        <div class="countdown" v-if="product.info.start_time * 1000 - new Date().getTime() <= 0 && product.info.end_time * 1000 - new Date().getTime() > 0">
           <div class="flex">
             <img src="@/assets/images/trade/clock.png" alt="" class="clock" />
             <span style="white-space: nowrap">{{ $t('lang54') }}</span>
@@ -43,7 +43,8 @@
             </template>
           </van-count-down>
         </div>
-        <div class="countdown end" v-else>{{ $t('lang173') }}</div>
+        <div class="countdown end" v-else-if="product.info.start_time * 1000 - new Date().getTime() > 0">{{ $t('lang72') }}</div>
+        <div class="countdown end" v-else-if="product.info.end_time * 1000 - new Date().getTime() <= 0">{{ $t('lang173') }}</div>
       </div>
       <div class="goods_info">
         <div class="flex jsb">
@@ -151,15 +152,15 @@
         <!-- <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" class="vanlist">
           <van-cell class="item" v-for="item in arealist" :key="item.id" :title="item.address" />
         </van-list> -->
-        <van-radio-group v-model="areaId" @change="handleChoose" v-if="arealist.length > 0">
+        <van-checkbox-group v-model="areaIds" @change="handleChoose" v-if="arealist.length > 0">
           <van-cell-group class="vanlist" @scroll="handleScroll">
             <van-cell class="item" v-for="item in arealist" :key="item.id" :title="item.address" clickable>
               <template #right-icon>
-                <van-radio :name="item.id" icon-size="16px" checked-color="#29b286" />
+                <van-checkbox :name="item.id" icon-size="16px" checked-color="#29b286" ref="checkboxes" />
               </template>
             </van-cell>
           </van-cell-group>
-        </van-radio-group>
+        </van-checkbox-group>
         <div class="nomore" v-else>
           <span>{{ $t('lang60') }}</span>
         </div>
@@ -194,7 +195,7 @@ export default {
       options: [],
       arealist: [],
       search: '',
-      areaId: '',
+      areaIds: [],
       loading: false,
       page: 1,
     };
@@ -247,7 +248,7 @@ export default {
       this.$router.push({ name });
     },
     getPopularInfo(id) {
-      homeApi.getPopularInfo({ ids: id }).then(res => {
+      homeApi.getPopularInfo({ ids: id, product_id: this.$route.query.product_id }).then(res => {
         if (res.code == 200) {
           this.product = res.data;
           this.product.info.img_url = res.data.info.img_url.split(',');
@@ -301,7 +302,7 @@ export default {
     },
     handleChoose(e) {
       console.log(e);
-      this.areaId = e;
+      this.areaIds = e;
     },
     submit() {
       //   Dialog.confirm({
@@ -315,7 +316,7 @@ export default {
       //       // on cancel
       //     });
 
-      if (!this.areaId) {
+      if (!this.areaIds) {
         return Notify({ type: 'warning', message: this.$t('lang69') });
       }
       let _this = this;
@@ -327,11 +328,11 @@ export default {
       })
         .then(() => {
           this.loading = true;
-          homeApi.create({ order_id: this.product.info.id, product_id: this.product.info.product_id, area_id: this.areaId }).then(res => {
+          homeApi.create({ order_id: this.product.info.id, product_id: this.product.info.product_id, area_id: this.areaIds.join(',') }).then(res => {
             if (res.code == 200) {
               this.loading = false;
               this.cascaderShow = false;
-              this.areaId = '';
+              this.areaIds = [];
               Toast({ message: res.msg });
               this.$router.push('assets');
             } else if (res.code == 15001) {

+ 31 - 20
src/views/trade/index.vue

@@ -27,24 +27,27 @@
           </div>
         </div>
         <div v-if="item.product.length > 0">
-          <div class="goods_list" v-for="(item1, index1) in item.product" :key="index1" @click="navigatorToPage('GoodsDetail', item1.id)">
+          <div class="goods_list" v-for="(item1, index1) in item.product" :key="index1" @click="navigatorToPage('GoodsDetail', item1.pro.id, item1.pro.product_id)">
             <van-image class="goods_list_img" radius="10" :src="item1.img_url" />
             <div class="right">
               <span class="ellipsis">{{ item1.name }}</span>
               <div class="cen">
                 <span class="money"
-                  >{{ item1.price }}<span class="ssm">{{ $t('lang174') }}</span></span
+                  >{{ item1.pro.price }}<span class="ssm">{{ $t('lang174') }}</span></span
                 >
-                <div class="yel">
-                  <van-count-down class="count" :time="item1.end_time*1000 - new Date().getTime()" :format="`${$t('lang8')} DD ${$t('lang9')} HH ${$t('lang10')} mm ${$t('lang11')} ss ${$t('lang12')}`" />
+                <div class="yel" v-if="item1.pro.status == 1">
+                  <van-count-down class="count" :time="item1.pro.end_time*1000 - new Date().getTime()" :format="`${$t('lang8')} DD ${$t('lang9')} HH ${$t('lang10')} mm ${$t('lang11')} ss ${$t('lang12')}`" />
                 </div>
+                <div class="yel" style="background-color: #f1f1f1;" v-else-if="item1.pro.status == 0">
+                <span class="count" style="color: #aaa;">{{ $t('lang72') }}</span>
+              </div>
               </div>
               <div class="flex jsb flex_end">
                 <div>
-                  <span class="time_text">{{ $t('lang6') }} {{ item1.cost_price }}{{ $t('lang174') }}</span>
+                  <span class="time_text">{{ $t('lang6') }} {{ item1.pro.cost_price }}{{ $t('lang174') }}</span>
                   <div class="progress">
-                    <van-progress :percentage="(item1.num / item1.stock) * 100 || 0" class="pro" color="#29b286" track-color="#9DDAC6" stroke-width="10" :show-pivot="false"> </van-progress>
-                    <span class="p_text">{{ $t('lang26') }}{{ (Math.floor((item1.num / item1.stock) * 100) * 100) / 100 || 0 }}%</span>
+                    <van-progress :percentage="(item1.pro.num / item1.pro.stock) * 100 || 0" class="pro" color="#29b286" track-color="#9DDAC6" stroke-width="10" :show-pivot="false"> </van-progress>
+                    <span class="p_text">{{ $t('lang26') }}{{ (Math.floor((item1.pro.num / item1.pro.stock) * 100) * 100) / 100 || 0 }}%</span>
                   </div>
                 </div>
                 <div class="buy">
@@ -221,8 +224,8 @@ export default {
     navigatorTo(name) {
       this.$router.push({ name });
     },
-    navigatorToPage(name, id) {
-      this.$router.push({ name, query: { id: id } });
+    navigatorToPage(name, id, product_id) {
+      this.$router.push({ name, query: { id: id, product_id: product_id } });
     },
     getIndexBaseInfo() {
       homeApi.getIndexBaseInfo().then(res => {
@@ -240,21 +243,29 @@ export default {
           this.showLoading = false;
           this.goodsInfo = res.data;
           this.goodsInfoExt = JSON.parse(JSON.stringify(res.data));
-          this.goodsInfoExt.forEach((element, index) => {
-            var idx = this.typeList.indexOf(element.type_id);
+          // this.goodsInfoExt.forEach((element, index) => {
+          //   var idx = this.typeList.indexOf(element.type_id);
 
-            // 收起
-            this.typeList.splice(idx, 1);
-            if (this.goodsInfo[index].product.length > 0) {
-              let info = JSON.parse(JSON.stringify(this.goodsInfoExt[index]));
+          //   // 收起
+          //   this.typeList.splice(idx, 1);
+          //   if (this.goodsInfo[index].product.length > 0) {
+          //     let info = JSON.parse(JSON.stringify(this.goodsInfoExt[index]));
 
-              if (info.product.length > 0) {
-                info.product.length = 1;
-              }
+          //     if (info.product.length > 0) {
+          //       info.product.length = 1;
+          //     }
+
+          //     this.$set(this.goodsInfo, index, info);
+          //   }
+          // });
+          this.goodsInfoExt.forEach((element, index) => {
+            var idx = this.typeList.indexOf(element.type_id);
 
-              this.$set(this.goodsInfo, index, info);
-            }
+            // 展开
+            this.typeList.push(element.type_id);
+            this.$set(this.goodsInfo, index, JSON.parse(JSON.stringify(this.goodsInfoExt[index])));
           });
+          
         } else {
           this.showLoading = false;
         }