|
@@ -81,6 +81,15 @@
|
|
|
<span class="total-price">¥{{getSum()[1]}}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="agree">
|
|
|
+ <label class="check-con" @click="isAgree=!isAgree">
|
|
|
+ <span class="check-box">
|
|
|
+ <span class="checkbox-inner" :class="{'checkbox-inner-checked':isAgree}"></span>
|
|
|
+ </span>
|
|
|
+ 同意<span style="" @click.stop="$router.push({name:'useimg',params:{id:'1v2',type:0,name: 'agreement'}})">四维看看销售协议</span>
|
|
|
+ </label>
|
|
|
+ <!-- <input type="checkbox" v-model="isAgree"> -->
|
|
|
+ </div>
|
|
|
<!-- <div class="xieyi"><input type="checkbox" />我已阅读并同意四维看看用户协议</div> -->
|
|
|
</div>
|
|
|
<div class="btn-confirm" @click="next()">付款</div>
|
|
@@ -92,14 +101,22 @@
|
|
|
import { mapState } from 'vuex'
|
|
|
import cinvoices from '@/components/cinvoices'
|
|
|
import payTypeModule from '@/components/payType'
|
|
|
+import browser from '@/util/browser'
|
|
|
|
|
|
+let paytypes = {
|
|
|
+ 0: 'wechatMobilePay',
|
|
|
+ 1: 'aliMobilePay'
|
|
|
+}
|
|
|
var cloneObj = function (obj) {
|
|
|
var newObj = {}
|
|
|
if (obj instanceof Array) {
|
|
|
newObj = []
|
|
|
}
|
|
|
for (var key in obj) {
|
|
|
- var val = obj[key] || ''
|
|
|
+ var val = obj[key]
|
|
|
+ if (!obj[key] && obj[key] !== 0) {
|
|
|
+ val = ''
|
|
|
+ }
|
|
|
newObj[key] = typeof val === 'object' ? cloneObj(val) : val
|
|
|
}
|
|
|
return newObj
|
|
@@ -182,7 +199,9 @@ export default {
|
|
|
selectedTxt: '不需要发票',
|
|
|
selectedId: 1,
|
|
|
isShowAddress: true,
|
|
|
- showinvoice: true
|
|
|
+ showinvoice: true,
|
|
|
+ isAgree: true,
|
|
|
+ isWeixin: browser.weixin
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
@@ -210,7 +229,8 @@ export default {
|
|
|
temp['selectedTxt'] = this.selectedTxt
|
|
|
|
|
|
this.$store.commit('PAYINFO', temp)
|
|
|
- this.$router.push({path: '/submit'})
|
|
|
+ this.pay()
|
|
|
+ // this.$router.push({path: '/submit'})
|
|
|
},
|
|
|
getSum () {
|
|
|
let sum = 0
|
|
@@ -220,6 +240,59 @@ export default {
|
|
|
count += item.goodsCount
|
|
|
})
|
|
|
return [count, sum]
|
|
|
+ },
|
|
|
+ async pay () {
|
|
|
+ if (!this.isAgree) {
|
|
|
+ this.$toast.show('warn', '请阅读并同意四维看看销售协议')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let {invoice, goods, payType, receiver} = this.payinfo
|
|
|
+ let params = {
|
|
|
+ goods,
|
|
|
+ receiver,
|
|
|
+ invoice,
|
|
|
+ payType,
|
|
|
+ abroad: this.language === 'en' ? 1 : 0
|
|
|
+
|
|
|
+ }
|
|
|
+ let res = await this.$http
|
|
|
+ .post('user/order/placeOrder', params, {
|
|
|
+ headers: {
|
|
|
+ token: this.token
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ this.$store.commit('ORDERINFO', {
|
|
|
+ orderSn: res.data.data.orderSn,
|
|
|
+ price: res.data.data.goodsAmount,
|
|
|
+ orderType: 0
|
|
|
+ })
|
|
|
+ this.$store.dispatch('getCart')
|
|
|
+ let data = {
|
|
|
+ orderId: res.data.data.id,
|
|
|
+ orderType: 0
|
|
|
+ }
|
|
|
+
|
|
|
+ this.orderId = res.data.data.id
|
|
|
+ this.orderType = 0
|
|
|
+
|
|
|
+ if (Number(payType) !== 2) {
|
|
|
+ if (this.isWeixin) {
|
|
|
+ let hostName = window.location.hostname
|
|
|
+ return location.replace(`https://open.weixin.qq.com/connect/oauth2/authorize?redirect_uri=https%3a%2f%2f${hostName}%2fapi%2forder%2fpay%2fwechatPreJsPay%3forderId=${this.orderId}%26orderType=${Number(this.orderType)}&appid=wx779dbafb46bab697&response_type=code&scope=snsapi_base&state=1&connect_redirect=1#wechat_redirect`)
|
|
|
+ }
|
|
|
+ let response = await this.$http
|
|
|
+ .post(`order/pay/${paytypes[payType]}`, data, {
|
|
|
+ headers: {
|
|
|
+ token: this.token
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let url = payType === 1 ? response.data.data.form : response.data.data.mweb_url
|
|
|
+ location.replace(url)
|
|
|
+ } else {
|
|
|
+ document.getElementById('formid').submit()
|
|
|
+ this.$toast.show('warn', this.langToast['3'])
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
async mounted () {
|