Files
xk-client-wx/subPackages/my/record-pay.vue
2025-02-13 10:39:12 +08:00

945 lines
21 KiB
Vue

<template>
<view class="container safe-area-inset-bottom">
<!-- 快递自提 -->
<view class="_choose">
<text>配送方式</text>
<view class="_fs" @click="toShowed">
<text>{{wayText}}</text>
<text class="iconfont icon-jiantou1"></text>
<u-action-sheet :list="list" v-model="toshowed" :tips="tips" border-radius="24"
:safe-area-inset-bottom="true" @click="chooseway"></u-action-sheet>
</view>
</view>
<!-- 收货地址 已添加地址 -->
<view class="head" v-if="isshow" @click="toChoose">
<view class="state">
<text>收货地址</text>
<view class="qh">
<view class="iconfont icon-jiantou1"></view>
</view>
</view>
<view class="name" @click="toChoose" v-if="!orderInfo.ProductOrder.address">
请先选择收货地址
</view>
<view class="name" @click="toChoose" v-if="orderInfo.ProductOrder.address">
{{JSON.parse(orderInfo.ProductOrder.address).name || '请先选择收货地址'}}
{{JSON.parse(orderInfo.ProductOrder.address).mobile || ''}}
</view>
<view class="choose_area" v-if="orderInfo.ProductOrder.address">
{{JSON.parse(orderInfo.ProductOrder.address).region || ''}}{{JSON.parse(orderInfo.ProductOrder.address).detail_address || ''}}
</view>
</view>
<!-- 到店自取 -->
<view class="head" v-if="isshowed">
<view class="state">
<text>到店自取</text>
</view>
<view class="name">
{{infoList.store.name}}
{{infoList.store.mobile}}
</view>
<view class="choose_area">
{{infoList.store.position}}
</view>
</view>
<!-- 商品列表 -->
<view class="card">
<!-- 门店 -->
<view class="store"><text class="iconfont icon-mendian"></text>萧康诊所门店</view>
<view class="list" v-if="chinese">
<view class="it" v-for="(item,index) in chinese.list" :key="item.id">
<!-- <view class="it_name">{{item.name}}</view> -->
<view class="it_name">{{item.name}}
<text class="it_num" style="margin-left: 8rpx;">x{{item.number}}</text>
</view>
<!-- <view class="it_price">
<text>{{item.price}}</text>
<view class="it_num">
x{{item.number}}
</view>
</view> -->
</view>
</view>
<!-- granular -->
<view class="list" v-if="granular">
<view class="it" v-for="(item,index) in granular.list" :key="item.id">
<view class="it_name">{{item.name}}
<text class="it_num" style="margin-left: 8rpx;">x{{item.number}}</text>
</view>
<!-- <view class="it_name">{{item.name}}</view>
<view class="it_price">
<text>{{item.price}}</text>
<view class="it_num">
x{{item.number}}
</view>
</view> -->
</view>
</view>
<view class="list_west" v-if="west">
<view class="list" v-for="(item,index) in west" :key="item.id">
<view class="img">
<image :src="item.content.image || '/static/empty/gwc.png'" mode=""></image>
</view>
<view class="it">
<view class="it_name">{{item.content.drug_name}}{{item.content.specification}}</view>
<view class="it_info">
{{item.content.usage}}
</view>
<view class="it_price">
<text>{{item.total_price}}</text>
<view class="it_num">
x{{item.number}}
</view>
</view>
</view>
</view>
</view>
<!-- 数量 -->
<view class="goods">
<view class="good_">
<text>商品总价</text>
<text class="price">{{orderInfo.ProductOrder.items_price}}</text>
</view>
<view class="good_">
<text>快递费</text>
<text class="price">{{orderInfo.ProductOrder.trans_expenses}}</text>
</view>
<view class="good_">
<text>诊疗费</text>
<text class="price">{{orderInfo.ProductOrder.treatement_price}}</text>
</view>
<view class="good_">
<text>加工费</text>
<view class="price">
<text v-if="payWay">{{payWay.dosage}} </text>
{{orderInfo.ProductOrder.process_price}}
</view>
</view>
<view class="good_">
<!-- <text>{{orderInfo.ProductOrder.count}}</text> -->
<text>总金额</text>
<view class="total">
合计:
<text class="price">{{orderInfo.ProductOrder.total_pay_price}}</text>
</view>
</view>
</view>
</view>
<!-- 须知 -->
<u-popup v-model="show" :safe-area-inset-bottom="true" mode="bottom" height="68%" border-radius="20"
:closeable="true">
<view class="agreen">
<u-parse :html="contented"></u-parse>
</view>
</u-popup>
<!-- 提醒 -->
<view class="umode">
<u-modal v-model="openshow" title="服务提示" :content="content" @confirm="confirm" @cancel="cancel"
:content-style="{color:'#666666',fontSize: '28rpx'}"
:title-style="{color:'#111000',fontWeight: '540',fontSize: '33rpx'}" :show-title="true"
:show-cancel-button="true" confirm-text="我需要" cancel-text="不需要" cancel-color="#F44336"
confirm-color="#536DFE"></u-modal>
</view>
<!-- 底部 -->
<view class="footer">
<!-- 须知 -->
<view class="check">
<u-icon size="35" :color="form['check']?'#E5E5E5':'#536DFE'" name="checkmark-circle-fill"
@click="toForm"></u-icon>
<view class="agreement">
提交订单即代表您已同意
<text @click="toShow">知情同意书</text>
</view>
</view>
<button v-if="flag === true" class="to_pay" @click="toPay">立即支付</button>
<button v-else class="to_pay_disabled" :disabled="true">立即支付</button>
</view>
<u-toast ref="uToast" />
</view>
</template>
<script>
import {
getaddressList,
getDelivery,
getPayConfig,
getProductInfo,
getUpdateUseWay,
getUseWayPay,
service,
storeInfo,
} from '../../request/api/api'
export default {
data() {
return {
isshow: true,
isshowed: false,
show: false,
order_no: '',
form: {
check: false
},
contented: `知情同意书`,
orderInfo: {
ProductOrder: {}
}, // 订单
chinese: [],
west: [],
granular: [],
actionList: [],
order_id: "", // 订单id
order_no: "", // 订单编号
p_id: "", // 处方id
list: [{
text: '快递到家'
}, {
text: '到店自取'
}],
toshowed: false,
tips: {
text: '配送方式',
color: '#111111',
fontSize: 38
},
wayText: "快递到家",
delivery_method: 0, // 快递方式 0 快递 1 自提
content: '', // 弹窗内容
openshow: false, // 弹窗是否展示
is_decoct: 1, // 代煎服务 1确定代煎 0不代煎
infoList: [], // 门店信息
payWay: "",
flag: true
}
},
onLoad(e) {
this.p_id = e.id
},
created() {
},
methods: {
// 不需要代煎-代煎费
cancel() {
this.openshow = false;
this.is_decoct = 0
this.getUpuseWay()
},
// 需要代煎
confirm() {
this.is_decoct = 1
this.getUpuseWay()
},
// 更新代煎服务
getUpuseWay() {
getUpdateUseWay({
method: "post",
data: {
is_decoct: this.is_decoct,
order_id: this.order_id,
store_id: uni.getStorageSync('store_id') || '11001'
}
}).then((res) => {
if (res.data.errcode == 0) {
this.getInfo()
// console.log(res, '确定代煎');
}
})
},
toShow() {
this.show = true
},
toShowed() {
this.toshowed = true
},
chooseway(index) {
this.wayText = this.list[index].text
this.delivery_method = index
if (index == 1) {
this.isshowed = true
this.isshow = false
this.toUpdata()
} else {
this.isshowed = false
this.isshow = true
this.toChoose()
}
// console.log(`点击了第${index + 1}项,内容为:${this.list[index].text}`)
},
// 更新配送方式
toUpdata() {
getDelivery({
method: "post",
data: {
address_id: uni.getStorageSync('address_id'),
delivery_method: this.delivery_method,
order_id: this.order_id,
store_id: uni.getStorageSync('store_id') || '11001'
}
}).then((res) => {
if (res.data.errcode == 0) {
this.getInfo()
// console.log(res, '确定代煎');
}
})
},
// 门店信息
getStoreInfo() {
storeInfo({
method: "post",
data: {
store_id: uni.getStorageSync('store_id') || '11001',
}
}).then((res) => {
// console.log(res, 'info');
if (res.data.errcode == 0) {
this.infoList = res.data.data
}
})
},
toForm() {
this.form['check'] = !this.form['check']
},
// 产品信息
getInfo() {
let list = {
store_id: uni.getStorageSync('store_id'),
prescription_id: this.p_id
}
getProductInfo({
method: "post",
data: list
}).then((res) => {
// console.log(res, 'info');
if (res.data.errcode == 0) {
this.orderInfo = res.data.data
this.chinese = res.data.data.chinese
this.west = res.data.data.west
this.granular = res.data.data.granular
this.order_id = res.data.data.ProductOrder.id
uni.setStorageSync('userWay_order_id', res.data.data.ProductOrder.id)
// this.order_no = res.data.data.ProductOrder.order_no
// console.log(this.west.content);
}
})
},
// 代煎费
getServe() {
getUseWayPay({
method: "post",
data: {
order_id: uni.getStorageSync('userWay_order_id'),
store_id: uni.getStorageSync('store_id') || '11001'
}
}).then((res) => {
if (res.data.errcode == 0) {
this.payWay = res.data.data
this.content =
`平台可以为您提供有偿代煎服务(${this.payWay.decoct_price}元/剂)您的处方共${this.payWay.dosage}剂, 费用${this.payWay.total_decoct_price}元。 您是否需要?`
// console.log(this.payWay, 'way');
setTimeout(() => {
this.openshow = true;
}, 500)
}
})
},
// 地址列表
getList() {
getaddressList({
method: "post",
data: {
store_id: uni.getStorageSync('store_id'),
}
}).then((res) => {
// console.log(res, 'list');
if (res.data.errcode == 0) {
this.actionList = res.data.data
}
})
this.toUpdata()
},
// 地址
toChoose() {
uni.navigateTo({
url: '/subPackages/setup/area-list?id=' + this.p_id + '&order_id=' + this.order_id
})
},
getKnow() {
service({
method: "get",
data: {
store_id: uni.getStorageSync('store_id'),
type:4
}
}).then((res) => {
// console.log(res, 'info');
if (res.data.errcode == 0) {
this.contented = res.data.data.content
}
})
},
// 支付
toPay() {
if (this.form['check']) {
uni.showToast({
icon: "error",
title: '请勾选协议'
})
that.flag = false
return
}
let that = this
if (that.flag) {
that.flag = false
// 获取支付配置
getPayConfig({
method: "post",
data: {
order_id: that.order_id,
store_id: uni.getStorageSync('store_id'),
}
}).then((res) => {
console.log(res.data.data.timeStamp, 'pay');
uni.showLoading({
title: "加载中"
});
if (res.data.errcode === 0) {
uni.requestPayment({
provider: res.data.data.appId,
timeStamp: res.data.data.timestamp,
nonceStr: res.data.data.nonceStr,
package: res.data.data.package,
signType: res.data.data.signType,
paySign: res.data.data.paySign,
success: (res) => {
console.log('success:' + JSON.stringify(res));
setTimeout(() => {
that.flag = false
uni.navigateTo({
url: '/subPackages/my/my-drug/drug-list'
})
uni.hideLoading();
}, 300)
},
fail: function(err) {
that.flag = false
console.log('fail:' + JSON.stringify(err));
uni.showToast({
title: '支付失败',
duration: 1500,
mask: false,
icon: 'error'
})
setTimeout(() => {
if (res.data.msg) {
uni.showToast({
title: res.data.msg,
duration: 1500,
mask: false,
icon: 'error'
})
that.flag = false
return
}
uni.hideLoading();
that.flag = true
}, 500)
}
})
}else{
uni.hideLoading();
that.$refs.uToast.show({
title: res.data.msg,
type: 'default',
icon: false
})
that.flag = true
}
if (res.data.code == 1) {
uni.hideLoading();
// uni.showToast({
// title: res.data.msg,
// duration: 1500,
// mask: false,
// icon: 'error'
// })
that.$refs.uToast.show({
title: res.data.msg,
type: 'default',
icon: false
})
that.flag = true
}
})
}
}
},
mounted() {
this.getKnow()
this.getStoreInfo()
const order_id = uni.getStorageSync('userWay_order_id')
// if (order_id) {
// this.getServe()
// } else {
// setTimeout(() => {
// this.getServe()
// }, 800)
// }
},
onShow() {
this.getInfo()
this.getList()
},
onUnload() {
uni.removeStorageSync('userWay_order_id')
}
}
</script>
<style lang="scss" scoped>
.container {
width: 750rpx;
max-height: 100%;
min-height: 100vh;
padding-bottom: env(safe-area-inset-bottom);
background: #F5F5F5;
.agreen {
padding: 60rpx 50rpx 20rpx;
// color: #6C7380;
// letter-spacing: 2rpx;
.top {
margin: 0 0 20rpx 0;
font-family: PingFang SC-Regular, PingFang SC;
text-align: center;
font-size: 32rpx;
font-weight: 500;
color: #222;
}
}
.umode {
font-size: 36rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #232323;
text-align: center;
text {
font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
}
}
.p_state {
width: 750rpx;
height: 160rpx;
background: #536DFE;
margin: 20rpx auto;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 40rpx;
.state {
font-family: PingFang SC-Bold, PingFang SC;
display: flex;
flex-direction: column;
text {
font-size: 36rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #FFFFFF;
}
.notice {
font-size: 24rpx;
font-weight: 400;
margin-top: 12rpx;
}
}
.iconfont {
font-size: 52rpx;
color: #fff;
}
}
._choose {
width: 750rpx;
height: 88rpx;
margin: 0rpx auto;
background: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 40rpx;
._fs {
display: flex;
align-items: center;
.iconfont {
font-size: 32rpx;
margin-left: 16rpx;
color: #222333;
}
}
}
.head {
width: 750rpx;
height: 168rpx;
margin: 20rpx auto;
background: #fff;
display: flex;
flex-direction: column;
justify-content: center;
padding: 0 40rpx;
.state {
font-size: 28rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #232323;
line-height: 0rpx;
display: flex;
align-items: center;
justify-content: space-between;
text {
display: inline-block;
width: 116rpx;
height: 38rpx;
line-height: 38rpx;
text-align: center;
background: #536DFE;
border-radius: 30rpx 30rpx 30rpx 30rpx;
font-size: 20rpx;
color: #FFFFFF;
margin-right: 14rpx;
}
.qh {
display: flex;
align-items: center;
.iconfont {
font-size: 28rpx;
margin-left: 16rpx;
}
}
}
.name {
font-size: 28rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #232323;
margin: 10rpx 0;
}
.choose_area {
font-size: 24rpx;
font-family: 'PingFang SC', sans-serif; /* 确保字体兼容性 */
font-weight: 400;
color: #232323;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2; /* 设置最大行数为2 */
overflow: hidden;
line-height: 1.5; /* 根据需要调整行高 */
word-break: break-all; /* 确保长单词或URL地址换行 */
}
}
.card {
width: 750rpx;
margin: 0 auto;
padding: 20rpx 12rpx 0rpx 20rpx;
background: #FFFFFF;
.store {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 500;
color: #232323;
margin-left: 20rpx;
padding: 10rpx 0;
.iconfont {
font-size: 39rpx;
color: #666666;
vertical-align: middle;
margin-right: 10rpx;
}
}
.list_west {
.list {
display: flex;
justify-content: space-around;
width: 100%;
padding: 32rpx;
display: flex;
align-items: center;
.img {
width: 200rpx;
height: 200rpx;
margin-right: 10rpx;
image {
width: 200rpx;
height: 200rpx;
border-radius: 8rpx;
}
}
.it {
flex: 1;
padding: 16rpx 10rpx;
font-family: PingFang SC-Bold, PingFang SC;
margin: 10rpx;
.it_name {
font-weight: bold;
color: #232323;
margin-bottom: 10rpx;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
overflow: hidden;
margin-bottom: 20rpx;
}
.it_info {
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
overflow: hidden;
margin-bottom: 20rpx;
}
.it_price {
display: flex;
align-items: center;
justify-content: space-between;
text {
font-size: 28rpx;
font-weight: bold;
color: #232323;
}
}
}
}
}
.list {
width: 100%;
padding: 12rpx 12rpx;
display: flex;
flex-wrap: wrap;
.it {
width: 30%;
padding: 16rpx 10rpx;
font-family: PingFang SC-Bold, PingFang SC;
margin: 0 10rpx 10rpx 0;
.it_name {
font-weight: bold;
color: #232323;
margin-bottom: 10rpx;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
text-overflow: ellipsis;
overflow: hidden;
padding-left: 5rpx;
}
.it_price {
display: flex;
align-items: center;
justify-content: space-between;
text {
font-size: 28rpx;
font-weight: bold;
color: #999999;
}
}
.it_num {
color: #999999;
}
}
}
.goods {
margin-top: 20rpx;
padding: 0 30rpx 10rpx;
margin-bottom: 40rpx;
.good_ {
display: flex;
align-items: center;
justify-content: space-between;
height: 88rpx;
text {
font-size: 28rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #232323;
}
.total {
font-size: 26rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
.price {
font-size: 34rpx;
font-weight: 500;
}
}
.price {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
}
}
}
}
.infos {
width: 750rpx;
margin: 20rpx auto 160rpx;
padding: 20rpx 32rpx;
background: #FFFFFF;
.title {
height: 44rpx;
font-size: 32rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #232323;
line-height: 44rpx;
}
._info {
display: flex;
justify-content: space-between;
align-items: center;
margin: 18rpx 0;
text {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #999999;
}
.info {
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
color: #232323;
}
}
}
.footer {
width: 750rpx;
height: 184rpx;
background: #fff;
position: fixed;
left: 0;
bottom: env(safe-area-inset-bottom);
display: flex;
justify-content: center;
flex-direction: column;
padding: 0rpx 24rpx;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
.check {
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20rpx;
.agreement {
margin-left: 16rpx;
text {
color: #536DFE;
}
}
}
.to_pay {
width: 690rpx;
height: 84rpx;
line-height: 84rpx;
background: #536DFE;
border-radius: 64rpx;
color: #FFFFFF;
text-align: center;
}
.to_pay_disabled {
width: 690rpx;
height: 84rpx;
line-height: 84rpx;
background: #8a9bf8;
border-radius: 64rpx;
color: #FFFFFF;
text-align: center;
}
}
}
</style>