Browse Source

立即购买直接去结算页

skyblued 3 years ago
parent
commit
9e3dfe8312

+ 2 - 2
src/views/cart/cart-confirm-agin/index.tsx

@@ -99,12 +99,12 @@ export default defineComponent({
                   title="总额"
                   value={'¥ ' + calcAmount.totalAmount}
                 ></Cell>
-                <Cell
+                {/* <Cell
                   border={false}
                   title="运费"
                   value={calcAmount.freightAmount}
                 ></Cell>
-                <Cell border={false} title="优惠" value={'-¥ ' + cartConfirm.orderInfo?.promotionAmount}></Cell>
+                <Cell border={false} title="优惠" value={'-¥ ' + cartConfirm.orderInfo?.promotionAmount}></Cell> */}
                 {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
             <Cell border={false} title="乐乐币抵扣" value={"-¥" + calcAmount.promotionAmount}></Cell> */}
               </CellGroup>

+ 131 - 101
src/views/cart/cart-confirm/index.tsx

@@ -11,7 +11,7 @@ import { addressType, cartConfirm, formateAttr } from '../cart'
 import styles from '../index.module.less'
 import Address from '../components/address'
 import request from '@/helpers/request'
-import { useRouter } from 'vue-router'
+import { useRoute, useRouter } from 'vue-router'
 import ColProtocol from '@/components/col-protocol'
 import Payment from '@/views/order-detail/payment'
 import { state } from '@/state'
@@ -26,17 +26,38 @@ import {
 export default defineComponent({
   name: 'cartConfirm',
   setup() {
-    const list = cartConfirm.cartPromotionItemList
-    const calcAmount = cartConfirm.calcAmount
-
+    const loading = ref(true)
+    const route = useRoute()
     const address = ref<addressType>()
-    if (cartConfirm.memberReceiveAddressList.length) {
-      const a =
-        cartConfirm.memberReceiveAddressList.find(
-          (n: any) => n.defaultStatus
-        ) || cartConfirm.memberReceiveAddressList[0]
-      if (a) address.value = a
-    }
+    onMounted(async () => {
+      loading.value = true
+      if (route.query.cartIds) {
+        try {
+          let { code, data } = await request.post(
+            '/api-mall-portal/order/generateConfirmOrder',
+            {
+              params: {
+                cartIds: route.query.cartIds
+              }
+            }
+          )
+          if (code === 200) {
+            cartConfirm.calcAmount = data.calcAmount
+            cartConfirm.cartPromotionItemList = data.cartPromotionItemList
+            cartConfirm.memberReceiveAddressList = data.memberReceiveAddressList
+          }
+        } catch (error) {}
+      }
+      loading.value = false
+      if (cartConfirm.memberReceiveAddressList.length) {
+        const a =
+          cartConfirm.memberReceiveAddressList.find(
+            (n: any) => n.defaultStatus
+          ) || cartConfirm.memberReceiveAddressList[0]
+        if (a) address.value = a
+      }
+    })
+
     const setAddress = (result: addressType) => {
       address.value = result
     }
@@ -83,10 +104,13 @@ export default defineComponent({
     const router = useRouter()
     //创建订单
     const createOrder = async () => {
-      const ids = list.reduce((arr, value: any) => {
-        arr.push(value.id)
-        return arr
-      }, [])
+      const ids = cartConfirm.cartPromotionItemList.reduce(
+        (arr, value: any) => {
+          arr.push(value.id)
+          return arr
+        },
+        []
+      )
       const body = {
         cartIds: ids,
         memberReceiveAddressId: address.value?.id
@@ -121,96 +145,102 @@ export default defineComponent({
     }
     return () => (
       <>
-        {list.length ? (
-          <div class={styles.cartConfirm}>
-            <div class={styles.cartConfirmBox}>
-              <Address item={address.value} setAddress={setAddress} />
-            </div>
-            <div
-              style={{ marginTop: '20px' }}
-              class={[styles.cartBox, styles.cartConfirmBox]}
-            >
-              <div class={styles.shopBox}>
-                {list.map((item: any) => (
-                  <div
-                    class={[styles.cartItem]}
-                    style={{ marginBottom: '10px' }}
-                  >
-                    <Card
-                      price={moneyFormat(item.price)}
-                      desc={formateAttr(item.productAttr)}
-                      title={item.productName}
-                      thumb={item.productPic}
-                      num={item.quantity}
-                    ></Card>
+        {loading.value ? null : (
+          <div>
+            {cartConfirm.cartPromotionItemList.length ? (
+              <div class={styles.cartConfirm}>
+                <div class={styles.cartConfirmBox}>
+                  <Address item={address.value} setAddress={setAddress} />
+                </div>
+                <div
+                  style={{ marginTop: '20px' }}
+                  class={[styles.cartBox, styles.cartConfirmBox]}
+                >
+                  <div class={styles.shopBox}>
+                    {cartConfirm.cartPromotionItemList.map((item: any) => (
+                      <div
+                        class={[styles.cartItem]}
+                        style={{ marginBottom: '10px' }}
+                      >
+                        <Card
+                          price={moneyFormat(item.price)}
+                          desc={formateAttr(item.productAttr)}
+                          title={item.productName}
+                          thumb={item.productPic}
+                          num={item.quantity}
+                        ></Card>
+                      </div>
+                    ))}
                   </div>
-                ))}
-              </div>
-              <CellGroup border={false}>
-                <Cell
-                  border={false}
-                  title="总额"
-                  value={'¥ ' + moneyFormat(calcAmount.totalAmount)}
-                ></Cell>
-                {/* <Cell
-                  border={false}
-                  title="运费"
-                  value={moneyFormat(calcAmount.freightAmount)}
-                ></Cell>
-                <Cell
-                  border={false}
-                  title="优惠"
-                  value={'-¥ ' + moneyFormat(calcAmount.promotionAmount)}
-                ></Cell> */}
-                {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
-            <Cell border={false} title="乐乐币抵扣" value={"-¥" + calcAmount.promotionAmount}></Cell> */}
-              </CellGroup>
-            </div>
+                  <CellGroup border={false}>
+                    <Cell
+                      border={false}
+                      title="总额"
+                      value={
+                        '¥ ' + moneyFormat(cartConfirm.calcAmount.totalAmount)
+                      }
+                    ></Cell>
+                    {/* <Cell
+                    border={false}
+                    title="运费"
+                    value={moneyFormat(cartConfirm.calcAmount.freightAmount)}
+                  ></Cell>
+                  <Cell
+                    border={false}
+                    title="优惠"
+                    value={'-¥ ' + moneyFormat(cartConfirm.calcAmount.promotionAmount)}
+                  ></Cell> */}
+                    {/* <Cell border={false} title="优惠卷" value="暂无可用优惠卷"></Cell>
+              <Cell border={false} title="乐乐币抵扣" value={"-¥" + cartConfirm.calcAmount.promotionAmount}></Cell> */}
+                  </CellGroup>
+                </div>
 
-            <div class={styles.payProtocol}>
-              <ColProtocol v-model={agreeStatus.value}></ColProtocol>
-            </div>
-            <SubmitBar
-              buttonText={`结算(${list.length})`}
-              buttonColor="var(--van-primary)"
-              disabled={list.length === 0}
-              onSubmit={() => onSubmit()}
-            >
-              <div class={styles.confirmBottom}>
-                合计{' '}
-                <span class={styles['price-des']}>
-                  ¥{moneyFormat(calcAmount.payAmount)}
-                </span>
+                <div class={styles.payProtocol}>
+                  <ColProtocol v-model={agreeStatus.value}></ColProtocol>
+                </div>
+                <SubmitBar
+                  buttonText={`结算(${cartConfirm.cartPromotionItemList.length})`}
+                  buttonColor="var(--van-primary)"
+                  disabled={cartConfirm.cartPromotionItemList.length === 0}
+                  onSubmit={() => onSubmit()}
+                >
+                  <div class={styles.confirmBottom}>
+                    合计{' '}
+                    <span class={styles['price-des']}>
+                      ¥{moneyFormat(cartConfirm.calcAmount.payAmount)}
+                    </span>
+                  </div>
+                </SubmitBar>
+                <div style={{ height: 'var(--van-submit-bar-height)' }}></div>
+                <ColPopup v-model={authPopup.value}>
+                  <UserAuth onSuccess={onAuthSuccess} />
+                </ColPopup>
+                <Popup
+                  show={paymentPopup.value}
+                  closeOnClickOverlay={false}
+                  position="bottom"
+                  round
+                  closeOnPopstate
+                  safeAreaInsetBottom
+                  style={{ minHeight: '30%' }}
+                >
+                  <Payment
+                    v-model={paymentPopup.value}
+                    orderInfo={orderInfo}
+                    paymentType="goodsPay"
+                    onBackOut={() => (paymentPopup.value = false)}
+                  />
+                </Popup>
               </div>
-            </SubmitBar>
-            <div style={{ height: 'var(--van-submit-bar-height)' }}></div>
-            <ColPopup v-model={authPopup.value}>
-              <UserAuth onSuccess={onAuthSuccess} />
-            </ColPopup>
-            <Popup
-              show={paymentPopup.value}
-              closeOnClickOverlay={false}
-              position="bottom"
-              round
-              closeOnPopstate
-              safeAreaInsetBottom
-              style={{ minHeight: '30%' }}
-            >
-              <Payment
-                v-model={paymentPopup.value}
-                orderInfo={orderInfo}
-                paymentType="goodsPay"
-                onBackOut={() => (paymentPopup.value = false)}
-              />
-            </Popup>
+            ) : (
+              <ColResult
+                buttonText="去购物车"
+                onClick={() => {
+                  router.push({ path: '/cart' })
+                }}
+              ></ColResult>
+            )}
           </div>
-        ) : (
-          <ColResult
-            buttonText="去购物车"
-            onClick={() => {
-              router.push({ path: '/cart' })
-            }}
-          ></ColResult>
         )}
       </>
     )

+ 7 - 0
src/views/cart/index.tsx

@@ -101,6 +101,13 @@ export default defineComponent({
     },
     //生成确认订单
     async generateConfirmOrder() {
+      this.$router.push({
+        path: '/cartConfirm',
+        query: {
+          cartIds: this.selectItems.join(',')
+        }
+      })
+      return
       const ids: number[] = [...this.selectItems]
       try {
         let { code, data } = await request.post(

+ 5 - 6
src/views/shop-mall/components/tab-list/index.tsx

@@ -48,8 +48,8 @@ export default defineComponent({
       loading: false,
       finished: false,
       params: {
-        productCategoryId: null as any,
-        productAttributeCategoryId: null as any,
+        productCategoryId: undefined as any,
+        productAttributeCategoryId: undefined as any,
         brandId: null as any,
         sort: null as any, // 1->按新品;2->按销量;3->价格从低到高;4->价格从高到低
         keyword: '',
@@ -77,12 +77,11 @@ export default defineComponent({
     async getList() {
       try {
         let params = this.params
-        // this.typeId && (params.productCategoryId = this.typeId)
-        params.productCategoryId = this.typeId ? this.typeId : undefined
-        params.productAttributeCategoryId = this.productAttributeCategoryId
+        params.productCategoryId = this.typeId ? this.typeId : undefined // 商品分类
+        params.productAttributeCategoryId = this.productAttributeCategoryId // 商品类型
           ? this.productAttributeCategoryId
           : undefined
-        params.brandId = this.brandId ? this.brandId : undefined
+        params.brandId = this.brandId ? this.brandId : undefined // 品牌
         params.sort = this.sort ? this.sort : undefined
         params.keyword = this.keyword ? this.keyword : undefined
         const res = await request.post('/api-mall-portal/product/search', {

+ 3 - 0
src/views/shop-mall/goods-detail/index.module.less

@@ -170,6 +170,9 @@
       margin-bottom: 0;
       line-height: 0;
     }
+    .van-badge{
+      background: #FF4E19;
+    }
   }
 }
 

+ 7 - 5
src/views/shop-mall/goods-detail/index.tsx

@@ -40,7 +40,8 @@ export default defineComponent({
       loading: false,
       addGoodsShow: false,
       selectGoodsItem: {},
-      cartCount: 0
+      cartCount: 0,
+      showType: 'cart'
     }
   },
   computed: {
@@ -130,7 +131,7 @@ export default defineComponent({
         closeable: true
       })
     },
-    onShowCart() {
+    onShowCart(type = 'cart') {
       this.selectGoodsItem = {
         price: this.product.pic,
         stock: this.product.stock,
@@ -142,6 +143,7 @@ export default defineComponent({
         productSubTitle: this.product.subTitle,
         id: this.product.id
       }
+      this.showType = type
       // 打开购物弹框
       this.addGoodsShow = true
     },
@@ -297,12 +299,12 @@ export default defineComponent({
                 type="primary"
                 class={styles.addCertBtn}
                 text="加入购物车"
-                onClick={this.onShowCart}
+                onClick={() => this.onShowCart()}
               />
               <ActionBarButton
                 type="primary"
                 text="立即购买"
-                onClick={this.onShowCart}
+                onClick={() => this.onShowCart('cartConfirm')}
               />
             </div>
           </ActionBar>
@@ -317,7 +319,7 @@ export default defineComponent({
             this.getCartCount()
           }}
         >
-          <AddGoodsCart item={this.selectGoodsItem} defaultRadio={this.radio} />
+          <AddGoodsCart item={this.selectGoodsItem} defaultRadio={this.radio} showType={this.showType} />
         </Popup>
       </div>
     )

+ 3 - 3
src/views/shop-mall/goods-list/index.module.less

@@ -25,8 +25,8 @@
   flex-wrap: wrap;
 }
 .filterTag {
-  border: 1px solid var(--van-primary);
-  color: var(--van-primary);
+  border: 1px solid #2dc7aa !important;
+  color: #2dc7aa !important;
   border-radius: 12px;
   font-size: 12px;
   background-color: #f7f8f9;
@@ -42,7 +42,7 @@
   align-items: center;
   margin-left: 5px;
   .icon-active {
-    color: var(--van-primary);
+    color: #2dc7aa;
   }
   .iconSort{
     margin-top: -5px;

+ 6 - 4
src/views/shop-mall/index.tsx

@@ -57,11 +57,13 @@ export default defineComponent({
       let dev = false
       let origin = location.origin + location.pathname + '#'
       if (!url) return
+      
       if (url.indexOf('http') < 0) {
         url = origin + url
       }
       console.log('跳转url:', url)
-      if (dev) {
+      let ua = navigator.userAgent.toLowerCase();
+      if (!ua.includes('colexiuapp')) {
         location.href = url
         return
       }
@@ -137,10 +139,10 @@ export default defineComponent({
           lazyRender
         >
           {this.productCategoryList.length > 0 && (
-            <Tab title="全部分类" name={0}>
+            <Tab title="全部" name={0}>
               <TabList
                 isTab={true}
-                typeId={0}
+                productAttributeCategoryId={0}
                 onOpenWebView={this.openWebView}
               />
             </Tab>
@@ -149,7 +151,7 @@ export default defineComponent({
             <Tab title={item.name} name={item.id}>
               <TabList
                 isTab={true}
-                typeId={item.id}
+                productAttributeCategoryId={item.id}
                 onOpenWebView={this.openWebView}
               />
             </Tab>

+ 30 - 19
src/views/shop-mall/modal/add-goods-cart/index.tsx

@@ -27,6 +27,10 @@ export default defineComponent({
       type: Number,
       default: 0
     },
+    showType: {
+      type: String,
+      default: 'cart'
+    },
     onOpenWebView: {
       type: Function,
       default: (n: any) => {}
@@ -108,27 +112,34 @@ export default defineComponent({
           data: body
         })
         if (code === 200) {
-          Dialog.confirm({
-            title: '提示',
-            message: '加入购物车成功,是否去决算?',
-            cancelButtonText: '继续购买',
-            confirmButtonText: '去结算',
-            confirmButtonColor: 'var(--van-primary)'
-          })
-            .then(() => {
-              // 如果为首页加入购物车跳转, 使用首页的公用跳转方法
-              if (this.onOpenWebView.toString() === 'n => {}') {
-                this.$router.push({
-                  path: '/cart'
-                })
-              } else {
-                this.onOpenWebView('/cart')
-              }
-              // on confirm
+          if (this.showType === 'cart') {
+            Dialog.confirm({
+              title: '提示',
+              message: '加入购物车成功,是否去结算?',
+              cancelButtonText: '继续购买',
+              confirmButtonText: '去结算',
+              confirmButtonColor: 'var(--van-primary)'
             })
-            .catch(() => {
-              // on cancel
+              .then(() => {
+                // 如果为首页加入购物车跳转, 使用首页的公用跳转方法
+                if (this.onOpenWebView.toString() === 'n => {}') {
+                  this.$router.push({
+                    path: '/cart'
+                  })
+                } else {
+                  this.onOpenWebView('/cart')
+                }
+              })
+              .catch(() => {
+              })
+          } else {
+            this.$router.push({
+              path: '/cartConfirm',
+              query: {
+                cartIds: data.id
+              }
             })
+          }
         }
       } catch (error) {}
     }