提交 207feb38 authored 作者: pengxiaohui's avatar pengxiaohui

微信支付

上级 5d7878b1
...@@ -19,8 +19,20 @@ export function getGoodsSpecs(data) { ...@@ -19,8 +19,20 @@ export function getGoodsSpecs(data) {
return httpRequest.post('/api/shop/commodity/spu/spec/value/search', data) return httpRequest.post('/api/shop/commodity/spu/spec/value/search', data)
} }
/** /**
* 创建订 * 支付下
*/ */
export function createOrder(data) { export function createOrder(data) {
return httpRequest.post('/api/shop/order/add', data) return httpRequest.post('/api/shop/order/add', data)
}
/**
* 查询支付状态
*/
export function checkPayStatus(data) {
return httpRequest.post('/api/shop/pay/order/callback', data)
}
/**
* 查询订单
*/
export function getOrderList(data) {
return httpRequest.post('/api/shop/order/range/search', data)
} }
\ No newline at end of file
...@@ -47,6 +47,7 @@ export default { ...@@ -47,6 +47,7 @@ export default {
price: item.price price: item.price
} }
}) })
console.log(this.list)
}, },
immediate: true, immediate: true,
deep: true deep: true
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
</div> </div>
<van-field label="规格" class="tag-item"> <van-field label="规格" class="tag-item">
<template #input> <template #input>
<tag-selection v-model="spec" :data="specList" :options="{ label: 'spec_values', value: 'spec_value_ids'}" @currentSelected="handleTagSelected"/> <tag-selection v-model="spec" :data="specList" :options="{ label: 'spec_values', value: 'sku_id'}" @currentSelected="handleTagSelected"/>
</template> </template>
</van-field> </van-field>
<van-form :show-error="false" @submit="handleSuccess"> <van-form :show-error="false" @submit="handleSuccess">
...@@ -117,6 +117,7 @@ export default { ...@@ -117,6 +117,7 @@ export default {
handleTagSelected(val) { handleTagSelected(val) {
this.price = val.price this.price = val.price
this.surplus = val.stock this.surplus = val.stock
this.spec = val.value
}, },
handleSuccess(val) { handleSuccess(val) {
const fields = [] const fields = []
...@@ -131,7 +132,7 @@ export default { ...@@ -131,7 +132,7 @@ export default {
spu_id: this.spu_id, spu_id: this.spu_id,
sku_id: this.spec, sku_id: this.spec,
buy_count: this.form.count, buy_count: this.form.count,
payment_method: '8', payment_method: '3',
app_button_text: JSON.stringify(fields) app_button_text: JSON.stringify(fields)
} }
this.$emit('placeOrder', params) this.$emit('placeOrder', params)
...@@ -172,7 +173,7 @@ export default { ...@@ -172,7 +173,7 @@ export default {
getGoodsSpecs(params).then(res => { getGoodsSpecs(params).then(res => {
this.specList = res.data this.specList = res.data
const [first = {}] = res.data const [first = {}] = res.data
this.spec = first.spec_value_ids this.spec = first.sku_id
this.price = first.price this.price = first.price
this.surplus = first.stock this.surplus = first.stock
}) })
......
...@@ -48,9 +48,10 @@ ...@@ -48,9 +48,10 @@
<script> <script>
import BuyPopup from './components/BuyPopup.vue' import BuyPopup from './components/BuyPopup.vue'
import PhoneCodeLoginPopup from '@/components/PhoneCodeLoginPopup.vue' import PhoneCodeLoginPopup from '@/components/PhoneCodeLoginPopup.vue'
import { getGoodsList, getShopList, createOrder } from '@/api/common.js' import { getGoodsList, getShopList, createOrder, checkPayStatus } from '@/api/common.js'
import store from '@/store' import store from '@/store'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { Dialog } from 'vant'
export default { export default {
components: { BuyPopup, PhoneCodeLoginPopup }, components: { BuyPopup, PhoneCodeLoginPopup },
data() { data() {
...@@ -62,7 +63,8 @@ export default { ...@@ -62,7 +63,8 @@ export default {
imgList: [], imgList: [],
shopInfo: {}, shopInfo: {},
popupOptions: {}, popupOptions: {},
orderInfo: {} orderInfo: {},
payment_order_id: ''
} }
}, },
computed: { computed: {
...@@ -75,11 +77,24 @@ export default { ...@@ -75,11 +77,24 @@ export default {
}, },
shop_id () { shop_id () {
return this.query.shop_id || '6800681447305773056' return this.query.shop_id || '6800681447305773056'
},
isBackFormWxPay () {
return window.sessionStorage.getItem('isBackFormWxPay')
} }
}, },
beforeMount() { beforeMount() {
this.fetchGoodsDetails() this.fetchGoodsDetails()
this.fetchShopDetails() this.fetchShopDetails()
if (this.isBackFormWxPay) {
Dialog.alert({
title: '支付确认',
message: '确认已经完成微信支付',
theme: 'round-button'
}).then(() => {
this.fetchCheckPayStatus()
})
window.sessionStorage.removeItem('isBackFormWxPay')
}
}, },
methods: { methods: {
handleVideoClick() { handleVideoClick() {
...@@ -108,6 +123,7 @@ export default { ...@@ -108,6 +123,7 @@ export default {
const params = Object.assign({}, this.orderInfo) const params = Object.assign({}, this.orderInfo)
params.customer_id = this.user.id params.customer_id = this.user.id
params.customer_phone = this.user.phone || '' params.customer_phone = this.user.phone || ''
params.buy_count = (params.buy_count).toString()
console.log(params) console.log(params)
this.fetchPlaceOrder(params) this.fetchPlaceOrder(params)
}, },
...@@ -145,8 +161,16 @@ export default { ...@@ -145,8 +161,16 @@ export default {
}, },
fetchPlaceOrder(params) { fetchPlaceOrder(params) {
createOrder(params).then(res => { createOrder(params).then(res => {
console.log(res) if (res.code === 0 && res.payment_url) {
window.sessionStorage.setItem('isBackFormWxPay', 1)
window.sessionStorage.setItem('payment_order_id', res.payment_order_id)
window.location.href = res.payment_url
}
}) })
},
fetchCheckPayStatus() {
const id = window.sessionStorage.getItem('payment_order_id') || ''
checkPayStatus({ payment_order_id: id }).then(res => {})
} }
} }
} }
......
...@@ -18,19 +18,26 @@ ...@@ -18,19 +18,26 @@
</van-tabs> </van-tabs>
<ul class="order-list"> <ul class="order-list">
<li class="order-item" v-for="item in list" :key="item.id"> <li class="order-item" v-for="item in list" :key="item.id">
<div class="thumb">
<img :src="item.thumb">
</div>
<div class="content"> <div class="content">
<div class="status-row">{{item.status | statusFilter}}</div> <div class="thumb">
<div class="title-row"> <img :src="item.thumb">
<div class="title van-ellipsis">{{item.spu_name}}</div>
<div class="price">{{item.price}}</div>
</div> </div>
<div class="spec-row"> <div class="right">
<p class="spec">{{item.spec}}</p> <div class="status-row">{{item.status | statusFilter}}</div>
<div class="title-row">
<div class="title van-ellipsis">{{item.spu_name}}</div>
<div class="price">{{item.price}}</div>
</div>
<div class="spec-row">
<div class="spec">{{item.spec}}</div>
<div>×{{item.num}}</div>
</div>
<div class="sum_pay">需付款¥{{item.sum_pay}}</div>
</div> </div>
<div class="sum_pay">需付款¥{{item.sum_pay}}</div> </div>
<div class="pay_bar" v-if="item.status === 0">
<p><span>更多</span></p>
<van-button plain round type="primary" size="mini" color="#C01540">付款</van-button>
</div> </div>
</li> </li>
</ul> </ul>
...@@ -85,46 +92,71 @@ export default { ...@@ -85,46 +92,71 @@ export default {
} }
.order-item{ .order-item{
background:#fff; background:#fff;
position:relative;
box-sizing:border-box;
padding:4vw 0 4vw 30vw;
height:36vw;
margin-top:15px;
border-radius:3px;
.thumb{
width:26vw;
height:26vw;
position:absolute;
left:0;
top:5vw;
img{
width:80%;
display:block;
margin:10% auto;
}
}
.content{ .content{
display:flex; position:relative;
flex-direction:column; box-sizing:border-box;
height:100%; padding:4vw 0 2vw 30vw;
padding-right:10px; height:36vw;
.status-row{ margin-top:15px;
line-height:0.48rem; border-radius:3px;
color:#C01540; .thumb{
text-align:right; width:26vw;
height:26vw;
position:absolute;
left:0;
top:5vw;
img{
width:80%;
display:block;
margin:10% auto;
}
} }
.title-row{ .right{
line-height:30px;
flex:1;
display:flex; display:flex;
.price{ flex-direction:column;
font-size:13px; height:100%;
padding-right:10px;
.status-row{
line-height:0.48rem;
color:#C01540;
text-align:right;
} }
.title{ .title-row{
font-size:14px; line-height:30px;
flex:1; flex:1;
display:flex;
.price{
font-size:13px;
}
.title{
font-size:14px;
flex:1;
}
} }
.spec-row{
color:#9B9B9B;
display:flex;
.spec{
flex:1;
}
}
.sum_pay{
text-align:right;
line-height:26px;
}
}
}
.pay_bar{
display:flex;
padding:0 10px 10px;
p{
flex:1;
text-align:left;
}
.van-button{
width:70px;
} }
} }
} }
</style> </style>
\ No newline at end of file
...@@ -2,7 +2,8 @@ import { getUser, logout } from '@/api/account' ...@@ -2,7 +2,8 @@ import { getUser, logout } from '@/api/account'
const user = { const user = {
state: { state: {
user: {}, user: {},
isLogin: false isLogin: false,
isWxBrowser: /micromessenger/.test(navigator.userAgent)
}, },
mutations: { mutations: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论