Files
jjx-web/pages/index/shop/pay.vue
T
2023-12-05 22:37:53 +08:00

180 lines
7.1 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>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<view class="w-1200 m-a bg-white p-40">
<template v-if="info">
<view class="pb-20 border-bottom flex justify-between items-center">
<text>订单号: {{ info.orderNo }}</text>
<text>下单时间: {{ info._add_time_str }}</text>
</view>
<view class="my-20">
<text class="font-bold text-35">商品详情</text>
<view class="flex justify-start items-start my-20">
<text class="w-15p">封面</text>
<text class="w-40p">名称</text>
<text class="w-15p">数量</text>
<text class="w-15p">单价</text>
<text class="w-15p">小计</text>
</view>
<view class="flex justify-start items-start my-20" v-for="(item, index) in info.goods">
<text class="w-15p">
<image :src="item.goodsCover" mode="aspectFit" class="goods-cover"/>
</text>
<text class="w-40p font-bold text-35">{{ item.goodsName }}</text>
<text class="w-15p">x{{ item.num }}</text>
<text class="w-15p text-main">¥{{ item.goodsPrice }}</text>
<text class="w-15p">{{ item.goodsPrice * item.num }}</text>
</view>
</view>
</template>
<el-row :gutter="10" class="mb-20">
<el-col :span="4">
<el-input v-model="name" placeholder="请输入收件人姓名"/>
</el-col>
<el-col :span="4">
<el-input v-model="phone" placeholder="请输入收件人手机号"/>
</el-col>
</el-row>
<el-row :gutter="10" class="border-bottom pb-20">
<el-col :span="4">
<el-select v-model="addressIndex[0]" placeholder="请选择省">
<el-option v-for="(item, index) in provinceData" :key="index"
:label="item.name"
:value="index">
</el-option>
</el-select>
</el-col>
<el-col :span="4">
<el-select v-model="addressIndex[1]" placeholder="请选择市" :disabled="addressIndex.length === 0">
<template v-if="addressIndex[0] !== null">
<el-option v-for="(item, index) in cityData[addressIndex[0]]" :key="index"
:label="item.name"
:value="index">
</el-option>
</template>
</el-select>
</el-col>
<el-col :span="4">
<el-select v-model="addressIndex[2]" placeholder="请选择区" :disabled="addressIndex.length === 1">
<template v-if="addressIndex[0] !== null && addressIndex[1] !== null">
<el-option v-for="(item, index) in areaData[addressIndex[0]][addressIndex[1]]" :key="index"
:label="item.name"
:value="index">
</el-option>
</template>
</el-select>
</el-col>
<el-col :span="12">
<el-input v-model="addressDetail" placeholder="请输入详细地址"/>
</el-col>
</el-row>
<view class="mt-20 w-50p flex flex-col justify-center items-center m-a">
<text class="text-main font-bold text-40 mb-20">订单金额:¥{{ info.amount }}</text>
<el-button type="primary" round :disabled="!phone || !name || addressIndex.length < 3" @click="onPay">立即支付</el-button>
</view>
<div class="pay-price" v-if="billQRCode">
<uv-qrcode ref="qrcode" size="240px" :value="billQRCode"></uv-qrcode>
<div class="pay-desc">请打开手机微信,扫一扫完成支付</div>
<el-button type="success" @click="onPayStatus">已完成支付</el-button>
</div>
</view>
<gap height="50"/>
<common-footer></common-footer>
<right-bar></right-bar>
</view>
</template>
<script>
import provinces from "@/uni_modules/vk-uview-ui/libs/address/provinces.json";
import citys from "@/uni_modules/vk-uview-ui/libs/address/citys.json";
import areas from "@/uni_modules/vk-uview-ui/libs/address/areas.json";
import dayjs from "dayjs";
const OpenSdk = require('../../user/lib/base').default;
const sdk = new OpenSdk({
appId: '10037e6f6823b20801682b6a5e5a0006',
appKey: '1c4e3b16066244ae9b236a09e5b312e8'
})
export default {
name: "order",
data() {
return {
id: null,
info: null,
provinceData: provinces,
cityData: citys,
areaData: areas,
addressIndex: [null, null, null],
addressDetail: '',
name: '',
phone: '',
billQRCode: null
}
},
methods: {
async getInfo() {
this.info = await vk.callFunction({
url: 'client/order/kh/getInfo',
data: {
id: this.id
}
})
},
onPay() {
const requestTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss')
const timestamp = dayjs().format('YYYYmmddHHmmSS')
console.log(timestamp)
console.log(requestTimestamp)
let data = {
queryUrl: 'https://test-api-open.chinaums.com/v1/netpay/bills/get-qrcode',
timestamp,
nonce: 'rp84ufhfn20yneo3tp',
content: {
requestTimestamp,
mid: '898201612345678',
tid: '88880001',
instMid: 'QRPAYDEFAULT',
totalAmount: 1,
notifyUrl: 'https://static-mp-0737e52b-fffa-4223-bcdf-d4ad3d9968a5.next.bspapp.com/#/'
}
}
/**
* 调用函数
*/
sdk.exec(data).then(res => {
const h = this.$createElement;
const result = JSON.parse(res);
if (result.errCode === 'SUCCESS') {
this.showQrcode = true
this.billQRCode = result.billQRCode
}
})
},
},
onLoad(options) {
if (options && options.id) {
this.id = options.id
this.getInfo()
}
}
}
</script>
<style lang="scss" scoped>
.goods-cover {
width: 100px;
height: 100px;
}
.pay-price {
margin-top: 20px;
}
.pay-desc {
font-size: 16px;
line-height: 2em;
}
</style>