shop-applet/pages/payment/get_payment.vue

529 lines
11 KiB
Vue
Raw Normal View History

2024-02-29 20:35:06 +08:00
<template>
2024-03-08 18:06:12 +08:00
<view class="container">
2024-03-22 10:50:55 +08:00
<view v-if="!isWeixin" class="v-navbar">
2024-03-08 18:06:12 +08:00
<u-navbar title="提货付款" :safeAreaInsetTop="false" :fixed="false" @leftClick="leftClick" bgColor="transparent"
2024-03-22 10:50:55 +08:00
leftIconColor="#333" :titleStyle="{color:'#333',fontWeight:'bold',fontSize:'32rpx'}">
2024-02-29 20:35:06 +08:00
</u-navbar>
</view>
2024-03-22 10:50:55 +08:00
<view style="height: 50rpx;"></view>
<view class="wrap">
<view class="shop">
<image src="@/static/shop_logo.webp" style="width: 62rpx;height: 54rpx;" />
<text class="shop-name" v-if="mer_name">{{mer_name||''}}</text>
2024-02-29 20:35:06 +08:00
</view>
2024-03-08 18:06:12 +08:00
<!-- 付款金额 -->
<view class="v-con">
2024-03-22 10:50:55 +08:00
<view class="v-con-text">订单金额</view>
<view class="v-con-input" @click="handleOpenKeyboard">
<text style="color: #303133;font-size:32rpx;"></text>
<u--input type="text" fontSize="23" height="112rpx" placeholder="请输入金额" border="none" readonly
v-model="cartForm.total_amount" placeholderStyle="color:#999;font-size:32rpx">
2024-03-08 18:06:12 +08:00
</u--input>
2024-03-22 10:50:55 +08:00
<view class="placeholder"></view>
2024-02-29 20:35:06 +08:00
</view>
2024-03-08 18:06:12 +08:00
2024-03-22 10:50:55 +08:00
<view class="v-con-group">
<view class="v-con-group-title">
<view class="v-con-group-title-left">套餐详情</view>
<view class="v-con-group-title-right" @click.stop="handleOpen">
<text>{{isOpen?'折叠':'展开'}}</text>
<u-icon :name="isOpen?'arrow-down' : 'arrow-right'" size="15"></u-icon>
</view>
2024-03-08 18:06:12 +08:00
</view>
2024-03-22 10:50:55 +08:00
<scroll-view scroll-y>
<view class="v-con-group-list" :style="{'max-height':isOpen?'400rpx':'0'}">
<block v-for="(item,indx) in merchantInfo" :key="indx">
<view class="v-con-group-list-item">
<image :src="item.image" :showLoading="true" style="width:86rpx;height:86rpx;" />
<text class="line1">{{item.store_name}}</text>
</view>
</block>
</view>
</scroll-view>
2024-02-29 20:35:06 +08:00
</view>
</view>
2024-03-08 18:06:12 +08:00
2024-03-22 10:50:55 +08:00
<view class="v-btn-wrap" @click="cartForm.total_amount?submitOrder():null">
<view class="v-btn">{{Number(cartForm.total_amount||0).toFixed(2)}} 确认支付</view>
2024-03-08 18:06:12 +08:00
</view>
<!-- 登陆 -->
2024-03-22 10:50:55 +08:00
<authorize :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun" />
2024-03-08 18:06:12 +08:00
</view>
<!-- 无商户信息提示 -->
2024-03-22 10:50:55 +08:00
<!-- <view class="empty">
<authorize v-show="!isWeixin" ref="authRef" :isAuto="isAuto" :isGoIndex="false" :isShowAuth="isShowAuth"
@authColse="authColse" @onLoadFun="onLoadFun">
2024-03-08 18:06:12 +08:00
</authorize>
2024-03-22 10:50:55 +08:00
</view> -->
<!-- 键盘 -->
<popups ref="popups" @confirm="handleConfirm" @clear="handleClear" @change="handleChange"></popups>
2024-02-29 20:35:06 +08:00
</view>
</template>
<script>
2024-03-22 10:50:55 +08:00
var that;
2024-02-29 20:35:06 +08:00
import {
2024-03-22 10:50:55 +08:00
getProductInfo1,
2024-02-29 20:35:06 +08:00
addCart,
orderCheck
} from "@/api/payment.js";
2024-03-08 18:06:12 +08:00
import Cache from '@/utils/cache';
import {
mapGetters
} from "vuex";
import authorize from '@/components/Authorize';
2024-03-22 10:50:55 +08:00
import {
Toast
} from "../../libs/uniApi";
import popups from "@/components/popups/index.vue";
2024-02-29 20:35:06 +08:00
export default {
2024-03-08 18:06:12 +08:00
components: {
2024-03-22 10:50:55 +08:00
authorize,
popups
2024-03-08 18:06:12 +08:00
},
computed: {
...mapGetters(['isLogin']),
},
2024-02-29 20:35:06 +08:00
data() {
return {
2024-03-22 10:50:55 +08:00
isEmpty: true,
// isWeixin: this.$wechat.isWeixin(),
isWeixin: false,
2024-02-29 20:35:06 +08:00
cartForm: {
product_id: '',
product_attr_unique: '',
cart_num: 1,
is_new: 1,
product_type: 0,
source: 999,
total_amount: ''
},
merchantInfo: '',
checkForm: {
address_id: '',
cart_id: [],
consumption_id: '',
product_type: 0,
source: 999,
takes: [],
use_coupon: {},
use_integral: false
2024-03-08 18:06:12 +08:00
},
isAuto: false, //没有授权的不会自动授权
isShowAuth: false, //是否隐藏授权
mer_id: '',
2024-03-22 10:50:55 +08:00
changeTxt: '展开',
isOpen: false,
keyBoardShow: false,
mer_name: ''
2024-02-29 20:35:06 +08:00
}
},
2024-03-08 18:06:12 +08:00
onLoad(opt) {
2024-03-22 10:50:55 +08:00
that = this;
2024-03-08 18:06:12 +08:00
this.mer_id = opt.mer_id;
},
2024-03-22 10:50:55 +08:00
2024-03-08 18:06:12 +08:00
onShow() {
if (!this.isLogin) {
Cache.set("login_back_url_weixin", "/" + getCurrentPages()[0].route + "?mer_id=" + this.mer_id);
this.isAuto = true;
this.isShowAuth = true;
2024-03-22 10:50:55 +08:00
if (this.isWeixin) {
this.$nextTick(() => {
this.$refs.authRef.toWecahtAuth();
})
}
2024-03-08 18:06:12 +08:00
} else {
2024-03-22 10:50:55 +08:00
this.checkForm.cart_id = [];
this.getProductInfoByMerid();
2024-03-08 18:06:12 +08:00
}
2024-02-29 20:35:06 +08:00
},
methods: {
2024-03-22 10:50:55 +08:00
// 打开键盘
handleOpenKeyboard() {
if (!this.isLogin) {
Cache.set("login_back_url_weixin", "/" + getCurrentPages()[0].route + "?mer_id=" + this.mer_id);
this.isAuto = true;
this.isShowAuth = true;
if (this.isWeixin) {
this.$nextTick(() => {
this.$refs.authRef.toWecahtAuth();
})
}
} else {
2024-03-23 14:40:10 +08:00
this.$refs.popups.handleOpen('money');
2024-03-22 10:50:55 +08:00
}
},
// 键盘提交
handleConfirm(e) {
if (!e) return;
this.cartForm.total_amount = e;
this.submitOrder();
},
// 清空
handleClear() {
this.cartForm.total_amount = '';
this.merchantInfo = [];
},
// 输入数字
handleChange(e) {
this.cartForm.total_amount = e;
uni.$u.debounce(that.getProductInfoByMerid, 200)
2024-03-08 18:06:12 +08:00
},
leftClick(e) {
uni.switchTab({
url: '/pages/index/index'
})
},
2024-03-22 10:50:55 +08:00
2024-03-08 18:06:12 +08:00
// 授权关闭
authColse: function(e) {
this.isShowAuth = e;
},
2024-03-22 10:50:55 +08:00
2024-03-08 18:06:12 +08:00
onLoadFun() {
this.getProductInfoByMerid(this.mer_id);
this.isShowAuth = false;
},
2024-02-29 20:35:06 +08:00
// 提交订单
2024-03-22 10:50:55 +08:00
async submitOrder() {
2024-02-29 20:35:06 +08:00
if (!this.cartForm.total_amount) {
return this.$util.Tips({
title: "请输入付款金额!"
})
}
2024-03-22 10:50:55 +08:00
// 循环加入购物车
for (var i = 0; i < that.merchantInfo.length; i++) {
let info = {
product_id: that.merchantInfo[i].product_id,
product_attr_unique: that.merchantInfo[i].unique,
cart_num: that.merchantInfo[i].num,
is_new: 1,
product_type: 0,
source: 999,
total_amount: that.cartForm.total_amount
};
try {
let res = await addCart(info);
that.checkForm.cart_id.push(res.data.cart_id);
} catch (e) {
return that.$util.Tips({
title: err.message || err.msg || err
})
}
}
if (that.checkForm.cart_id && that.checkForm.cart_id.length > 0) {
2024-03-08 18:06:12 +08:00
orderCheck(that.checkForm).then(res1 => {
uni.navigateTo({
2024-03-22 10:50:55 +08:00
url: "/pages/payment/settlement",
2024-03-08 18:06:12 +08:00
success: (res) => {
2024-03-22 10:50:55 +08:00
uni.setStorageSync('datas', {
platformConsumption: res1.data.platformConsumption ||
[],
productData: that.merchantInfo,
checkForm: that.checkForm,
money: that.cartForm.total_amount,
merName: that.mer_name,
money: that.cartForm.total_amount,
key: res1.data.key
})
},
fail(err) {
console.log(err)
2024-03-08 18:06:12 +08:00
}
})
2024-03-22 10:50:55 +08:00
}).catch(err => {
Toast(err.message || err)
});
}
2024-02-29 20:35:06 +08:00
},
2024-03-22 10:50:55 +08:00
// 折叠商品
handleOpen() {
this.isOpen = !this.isOpen;
},
// 根据店铺获取商品
getProductInfoByMerid(merid, money) {
getProductInfo1({
mer_id: that.mer_id,
money: that.cartForm.total_amount
2024-02-29 20:35:06 +08:00
}).then(res => {
2024-03-22 10:50:55 +08:00
if (!that.cartForm.total_amount) {
this.mer_name = res.data.merchant;
} else {
that.merchantInfo = res.data.list;
}
2024-02-29 20:35:06 +08:00
}).catch((err) => {
2024-03-22 10:50:55 +08:00
that.$util.Tips({
2024-03-08 18:06:12 +08:00
title: err.message || err.msg || err
2024-03-22 10:50:55 +08:00
}, () => {
2024-03-08 18:06:12 +08:00
})
// #ifdef APP
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 1500)
// #endif
// #ifndef APP
that.isEmpty = true;
// #endif
2024-02-29 20:35:06 +08:00
})
}
}
}
</script>
2024-03-08 18:06:12 +08:00
<style lang="scss">
2024-02-29 20:35:06 +08:00
page {
2024-03-22 10:50:55 +08:00
background-color: #F9F9F9;
2024-03-08 18:06:12 +08:00
}
.empty {
2024-03-22 10:50:55 +08:00
margin: 0;
2024-03-08 18:06:12 +08:00
text-align: center;
image,
uni-image {
display: inline-block;
width: 414rpx;
height: 305rpx;
}
text {
display: block;
color: #666;
font-size: 26rpx;
}
2024-02-29 20:35:06 +08:00
}
.container {
position: relative;
2024-03-08 18:06:12 +08:00
height: 100vh;
2024-03-22 10:50:55 +08:00
// background-image: url("https://lihai001.oss-cn-chengdu.aliyuncs.com/def/c582c202402291601584806.webp");
2024-02-29 20:35:06 +08:00
background-size: 100% auto;
background-repeat: no-repeat;
2024-03-08 18:06:12 +08:00
padding-top: var(--status-bar-height);
2024-02-29 20:35:06 +08:00
.v-desc {
2024-03-08 18:06:12 +08:00
position: absolute;
top: 196rpx;
z-index: 10;
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
padding: 0 20rpx;
background: transparent;
2024-02-29 20:35:06 +08:00
.v-desc-main {
margin-bottom: 30rpx;
font-weight: 600;
font-size: 42rpx;
color: #FFFFFF;
}
.v-desc-sub {
font-weight: 500;
font-size: 24rpx;
color: #FFFFFF;
}
}
2024-03-22 10:50:55 +08:00
.wrap {
margin: 0 52rpx 0 54rpx;
}
.shop {
display: flex;
align-items: center;
margin-bottom: 54rpx;
text {
margin-left: 32rpx;
}
}
2024-02-29 20:35:06 +08:00
.v-con {
2024-03-22 10:50:55 +08:00
margin: 0 auto 150rpx;
2024-02-29 20:35:06 +08:00
.v-con-text {
font-weight: 400;
2024-03-22 10:50:55 +08:00
font-size: 30rpx;
color: #000000;
2024-02-29 20:35:06 +08:00
}
.v-con-input {
2024-03-22 10:50:55 +08:00
position: relative;
2024-03-08 18:06:12 +08:00
display: flex;
align-items: center;
2024-03-22 10:50:55 +08:00
height: 112rpx;
margin-bottom: 32rpx;
2024-02-29 20:35:06 +08:00
border-bottom: 1rpx solid #D6D6D6;
2024-03-22 10:50:55 +08:00
/deep/.uni-input-input {
height: 112rpx;
font-weight: bold;
font-size: 72rpx;
}
text {
font-weight: 400;
font-size: 32rpx;
color: #000000;
}
.placeholder {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
2024-02-29 20:35:06 +08:00
}
.v-wrap {
2024-03-08 18:06:12 +08:00
display: flex;
align-items: center;
padding-left: 20rpx;
2024-02-29 20:35:06 +08:00
width: 666rpx;
height: 210rpx;
.v-wrap-money {
2024-03-08 18:06:12 +08:00
display: flex;
align-items: center;
2024-02-29 20:35:06 +08:00
color: #FF5E0C;
2024-03-08 18:06:12 +08:00
margin-right: 30rpx;
2024-02-29 20:35:06 +08:00
.icon {
2024-03-08 18:06:12 +08:00
font-size: 34rpx;
2024-02-29 20:35:06 +08:00
}
.num {
font-size: 46rpx;
2024-03-08 18:06:12 +08:00
display: inline-block;
overflow: auto;
width: 180rpx;
2024-02-29 20:35:06 +08:00
}
}
.v-wrap-desc {
.v-wrap-desc-main {
margin-bottom: 16rpx;
font-weight: 600;
font-size: 32rpx;
color: #2E2E2E;
}
.v-wrap-desc-sub {
font-weight: 400;
font-size: 24rpx;
color: #2E2E2E;
}
}
}
2024-03-08 18:06:12 +08:00
2024-02-29 20:35:06 +08:00
2024-03-22 10:50:55 +08:00
.v-con-group {
.v-con-group-title {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 32rpx;
.v-con-group-title-left {
font-weight: 400;
font-size: 30rpx;
color: #000000;
}
.v-con-group-title-right {
display: flex;
align-items: center;
text {
margin-right: 18rpx;
font-weight: 400;
font-size: 30rpx;
color: #000000;
}
}
}
.v-con-group-list {
transition: max-height linear .1s;
.v-con-group-list-item {
display: flex;
align-items: center;
margin-bottom: 14rpx;
text {
margin-left: 30rpx;
font-size: 26rpx;
color: #333333;
}
}
2024-02-29 20:35:06 +08:00
}
}
}
2024-03-22 10:50:55 +08:00
.v-btn-wrap {
width: 100%;
height: 90rpx;
line-height: 90rpx;
background: #40AE36;
border-radius: 10rpx;
font-weight: 400;
font-size: 32rpx;
color: #FFFFFF;
text-align: center;
// position: fixed;
// z-index: 11;
// bottom: 0;
// left: 0;
// display: flex;
// justify-content: center;
// align-items: center;
// width: 100%;
// height: 240rpx;
// background-color: #FDD6A6;
// .v-btn {
// width: 650rpx;
// height: 100rpx;
// line-height: 100rpx;
// background: #FF8056;
// box-shadow: 0rpx 3rpx 3rpx 1rpx rgba(255, 94, 12, 0.4);
// border-radius: 55rpx 55rpx 55rpx 55rpx;
// border: 1rpx solid #FF8056;
// font-weight: 600;
// font-size: 32rpx;
// color: #FFFFFF;
// text-align: center;
// &:active {
// opacity: .8;
// }
// }
}
2024-02-29 20:35:06 +08:00
}
</style>