فهرست منبع

商品创建订单

xiaohaizhao 1 سال پیش
والد
کامیت
647f8e3896
6فایلهای تغییر یافته به همراه341 افزوده شده و 6 حذف شده
  1. 6 0
      pages.json
  2. 6 3
      store/deliveryAddress/index.vue
  3. 20 0
      store/orderForm/detail.vue
  4. 13 0
      store/orderForm/index.vue
  5. 287 0
      store/orderForm/insert.vue
  6. 9 3
      store/product/detail.vue

+ 6 - 0
pages.json

@@ -67,6 +67,12 @@
 			"path": "deliveryAddress/index"
 		}, {
 			"path": "deliveryAddress/insert"
+		}, {
+			"path": "orderForm/index"
+		}, {
+			"path": "orderForm/detail"
+		}, {
+			"path": "orderForm/insert"
 		}]
 	}],
 	"preloadRule": {

+ 6 - 3
store/deliveryAddress/index.vue

@@ -5,7 +5,7 @@
         </view>
         <My_listbox ref="List" @getlist="getList" bottomHeight="70">
             <view class="item" v-for="(item, index) in list" :key="item.contactsid">
-                <view class="head" hover-class="navigator-hover">
+                <view class="head" hover-class="navigator-hover" @click="onClick(item)">
                     <view class="label u-line-1">
                         <text class="iconfont icon-dizhi-hui" />
                         <text style="margin-right: 10px;">
@@ -61,9 +61,9 @@ export default {
             list: [],
         }
     },
-    onLoad() {
+    onLoad(options) {
         uni.setNavigationBarTitle({
-            title: '收货地址',
+            title: options.title || '收货地址',
         });
         this.getList(true)
     },
@@ -156,6 +156,9 @@ export default {
             uni.navigateTo({
                 url: '/store/deliveryAddress/insert?data=' + JSON.stringify(item),
             });
+        },
+        onClick(item) {
+            this.$Http.selectAddress && this.$Http.selectAddress(item)
         }
     },
 }

+ 20 - 0
store/orderForm/detail.vue

@@ -0,0 +1,20 @@
+<template>
+    <view>
+
+    </view>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+
+        }
+    },
+    onLoad(options) {
+        console.log(options)
+    }
+}
+</script>
+
+<style></style>

+ 13 - 0
store/orderForm/index.vue

@@ -0,0 +1,13 @@
+<template>
+    <view>
+
+    </view>
+</template>
+
+<script>
+export default {
+
+}
+</script>
+
+<style></style>

+ 287 - 0
store/orderForm/insert.vue

