nurseWeChatAppletUI/pages/confirmOrder/confirmOrder.vue
2023-05-05 11:43:11 +08:00

214 lines
5.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="app">
<view class="bodys">
<view class="addressinfo">
<view class="namephone">
{{updata.receiver}},{{updata.phone}}
</view>
<view class="picture">
<span @tap='upaddress()'>修改地址</span>
<u-icon name="arrow-right" color="#ffffff" size="32"></u-icon>
</view>
<view class="address">
{{updata.receiveAddress}}
</view>
</view>
</view>
<view class="commodity">
<view class="commodityInfo">
<image :src="updata.img" mode=""></image>
<view class="infos">
<view class="detail">
<view class="spangoodsName">
{{updata.goodsName}}
</view>
<view class="spanprice"> {{updata.goodsPrice}}</view>
</view>
<view class="model">
型号:<span>{{updata.goodsAttributeName}}</span>
</view>
</view>
</view>
<view class="quantity">
<view class="header">
数量
</view>
<view class="number">
<u-number-box :min="1" :max="updata.goodsStock" v-model="updata.goodsCount" @minus='delnumber'
@plus='addnumber'>
</u-number-box>
</view>
</view>
</view>
<!-- <view class="integral">
<view class="header">
积分抵扣
</view>
<view class="number">
共5积分满100可用
</view>
</view> -->
<view class="price">
<view class="priceinfo">
<view class="header money">
商品金额
</view>
<view class="number money">
¥{{updata.totalPrice}}
</view>
</view>
<view class="priceinfo">
<view class="header money">
运费
</view>
<view class="number money">
+¥0.0
</view>
</view>
<view class="freight">
<view class="number total">
¥{{updata.totalPrice}}
</view>
</view>
</view>
<view class="bottom">
<view class="moneys">
¥{{updata.totalPrice}}
</view>
<view class="submit" @tap='show=true'>
提交订单
</view>
</view>
<!-- 弹框 -->
<view class="frame">
<u-popup v-model="show" mode="bottom" length="45%" border-radius="30">
<view class="payment">
<span>请选择支付方式</span>
<view class="cencel" @tap="show = false">
<image src="../../static/gb.png" mode=""></image>
</view>
</view>
<view class="chat">
<image src="/static/chat.png" mode=""></image>
<span>微信支付</span>
</view>
<view class="submits" @tap='buy'>
<span>确认支付</span><span>¥{{updata.totalPrice}}</span>
</view>
</u-popup>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import baseurl from '@/api/baseurl.js'
import {
addStationGoodsOrder,
appletGoodsOrderPay
} from '@/api/confirmOrder/index.js'
export default {
data() {
return {
show: false,
openid: '',
updata: {},
Patient: {},
}
},
methods: {
buy() {
var that = this
addStationGoodsOrder(this.updata).then(res => {
if (res.code == 500) {
this.$refs.uToast.show({
title: res.msg,
type: 'error'
})
} else {
let id = res.data.id
let paydata = res.data
paydata.openid = this.openid
paydata.payType = "WECHAT_PAY"
paydata.paymentPrice = res.data.totalPrice
appletGoodsOrderPay(paydata).then(response => {
if (response.code == 200) {
uni.requestPayment({
timeStamp: response.data.timeStamp,
nonceStr: response.data.nonceStr,
package: response.data.prepayId,
signType: response.data.signType,
paySign: response.data.paySign,
success: function(res) {
that.$refs.uToast.show({
title: '支付成功',
type: 'success',
duration: 1500,
url: '/pages/paysuccess/paysuccess'
})
},
fail: function(err) {
that.$refs.uToast.show({
title: '取消支付',
type: 'error',
duration: 1500,
url: `/pages/payorderDetails/payorderDetails?goodsOrderId=${id}`
})
// uni.navigateTo({
// url: `/pages/payorderDetails/payorderDetails?goodsOrderId=${id}`
// })
}
});
} else {
that.$refs.uToast.show({
title: response.msg,
type: 'error',
duration: 2000
})
}
})
}
})
},
delnumber(e) {
this.updata.totalPrice = (e.value * this.updata.goodsPrice).toFixed(2)
},
addnumber(e) {
this.updata.totalPrice = (e.value * this.updata.goodsPrice).toFixed(2)
},
upaddress() {
uni.navigateTo({
url: `/pages/modifyAddress/modifyAddress?updata=${JSON.stringify(this.updata)}`
})
},
},
onLoad(options) {
this.updata = JSON.parse(options.updata)
if (this.updata.totalPrice == 'null' || !this.updata.totalPrice) {
this.updata.totalPrice = 0
}
},
onShow() {
var that = this
const value = uni.getStorageSync('openid');
if (value) {
that.openid = value
} else {}
let useritem = null
uni.$on('updata', function(data) {
that.updata = JSON.parse(data.updata)
if (data.useritem) {
useritem = JSON.parse(data.useritem)
that.updata.receiver = useritem.receiveName
that.updata.phone = useritem.receivePhone
that.updata.receiveAddress = useritem.address
}
uni.$off('updata')
})
}
}
</script>
<style lang="scss">
@import './confirmOrder.scss'
</style>