提交 513e09b2 authored 作者: 王鹏飞's avatar 王鹏飞

fix: #2011, #2021

上级 db095aef
......@@ -23,7 +23,7 @@
</div>
</template>
</van-field>
<van-field v-for="item in fieldsMap" v-model="form[item.key]" :key="item.key" :name="item.key" :label="item.label" :type="item.type" :placeholder="item.placeholder" :rules="[{ required: item.required, message: '请输入留言' }, { validator: item.validator, message: item.errorMsg || '输入格式有误' }]"/>
<van-field v-for="item in fieldsMap" v-model="form[item.key]" :key="item.key" :name="item.key" :label="item.label" :type="item.type" :placeholder="item.placeholder" :rules="[{ required: item.required, message: item.placeholder }, { validator: item.validator, message: item.errorMsg || '输入格式有误' }]"/>
<div style="margin: 16px;">
<van-button type="primary" round block color="#C01540" size="small">下一步</van-button>
</div>
......@@ -165,6 +165,16 @@ export default {
this.$emit('placeOrder', params)
},
assembleFields(list) {
const map = {
text: { type: 'text', placeholder: '请填写留言' },
number: { type: 'number', placeholder: '请填写数字' },
email: { type: 'text', placeholder: '请填写邮箱', errorMsg: '邮箱格式有误' },
date: { type: 'text', placeholder: '请填写日期' },
time: { type: 'text', placeholder: '请填写时间' },
id: { type: 'text', placeholder: '请填写身份证号', errorMsg: '身份证格式有误' },
image: { type: 'text', placeholder: '请上传图片' },
phone: { type: 'tel', placeholder: '请填写手机号', errorMsg: '手机格式有误' }
}
const fieldsMap = {}
list.forEach((item, index) => {
const field = {
......@@ -176,28 +186,10 @@ export default {
placeholder: '请填写留言'
}
this.$set(this.form, field.key, '')
field.placeholder = '请填写留言'
if (item.type === 'text' && item.multiple) {
field.type = 'textarea'
} else if (['email', 'phone', 'id'].includes(item.type)) {
if (this.validatorMap[item.type]) {
field.validator = this.validatorMap[item.type]
field.placeholder = '请填写邮箱'
let errorMsg = '邮箱格式有误'
if (item.type === 'phone') {
field.type = 'tel'
errorMsg = '手机格式有误'
field.placeholder = '请填写手机号'
} else if (item.type === 'id') {
field.type = 'text'
errorMsg = '身份证格式有误'
field.placeholder = '请填写身份证号'
}
field.errorMsg = errorMsg
} else if (item.type === 'number') {
field.type = 'number'
field.placeholder = '请填写身份证号'
}
fieldsMap[field.key] = field
fieldsMap[field.key] = Object.assign({}, field, map[item.type])
})
this.fieldsMap = fieldsMap
console.log('field', fieldsMap)
......
......@@ -2,7 +2,7 @@
<div class="buy-container">
<van-swipe class="my-swipe" indicator-color="white" @change="index => swipeAcitve = index">
<van-swipe-item class="video" v-if="details.main_chart_oss" @click="handleVideoClick">
<video :src="details.main_chart_oss" controls="controls" ref="video"></video>
<video :src="details.main_chart_oss" controls="controls" playsinline :poster="`${details.main_chart_oss}?x-oss-process=video/snapshot,t_10,f_jpg,w_0,h_0,m_fast`" ref="video"></video>
<van-icon :name="videoPlay ? 'pause-circle-o':'play-circle-o'" />
</van-swipe-item>
<van-swipe-item v-for="(item, index) in imgList" :key="item.url">
......@@ -38,6 +38,9 @@
</template>
</van-cell>
</div>
<div class="item" v-if="details.spu_context">
<div v-html="details.spu_context"></div>
</div>
<div class="bottom-bar" v-if="details.sales_type === '1'">
<van-button type="primary" round block color="#C01540" size="small" @click="handleBuy">{{details.buy_button_text || '立即购买'}}</van-button>
</div>
......@@ -48,7 +51,7 @@
<script>
import BuyPopup from './components/BuyPopup.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 { getOpenId } from '@/api/account.js'
import store from '@/store'
import { mapGetters } from 'vuex'
......@@ -68,12 +71,11 @@ export default {
payment_order_id: '',
payment_method: '12',
order_params: '',
order_details_url: window.location.origin + '/order-details',
openId: ''
order_details_url: window.location.origin + '/order-details'
}
},
computed: {
...mapGetters(['user', 'isPhone', 'isWxBrowser']),
...mapGetters(['user', 'isWxBrowser']),
query() {
return this.$route.query
},
......@@ -82,15 +84,18 @@ export default {
},
shop_id () {
return this.query.shop_id || '6800681447305773056'
},
isBackFormPay () {
return window.sessionStorage.getItem('isBackFormPay')
},
openId () {
return window.localStorage.getItem('openId') // 'oF3a-t9pFpmL2gWuTmtWs5HlDGkU'
}
},
beforeMount() {
this.fetchGoodsDetails()
this.fetchShopDetails()
let openId = window.localStorage.getItem('openId')
if (openId === 'undefined' || openId === 'null') openId = ''
this.openId = openId // 'oF3a-t9pFpmL2gWuTmtWs5HlDGkU'
if (this.isWxBrowser && !openId) {
if (this.isWxBrowser && !this.openId) {
const { code } = this.$route.query
if (code) this.fetchOpenId(code)
else this.getCode()
......@@ -110,10 +115,6 @@ export default {
this.$router.push({ path: '/shop', query: { shop_id: id } })
},
async handleBuy() {
// if (!this.isPhone) {
// Toast.fail('只支持在手机端购买')
// return
// }
const isLogin = store.state.isLogin || (await store.dispatch('checkLogin'))
if (isLogin) {
// if (this.isWxBrowser) {
......@@ -145,10 +146,8 @@ export default {
fetchOpenId(code) {
getOpenId({ code, identity: 'ezijing' }).then(response => {
if (response.code === 0) {
if (response.openid) {
this.openId = response.openid || ''
window.localStorage.setItem('openId', response.openid || '')
} else window.localStorage.removeItem('openId')
this.openId = response.openid
window.localStorage.setItem('openId', this.openId)
} else {
this.getCode()
}
......@@ -167,6 +166,7 @@ export default {
if (typeof imgsJson === 'string' && Array.isArray(JSON.parse(imgsJson))) {
this.imgList = JSON.parse(imgsJson)
}
this.swipeAcitve = first.main_chart_oss ? 0 : 1
this.popupOptions = {
specs: first.spec,
fields: first.app_button_text,
......@@ -195,6 +195,10 @@ export default {
}
})
},
fetchCheckPayStatus() {
const id = window.sessionStorage.getItem('payment_order_id') || ''
checkPayStatus({ payment_order_id: id }).then(res => {})
},
placeOrderCallback(res) {
const payType = this.payment_method
if (payType === '3') {
......@@ -214,7 +218,7 @@ export default {
// window.sessionStorage.setItem('isBackFormH5Pay', 1)
window.localStorage.setItem('payment_order_id', res.payment_order_id)
window.localStorage.setItem('order_detail_id', res.order_detail_id)
window.location.href = res.payment_url + '&redirect_url=' + encodeURIComponent(this.order_details_url)
window.location.href = res.payment_url + '&redirect_url=' + encodeURIComponent(window.location.href)
} else if (payType === '12') {
// 支付宝网页支付
// window.sessionStorage.setItem('isBackFormH5Pay', 1)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论