@@ -0,0 +1,287 @@
+<template>
+    <view>
+        <navigator url="/store/deliveryAddress/index?title=选择地址" @click="toSelect" class="address-box"
+            hover-class="navigator-hover">
+            <view class="empty" v-if="address.contactsid == 0">
+                请选择收货地址
+            </view>
+            <view class="contacts" v-else>
+                <view class="label">
+                    <text class="iconfont icon-dizhi-hui" />
+                    <text style="margin-right: 10px;">
+                        {{ address.name }}
+                    </text>
+                    <text>
+                        {{ address.phonenumber }}
+                    </text>
+                </view>
+                <view class="address">
+                    {{ getCity(address) }}
+                </view>
+            </view>
+            <view class="iconfont icon-a-wodetiaozhuan" />
+        </navigator>
+
+        <view class="product">
+            <u--image :src="product.cover" width="86" height="80" radius="8">
+                <template v-slot:loading>
+                    <u-loading-icon color="red"></u-loading-icon>
+                </template>
+            </u--image>
+            <view class="content">
+                <view class="title u-line-1">{{ product.name }}</view>
+
+                <view class="price-box">
+                    {{ product.pricetype == '一口价' ? '价格' : '定金' }}
+                    <text style="color: #E3041F;margin-left: 4px;">
+                        ¥
+                    </text>
+                    <text class="price">
+                        {{ CNY(product.pricetype == '一口价' ? product.price : product.price_deposit, '') }}
+                    </text>
+                    <text style="color: #E3041F;margin-left: 4px;">
+                        元
+                    </text>
+                </view>
+            </view>
+        </view>
+        <storeInfo ref="storeInfo" marTop="10" />
+        <view class="address-box" hover-class="navigator-hover">
+            <view class="empty">
+                小计
+            </view>
+            <view class="price">
+                {{ CNY(product.pricetype == '一口价' ? product.price : product.price_deposit) }}
+            </view>
+        </view>
+
+        <view class="footer">
+            <view class="content">
+                <view class="price-box">
+                    总计:
+                    <view class="price">
+                        {{ CNY(product.pricetype == '一口价' ? product.price : product.price_deposit) }}
+                    </view>
+                </view>
+                <view class="submit" :class="address.contactsid == 0 || loading ? 'forbidden' : ''"
+                    hover-class="navigator-hover" @click="address.contactsid == 0 || loading ? '' : submit()">
+                    <u-loading-icon v-if="loading" />
+                    <block v-else>
+                        支付
+                    </block>
+                </view>
+            </view>
+        </view>
+    </view>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+            address: {
+                contactsid: 0
+            },
+            product: {},
+            loading: false
+        }
+    },
+    onLoad(options) {
+        if (options.data) {
+            let data = JSON.parse(options.data)
+            console.log(data)
+            this.product = data;
+        }
+        this.getDefault()
+    },
+    methods: {
+        getDefault() {
+            this.$Http.basic({
+                "id": 20240506103702,
+                "content": {
+                    "where": {
+                        isdefault: 1
+                    }
+                },
+            }).then(res => {
+                console.log("获取默认地址", res)
+                if (this.cutoff(res.msg)) return;
+                if (res.data.length) this.address = res.data[0];
+            })
+        },
+        submit() {
+            this.loading = true;
+            let store = this.$refs.storeInfo.detail;
+            this.$Http.basic({
+                "id": 20240429152502,
+                "content": {
+                    "sa_custorderid": 0,
+                    "items": [
+                        {
+                            "sa_fadid": this.product.sa_fadid,
+                            "qty": 1
+                        }
+                    ],
+                    "rec_contactsid": this.address.contacts,
+                    "sys_enterpriseid": store.sys_enterpriseid,
+                    "sa_storeid": store.sa_storeid,
+                    "remarks": ""
+                },
+            }).then(res => {
+                this.loading = false;
+                console.log("创建订单", res)
+                if (this.cutoff(res.msg)) return;
+            })
+        },
+        toSelect() {
+            this.$Http.selectAddress = function (address) {
+                this.address = address;
+                uni.navigateBack();
+                delete this.$Http.selectAddress
+            }.bind(this)
+        }
+    },
+}
+</script>
+
+<style lang="scss" scoped>
+.address-box {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    margin-top: 10px;
+    width: 100vw;
+    height: 64px;
+    background: #FFFFFF;
+    padding: 0 10px;
+    box-sizing: border-box;
+
+    .empty {
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-size: 14px;
+        color: #333333;
+    }
+
+    .price {
+        font-family: Source Han Sans SC, Source Han Sans SC;
+        font-size: 16px;
+        color: #E3041F;
+    }
+
+    .contacts {
+        .label {
+
+            line-height: 20px;
+            font-family: Source Han Sans SC, Source Han Sans SC;
+            font-weight: bold;
+            font-size: 14px;
+            color: #000000;
+
+            .iconfont {
+                font-size: 12px;
+                color: #333333;
+                margin-right: 5px;
+            }
+        }
+
+        .address {
+            line-height: 17px;
+            font-family: Source Han Sans SC, Source Han Sans SC;
+            font-size: 12px;
+            color: #666666;
+            margin-top: 7px;
+        }
+    }
+
+}
+
+.product {
+    display: flex;
+    width: 100vw;
+    background: #fff;
+    padding: 10px;
+    box-sizing: border-box;
+    margin-top: 10px;
+
+    .content {
+        margin-left: 20px;
+        flex: 1;
+        height: 100%;
+
+        .title {
+            line-height: 24px;
+            font-family: Source Han Sans SC, Source Han Sans SC;
+            font-weight: bold;
+            font-size: 16px;
+            color: #333333;
+            margin-top: 10px;
+        }
+
+        .price-box {
+            margin-top: 10px;
+            font-size: 12px;
+            color: #333333;
+
+            .price {
+                color: #E3041F;
+                font-size: 18px;
+                font-weight: bold;
+            }
+        }
+
+
+    }
+
+}
+
+.footer {
+    position: fixed;
+    width: 100vw;
+    height: 65px;
+    background: #FFFFFF;
+    box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
+    bottom: 0;
+    left: 0;
+    padding: 10px;
+    padding-top: 5px;
+    box-sizing: border-box;
+
+    .content {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        height: 45px;
+        width: 100%;
+
+        .price-box {
+            display: flex;
+            font-size: 14px;
+            color: #333333;
+
+            .price {
+                color: #E3041F;
+                font-size: 16px;
+                font-weight: bold;
+            }
+        }
+
+        .submit {
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            width: 100px;
+            height: 45px;
+            background: #C30D23;
+            border-radius: 5px;
+            font-family: PingFang SC, PingFang SC;
+            font-size: 14px;
+            color: #FFFFFF;
+        }
+    }
+
+}
+
+.forbidden {
+    opacity: .6;
+}
+</style>

+ 9 - 3
store/product/detail.vue

@@ -137,9 +137,9 @@
                     致电
                 </view>
             </view>
-            <navigator class="place-an-order" url="" hover-class="navigator-hover">
+            <view class="place-an-order" @click="purchase" hover-class="navigator-hover">
                 预约购买
-            </navigator>
+            </view>
         </view>
     </view>
 </template>
@@ -184,8 +184,9 @@ export default {
             }).then(res => {
                 console.log("商品详情", res)
                 if (this.cutoff(res.msg)) return;
-                this.files = formattedFiles(res.data.attinfos_pic.map(v => v.attinfos[0])).map(v => {
+                this.files = formattedFiles(res.data.attinfos_pic.map(v => v.attinfos[0])).map((v, i) => {
                     if (v.fileType == 'image') v.cover = this.getSpecifiedImage(v, 'compressed')
+                    if (i == 0) res.data.cover = v.cover;
                     return v
                 })
                 this.detail = res.data;
@@ -214,6 +215,11 @@ export default {
                 this.detail.iscollect = iscollect ? 0 : 1
             })
         },
+        purchase() {
+            uni.navigateTo({
+                url: '/store/orderForm/insert?data=' + JSON.stringify(this.detail),
+            })
+        }
     },
 }
 </script>