Ver código fonte

权益按钮逻辑调整

ifcheng 2 anos atrás
pai
commit
973f896841
2 arquivos alterados com 39 adições e 23 exclusões
  1. 38 23
      src/pages/benefits/index.vue
  2. 1 0
      src/pages/fill-order/StepOne.vue

+ 38 - 23
src/pages/benefits/index.vue

@@ -41,21 +41,11 @@
             >
           </p>
           <button
-            v-if="
-              (item.type == 1 && item.available) || [2, 4].includes(+item.type)
-            "
+            v-if="item.available && getButtonText(item)"
             class="ptc-button"
             @click="onClickButton(item)"
           >
-            {{
-              item.type == 1
-                ? 'Apply'
-                : item.type == 2
-                ? item.button_name
-                : item.receive_method == 2
-                ? 'Nearby shops'
-                : 'Send to me'
-            }}
+            {{ getButtonText(item) }}
           </button>
         </div>
       </div>
@@ -83,18 +73,43 @@ export default defineComponent({
     }
   },
   methods: {
+    getButtonText(item) {
+      switch (+item.type) {
+        case 1:
+          return +item.need_apply ? 'Apply' : 'Nearby shops'
+        case 2:
+          return item.button_type === 'contact_us'
+            ? 'Contact us'
+            : item.button_type && item.button_name
+        case 4:
+          return +item.receive_method === 2 ? 'Nearby shops' : 'Send to me'
+        default:
+          return ''
+      }
+    },
     onClickButton(right) {
-      right.type === '1'
-        ? this.$router.push(`/repaire/appointment?right_id=${right.id}`)
-        : right.type === '2'
-        ? (location.href = right.button_link)
-        : this.$router.push({
-            path: '/mailing',
-            query: {
-              right_id: right.id,
-              right_name: right.title,
-            },
-          })
+      switch (+item.type) {
+        case 1:
+          return +item.need_apply
+            ? this.$router.push(`/repaire/appointment?right_id=${right.id}`)
+            : 'Nearby shops'
+        case 2:
+          return item.button_type === 'contact_us'
+            ? 'Contact us'
+            : item.button_type && (location.href = right.button_link)
+        case 4:
+          return +item.receive_method === 2
+            ? 'Nearby shops'
+            : this.$router.push({
+                path: '/mailing',
+                query: {
+                  right_id: right.id,
+                  right_name: right.title,
+                },
+              })
+        default:
+          return ''
+      }
     },
   },
 })

+ 1 - 0
src/pages/fill-order/StepOne.vue

@@ -150,6 +150,7 @@ async function next() {
   &-icon {
     width: 36px;
     height: 36px;
+    background-repeat: no-repeat;
     background-size: contain;
   }