Ver código fonte

结算页发票选择逻辑

yangc 7 anos atrás
pai
commit
199b8e0a09
3 arquivos alterados com 25 adições e 19 exclusões
  1. 13 3
      pages/mobile/center/user/pay/_orderId.vue
  2. 6 8
      plugins/axios.js
  3. 6 8
      store/index.js

+ 13 - 3
pages/mobile/center/user/pay/_orderId.vue

@@ -212,14 +212,14 @@
                    :title="'选择发票'"
                    @closeAction="showInvoiceModal = false">
       <ul class="invoice-list">
-        <li @click="setInvoiceCheck(-1)">
+        <!--<li @click="setInvoiceCheck(-1)">
           <div class="inv-content">
             <label class="bottom-modal-check mobile-cart-check" :class="{active: selectedInvoiceIndex === -1}">
               <input type="checkbox">
             </label>
             <span class="inv-head">暂不开票</span>
           </div>
-        </li>
+        </li>-->
         <li v-for="(inv, index) in invoiceData" @click.stop="setInvoiceCheck(index)">
           <div class="inv-content">
             <label class="bottom-modal-check mobile-cart-check" :class="{'active': selectedInvoiceIndex === index}">
@@ -493,6 +493,10 @@
         return this.$store.state.userCenter.list.address.data
       },
       invoiceData () {
+        let invoiceData = this.$store.state.userCenter.list.invoice.data
+        if (invoiceData && invoiceData.length) {
+          this.selectedInvoiceIndex = 0
+        }
         return this.$store.state.userCenter.list.invoice.data
       },
       // 已选择完的发票
@@ -976,12 +980,18 @@
         })
       },
       reloadInvoice () {
-        this.$store.dispatch('userCenter/loadPayInvoice')
+        return this.$store.dispatch('userCenter/loadPayInvoice')
       },
       async addinvoiceFn(ty, item) {
         this.showAddinvoice = false
+        if (!this.invoiceData || !this.invoiceData.length) {
+          this.showInvoiceModal = false
+        }
         if (ty) {
           this.reloadInvoice()
+//            .then(() => {
+//            this.setInvoiceCheck(++this.selectedInvoiceIndex)
+//          })
         }
       },
       updateInvoice(item, index) {

+ 6 - 8
plugins/axios.js

@@ -47,15 +47,13 @@ service.interceptors.request.use(config => {
 })
 
 service.interceptors.response.use(response => {
-  const cookies = response.headers['set-cookie']
-  if (cookies && cookies.length) {
+  const cookie = response.headers['set-cookie']
+  if (cookie && cookie.length) {
+    let cookies = cookie.split(';')
     for (let i = 0; i < cookies.length; i++) {
-      if (cookies[i].indexOf('JSESSIONID') > -1) {
-        const sessionId = cookies[i]
-        const first = sessionId.indexOf(';')
-        const second = sessionId.lastIndexOf(';')
-        const newSessionId = sessionId.replace(sessionId.substring(first, second), '')
-        store.commit('option/SET_SESSION_ID', newSessionId)
+      let cookieArr = cookies[i].split(':')
+      if (cookieArr.length === 2 && cookieArr[0] === 'JSESSIONID') {
+        store.commit('option/SET_SESSION_ID', cookieArr[1])
         break
       }
     }

+ 6 - 8
store/index.js

@@ -39,14 +39,12 @@ export const actions = {
       store.commit('option/GET_MESSAGETYPE', messageType)
     }
     if (cookie && cookie.length) {
-      for (let i = 0; i < cookie.length; i++) {
-        let cookies = cookie.split(';')
-        for (let i = 0; i < cookies.length; i++) {
-          let cookieArr = cookies[i].split(':')
-          if (cookieArr.length === 2 && cookieArr[0] === 'JSESSIONID') {
-            store.commit('option/SET_SESSION_ID', cookieArr[1])
-            break
-          }
+      let cookies = cookie.split(';')
+      for (let i = 0; i < cookies.length; i++) {
+        let cookieArr = cookies[i].split(':')
+        if (cookieArr.length === 2 && cookieArr[0] === 'JSESSIONID') {
+          store.commit('option/SET_SESSION_ID', cookieArr[1])
+          break
         }
       }
       axios.defaults.headers['cookie'] = store.state.option.cookies + '; ' + store.state.option.sessionId