skyblued 3 rokov pred
rodič
commit
aed1a8da59

+ 217 - 58
src/views/goods-order/after-sale.tsx

@@ -1,5 +1,7 @@
 import ColHeader from '@/components/col-header'
 import ColResult from '@/components/col-result'
+import request from '@/helpers/request'
+import { state } from '@/state'
 import {
   ActionSheet,
   Button,
@@ -9,9 +11,11 @@ import {
   Image,
   List,
   Tab,
-  Tabs
+  Tabs,
+  Toast
 } from 'vant'
 import { defineComponent } from 'vue'
+import Item from './item'
 import styles from './index.module.less'
 
 export default defineComponent({
@@ -19,21 +23,152 @@ export default defineComponent({
   data() {
     return {
       active: '0',
-      list: [1],
+      list: [],
       dataShow: true, // 判断是否有数据
       loading: false,
       finished: false,
+      show: false,
       params: {
-        search: '',
-        groupStatus: 'APPLY',
-        page: 1,
-        rows: 20
+        pageNum: 1,
+        pageSize: 20
       },
-      show: false
+
+      returnGood: {
+        description: '',
+        memberUsername: '',
+        orderId: 0,
+        orderSn: '',
+        productAttr: '',
+        productBrand: '',
+        productCount: 0,
+        productId: 0,
+        productName: '',
+        productPic: '',
+        productPrice: 0,
+        productRealPrice: 0,
+        proofPics: '',
+        reason: '',
+        returnName: '',
+        returnPhone: '',
+        returnOrderSn: ''
+      },
+      reason: '', // 退货原因
+      returnOrderSn: '' // 退货快递单号
+    }
+  },
+  watch: {
+    active() {
+      this.init()
+      this.getList()
     }
   },
   methods: {
-    getList() {}
+    init() {
+      this.params.pageNum = 1
+      this.finished = false
+      this.list = []
+    },
+
+    async getList() {
+      //避免重复请求
+      if (this.loading && this.finished) {
+        return
+      }
+      this.loading = true
+      let res: any
+      if (this.active === '0') {
+        // 可退货列表
+        res = await this.getIsReturnOrderList()
+      } else {
+        // 退货申请列表
+        res = await this.getReturnList()
+      }
+      // console.log(res)
+      if (!res.data.list) {
+        this.dataShow = false
+      }
+      if (res.code === 200 && res.data.list) {
+        this.list = [].concat(this.list, res.data.list)
+        this.params.pageNum = res.data.pageNum + 1
+      }
+      this.finished = this.params.pageNum >= res.data.totalPage
+      this.loading = false
+    },
+
+    //获取可退货列表
+    async getIsReturnOrderList() {
+      try {
+        let res = await request.get('/api-mall-portal/order/list', {
+          params: {
+            ...this.params,
+            status:
+              this.active === '0' ? '1,2,3' : this.active === '1' ? '' : ''
+          }
+        })
+        return res
+      } catch (error) {}
+      return {}
+    },
+
+    // 获取退货申请
+    async getReturnList() {
+      try {
+        let res = await request.post('/api-mall-portal/returnApply/list', {
+          data: {
+            ...this.params,
+            status: this.active === '1' ? '0' : '1'
+          }
+        })
+        return res
+      } catch (error) {}
+      return {}
+    },
+
+    // 设置退货参数
+    setReturnParams(item: any, n: any): void {
+      this.returnGood.memberUsername = state.user.data.username
+      this.returnGood.orderId = item.id
+      this.returnGood.orderSn = item.orderSn
+      this.returnGood.productAttr = n.productAttr
+      this.returnGood.productBrand = n.productBrand
+      this.returnGood.productCount = n.productQuantity
+      this.returnGood.productId = n.productId
+      this.returnGood.productName = n.productName
+      this.returnGood.productPic = n.productPic
+      this.returnGood.productPrice = n.productPrice
+      this.returnGood.productRealPrice = n.productPrice
+      this.returnGood.proofPics = ''
+      this.returnGood.returnName = item.receiverName
+      this.returnGood.returnPhone = item.receiverPhone
+      console.log(this.returnGood)
+    },
+    // 退商品
+    async setReturnShop() {
+      if (!this.reason) {
+        Toast('请填写退货原因!')
+        return
+      }
+      this.returnGood.reason = this.reason
+      this.returnGood.returnOrderSn = this.returnOrderSn
+      try {
+        let res = await request.post('/api-mall-portal/returnApply/create', {
+          data: {
+            ...this.returnGood
+          }
+        })
+        if (res.code === 200) {
+          Toast({
+            message: '退货申请成功!',
+            onOpened: () => {
+              this.show = false
+              this.reason = ''
+              this.returnOrderSn = ''
+              this.active = '1'
+            }
+          })
+        }
+      } catch (error) {}
+    }
   },
   render() {
     return (
@@ -56,60 +191,74 @@ export default defineComponent({
 
         {this.dataShow ? (
           <List
-            v-model:loading={this.loading}
+            loading={this.loading}
             finished={this.finished}
             finishedText=" "
             class={[styles.goodsList]}
             onLoad={this.getList}
           >
             {this.list.map((item: any) => (
-              <CellGroup class={styles.cellGroup}>
-                <Cell
-                  center
-                  v-slots={{
-                    icon: () => (
-                      <Image
-                        class={styles.goodsImg}
-                        src="https://cdn.jsdelivr.net/npm/@vant/assets/cat.jpeg"
-                        fit="cover"
-                      />
-                    ),
-                    default: () => (
-                      <div class={styles.goodsContainer}>
-                        <div class={[styles.goodsTitle, 'van-ellipsis']}>
-                          次中音号降调JBBR-1220次中音号降调JBBR-1220次中音号降调JBBR-1220
-                        </div>
-                        <div class={styles.model}>型号:默认</div>
-                        <div class={styles.goodsPrice}>
-                          <span class={styles.price}>
-                            <i>¥</i>2,5000.0
-                          </span>
-                          <span class={styles.num}>x1</span>
-                        </div>
-                      </div>
-                    )
-                  }}
-                ></Cell>
-                <Cell
-                  center
-                  v-slots={{
-                    default: () => (
-                      <div class={styles.btnList}>
-                        <Button
-                          size="small"
-                          round
-                          type="primary"
-                          onClick={() => {
-                            this.show = true
-                          }}
-                        >
-                          申请退货
-                        </Button>
-                      </div>
-                    )
-                  }}
-                ></Cell>
-              </CellGroup>
+              <>
+                {item.orderItemList && item.orderItemList.length ? (
+                  item.orderItemList.map((n: any) => (
+                    <CellGroup class={styles.cellGroup}>
+                      <Item item={n} />
+                      <Cell
+                        center
+                        v-slots={{
+                          default: () => (
+                            <div class={styles.btnList}>
+                              {this.active === '0' &&
+                              (item.status !== 0 || item.status !== 6) ? (
+                                <Button
+                                  size="small"
+                                  round
+                                  type="primary"
+                                  onClick={() => {
+                                    this.show = true
+                                    this.setReturnParams(item, n)
+                                  }}
+                                >
+                                  退货申请
+                                </Button>
+                              ) : null}
+                            </div>
+                          )
+                        }}
+                      ></Cell>
+                    </CellGroup>
+                  ))
+                ) : (
+                  <CellGroup class={styles.cellGroup}>
+                    <Item item={item} />
+                    <Cell
+                      center
+                      v-slots={{
+                        default: () => (
+                          <div class={styles.btnList}>
+                            {this.active !== '0' && item.status === 0 ? (
+                              <Button
+                                size="small"
+                                round
+                                type="primary"
+                                onClick={() => {
+                                  this.show = true
+                                }}
+                              >
+                                撤销申请
+                              </Button>
+                            ) : (
+                              <div class={styles.returnDes}>
+                                该商品金额已于 2021-03-24 13:34:24 原路退还
+                              </div>
+                            )}
+                          </div>
+                        )
+                      }}
+                    ></Cell>
+                  </CellGroup>
+                )}
+              </>
             ))}
           </List>
         ) : (
@@ -123,11 +272,21 @@ export default defineComponent({
               placeholder="请输入退货原因"
               type="textarea"
               rows={3}
+              v-model={this.reason}
+            />
+            <Field
+              v-model={this.returnOrderSn}
+              class={[styles.field]}
+              placeholder="请输入退货快递单号"
             />
-            <Field class={[styles.field]} placeholder="请输入退货快递单号" />
           </div>
           <div class={styles['btn-group']}>
-            <Button type="primary" block round>
+            <Button
+              type="primary"
+              block
+              round
+              onClick={() => this.setReturnShop()}
+            >
               确定
             </Button>
           </div>

+ 88 - 0
src/views/goods-order/components/after-sale-btns/index.tsx

@@ -0,0 +1,88 @@
+import { moneyFormat } from '@/helpers/utils'
+import { Button, Cell } from 'vant'
+import { defineComponent } from 'vue'
+import styles from '../../index.module.less'
+
+export default defineComponent({
+  name: 'AfterSaleBtns',
+  props: {
+    item: {
+      type: Object,
+      default: {}
+    },
+    onCancelOrder: {
+      type: Function,
+      default: (n: any) => {}
+    },
+    onPayOrder: {
+      type: Function,
+      default: (n: any) => {}
+    },
+    onConfirmReceipt: {
+      type: Function,
+      default: (n: any) => {}
+    }
+  },
+  setup({ item, onCancelOrder, onPayOrder, onConfirmReceipt }) {
+    return () => (
+      <Cell
+        center
+        v-slots={{
+          title: () => (
+            <div class={styles.orderPrice}>
+              订单金额
+              <span class={styles.price} style={{ paddingLeft: '5px' }}>
+                <i>¥</i>
+                {moneyFormat(item.payAmount)}
+              </span>
+            </div>
+          ),
+          default: () => (
+            <div class={styles.btnList}>
+              {/* <span class={styles.sureGoods}>已确认收货</span> */}
+
+              {item.status === 0 || item.status === 6 ? (
+                <>
+                  <Button
+                    size="small"
+                    round
+                    onClick={(e: Event) => {
+                      e.stopPropagation()
+                      onCancelOrder(item)
+                    }}
+                  >
+                    取消订单
+                  </Button>
+                  <Button
+                    size="small"
+                    round
+                    type="primary"
+                    onClick={(e: Event) => {
+                      e.stopPropagation()
+                      onPayOrder(item)
+                    }}
+                  >
+                    继续支付
+                  </Button>
+                </>
+              ) : null}
+              {item.status === 2 ? (
+                <Button
+                  size="small"
+                  round
+                  type="primary"
+                  onClick={(e: Event) => {
+                    e.stopPropagation()
+                    onConfirmReceipt(item)
+                  }}
+                >
+                  确认收货
+                </Button>
+              ) : null}
+            </div>
+          )
+        }}
+      ></Cell>
+    )
+  }
+})

+ 60 - 103
src/views/goods-order/index.tsx

@@ -6,12 +6,14 @@ import { defineComponent } from 'vue'
 import styles from './index.module.less'
 import { orderState } from '@/views/shop-mall/shop-mall'
 import { cartConfirm } from '@/views/cart/cart'
+import Item from './item'
+import AfterSaleBtns from './components/after-sale-btns'
 
 export default defineComponent({
   name: 'shop-order',
   data() {
     return {
-      active: -1,
+      active: 0,
       list: [],
       dataShow: true, // 判断是否有数据
       loading: false,
@@ -24,7 +26,7 @@ export default defineComponent({
       },
       page: {
         pageNum: 1,
-        pageSize: 10
+        pageSize: 20
       }
     }
   },
@@ -43,14 +45,14 @@ export default defineComponent({
     },
     async getList() {
       if (this.loading || this.finished) {
-        return 
+        return
       }
       this.loading = true
       try {
         let { code, data } = await request.get('/api-mall-portal/order/list', {
           params: {
             ...this.page,
-            status: this.active
+            status: this.active === 0 ? '0,4' : this.active === 1 ? '1,2' : '3'
           }
         })
 
@@ -93,6 +95,27 @@ export default defineComponent({
     payOrder(item: any) {
       cartConfirm.orderInfo = item
       this.$router.push({ path: '/cartConfirmAgin' })
+    },
+
+    // 确认收货
+    async onConfirmReceipt(item: any) {
+      let dialog = await Dialog.confirm({
+        title: '提示',
+        message: '确认收货?',
+        confirmButtonText: '收货',
+        confirmButtonColor: 'var(--van-primary)'
+      })
+      if (dialog === 'confirm') {
+        let res = await request.post(
+          '/api-mall-portal/order/confirmReceiveOrder',
+          { params: { orderId: item.id } }
+        )
+        if (res.code === 200) {
+          item.status = 3
+          // this.init()
+          // this.getList()
+        }
+      }
     }
   },
   render() {
@@ -108,9 +131,9 @@ export default defineComponent({
                 color="var(--van-primary)"
                 lineWidth={28}
               >
-                <Tab name={-1} title="全部"></Tab>
-                <Tab name={1} title="处理中"></Tab>
-                <Tab name={2} title="已处理"></Tab>
+                <Tab name={0} title="待支付"></Tab>
+                <Tab name={1} title="待收货"></Tab>
+                <Tab name={2} title="已收货"></Tab>
               </Tabs>
             )
           }}
@@ -125,103 +148,37 @@ export default defineComponent({
             onLoad={this.getList}
           >
             {this.list.map((item: any) => (
-              <CellGroup
-                class={styles.cellGroup}
-                onClick={() => {
-                  this.$router.push({
-                    path: '/shopOrderDetail',
-                    query: { id: item.id }
-                  })
-                }}
-              >
-                <Cell
-                  title={item.createTime}
-                  titleClass={styles.payTime}
-                  value={orderState[item.status]}
-                  valueClass={styles.payStatus}
-                ></Cell>
-                {item.orderItemList
-                  ? item.orderItemList.map((n: any) => (
-                      <Cell
-                        center
-                        v-slots={{
-                          icon: () => (
-                            <Image
-                              class={styles.goodsImg}
-                              src={n.productPic}
-                              fit="cover"
-                            />
-                          ),
-                          default: () => (
-                            <div class={styles.goodsContainer}>
-                              <div class={[styles.goodsTitle, 'van-ellipsis']}>
-                                {n.productName}
-                              </div>
-                              <div class={styles.model}>{n.productAttr}</div>
-                              <div class={styles.goodsPrice}>
-                                <span class={styles.price}>
-                                  <i>¥</i>
-                                  {((n.productPrice * 100) / 100).toFixed(2)}
-                                </span>
-                                <span class={styles.num}>
-                                  x{n.productQuantity}
-                                </span>
-                              </div>
-                            </div>
-                          )
-                        }}
-                      ></Cell>
-                    ))
-                  : null}
-                <Cell
-                  center
-                  v-slots={{
-                    title: () => (
-                      <div class={styles.orderPrice}>
-                        订单金额
-                        <span
-                          class={styles.price}
-                          style={{ paddingLeft: '5px' }}
-                        >
-                          <i>¥</i>
-                          {((item.payAmount * 100) / 100).toFixed(2)}
-                        </span>
-                      </div>
-                    ),
-                    default: () => (
-                      <div class={styles.btnList}>
-                        {/* <span class={styles.sureGoods}>已确认收货</span> */}
-
-                        {item.status === 0 || item.status === 6 ? (
-                          <>
-                            <Button
-                              size="small"
-                              round
-                              onClick={(e: Event) => {
-                                e.stopPropagation()
-                                this.cancelOrder(item)
-                              }}
-                            >
-                              取消订单
-                            </Button>
-                            <Button
-                              size="small"
-                              round
-                              type="primary"
-                              onClick={(e: Event) => {
-                                e.stopPropagation()
-                                this.payOrder(item)
-                              }}
-                            >
-                              继续支付
-                            </Button>
-                          </>
-                        ) : null}
-                      </div>
-                    )
+              <>
+                <CellGroup
+                  class={styles.cellGroup}
+                  onClick={() => {
+                    this.$router.push({
+                      path: '/shopOrderDetail',
+                      query: { id: item.id }
+                    })
                   }}
-                ></Cell>
-              </CellGroup>
+                >
+                  <Cell
+                    title={item.createTime}
+                    titleClass={styles.payTime}
+                    value={orderState[item.status]}
+                    valueClass={
+                      [0, 4, 5, 6].includes(item.status)
+                        ? styles.payStatus
+                        : styles.paySuccess
+                    }
+                  ></Cell>
+                  {item.orderItemList && item.orderItemList.length
+                    ? item.orderItemList.map((n: any) => <Item item={n} />)
+                    : null}
+                  <AfterSaleBtns
+                    item={item}
+                    onCancelOrder={this.cancelOrder}
+                    onPayOrder={this.payOrder}
+                    onConfirmReceipt={this.onConfirmReceipt}
+                  />
+                </CellGroup>
+              </>
             ))}
           </List>
         ) : (

+ 41 - 0
src/views/goods-order/item.tsx

@@ -0,0 +1,41 @@
+import { moneyFormat } from '@/helpers/utils'
+import { Cell, Image } from 'vant'
+import { defineComponent } from 'vue'
+import styles from './index.module.less'
+
+export default defineComponent({
+  name: 'GoodItem',
+  props: {
+    item: {
+      type: Object,
+      default: {}
+    }
+  },
+  setup({ item }) {
+    return () => (
+      <Cell
+        center
+        v-slots={{
+          icon: () => (
+            <Image class={styles.goodsImg} src={item.productPic} fit="cover" />
+          ),
+          default: () => (
+            <div class={styles.goodsContainer}>
+              <div class={[styles.goodsTitle, 'van-ellipsis']}>
+                {item.productName}
+              </div>
+              <div class={styles.model}>{item.productAttr}</div>
+              <div class={styles.goodsPrice}>
+                <span class={styles.price}>
+                  <i>¥</i>
+                  {moneyFormat(item.productPrice)}
+                </span>
+                <span class={styles.num}>x{item.productQuantity}</span>
+              </div>
+            </div>
+          )
+        }}
+      ></Cell>
+    )
+  }
+})

+ 48 - 4
src/views/shop-mall/goods-detail/index.tsx

@@ -18,11 +18,13 @@ import {
   ActionBarIcon,
   Icon,
   Badge,
-  Toast
+  Toast,
+  Popup
 } from 'vant'
 import { defineComponent } from 'vue'
 import styles from './index.module.less'
 import iconShopCart from '../images/icon-shop-cart.png'
+import AddGoodsCart from '../modal/add-goods-cart'
 
 export default defineComponent({
   name: 'goods-detail',
@@ -32,10 +34,12 @@ export default defineComponent({
       id: query.id,
       albumPics: [],
       product: {} as any,
-      radio: '',
+      radio: 0,
       skuStockListTemp: [],
       detailMobileHtml: '',
-      loading: false
+      loading: false,
+      addGoodsShow: false,
+      selectGoodsItem: {}
     }
   },
   computed: {
@@ -82,6 +86,16 @@ export default defineComponent({
         : [result.product.pic]
       this.product = result.product
       this.skuStockListTemp = result.skuStockList || []
+      if (this.skuStockListTemp.length) {
+        let len = this.skuStockListTemp.length
+        for (let i = 0; i < len; i++) {
+          let item = this.skuStockListTemp[i] as any
+          if (item.stock >= 0) {
+            this.radio = item.id
+            break
+          }
+        }
+      }
       this.detailMobileHtml = result.product.detailMobileHtml
     } catch {}
   },
@@ -114,6 +128,21 @@ export default defineComponent({
         closeable: true
       })
     },
+    onShowCart() {
+      this.selectGoodsItem = {
+        price: this.product.pic,
+        stock: this.product.stock,
+        skuStockList: this.skuStockListTemp.length ? this.skuStockListTemp : undefined,
+        brandName: this.product.brandName,
+        productCategoryId: this.product.productCategoryId,
+        name: this.product.name,
+        productSn: this.product.productSn,
+        productSubTitle: this.product.subTitle,
+        id: this.product.id
+      }
+      // 打开购物弹框
+      this.addGoodsShow = true
+    },
     onBuy() {
       // 购买
       if (!this.radio) {
@@ -240,6 +269,9 @@ export default defineComponent({
             <ActionBarIcon
               icon="cart-o"
               // text="购物车"
+              onClick={() => {
+                this.$router.push('/cart')
+              }}
               v-slots={{
                 icon: () => <Icon name={iconShopCart} size={30} />
               }}
@@ -249,15 +281,27 @@ export default defineComponent({
                 type="primary"
                 class={styles.addCertBtn}
                 text="加入购物车"
+                onClick={this.onShowCart}
               />
               <ActionBarButton
                 type="primary"
                 text="立即购买"
-                onClick={this.onBuy}
+                onClick={this.onShowCart}
               />
             </div>
           </ActionBar>
         )}
+        <Popup
+          show={this.addGoodsShow}
+          closeable
+          position="bottom"
+          round
+          onClose={() => {
+            this.addGoodsShow = false
+          }}
+        >
+          <AddGoodsCart item={this.selectGoodsItem} defaultRadio={this.radio} />
+        </Popup>
       </div>
     )
   }

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

@@ -44,4 +44,8 @@
   .icon-active {
     color: var(--van-primary);
   }
+  .iconSort{
+    margin-top: -5px;
+    margin-left: -1px;
+  }
 }

+ 21 - 13
src/views/shop-mall/goods-list/index.tsx

@@ -8,13 +8,15 @@ import ColSearch from '@/components/col-search'
 export default defineComponent({
   name: 'goods-list',
   data() {
+    console.log(this.$route)
+    const query = this.$route.query
     return {
       typeId: 0,
       filterActive: 0,
       filterListShow: false,
       productCategory: {
-        name: '',
-        id: 0
+        name: query.tag || '',
+        id: Number(query.id) || 0
       },
       productAttributeCategory: {
         name: '',
@@ -55,12 +57,14 @@ export default defineComponent({
     onClearTag(key: string) {
       this[key] = { id: 0, name: '' }
       let goodsFilter = this.$refs.goodsFilter as any
-      if (key === 'productCategory') {
-        goodsFilter.setParams('productCategorySmallVoList')
-      } else if (key === 'productAttributeCategory') {
-        goodsFilter.setParams('productAttributeCategoryList')
-      } else {
-        goodsFilter.setParams('brandList')
+      if (goodsFilter) {
+        if (key === 'productCategory') {
+          goodsFilter.setParams('productCategorySmallVoList')
+        } else if (key === 'productAttributeCategory') {
+          goodsFilter.setParams('productAttributeCategoryList')
+        } else {
+          goodsFilter.setParams('brandList')
+        }
       }
       this.$nextTick(() => {
         this.onSearch()
@@ -70,7 +74,7 @@ export default defineComponent({
       let tabList = this.$refs.tabList as any
       tabList.onSearch()
     },
-    searchBtn(keyword?: string){
+    searchBtn(keyword?: string) {
       this.keyword = keyword
       this.$nextTick(() => {
         this.onSearch()
@@ -108,8 +112,8 @@ export default defineComponent({
                   size={12}
                 />
                 <Icon
-                  class={this.filterActive === 4 ? styles['icon-active'] : ''}
-                  style={{ transform: 'rotate(90deg)', marginTop: '-5px' }}
+                  class={[styles.iconSort, this.filterActive === 4 ? [styles['icon-active']] : '']}
+                  style={{ transform: 'rotate(90deg)'}}
                   name="play"
                   size={12}
                 />
@@ -171,7 +175,7 @@ export default defineComponent({
 
         <TabList
           ref="tabList"
-          typeId={this.productCategory.id}
+          typeId={Number(this.productCategory.id)}
           productAttributeCategoryId={this.productAttributeCategory.id}
           brandId={this.brand.id}
           sort={this.filterActive}
@@ -187,7 +191,11 @@ export default defineComponent({
             this.filterListShow = false
           }}
         >
-          <GoodsFilterList ref="goodsFilter" setFilter={this.setFilter} />
+          <GoodsFilterList
+            cateGoryId={this.productCategory.id}
+            ref="goodsFilter"
+            setFilter={this.setFilter}
+          />
         </Popup>
       </div>
     )

+ 43 - 7
src/views/shop-mall/index.tsx

@@ -1,5 +1,5 @@
 import ColHeader from '@/components/col-header'
-import { Divider, Icon, Image, Sticky, Swipe, SwipeItem, Tab, Tabs } from 'vant'
+import { Dialog, Divider, Icon, Image, Sticky, Swipe, SwipeItem, Tab, Tabs } from 'vant'
 import { defineComponent } from 'vue'
 import HotGoods from './components/hot-goods'
 import MenuList from './components/menu-list'
@@ -8,6 +8,7 @@ import styles from './index.module.less'
 import iconShopCart from './images/icon-shop-cart.png'
 import request from '@/helpers/request'
 import { useRect } from '@vant/use'
+import { postMessage } from '@/helpers/native-message'
 
 export default defineComponent({
   name: 'shop-mall',
@@ -40,7 +41,27 @@ export default defineComponent({
     } catch {}
   },
   methods: {
-    onSearch() {}
+    onSearch() {},
+    openWebView(url: string): void {
+      // console.log(url)
+      let dev = false
+      let origin = location.origin + '/#'
+      if (!url) return
+      url = origin + url
+      console.log('跳转url:', url)
+      if (dev) {
+        location.href = url
+        return
+      }
+      postMessage({
+        api: 'openWebView',
+        content: {
+          url: url,
+          orientation: 1,
+          isHideTitle: false
+        }
+      })
+    }
   },
   render() {
     return (
@@ -49,6 +70,7 @@ export default defineComponent({
           <ColHeader
             border={false}
             background="linear-gradient(#59e5d5, 30%, #f6f8f9)"
+            onClickRight={() => this.openWebView('/cart')}
             v-slots={{
               right: () => (
                 <div class={styles['icon-shop-cart']}>
@@ -74,16 +96,22 @@ export default defineComponent({
           lazyRender
         >
           {this.advertiseList.map((item: any) => (
-            <SwipeItem>
+            <SwipeItem onClick={() => this.openWebView(item.url)}>
               <Image class={styles.swipeItemImg} src={item.pic} fit="cover" />
             </SwipeItem>
           ))}
         </Swipe>
 
-        <MenuList productList={this.productList} />
+        <MenuList
+          productList={this.productList}
+          onOpenWebView={this.openWebView}
+        />
 
         {this.hotProductList.length === 3 && (
-          <HotGoods hotProductList={this.hotProductList} />
+          <HotGoods
+            hotProductList={this.hotProductList}
+            onOpenWebView={this.openWebView}
+          />
         )}
 
         <Tabs
@@ -98,12 +126,20 @@ export default defineComponent({
         >
           {this.productCategoryList.length > 0 && (
             <Tab title="全部分类" name={0}>
-              <TabList typeId={0} />
+              <TabList
+                isTab={true}
+                typeId={0}
+                onOpenWebView={this.openWebView}
+              />
             </Tab>
           )}
           {this.productCategoryList.map((item: any) => (
             <Tab title={item.name} name={item.id}>
-              <TabList typeId={item.id} />
+              <TabList
+                isTab={true}
+                typeId={item.id}
+                onOpenWebView={this.openWebView}
+              />
             </Tab>
           ))}
         </Tabs>

+ 15 - 3
src/views/shop-mall/modal/add-goods-cart/index.tsx

@@ -22,6 +22,10 @@ export default defineComponent({
     item: {
       type: Object,
       default: {}
+    },
+    defaultRadio: {
+      type: Number,
+      default: ''
     }
   },
   data() {
@@ -63,7 +67,12 @@ export default defineComponent({
         }
       })
       // 处理默认显示
-      const { id, price, pic, stock, spDataJson, skuCode } = skuStockList[0]
+      let index = 0
+      if (this.defaultRadio) {
+        let i = skuStockList.findIndex(n => n.id == this.defaultRadio)
+        index = i > -1 ? i : 0
+      }
+      const { id, price, pic, stock, spDataJson, skuCode } = skuStockList[index]
       this.radio = id
       this.selectItem = {
         id,
@@ -73,6 +82,7 @@ export default defineComponent({
         spDataJson,
         skuCode
       }
+
       return skuStockList
     }
   },
@@ -83,6 +93,7 @@ export default defineComponent({
       const selectItem = this.selectItem
       const item = this.item
       const body = {
+        productBrand: item.brandName,
         price: selectItem.price, //添加到购物车的价格
         productCategoryId: item.productCategoryId, //商品分类
         productName: item.name, // 商品名称
@@ -95,7 +106,7 @@ export default defineComponent({
         productId: item.id,
         productAttr: selectItem.spDataJson
       }
-      console.log(body)
+      // console.log(body)
       try {
         let { code, data } = await request.post('/api-mall-portal/cart/add', {
           data: body
@@ -105,7 +116,8 @@ export default defineComponent({
             title: '提示',
             message: '加入购物车成功,是否去决算?',
             cancelButtonText: '继续购买',
-            confirmButtonText: '去结算'
+            confirmButtonText: '去结算',
+            confirmButtonColor: 'var(--van-primary)'
           })
             .then(() => {
               // on confirm

+ 10 - 0
src/views/shop-mall/modal/goods-filter-list/index.tsx

@@ -25,6 +25,10 @@ export default defineComponent({
     setFilter: {
       type: Function,
       default: (item: any) => {}
+    },
+    cateGoryId:{
+      type: Number,
+      default: 0
     }
   },
   data() {
@@ -57,6 +61,12 @@ export default defineComponent({
         this.brandList = brandList
         this.productAttributeCategoryList = productAttributeCategoryList
         this.productCategorySmallVoList = productCategorySmallVoList
+
+        if (this.cateGoryId) {
+          let i = productCategorySmallVoList.findIndex(n => n.id == this.cateGoryId)
+          console.log(i)
+          this.params.productCategorySmallVoList = i > -1 ? i : null
+        }
       } catch {
         this.dataShow = false
       }

+ 3 - 2
src/views/shop-mall/shop-mall.ts

@@ -1,8 +1,9 @@
 export const orderState = {
-    0: '待付',
+    0: '待付',
     1: '待发货',
     2: '已发货',
     3: '已完成',
     4: '已关闭',
-    5: '无效订单'
+    5: '无效订单',
+    6: '待支付'
   }