Selaa lähdekoodia

价格格式化

skyblued 3 vuotta sitten
vanhempi
commit
b5a78bef24

+ 4 - 12
src/views/cart/cart-confirm-agin/index.tsx

@@ -11,22 +11,17 @@ import { state } from '@/state'
 import ColPopup from '@/components/col-popup'
 import UserAuth from '@/views/order-detail/userAuth'
 import ColResult from '@/components/col-result'
+import { moneyFormat } from '@/helpers/utils'
 export default defineComponent({
   setup() {
-    console.log(cartConfirm)
+    // console.log(cartConfirm)
     const list = cartConfirm.orderInfo?.orderItemList || []
     const calcAmount = {
       totalAmount: cartConfirm.orderInfo?.totalAmount || 0,
       payAmount: cartConfirm.orderInfo?.payAmount || 0,
       freightAmount: cartConfirm.orderInfo?.freightAmount || 0
     }
-
-    onMounted(() => {
-      // console.log(cartConfirm, '确认订单商品')
-    })
-
     const payType = ref(0) // 0->未支付;1->支付宝;2->微信
-
     const address: addressType = {
       city: cartConfirm.orderInfo?.receiverCity,
       detailAddress: cartConfirm.orderInfo?.receiverDetailAddress,
@@ -36,7 +31,6 @@ export default defineComponent({
       province: cartConfirm.orderInfo?.receiverProvince,
       region: cartConfirm.orderInfo?.receiverRegion
     }
-
     const agreeStatus = ref(false)
     const paymentPopup = ref(false)
     const authPopup = ref(false)
@@ -89,9 +83,7 @@ export default defineComponent({
                     style={{ marginBottom: '10px' }}
                   >
                     <Card
-                      price={((item.productPrice * 100) / 100).toFixed(
-                        2
-                      )}
+                      price={moneyFormat(item.productPrice)}
                       desc={item.productAttr}
                       title={item.productName}
                       thumb={item.productPic}
@@ -129,7 +121,7 @@ export default defineComponent({
               <div class={styles.confirmBottom}>
                 合计{' '}
                 <span class={styles['price-des']}>
-                  ¥{((calcAmount.payAmount * 1000) / 1000).toFixed(2)}
+                  ¥{moneyFormat(calcAmount.payAmount)}
                 </span>
               </div>
             </SubmitBar>

+ 11 - 8
src/views/cart/cart-confirm/index.tsx

@@ -11,6 +11,7 @@ import { state } from '@/state'
 import ColPopup from '@/components/col-popup'
 import UserAuth from '@/views/order-detail/userAuth'
 import ColResult from '@/components/col-result'
+import { moneyFormat } from '@/helpers/utils'
 export default defineComponent({
   setup() {
     const list = cartConfirm.cartPromotionItemList
@@ -25,7 +26,7 @@ export default defineComponent({
     const address = cartConfirm.memberReceiveAddressList.length
       ? cartConfirm.memberReceiveAddressList.find(
           (n: any) => n.defaultStatus
-        ) || cartConfirm.memberReceiveAddressList[0]
+        ) || cartConfirm.memberReceiveAddressList[0] || {}
       : {}
 
     const agreeStatus = ref(false)
@@ -37,6 +38,10 @@ export default defineComponent({
     })
     // 提交
     const onSubmit = () => {
+      if (!(address as any).id){
+        Toast('请选择收货地址')
+        return
+      }
       if (!agreeStatus.value) {
         Toast('请先阅读并同意《酷乐秀平台服务协议》')
         return
@@ -103,9 +108,7 @@ export default defineComponent({
                     style={{ marginBottom: '10px' }}
                   >
                     <Card
-                      price={((item.price * item.quantity * 100) / 100).toFixed(
-                        2
-                      )}
+                      price={moneyFormat(item.price)}
                       desc={item.productAttr}
                       title={item.productName}
                       thumb={item.productPic}
@@ -118,14 +121,14 @@ export default defineComponent({
                 <Cell
                   border={false}
                   title="总额"
-                  value={'¥ ' + calcAmount.totalAmount}
+                  value={'¥ ' + moneyFormat(calcAmount.totalAmount)}
                 ></Cell>
                 <Cell
                   border={false}
                   title="运费"
-                  value={calcAmount.freightAmount}
+                  value={moneyFormat(calcAmount.freightAmount)}
                 ></Cell>
-                <Cell border={false} title="优惠" value={'-¥ ' + calcAmount.promotionAmount}></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>
@@ -142,7 +145,7 @@ export default defineComponent({
             >
               <div class={styles.confirmBottom}>
                 合计{' '}
-                <span class={styles['price-des']}>¥{(calcAmount.payAmount * 1000 / 1000).toFixed(2)}</span>
+                <span class={styles['price-des']}>¥{moneyFormat(calcAmount.payAmount)}</span>
               </div>
             </SubmitBar>
             <div style={{ height: 'var(--van-submit-bar-height)' }}></div>

+ 3 - 5
src/views/cart/index.tsx

@@ -6,6 +6,7 @@ import request from '@/helpers/request'
 import { cartConfirm } from './cart'
 import item from '@/teacher/music/list/item'
 import ColResult from '@/components/col-result'
+import { moneyFormat } from '@/helpers/utils'
 
 export default defineComponent({
   name: 'cart',
@@ -111,6 +112,7 @@ export default defineComponent({
           cartConfirm.calcAmount = data.calcAmount
           cartConfirm.cartPromotionItemList = data.cartPromotionItemList
           cartConfirm.memberReceiveAddressList = data.memberReceiveAddressList
+          // alert(JSON.stringify(data.memberReceiveAddressList))
           this.$router.push({
             path: '/cartConfirm'
           })
@@ -135,7 +137,6 @@ export default defineComponent({
         ) : (
           <>
             <ColHeader
-              isBack
               onClickRight={() => (this.isManage = !this.isManage)}
               v-slots={{
                 right: () => (
@@ -151,10 +152,7 @@ export default defineComponent({
                   <div class={styles.cartItem}>
                     <Checkbox name={item.id}>
                       <Card
-                        price={(
-                          (item.price * item.quantity * 100) /
-                          100
-                        ).toFixed(2)}
+                        price={moneyFormat(item.price)}
                         desc={item.productAttr}
                         title={item.productName}
                         thumb={item.productPic}

+ 11 - 0
src/views/goods-order/index.module.less

@@ -11,6 +11,12 @@
   color: #666666;
   line-height: 18px;
 }
+.payStatus{
+  color: #FF4E19;
+}
+.paySuccess{
+  color: var(--van-primary);
+}
 
 .cellGroup {
   margin: 12px 14px;
@@ -92,3 +98,8 @@
 .btn-group {
   padding: 0 15% 12px;
 }
+.returnDes{
+  color: #666;
+  font-size: 14px;
+  margin-right: auto;
+}

+ 2 - 1
src/views/shop-mall/components/shop-item/index.tsx

@@ -1,3 +1,4 @@
+import { moneyFormat } from '@/helpers/utils'
 import { Card } from 'vant'
 import { defineComponent } from 'vue'
 import styles from './index.module.less'
@@ -23,7 +24,7 @@ export default defineComponent({
         thumb={item.productPic}
         title={item.productName}
         desc={item.productAttr}
-        price={((item.productPrice * 100) / 100).toFixed(2)}
+        price={moneyFormat(item.productPrice)}
         num={item.productQuantity}
       ></Card>
     )

+ 3 - 2
src/views/shop-mall/shop-order-detail/index.tsx

@@ -6,6 +6,7 @@ import ShopItem from '../components/shop-item'
 import styles from './index.module.less'
 import { order, item } from './shop-detial'
 import { orderState } from '@/views/shop-mall/shop-mall'
+import { moneyFormat } from '@/helpers/utils'
 
 export default defineComponent({
   name: 'shop-order-detail',
@@ -56,12 +57,12 @@ export default defineComponent({
               <Cell
                 border={false}
                 title="商品价格:"
-                value={'¥ ' + order.value?.totalAmount}
+                value={'¥ ' + moneyFormat(order.value?.totalAmount)}
               ></Cell>
               <Cell
                 border={false}
                 title="优惠价格:"
-                value={'-¥ ' + order.value?.promotionAmount}
+                value={'-¥ ' + moneyFormat(order.value?.promotionAmount)}
               ></Cell>
               <Cell
                 border={false}