diff --git a/apps/pages/home/index.js b/apps/pages/home/index.js index 0c27532..e7bc470 100644 --- a/apps/pages/home/index.js +++ b/apps/pages/home/index.js @@ -81,6 +81,11 @@ export default [ path: '/xianyu/channel', component: () => import(/* webpackChunkName: "channel" */ './channel/channel') }, + { + name: 'home', + path: '/', + component: () => import(/* webpackChunkName: "channel" */ './channel/channel') + }, ...news, ...Mine, ...Trade, diff --git a/apps/pages/order/buyer-ask-order.vue b/apps/pages/order/buyer-ask-order.vue index 731c116..6b4c4e2 100644 --- a/apps/pages/order/buyer-ask-order.vue +++ b/apps/pages/order/buyer-ask-order.vue @@ -9,13 +9,13 @@ <!--商品信息--> <div class="productDetail"> <div class="productImageWrapper"> - <!--<ImageFormat class="image" :lazy="lazy" :src="" :width="136" :height="180"></ImageFormat>--> + <ImageFormat class="image" :lazy="lazy" :src="originProductData.image" :width="136" :height="180"></ImageFormat> </div> <div class="productPrice"> <span class="size">{{sizeInfo}}</span> <div class="pricedetail"> - <span class="priceTitle">最低售价</span> - <span class="price">{{''}}</span> + <span class="priceTitle">最低售价: </span> + <span class="price">{{originProductData.least_price || '-'}}</span> </div> </div> </div> @@ -23,49 +23,46 @@ <span class="inputViewIcon"> ¥ </span> - <Input class="wordText" v-model="inputPrice" clearable="true" type="number" placeholder="定价需以9为结尾,例如1999"></Input> + <Input class="wordText" v-model="inputPrice" type="number" placeholder="定价需以9为结尾" @input="onTextChange"></Input> </div> <div> <div class="sales"> <span class="tipHeaderText">需要支付保证金:</span> - <span class="tipPriceText">¥{{''}}</span> + <span class="tipPriceText">¥{{computeInfo.depositAmount}}</span> </div> </div> <div class="saleDetailTips"> - {{terms}} + {{configTip.tips}} </div> <div class="space"></div> <div class="line"></div> <div class="space"></div> - <div> - <span>商品金额:</span> - <span>{{''}}</span> - </div> - <div> - <span>运费:</span> - <span>{{''}}</span> - </div> - <div> - <span>预计实付金额:</span> - <span>{{''}}</span> + <div class="feeContainer" v-for="(item,index ) in computeInfo.promotionFormulaList"> + <span :class="{'feeCommonText': true, 'feeTotalLeft':index === computeInfo.promotionFormulaList.length - 1}">{{item.promotion}}</span> + <span :class="{'feeCommonText': true, 'feeTotalRight':index === computeInfo.promotionFormulaList.length - 1}">{{item.promotionAmount}}</span> </div> + <div class="space"></div> + <div class="line"></div> + <div class="space"></div> - <order-address></order-address> + <order-address :data="addressInfo"></order-address> <div class="line"></div> <div class="space"></div> - <day-choose></day-choose> + <day-choose :value="chooseDay" :options="dayOptions" :choose="BUYER_ASK_SET_CHOOSEDAY"></day-choose> <div class="space"></div> <div class="line"></div> <div class="bottomContainer"> - - <Button type="submit" disabled="true">提交</Button> + <OrderAgree :value="isAgreeTerms" @input="isAgreeTerms = !isAgreeTerms" class="agree-wrapper"></OrderAgree> + <div> + <Button :disabled="!isAgreeTerms" type="submit" @click="submitClick">提交</Button> + </div> </div> </div> @@ -79,13 +76,19 @@ import {Input, Button} from 'cube-ui'; import OrderAddress from './components/confirm/address'; import DayChoose from './components/askorder/day-choose'; +import OrderAgree from './components/confirm/agree'; +import { createNamespacedHelpers } from 'vuex'; +import {debounce, get} from 'lodash'; +const {mapState, mapActions, mapMutations, mapGetters} = createNamespacedHelpers( + 'order/buyerAskOrder' +); export default { name: 'BuyerAskOrder', - components: {Button, DayChoose, OrderAddress}, + components: {Button, Input, DayChoose, OrderAddress, OrderAgree}, props: { lazy: Boolean, - product: Object, + storageId: Number, }, component: { Input, @@ -95,18 +98,198 @@ export default { data() { return { inputPrice: '', - terms: '求购须支付定金。\n卖家接单后,你需要在24小时内支付商品款。卖家将在你付款后36小时内发货。' + isAgreeTerms: false, }; }, computed: { - + ...mapState([ + 'notFirstOrder', + 'addressInfo', + 'originProductData', + 'configTip', + 'computeInfo', + 'isShowToast', + 'toasMessage', + 'chooseDay', + 'isShowDialog', + 'preTip', + 'publishresult', + ]), + ...mapGetters([ + 'dayOptions', + 'chooseDayId', + ]), sizeInfo: { get() { - return '44' - // return goodsInfo ? goodsInfo.colorName + ',' + goodsInfo.sizeName : '' + return this.originProductData.colorName + ', ' + this.originProductData.sizeName + '码';// '黑色, 48码'; + } + }, + + }, + + mounted() { + this.BUYER_ASK_SET_STORAGEID(this.storageId); + this.fetchBuyerOrderCount({ tabType: 'buy'}); + this.fetchConfig(); + this.$on("addressinfo", function (address) { + console.log(address) + }) + }, + + watch: { + isShowToast(val) { + + if (val) { + this.showToast(); + } + }, + isShowDialog(val) { + + if (val) { + this.showDialog(); + } + } + }, + + methods: { + ...mapMutations([ + 'BUYER_ASK_SET_SHOWTOAST', + 'BUYER_ASK_SET_CHOOSEDAY', + 'BUYER_ASK_SET_SHOWDIALOG', + 'BUYER_ASK_SET_STORAGEID', + ]), + ...mapActions([ + 'fetchConfig', + 'fetchBuyerOrderCount', + 'buyerCompute', + 'buyerPrePublish', + 'buyerPublish', + ]), + + onTextChange: debounce(function() { + if (this.originProductData.least_price && this.originProductData.skup && this.originProductData.least_price <= this.inputPrice) { + this.showBuyDialog(); + } else { + this.buyerCompute({price: this.inputPrice, storage_id: this.storageId }); + } + }, 500, {leading: false, trailing: true}), + + showToast() { + this.BUYER_ASK_SET_SHOWTOAST(false); + this.$createToast({ + time: 1000, + type: 'txt', + txt: this.toasMessage + }).show(); + }, + + showBuyDialog() { + this.$createDialog({ + type: 'confirm', + title: '求购价格过高', + content: '您的出价高于当前售价,建议直接购买', + confirmBtn: { + text: '去购买', + active: true, + disabled: false, + href: 'javascript:;', + }, + cancelBtn: { + text: '取消', + active: false, + disabled: false, + href: 'javascript:;' + }, + onConfirm: () => { + this.$router.push({ + name: 'OrderBuyConfirm', + query: { + storageId: this.storageId || '', + skup: this.originProductData.skup || '', + productId: this.originProductData.productId || '', + }, + }); + }, + onCancel: () => { + this.buyerCompute({price: this.inputPrice, storage_id: this.storageId }); + } + }).show(); + }, + + showDialog() { + this.BUYER_ASK_SET_SHOWDIALOG(false); + + if (this.preTip) { + this.$createDialog({ + type: 'confirm', + title: this.preTip.title || '', + content: this.preTip.content || `确认以${this.inputPrice}元的价格求购`, + confirmBtn: { + text: this.preTip.confirm, + active: true, + disabled: false, + href: 'javascript:;', + }, + cancelBtn: { + text: this.preTip.cancel, + active: false, + disabled: false, + href: 'javascript:;' + }, + + onConfirm: () => { + this.publishProduct() + }, + + onCancel: () => { + + } + + }).show(); + } else { + this.publishProduct() } + + }, + + submitClick() { + this.buyerPrePublish({price: this.inputPrice, storage_id: this.storageId, address_id: this.addressInfo.address_id}); + }, + + publishProduct() { + this.buyerPublish({price: this.inputPrice, storage_id: this.storageId, address_id: this.addressInfo.address_id, time_limit_id: this.chooseDayId}).then(() => { + this.payOrder(); + }); + }, + + payOrder() { + let vm = this; + this.$createOrderPayType({ + price: get(this.publishresult, 'depositAmount', ''), + desc: '保证金', + orderCode: get(this.publishresult, 'orderCode', ''), + extra: JSON.stringify({ + type: 'buy', + back: { + name: 'ProductDetail', + params: { + productId: get(this.originProductData, 'productId', '') + } + }, + forward: { + name: 'SellPayOk', + query: { + orderCode: get(this.publishresult, 'orderCode', ''), + } + } + }), + onCloseAction() { + // vm.onClose(orderResult.data.orderCode); + } + }).show(); } + } }; </script> @@ -119,9 +302,10 @@ export default { } .topContainer { - height: calc(100% - 100px); - padding-left: 20px; - padding-right: 20px; + height: calc(100% - 100*2px); + padding-left: 20*2px; + padding-right: 20*2px; + margin-bottom: 200px; } .topView { @@ -135,50 +319,51 @@ export default { .title { font-weight: bold; - font-size: 34px; + font-size: 34*2px; color: #000; - letter-spacing: 0.41px; - line-height: 41px; - margin-left: 20px; - margin-top: 5px; + letter-spacing: 0.41*2px; + line-height: 41*2px; + margin-left: 20*2px; + margin-top: 5*2px; } .productDetail { display: flex; flex-direction: row; - width: calc(100% - 40); - height: 120px; - margin-left: 20px; + width: calc(100% - 40*2px); + height: 120*2px; + margin-left: 20*2px; align-items: center; - margin-top: 5px; + margin-top: 5*2px; background-color: white; } .productImageWrapper { - width: 120px; - height: 120px; + width: 120*2px; + height: 120*2px; background-color: white; display: flex; justify-content: center; align-items: center; + overflow: hidden; } .productImage { - width: 110px; - height: 110px; + width: 110*2px; + height: 110*2px; } .productPrice { - width: calc(100% - 120px - 40px - 10px); - height: 120px; - margin-left: 10px; + width: calc(100% - 120*2px - 40*2px - 10*2px); + height: 120*2px; + margin-left: 10*2px; } .size { - margin-top: 37px; + margin-top: 37*2px; font-family: "PingFang SC"; - font-size: 12px; + font-size: 12*2px; color: #999; letter-spacing: 0; } @@ -186,39 +371,39 @@ export default { .pricedetail { display: flex; flex-direction: row; - height: 30px; - margin-top: 5px; + height: 30*2px; + margin-top: 5*2px; align-items: flex-end; } .priceTitle { font-family: "PingFang SC"; - font-size: 14px; + font-size: 14*2px; color: #000; letter-spacing: 0; } .price { font-family: "DIN Alternate"; - font-size: 14px; + font-size: 14*2px; color: #000; - line-height: 20.5px; + line-height: 20.5*2px; letter-spacing: 0px; } .priceTip { font-family: "PingFang SC"; - font-size: 12px; + font-size: 12*2px; color: #D0021B; letter-spacing: 0px; - width: 80px; + width: 80*2px; text-align: right; } .inputView { - width: calc(100% - 40px); - height: 50px; - border-radius: 5px; + width: calc(100%); + height: 50*2px; + border-radius: 5*2px; display: flex; flex-direction: row; align-items: center; @@ -226,16 +411,18 @@ export default { } .inputViewIcon{ - line-height: 50px; - font-size: 20px; + line-height: 50*2px; + font-size: 20*2px; color: #000; - margin-left: 10px; + margin-left: 10*2px; } .wordText { - margin-left: 10px; + margin-left: 10*2px; font-family: "DIN Alternate"; - font-size: 16px; + font-size: 28*2px; + height: 100%; + line-height: 100%; color: #000; width: 100%; background-color: transparent; @@ -249,59 +436,95 @@ export default { .tipHeaderText { font-family: "PingFang SC"; - font-size: 14px; + font-size: 14*2px; color:#000; letter-spacing: 0; - margin-left: 20px; - margin-top: 15px; + //<!--margin-left: 20*2px;--> + margin-top: 15*2px; } .tipPriceText { font-family: "PingFang SC"; - font-size: 14px; + font-size: 14*2px; color: #D0021B; letter-spacing: 0; - margin-top: 15px; + margin-top: 15*2px; } .saleDetailTips { font-family: "PingFang SC"; - font-size: 12px; + font-size: 12*2px; color: #999; letter-spacing: 0px; - margin-top: 5px; - margin-left: 20px; - width: calc(100% - 40px); + margin-top: 5*2px; + //<!--margin-left: 20*2px;--> + width: calc(100% - 40*2px); } .space { width: 100%; background-color: white; - height: 20px; + height: 20*2px; } .line { width: 100%; - height: 1px; + height: 1*2px; background-color: #eee; } .priceCell { display: flex; width: 100%; - height: 25px; + height: 25*2px; align-items: center; justify-content: space-between; } + .feeContainer { + display: flex; + align-items: center; + justify-content: space-between; + flex-direction: row; + margin-bottom: 6*2px; + } + + .feeCommonText { + font-family: PingFang-SC-Regular; + font-size: 14*2px; + color: #999999; + letter-spacing: 0; + } + + .feeTotalLeft { + font-family: PingFang-SC-Regular; + font-size: 14*2px; + color: #000000; + letter-spacing: 0; + } + + .feeTotalRight { + font-family: PingFangSC-Regular; + font-size: 14px; + color: #D0021B; + letter-spacing: 0; + text-align: right; + } + .bottomContainer { position: absolute; bottom: 0px; - height: 100px; - display: flex; - align-items: stretch; + /*height: 100px;*/ width: 100%; left: 0px; } + .agree-wrapper { + height: 60px; + background-color: white; + border-top: 1px solid #eee; + padding: 0 40px; + line-height: 60px; + } + </style> diff --git a/apps/pages/order/components/askorder/day-choose.vue b/apps/pages/order/components/askorder/day-choose.vue index 02e6c26..4438a65 100644 --- a/apps/pages/order/components/askorder/day-choose.vue +++ b/apps/pages/order/components/askorder/day-choose.vue @@ -11,7 +11,7 @@ </div> </div> <Select - v-model="value" + v-model="chooseday" :title="title" :options="options" @change="change" @@ -27,12 +27,37 @@ import {Select} from 'cube-ui'; export default { name: 'DayChoose', + props: { + options: { + type: Array, + default: [], + }, + value: { + type: String, + default: '', + }, + choose: { + type: Function, + default: ()=>{}, + } + }, components: {Select}, + computed: { + chooseday: { + get() { + return this.value; + }, + set(val) { + + } + } + }, + data() { return { - options: ['1天', '3天', '7天', '15天', '30天'], - value: '7天', + // options: ['1天', '3天', '7天', '15天', '30天'], + // value: '7天', title: '选择求购时限', }; @@ -40,6 +65,7 @@ export default { methods: { change(value, index, text) { console.log('change', value, index, text); + this.choose && this.choose(value); } } diff --git a/apps/pages/order/index.js b/apps/pages/order/index.js index 499c71b..c6a5982 100644 --- a/apps/pages/order/index.js +++ b/apps/pages/order/index.js @@ -52,6 +52,19 @@ export default [ name: 'buyerAskOrder', // 买家求购确认 path: '/xianyu/order/buyeraskorder.html', component: () => import('./buyer-ask-order'), + props: route => ({ + storageId: route.query.storageId + }) + }, + + { + name: 'sellAskOrder', // 卖家求购确认 + path: '/xianyu/order/selleraskorder.html', + component: () => import('./seller-ask-order'), + props: route => ({ + skup: route.query.skup, + price: route.query.price, + }) }, // 物流信息 diff --git a/apps/pages/order/seller-ask-order.vue b/apps/pages/order/seller-ask-order.vue new file mode 100644 index 0000000..394ebb0 --- /dev/null +++ b/apps/pages/order/seller-ask-order.vue @@ -0,0 +1,196 @@ +<!--卖家求购变现--> +<template> + <LayoutApp :show-back="true"> + <div class="body"> + <TitleComp txt="变现"></TitleComp> + <ProductInfo :data="originProductData" class="product-info"></ProductInfo> + <div class="inputView"> + <span class="inputViewIcon"> + ¥ + </span> + <span class="wordText">{{price}}</span> + </div> + <OrderMargin class="order-item order-margin" :data="computeTip"></OrderMargin> + <OrderFee class="order-item" :data="computeTip"></OrderFee> + <AddressInfo :data="addressInfo" class="order-item"></AddressInfo> + </div> + <div class="footer"> + <OrderAgree :value="isAgreeTerms" @input="isAgreeTerms = !isAgreeTerms" class="agree-wrapper"></OrderAgree> + <div> + <Button :disabled="!isAgreeTerms" type="submit" @click="submitClick">提交</Button> + </div> + </div> + </LayoutApp> +</template> + +<script> +import {Button} from 'cube-ui'; +import ProductInfo from './components/confirm/product'; +import InputPrice from './components/confirm/input-price'; +import AddressInfo from './components/confirm/address'; +import TitleComp from './components/confirm/title'; +import OrderMargin from './components/confirm/order-margin'; +import OrderFee from './components/confirm/order-fee'; +import OrderAgree from './components/confirm/agree'; +import {get} from 'lodash' + +import { createNamespacedHelpers} from 'vuex'; +const { mapState, mapActions, mapMutations, mapGetters} = createNamespacedHelpers( + 'order/sellerAskOrder' +); + +export default { + name: 'seller-ask-order', + props: { + skup: Number, + price: Number, + }, + components: { + Button, + ProductInfo, + AddressInfo, + InputPrice, + TitleComp, + OrderMargin, + OrderFee, + OrderAgree + }, + + data() { + return { + isAgreeTerms: false, + }; + }, + + computed: { + ...mapState([ + 'originProductData', + + // 'price', + 'computeTip', + 'addressInfo', + 'publishinfo', + ]), + ...mapGetters([ + + ]), + + }, + + mounted() { + this.fetchSellerOrderCount({tabType: 'sell'});// 19268 + this.sellerCompute({price: this.price, skup: this.skup}); + + }, + + watch: { + + }, + + methods: { + ...mapMutations([ + + ]), + ...mapActions([ + 'fetchSellerOrderCount', + 'sellerCompute', + 'sellerPublish', + ]), + submitClick() { + this.sellerPublish({price: this.price, skup: this.skup, address_id: this.addressInfo.address_id}) + .then(() => { + this.payOrder(); + }); + }, + payOrder() { + let vm = this; + + this.$createOrderPayType({ + price: get(this.computeTip, 'earnestMoney', 0), + desc: '保证金', + orderCode: get(this.publishinfo, 'orderCode', ''), + extra: JSON.stringify({ + type: 'sell', + back: { + name: 'ProductDetail', + params: { + productId: get(this.originProductData, 'productId', '') + } + }, + forward: { + name: 'SellPayOk', + query: { + orderCode: get(this.publishinfo, 'orderCode', '') + } + } + }), + onCloseAction() { + // vm.onClose(orderResult.data.orderCode); + } + }).show(); + } + } + +}; +</script> + +<style lang="scss" scoped> + .body { + height: 100%; + margin: 0 40px; + padding-bottom: 200px; + overflow-y: auto; + } + .footer { + position: absolute; + bottom: 0; + width: 100%; + z-index: 1; + } + + .inputView { + width: calc(100%); + height: 50*2px; + border-radius: 5*2px; + display: flex; + flex-direction: row; + align-items: center; + background-color: #f5f5f5; + } + + .inputViewIcon{ + line-height: 50*2px; + font-size: 20*2px; + color: #000; + margin-left: 10*2px; + } + + .wordText { + margin-left: 10*2px; + font-family: "DIN Alternate"; + font-size: 28*2px; + height: 50*2px; + line-height: 50*2px; + color: #000; + width: 100%; + background-color: transparent; + } + + .agree-wrapper { + height: 60px; + background-color: white; + border-top: 1px solid #eee; + padding: 0 40px; + line-height: 60px; + } + + .order-item { + padding-top: 40px; + padding-bottom: 40px; + } + + .order-item + .order-item { + border-top: 1px solid #eee; + } + +</style> diff --git a/apps/pages/product/components/action-sheet.vue b/apps/pages/product/components/action-sheet.vue index f478f3b..4547387 100644 --- a/apps/pages/product/components/action-sheet.vue +++ b/apps/pages/product/components/action-sheet.vue @@ -8,7 +8,12 @@ v-show="isVisible" @mask-click="maskClick"> <transition :name="transition" appear> - <div class="cube-action-sheet-panel" v-show="isVisible" @click.stop> + <div class="cube-action-sheet-panel" + :class="{'with-radius': hasBorderRadius}" + :style="panelStyle" + v-show="isVisible" + ref="panel" + @click.stop="fakeMask"> <slot></slot> </div> </transition> @@ -26,6 +31,20 @@ export default { type: String, default: 'bottom', }, + panelStyle: { + type: Object, + default() { + return {}; + }, + }, + hasBorderRadius: { + type: Boolean, + default: true, + }, + emulateMask: { + type: Boolean, + default: false, + }, }, data() { return { @@ -59,7 +78,12 @@ export default { this._shownCallback(); }); } - } + }, + fakeMask(e) { + if (this.emulateMask && e.target === this.$refs.panel) { + this.hide(); + } + }, }, components: { 'cube-popup': Popup, diff --git a/apps/pages/product/components/buy-sheet.vue b/apps/pages/product/components/buy-sheet.vue index 955bdfb..894127a 100644 --- a/apps/pages/product/components/buy-sheet.vue +++ b/apps/pages/product/components/buy-sheet.vue @@ -1,15 +1,15 @@ <template> - <action-sheet @hidden="onHidden" position="right" ref="popup"> + <action-sheet @hidden="onHidden" position="right" ref="popup" + :panelStyle="{background: 'transparent', paddingLeft: '20%'}" + :hasBorderRadius="false" + :emulateMask="true"> <div class="buy-sheet"> - <div class="header"> - <div class="back-wrapper flex" @touchend="onBack"> - <div class="back"></div> - </div> - </div> + <div class="header">求购<i class="cubeic-question"></i></div> <div class="title"> <div class="title-thumbnail"> <square-img :src="imageUrl" :width="300" :height="300"/> </div> + <div>选择尺码填写理想的价格发布求购</div> <div>{{productDetail.product_name}} {{goodsName}}</div> </div> <div class="size-list"> @@ -17,7 +17,7 @@ <ul> <li :class="['size-item', item.available ? '': 'disable']" v-for="(item, idx) in sizeViewList" :key="idx" @click="buy(item)"> <div class="size"><span>{{item.name}}</span><span v-if="item.subName">{{item.subName}}</span></div> - <div class="price">¥ {{item.price}} <i class="cubeic-arrow"></i></div> + <div class="price">最高求购价 ¥{{item.price}} <i class="cubeic-arrow"></i></div> </li> </ul> </cube-scroll> @@ -29,13 +29,13 @@ <script> import { Scroll } from 'cube-ui'; import { get } from 'lodash'; -import { createNamespacedHelpers } from 'vuex'; +import { createNamespacedHelpers, mapActions } from 'vuex'; import ActionSheet from './action-sheet'; import stateShortCutsMixins from '../mixins'; import SquareImg from './square-img'; -const { mapActions, mapGetters } = createNamespacedHelpers('product'); +const { mapActions: mapProductAction, mapGetters } = createNamespacedHelpers('product'); export default { name: 'BuySheet', @@ -48,14 +48,14 @@ export default { computed: { ...mapGetters(['productDetail']), sizeList() { - return get(this.productDetail, 'goods_list_tabs.goods_list[0].size_list', []); + return get(this.productDetail, 'goods_list[0].size_list', []); }, sizeViewList() { return this.sizeList.map(info => { let price; - if (info.least_price > 0) { - price = `${info.least_price}`; + if (info.bid_moster_price > 0) { + price = `${info.bid_moster_price}`; } else { price = '-'; } @@ -69,6 +69,7 @@ export default { price, storage_id: info.storage_id, available: info.storage_num > 0 && price !== '-', + skup: info.skup, }; }); }, @@ -83,26 +84,49 @@ export default { this.$refs.popup.show(); }, methods: { - ...mapActions(['updateTradeInfo']), + ...mapActions('order/buyerAskOrder', [ + 'BUYER_ASK_SET_PRODUCTINFO' + ]), + ...mapProductAction(['updateTradeInfo']), onHidden() { this.$emit('hidden'); }, buy(product) { - if (!product.available) { - return; - } - this.onBack(); - this.updateTradeInfo({ - productId: this.productDetail.product_id, - sizeInfo: product, - }).then((data) => { - this.$router.push({ - name: 'OrderBuyConfirm', - query: data, - }); - }); + this.$yoho.auth() + .then(() => { + this.hide(); + this.updateTradeInfo({ + productId: this.productDetail.product_id, + sizeInfo: product, + }).then((data) => { + /** + * 跳转到求购确认页面 + * data: + * productId: number + * sizeId: number + * storageId: number + */ + this.$store.commit('order/buyerAskOrder/BUYER_ASK_SET_PRODUCTINFO', { + least_price: this.productDetail.least_price, + sizeName: product.name, + sizeId: get(data, 'sizeId', ''), + colorName: get(this.productDetail, 'goods_list[0].color_name', ''), + product_name: this.goodsName, + productId: get(data, 'productId', ''), + image: this.imageUrl, + skup: product.skup, + }) + this.$router.push({ + name: 'buyerAskOrder', + query: { + storageId: data.storageId || '' + }, + }); + }); + }) + }, - onBack() { + hide() { this.$refs.popup.hide(); }, }, @@ -117,54 +141,39 @@ export default { display: flex; flex-direction: column; position: relative; - .size-list { - flex: 1; - padding: 10px 40px; - overflow: scroll; - } + padding: 0 40px; + background: #fff; } - .title-thumbnail { - width: 140px; - height: 140px; - margin: 0 auto; - display: block; + + .size-list { + flex: 1 0 100%; + overflow: hidden; } .header { - width: 100%; - height: 90px; - padding-left: 40px; - padding-right: 40px; - display: flex; - justify-content: flex-end; - align-items: stretch; - box-sizing: border-box; position: absolute; top: 0; + right: 40px; + line-height: 88px; + font-size: 28px; + color: #999; + letter-spacing: 0; + text-align: right; + } - .flex { - display: flex; - align-items: center; - } - - .back-wrapper { - height: 100%; - } - - .back { - width: 48px; - height: 48px; - background: url(~statics/image/address/close.png) no-repeat; - background-size: cover; - } + .title-thumbnail { + width: 200px; + height: 200px; + margin: 0 auto; + display: block; } .title { - padding: 20px 40px 80px; + font-size: 24px; + color: #999; + letter-spacing: 0; text-align: center; - font-weight: bold; - font-size: 0.9em; - border-bottom: 1px solid #ddd; + padding-bottom: 28px; } .size-item { @@ -172,17 +181,14 @@ export default { justify-content: space-between; align-items: center; color: #000; - font-size: 32px; - padding: 40px; - margin-bottom: 40px; - border-bottom: 1px solid #ddd; + line-height: 120px; + border-bottom: 1px solid #eee; .size { - line-height: 1.8; display: flex; - font-size: 1.3em; - font-weight: bold; align-items: baseline; + font-size: 40px; + letter-spacing: 0; span:nth-child(2) { font-size: 0.8em; @@ -194,15 +200,20 @@ export default { .price { display: flex; align-items: center; + font-size: 24px; + letter-spacing: 0; + text-align: right; i { display: inline-block; margin-left: 5px; - color: #999; + color: #888; } } + &.disable { - .size, .price { + .size, + .price { color: #999; } } diff --git a/apps/pages/product/components/size-select-sheet.vue b/apps/pages/product/components/size-select-sheet.vue index 6cf08c8..881c331 100644 --- a/apps/pages/product/components/size-select-sheet.vue +++ b/apps/pages/product/components/size-select-sheet.vue @@ -26,8 +26,10 @@ @select="onSelectSize" @add="onAdd" /> <transition name="slide-up"> - <div class="footer" v-if="isTradable"> - <cube-button @click="select" class="active">{{config.title}}</cube-button> + + <div class="footer" v-if="isAvailable"> + <cube-button v-if="config.type === 'sell'" @click="convertToCash" :class="{active: isMarketable}">变现<span> <i>¥</i>{{cashPrice}}</span></cube-button> + <cube-button @click="select" :class="{active: isTradable}">{{config.title}}</cube-button> </div> </transition> </div> @@ -38,13 +40,13 @@ <script> import { Scroll, Button } from 'cube-ui'; import { get } from 'lodash'; -import { createNamespacedHelpers } from 'vuex'; +import { createNamespacedHelpers, mapActions } from 'vuex'; import ActionSheet from './action-sheet'; import SizeList from './size-list'; import SquareImg from './square-img'; -const { mapActions, mapState } = createNamespacedHelpers('product'); +const { mapActions: mapProductActions, mapState } = createNamespacedHelpers('product'); export default { name: 'SizeSelectSheet', @@ -113,12 +115,34 @@ export default { (this.config.type === 'buy' && this.selectedSize.storage_num > 0 && this.selectedSize.least_price !== '-') || (this.config.type === 'sell')); }, + + /** + * 变现价格,使用bid_moster_price + */ + cashPrice() { + if (this.selectedSize && this.selectedSize.hasOwnProperty('bid_moster_price')) { + return this.selectedSize.bid_moster_price; + } + + return '-'; + }, + + /** + * 可变现 + * 通过bid_moster_price或bid_skup判断 + */ + isMarketable() { + return this.cashPrice > 0; + } }, mounted() { this.$refs.popup.show(); }, methods: { - ...mapActions(['updateTradeInfo']), + ...mapActions('order/sellerAskOrder', [ + 'SELLER_ASK_SET_PRODUCTINFO' + ]), + ...mapProductActions(['updateTradeInfo']), onHidden() { this.$emit('hidden'); }, @@ -145,6 +169,37 @@ export default { bid_skup: this.selectedSize.bid_skup, }); }, + convertToCash() { + if (!this.isMarketable) { + return; + } + this.hide(); + + if (get(this.selectedSize, 'bid_skup', 0) == 0) { + return; + } + + this.$yoho.auth() + .then(() => { + + this.$store.commit('order/sellerAskOrder/SELLER_ASK_SET_PRODUCTINFO',{ + goodImg: get(this.product, 'goods_list[0].image_list[0].image_url', ''), + colorName: get(this.product, 'goods_list[0].color_name', ''), + sizeName: this.sizeName, + goodPrice: get(this.productDetail, 'least_price', 0), + productId: this.product.product_id + }); + // 跳转变现 + this.$router.push({ + name: 'sellAskOrder', + query: { + skup: get(this.selectedSize, 'bid_skup', 0), + price: get(this.selectedSize, 'bid_moster_price', 0), + } + }); + }); + + }, }, }; </script> diff --git a/apps/pages/product/product-detail.vue b/apps/pages/product/product-detail.vue index 83ccc20..c710a4b 100644 --- a/apps/pages/product/product-detail.vue +++ b/apps/pages/product/product-detail.vue @@ -21,6 +21,7 @@ <span class="dot" :class="{active: props.current === index}" v-for="(item, index) in props.dots">{{index + 1}}</span> </template> </cube-slide> + <div class="qiugou" @click="qiugou"></div> </div> <div class="info"> @@ -87,7 +88,7 @@ @select="onSelectTradeProduct" @add="onRequestSize"/> <size-request-sheet v-if="showSizeRequestSheet" @hidden="onSizeRequestHidden"/> - <buy-sheet v-if="showBuySheet" @hidden="onBuyHidden"/> + <buy-sheet v-if="showBuySheet" @hidden="onBuyHidden" /> </div> </template> @@ -284,7 +285,6 @@ export default { }, async sell() { await this.$yoho.auth(); - this.selectSizeConfig = { dest: 'OrderSellConfirm', type: 'sell', @@ -350,7 +350,12 @@ export default { onSizeRequestHidden() { this.showSizeRequestSheet = false; }, - + qiugou() { + this.showBuySheet = true; + }, + onBuyHidden() { + this.showBuySheet = false; + }, }, }; </script> @@ -393,6 +398,16 @@ export default { background-color: #08304b; } } + + .qiugou { + position: absolute; + top: 0; + right: - 58px; + width: 58px; + height: 48px; + background: top left url("~statics/image/product/qiugou@3x.png") no-repeat; + background-size: 100% 100%; + } } .cube-slide-item { diff --git a/apps/statics/image/product/qiugou@3x.png b/apps/statics/image/product/qiugou@3x.png new file mode 100644 index 0000000..4ad4b1c Binary files /dev/null and b/apps/statics/image/product/qiugou@3x.png differ diff --git a/apps/store/address/address/mutations.js b/apps/store/address/address/mutations.js index de248e1..243182d 100644 --- a/apps/store/address/address/mutations.js +++ b/apps/store/address/address/mutations.js @@ -21,5 +21,7 @@ export default { // 修改根状态 this.state.order.orderConfirm.address = addressInfo; + this.state.order.buyerAskOrder.addressInfo = addressInfo; + this.state.order.sellerAskOrder.addressInfo = addressInfo; } }; diff --git a/apps/store/order/buyer-ask-order.js b/apps/store/order/buyer-ask-order.js new file mode 100644 index 0000000..e34542d --- /dev/null +++ b/apps/store/order/buyer-ask-order.js @@ -0,0 +1,399 @@ +/** + * buyer-ask-order.js + *@author dennis + *@createtime 9/25/19 + *@description 买家求购状态管理 + */ + +import {Types} from './types'; +import { + get +} from 'lodash'; + +const { + BUYER_ORDERCOUNT_REQUEST, + BUYER_ORDERCOUNT_SUCCESS, + BUYER_ORDERCOUNT_FAILURE, + BUYER_ADDRESS_REQUEST, + BUYER_ADDRESS_SUCCESS, + BUYER_ADDRESS_FAILURE, + BUYER_ASK_CONFIG_SUCCESS, + BUYER_ASK_CONFIG_FAILURE, + BUYER_ASK_COMPUTE_REQUEST, + BUYER_ASK_COMPUTE_SUCCESS, + BUYER_ASK_COMPUTE_FAILURE, + BUYER_ASK_PREPUBLISH_SUCCESS, + BUYER_ASK_PREPUBLISH_FAILURE, + BUYER_ASK_PREPUBLISH_REQUEST, + BUYER_ASK_PUBLISH_REQUEST, + BUYER_ASK_PUBLISH_SUCCESSS, + BUYER_ASK_PUBLISH_FAILURE, + BUYER_ASK_SET_SHOWTOAST, + BUYER_ASK_SET_CHOOSEDAY, + BUYER_ASK_SET_SHOWDIALOG, + BUYER_ASK_SET_STORAGEID, + BUYER_ASK_SET_PRODUCTINFO, +} = Types; + +const TIP = '请求失败'; + +const DEFAULT_COMPUTE_INFO = { + depositAmount: '0', + promotionFormulaList: [ + { + promotion: '商品金额', + promotionAmount: '¥-' + }, + { + promotion: '运费', + promotionAmount: '¥-' + }, + { + promotion: '实付金额', + promotionAmount: '¥-' + } + ] +}; + +const DEFUALT_CONFIG_TIP = { + timeLimit: { + defaultItem: { + desc: '7天', + id: 3 + }, + items: [ + { + desc: '1天', + id: 1 + }, + { + desc: '3天', + id: 2 + }, + { + desc: '7天', + id: 3 + }, + { + desc: '15天', + id: 4 + }, + { + desc: '30天', + id: 5 + } + ] + }, + tips: '求购须支付定金。卖家接单后,你需要在24小时内支付商品款。卖家将在你付款后36小时内发货。' +}; + +const TEST_PRODUCT_INFO = { + least_price: 1119.00, + max_price: 20000.00, + max_sort_id: 10, + min_price: 0.01, + offer_price: 200.00, + product_code: 'OMRG001S181851110112', + product_id: 10000068, + product_name: 'Timberland 红色女靴', + sale_time: '2016.01.01', + image: 'http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/0124eed582cab20be7047c796c314cbc76.jpg?imageMogr2/thumbnail/{width}x{height}/background/d2hpdGU=/position/center/quality/80' +}; + +export default function() { + + return { + namespaced: true, + state: { + notFirstOrder: false, + storageId: '10000130', + originProductData: TEST_PRODUCT_INFO, + + addressInfo: null, + + configTip: DEFUALT_CONFIG_TIP, + + iscomputefetch: false, + isprepublish: false, + ispublish: false, + computeInfo: DEFAULT_COMPUTE_INFO, + preTip: null, + publishresult: {}, + toasMessage: '', + isShowToast: false, + chooseDay: '7天', + isShowDialog: false, + }, + getters: { + dayOptions(state) { + let orginallist = get(state, ['configTip', 'timeLimit', 'items'], []); + + return orginallist.map(item => { + return get(item, ['desc'], ''); + }); + + }, + + chooseDayId(state) { + let orginallist = get(state, ['configTip', 'timeLimit', 'items'], []); + + let dayid = 3; + + orginallist.forEach(item => { + if (item.desc === state.chooseDay) { + dayid = item.id; + } + }); + + return dayid; + + }, + }, + + mutations: { + + [BUYER_ASK_SET_PRODUCTINFO](state, payload) { + state.originProductData = payload + }, + + [BUYER_ASK_SET_STORAGEID](state, payload) { + state.storageId = payload + }, + + [BUYER_ASK_SET_SHOWTOAST](state, payload) { + state.isShowToast = payload ? true : false; + }, + + [BUYER_ASK_SET_SHOWDIALOG](state, payload) { + state.isShowDialog = payload ? true : false; + }, + + [BUYER_ASK_SET_CHOOSEDAY](state, payload) { + state.chooseDay = payload; + }, + + [BUYER_ORDERCOUNT_REQUEST](state) { + + }, + + [BUYER_ORDERCOUNT_SUCCESS](state, data) { + state.notFirstOrder = get(data, ['cnt'], 0) > 0; + }, + + [BUYER_ORDERCOUNT_FAILURE](state, message) { + + }, + + [BUYER_ADDRESS_REQUEST]() { + + }, + + [BUYER_ADDRESS_SUCCESS](state, payload) { + let list = payload || []; + let defaultAddress; + + list.forEach(item => { + + if (item.is_default === 'Y') { + defaultAddress = item; + } + }); + + state.addressInfo = defaultAddress; + + }, + + [BUYER_ADDRESS_FAILURE]() { + + }, + + [BUYER_ASK_CONFIG_SUCCESS](state, payload) { + + state.configTip = payload; + }, + + [BUYER_ASK_CONFIG_FAILURE](state, payload) { + + }, + + [BUYER_ASK_COMPUTE_REQUEST](state) { + state.iscomputefetch = true; + }, + + [BUYER_ASK_COMPUTE_SUCCESS](state, payload) { + state.iscomputefetch = false; + state.computeInfo = payload; + }, + + [BUYER_ASK_COMPUTE_FAILURE](state, payload) { + state.iscomputefetch = false; + state.computeInfo = DEFAULT_COMPUTE_INFO; + state.toasMessage = payload; + state.isShowToast = true; + }, + + [BUYER_ASK_PREPUBLISH_REQUEST](state) { + state.isprepublish = true; + }, + + [BUYER_ASK_PREPUBLISH_SUCCESS](state, payload) { + state.isprepublish = false; + if (payload) { + state.preTip = payload; + } else { + state.preTip = null; + } + state.isShowDialog = true; + + }, + + [BUYER_ASK_PREPUBLISH_FAILURE](state, payload) { + state.isprepublish = false; + state.preTip = null; + state.toasMessage = payload; + state.isShowToast = true; + }, + + [BUYER_ASK_PUBLISH_REQUEST](state) { + state.ispublish = true; + }, + + [BUYER_ASK_PUBLISH_SUCCESSS](state, payload) { + state.ispublish = false; + state.publishresult = payload; + + }, + + [BUYER_ASK_PUBLISH_FAILURE](state, payload) { + state.ispublish = false; + state.publishresult = {}; + state.toasMessage = payload; + state.isShowToast = true; + } + + }, + + actions: { + + fetchBuyerOrderCount({commit, dispatch}, {tabType = 'buy', uid} = {}) { + commit(BUYER_ORDERCOUNT_REQUEST); + this.$api.get('/api/order/ordercount', { + tabType, + uid + }).then(result => { + + if (result.code === 200) { + commit(BUYER_ORDERCOUNT_SUCCESS, result.data); + if (get(result, ['data', 'cnt'], 0) > 0) { + dispatch('fetchAddress', {}); + } else { + console.log('first order'); + } + } else { + commit(BUYER_ORDERCOUNT_FAILURE, result.message); + } + + }, error => { + commit(BUYER_ORDERCOUNT_FAILURE, ''); + console.log(error); + }); + + }, + + fetchAddress({commit}, {uid} = {}) { + commit(BUYER_ADDRESS_REQUEST); + this.$api.get('/api/address/gethidden', { + uid + }).then(result => { + if (result.code === 200) { + commit(BUYER_ADDRESS_SUCCESS, result.data); + } else { + commit(BUYER_ADDRESS_FAILURE, result.message); + } + }, error => { + commit(BUYER_ADDRESS_FAILURE, ''); + console.log(error); + }); + }, + + fetchConfig({commit}, {} = {}) { + this.$api.get('/api/order/buyaskconfig', { + + }).then(result => { + if (result.code === 200) { + commit(BUYER_ASK_CONFIG_SUCCESS, result.data); + } else { + console.log(result); + } + }, error => { + console.log(error); + }); + }, + + buyerCompute({commit}, {price = 0, storage_id = 0, uid} = {}) { + commit(BUYER_ASK_COMPUTE_REQUEST); + this.$api.get('/api/order/buyeraskcompute', { + uid, + price, + storage_id, + }).then(result => { + + if (result.code === 200) { + + commit(BUYER_ASK_COMPUTE_SUCCESS, get(result, ['data'], {})); + } else { + commit(BUYER_ASK_COMPUTE_FAILURE, get(result, ['message'], TIP)); + } + + }, error => { + + console.log(error); + + commit(BUYER_ASK_COMPUTE_FAILURE, TIP); + + }); + }, + + buyerPrePublish({commit, dispatch}, {price = 0, storage_id = 0, uid, address_id = ''} = {}) { + commit(BUYER_ASK_PREPUBLISH_REQUEST); + this.$api.get('/api/order/buyeraskprepublish', { + price, + storage_id, + uid, + address_id, + }).then(result => { + if (result.code === 200) { + commit(BUYER_ASK_PREPUBLISH_SUCCESS, get(result, ['data', 'dialog'], null)); + } else { + commit(BUYER_ASK_PREPUBLISH_FAILURE, result.message); + } + }, error => { + console.log(error); + commit(BUYER_ASK_PREPUBLISH_FAILURE, TIP); + }); + }, + + async buyerPublish({commit, dispatch}, {price = 0, storage_id = 0, uid, address_id = '', time_limit_id = ''} = {}) { + commit(BUYER_ASK_PUBLISH_REQUEST); + return this.$api.get('/api/order/buyeraskpublish', { + price, + storage_id, + uid, + address_id, + time_limit_id + }).then(result => { + if (result.code === 200) { + commit(BUYER_ASK_PUBLISH_SUCCESSS, result.data); + } else { + commit(BUYER_ASK_PUBLISH_FAILURE, result.message); + } + }, error => { + console.log(error); + commit(BUYER_ASK_PUBLISH_FAILURE, TIP); + }); + } + } + }; + +} + diff --git a/apps/store/order/index.js b/apps/store/order/index.js index 5ea6dcc..bb69d07 100644 --- a/apps/store/order/index.js +++ b/apps/store/order/index.js @@ -2,8 +2,10 @@ import priceChange from './price-change'; import orderList from './order-list'; import orderConfirm from './order-confirm'; import orderDetail from './order-detail'; +import buyerAskOrder from './buyer-ask-order'; import orderLogistics from './order-logistics'; import orderDeliver from './order-deliver'; +import sellerAskOrder from './seller-ask-order'; import inSaleOrderList from './in-sale-order-list'; export default function() { @@ -14,8 +16,10 @@ export default function() { orderList: orderList(), orderConfirm: orderConfirm(), orderDetail: orderDetail(), + buyerAskOrder: buyerAskOrder(), logisticsInfo: orderLogistics(), orderDeliver: orderDeliver(), + sellerAskOrder: sellerAskOrder(), inSaleOrderList: inSaleOrderList(), }, }; diff --git a/apps/store/order/seller-ask-order.js b/apps/store/order/seller-ask-order.js new file mode 100644 index 0000000..e1c9989 --- /dev/null +++ b/apps/store/order/seller-ask-order.js @@ -0,0 +1,195 @@ +/** + * seller-ask-order.js + *@author dennis + *@createtime 9/29/19 + *@description 卖家求购变现状态管理 + */ + +import {Types} from './types'; +import {get} from 'lodash'; + +const TIP = '请求失败'; + +const { + SELLER_ORDERCOUNT_REQUEST, + SELLER_ORDERCOUNT_SUCCESS, + SELLER_ORDERCOUNT_FAILURE, + SELLER_ADDRESS_REQUEST, + SELLER_ADDRESS_SUCCESS, + SELLER_ADDRESS_FAILURE, + SELLER_ASK_COMPUTE_REQUEST, + SELLER_ASK_COMPUTE_SUCCESS, + SELLER_ASK_COMPUTE_FAILURE, + SELLER_ASK_PUBLISH_REQUEST, + SELLER_ASK_PUBLISH_SUCCESS, + SELLER_ASK_PUBLISH_FAILURE, + SELLER_ASK_SET_PRICE, + SELLER_ASK_SET_SKUP, + SELLER_ASK_SET_PRODUCTINFO, +} = Types; + +const TEST_PRODUCT_INFO = { + least_price: 1119.00, + max_price: 20000.00, + max_sort_id: 10, + min_price: 0.01, + offer_price: 200.00, + product_code: 'OMRG001S181851110112', + product_id: 10000068, + product_name: 'Timberland 红色女靴', + sale_time: '2016.01.01', + goodImg: 'http://img11.static.yhbimg.com/goodsimg/2018/10/18/17/0124eed582cab20be7047c796c314cbc76.jpg?imageMogr2/thumbnail/{width}x{height}/background/d2hpdGU=/position/center/quality/80', + colorName: '黑色', + sizeName: '42码', + goodPrice: 1119.00, +}; + +export default function() { + + return { + namespaced: true, + + state: { + originProductData: TEST_PRODUCT_INFO, + price: 1200, + computeTip: null, + addressInfo: null, + publishinfo: null, + + }, + getter: { + + }, + + mutations: { + + [SELLER_ASK_SET_PRODUCTINFO](state, payload) { + state.originProductData = payload + }, + + [SELLER_ORDERCOUNT_SUCCESS](state, payload) { + + }, + + [SELLER_ADDRESS_SUCCESS](state, payload) { + let list = payload || []; + let defaultAddress; + + list.forEach(item => { + + if (item.is_default === 'Y') { + defaultAddress = item; + } + }); + + state.addressInfo = defaultAddress; + + }, + + [SELLER_ASK_COMPUTE_REQUEST](state) { + + }, + + [SELLER_ASK_COMPUTE_SUCCESS](state, payload) { + state.computeTip = payload + }, + + [SELLER_ASK_COMPUTE_FAILURE](state, payload) { + state.computeTip = null + }, + + [SELLER_ASK_PUBLISH_REQUEST](state) { + + }, + + [SELLER_ASK_PUBLISH_SUCCESS](state, payload) { + state.publishinfo = payload + }, + + [SELLER_ASK_PUBLISH_FAILURE](state, payload) { + state.publishinfo = null + } + }, + + actions: { + + fetchSellerOrderCount({commit, dispatch}, {tabType = 'sell', uid} = {}) { + this.$api.get('/api/order/ordercount', { + tabType, + uid + }).then(result => { + + if (result.code === 200) { + commit(SELLER_ORDERCOUNT_SUCCESS, result.data); + if (get(result, ['data', 'cnt'], 0) > 0) { + dispatch('fetchSellerAddress', {}); + } else { + console.log('first order'); + } + } else { + console.log(result.message); + + // commit(BUYER_ORDERCOUNT_FAILURE, result.message); + } + }, error => { + + console.log(error); + }); + }, + + fetchSellerAddress({commit}, {uid} = {}) { + + this.$api.get('/api/address/gethidden', { + uid + }).then(result => { + if (result.code === 200) { + commit(SELLER_ADDRESS_SUCCESS, result.data); + } else { + console.log(result.message); + + // commit(BUYER_ADDRESS_FAILURE, result.message); + } + }, error => { + console.log(error); + }); + }, + + sellerCompute({commit}, {price, skup, uid} = {}) { + commit(SELLER_ASK_COMPUTE_REQUEST); + this.$api.get('/api/order/sellask/compute', { + price, + skup, + uid, + }).then(result => { + if (result.code === 200) { + commit(SELLER_ASK_COMPUTE_SUCCESS, result.data); + } else { + commit(SELLER_ASK_COMPUTE_FAILURE, result.message); + } + }, error => { + console.log(error); + commit(SELLER_ASK_COMPUTE_FAILURE, TIP); + }); + }, + + sellerPublish({commit}, {price, skup, address_id, uid} = {}) { + commit(SELLER_ASK_PUBLISH_REQUEST); + return this.$api.get('/api/order/sellask/publish', { + price, + skup, + address_id, + uid, + }).then(result => { + if (result.code === 200) { + commit(SELLER_ASK_PUBLISH_SUCCESS, result.data); + } else { + commit(SELLER_ASK_PUBLISH_FAILURE, result.message); + } + }, error => { + console.log(error); + commit(SELLER_ASK_PUBLISH_FAILURE, TIP); + }); + } + }, + }; +} diff --git a/apps/store/order/types.js b/apps/store/order/types.js new file mode 100644 index 0000000..080b155 --- /dev/null +++ b/apps/store/order/types.js @@ -0,0 +1,49 @@ +/** + * types.js + *@author dennis + *@createtime 9/25/19 + *@description 枚举 + */ + +export const Types = { + BUYER_ORDERCOUNT_REQUEST: 'BUYER_ORDERCOUNT_REQUEST', + BUYER_ORDERCOUNT_SUCCESS: 'BUYER_ORDERCOUNT_SUCCESS', + BUYER_ORDERCOUNT_FAILURE: 'BUYER_ORDERCOUNT_FAILURE', + BUYER_ADDRESS_REQUEST: 'BUYER_ADDRESS_REQUEST', + BUYER_ADDRESS_SUCCESS: 'BUYER_ADDRESS_SUCCESS', + BUYER_ADDRESS_FAILURE: 'BUYER_ADDRESS_FAILURE', + BUYER_ASK_CONFIG_SUCCESS: 'BUYER_ASK_CONFIG_SUCCESS', + BUYER_ASK_CONFIG_FAILURE: 'BUYER_ASK_CONFIG_FAILURE', + BUYER_ASK_COMPUTE_REQUEST: 'BUYER_ASK_COMPUTE_REQUEST', + BUYER_ASK_COMPUTE_SUCCESS: 'BUYER_ASK_COMPUTE_SUCCESS', + BUYER_ASK_COMPUTE_FAILURE: 'BUYER_ASK_COMPUTE_FAILURE', + BUYER_ASK_PREPUBLISH_SUCCESS: 'BUYER_ASK_PREPUBLISH_SUCCESS', + BUYER_ASK_PREPUBLISH_FAILURE: 'BUYER_ASK_PREPUBLISH_FAILURE', + BUYER_ASK_PREPUBLISH_REQUEST: 'BUYER_ASK_PREPUBLISH_REQUEST', + BUYER_ASK_PUBLISH_REQUEST: 'BUYER_ASK_PUBLISH_REQUEST', + BUYER_ASK_PUBLISH_SUCCESSS: 'BUYER_ASK_PUBLISH_SUCCESSS', + BUYER_ASK_PUBLISH_FAILURE: 'BUYER_ASK_PUBLISH_FAILURE', + BUYER_ASK_SET_SHOWTOAST: 'BUYER_ASK_SET_SHOWTOAST', + BUYER_ASK_SET_CHOOSEDAY: 'BUYER_ASK_SET_CHOOSEDAY', + BUYER_ASK_SET_SHOWDIALOG: 'BUYER_ASK_SET_SHOWDIALOG', + BUYER_ASK_SET_STORAGEID: 'BUYER_ASK_SET_STORAGEID', + BUYER_ASK_SET_PRODUCTINFO: 'BUYER_ASK_SET_PRODUCTINFO', + + SELLER_ORDERCOUNT_REQUEST: 'SELLER_ORDERCOUNT_REQUEST', + SELLER_ORDERCOUNT_SUCCESS: 'SELLER_ORDERCOUNT_SUCCESS', + SELLER_ORDERCOUNT_FAILURE: 'SELLER_ORDERCOUNT_FAILURE', + SELLER_ADDRESS_REQUEST: 'SELLER_ADDRESS_REQUEST', + SELLER_ADDRESS_SUCCESS: 'SELLER_ADDRESS_SUCCESS', + SELLER_ADDRESS_FAILURE: 'SELLER_ADDRESS_FAILURE', + SELLER_ASK_COMPUTE_REQUEST: 'SELLER_ASK_COMPUTE_REQUEST', + SELLER_ASK_COMPUTE_SUCCESS: 'SELLER_ASK_COMPUTE_SUCCESS', + SELLER_ASK_COMPUTE_FAILURE: 'SELLER_ASK_COMPUTE_FAILURE', + SELLER_ASK_PUBLISH_REQUEST: 'SELLER_ASK_PUBLISH_REQUEST', + SELLER_ASK_PUBLISH_SUCCESS: 'SELLER_ASK_PUBLISH_SUCCESS', + SELLER_ASK_PUBLISH_FAILURE: 'SELLER_ASK_PUBLISH_FAILURE', + SELLER_ASK_SET_PRICE: 'SELLER_ASK_SET_PRICE', + SELLER_ASK_SET_SKUP: 'SELLER_ASK_SET_SKUP', + SELLER_ASK_SET_PRODUCTINFO: 'SELLER_ASK_SET_PRODUCTINFO', + +}; + diff --git a/config/address-api-map.js b/config/address-api-map.js index e3d614d..6fecbcd 100644 --- a/config/address-api-map.js +++ b/config/address-api-map.js @@ -2,6 +2,7 @@ module.exports = { '/api/address/gethidden': { auth: true, api: 'app.address.gethidden', + auth: true, params: {} }, '/api/address/getTags': { diff --git a/config/api-constants.js b/config/api-constants.js index e69de29..fa78968 100644 --- a/config/api-constants.js +++ b/config/api-constants.js @@ -0,0 +1,36 @@ + +// 查询订单数量 +const ORDER_COUNT = 'ufo.order.getAllCnt'; + +//返回求购期限 +const BUYER_ASK_CONFIG = 'ufo.buyer.bid.config'; +//计算价格 +const BUYER_ASK_COMPUTE = 'ufo.buyer.bid.compute'; +//预发布,提示 +const BUYER_ASK_TIPS = 'ufo.buyer.bid.prePublish'; +//发布 +const BUYER_ASK_PUBLISH = 'ufo.buyer.bid.publish'; +//买家调价计算 +const BUYER_ASK_COMPUTE_CHANGE_PRICE = 'ufo.buyer.bid.computeChangePrice'; +//买家预调价 +const BUYER_ASK_PRE_CHANGE_PRICE = 'ufo.buyer.bid.preChangePrice'; +//买家调价 +const BUYER_ASK_CHANGE_PRICE = 'ufo.buyer.bid.changePrice'; +//变现前计算 +const SELLER_ASK_PRE_COMPUTE = 'ufo.seller.bid.compute'; +//变现 +const SELLER_ASK_PUBLISH = 'ufo.seller.bid.publish'; + + +module.exports = { + ORDER_COUNT, + BUYER_ASK_CONFIG, + BUYER_ASK_COMPUTE, + BUYER_ASK_TIPS, + BUYER_ASK_PUBLISH, + BUYER_ASK_COMPUTE_CHANGE_PRICE, + BUYER_ASK_PRE_CHANGE_PRICE, + BUYER_ASK_CHANGE_PRICE, + SELLER_ASK_PRE_COMPUTE, + SELLER_ASK_PUBLISH, +}; diff --git a/config/api-map.js b/config/api-map.js index aaf9e9b..46a3c52 100644 --- a/config/api-map.js +++ b/config/api-map.js @@ -4,8 +4,10 @@ const listApi = require('./list-api-map'); const homeApi = require('./home-api-map'); const passportApi = require('./passport-api-map'); const addressApi = require('./address-api-map'); +const buyerAskApi = require('./buyerask-api-map') const orderListApi = require('./order-api-map'); const categoryApi = require('./category-api-map'); +const sellerAskApi = require('./sellerask-api-map'); module.exports = { ...orderApi, @@ -14,6 +16,8 @@ module.exports = { ...homeApi, ...passportApi, ...addressApi, + ...buyerAskApi, ...orderListApi, ...categoryApi, + ...sellerAskApi, }; diff --git a/config/buyerask-api-map.js b/config/buyerask-api-map.js new file mode 100644 index 0000000..bb60dd3 --- /dev/null +++ b/config/buyerask-api-map.js @@ -0,0 +1,85 @@ +/** + * buyerask-api-map.js + *@author dennis + *@createtime 9/26/19 + *@description 买家求购 + */ + +const API = require('./api-constants'); + +module.exports = { + '/api/order/buyaskconfig': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_CONFIG, + params: {} + }, + '/api/order/buyeraskcompute': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_COMPUTE, + params: { + price: {type: Number, required: true}, + storage_id: {type: Number, required: true}, + } + }, + '/api/order/buyeraskprepublish': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_TIPS, + params: { + price: {type: Number, required: true}, + storage_id: {type: Number, required: true}, + address_id: {type: String, required: true}, + } + }, + + '/api/order/buyeraskpublish': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_PUBLISH, + params: { + price: {type: Number, required: true}, + storage_id: {type: Number, required: true}, + address_id: {type: String, required: true}, + time_limit_id: {type: Number, required: true}, // 有效期 + } + }, + + '/api/order/buyerask/computechangeprice': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_COMPUTE_CHANGE_PRICE, + params: { + price: {type: Number, required: true}, + orderCode: {type: String, required: true}, + } + }, + '/api/order/buyerask/prechangeprice': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_PRE_CHANGE_PRICE, + params: { + price: {type: Number, required: true}, + orderCode: {type: String, required: true}, + } + }, + + '/api/order/buyerask/changeprice': { + ufo: true, + auth: true, + path: 'shopping/bid', + api: API.BUYER_ASK_CHANGE_PRICE, + params: { + price: {type: Number, required: true}, + orderCode: {type: String, required: true}, + } + } + +}; diff --git a/config/order-api-map.js b/config/order-api-map.js index 617bb77..c60152f 100644 --- a/config/order-api-map.js +++ b/config/order-api-map.js @@ -1,3 +1,5 @@ +const API = require('./api-constants'); + module.exports = { // 获取调价商品及尺码信息 '/api/ufo/seller/entryGoodsSizeList': { @@ -92,7 +94,6 @@ module.exports = { ufo: true, auth: true, api: 'ufo.order.list', - // 类型定义 params: { limit: { type: Number }, // page size @@ -225,6 +226,16 @@ module.exports = { auth: true, ufo: true, api: 'ufo.sellerOrder.computePublishPrd', + + }, + + '/api/order/ordercount': { + ufo: true, + auth: true, + api: API.ORDER_COUNT, + params: { + tabType: { type: String, require: true }, // 订单来源 + } }, // 判断用户状态 diff --git a/config/sellerask-api-map.js b/config/sellerask-api-map.js new file mode 100644 index 0000000..eb810f5 --- /dev/null +++ b/config/sellerask-api-map.js @@ -0,0 +1,34 @@ +/** + * sellerask-api-map.js + *@author dennis + *@createtime 9/29/19 + *@description 卖家求购变现 + */ + +const API = require('./api-constants'); + +module.exports = { + + '/api/order/sellask/compute': { + ufo: true, + auth: true, + path: '', + api: API.SELLER_ASK_PRE_COMPUTE, + params: { + skup: {type: Number, required: true}, + price: {type: Number, required: true}, + } + }, + + '/api/order/sellask/publish': { + ufo: true, + auth: true, + path: '', + api: API.SELLER_ASK_PUBLISH, + params: { + skup: {type: Number, required: true}, + price: {type: Number, required: true}, + address_id: {type: String, required: true}, + } + }, +} diff --git a/doraemon/middleware/ssr-api.js b/doraemon/middleware/ssr-api.js index 4327f2f..e9db0aa 100644 --- a/doraemon/middleware/ssr-api.js +++ b/doraemon/middleware/ssr-api.js @@ -70,7 +70,7 @@ module.exports = async (req, res, next) => { } else if (apiInfo.ufo) { result = await apiCtx[method]({ api: ufoAPI, - url: apiInfo.path || '', + url: apiInfo.path ? apiInfo.path : '', data: params, param: { cache: cache, @@ -86,6 +86,7 @@ module.exports = async (req, res, next) => { }); } if (result) { + // console.log(result); return res.json(handleResult(result, apiInfo)); } return res.json({