123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <template>
- <view class="order">
- <!-- 默认地址 -->
- <van-cell icon="contact-o" is-link>
- <template #title class="tips">
- <view class="top">姓名:{{defaultArr === '' ? '' : addressList[0].receiver + " " + addressList[0].mobile}}
- </view>
- <view class="bottom van-ellipsis">地址:{{defaultArr === "" ? "展示默认地址" : defaultArr}}</view>
- </template>
- </van-cell>
- <!-- 商品信息 -->
- <view class="main">
- <view v-for="(item,index) in shopCart.shopCartOrders" :key="index">
- <view v-for="(item1,index1) in item.shopCartItemDiscounts[0].shopCartItems" :key="index1">
- <view class="shopName">
- {{item.shopName}}
- </view>
- <van-card :num="item1.prodCount" :price="item1.price" :desc="item1.skuName" :title="item1.prodName"
- :thumb="item1.pic">
- <template #footer>
- <view>
- <van-stepper :value="item1.prodCount" disabled integer />
- <view class="free">
- 邮费:<text>{{item.transfee}}元</text>
- </view>
- </view>
- </template>
- </van-card>
- </view>
- </view>
- <!-- 订单备注 -->
- <van-cell title="订单备注" value="请输入订单信息" :label="item.remarks" :border="false" />
- <!-- 优惠劵 -->
- <van-cell title="优惠劵" is-link value="暂无可用" :border="false" />
- </view>
- <!-- 分割线 -->
- <van-divider custom-style="border:7px solid #eee"/>
- <!-- 订单信息 -->
- <van-cell title="总金额" value="">
- <template #default>
- <view>¥{{shopCart.total}}</view>
- </template>
- </van-cell>
- <van-cell title="优惠金额" :value="shopCart.orderReduce" />
- <van-cell title="商品总数" :value="shopCart.totalCount" />
- <van-cell title="支付金额" value="">
- <template #default>
- <view class="payCount">
- 合计:¥{{shopCart.actualTotal}}
- </view>
- </template>
- </van-cell>
- <!-- 按钮 -->
- <van-submit-bar
- :price="shopCart.actualTotal * 100"
- button-text="提交订单"
- @submit="onSubmit"
- />
- </view>
- </template>
- <script>
- import {
- prodInfo
- } from '@/api/address.js'
- import {
- confirm,
- submit,
- pay
- } from '@/api/order.js'
- export default {
- data() {
- return {
- addressList: [],
- defaultArr: "",
- shopCart: [],
- shopMain:{
- orderShopParam: [
- {
- shopId: 0,
- remarks: ""
- }
- ],
- }
- }
- },
- onShow() {
- this.confirm = JSON.parse(uni.getStorageSync("confirm"));
- this.getAddress();
- this.getCard();
- },
- methods: {
- async getAddress() {
- this.addressList = await prodInfo();
- for (const key in this.addressList) {
- // console.log(key)
- if (Object.hasOwnProperty.call(this.addressList, key)) {
- if (this.addressList[key].commonAddr === 1) {
- console.log(this.addressList[key])
- const result = this.addressList[key];
- this.defaultArr = result.province + "" + result.city + "" + result.area + "" + result.addr;
- }
- }
- }
- },
- async getCard() {
- let result = await confirm(this.confirm);
- result.shopCartOrders.map(item => item.remarks = "");
- this.shopCart = result;
- console.log(this.shopCart, 'shopCart');
- },
- async onSubmit() {
- console.log("点击")
- let cardInfo = this.shopCart.shopCartOrders;
- for(var i=0;i<cardInfo.length;i++) {
- this.shopMain.orderShopParam.push({
- shopId: cardInfo[i].shopId,
- remarks: cardInfo[i].remarks
- })
- }
- let result = await submit(this.shopMain);
- console.log(result,'结果')
- let shopList = await pay({
- orderNumbers: result.orderNumbers,
- payType: 1
- })
- uni.showModal({
- title:"支付成功",
- content:"恭喜您完成支付!",
- success: function(res) {
- uni.switchTab({
- url:"/pages/my/my"
- })
- }
- })
-
- }
- }
- }
- </script>
- <style lang="scss">
- .van-ellipsis {
- width: 500rpx;
- }
- .main {
- padding: 20rpx;
-
- .shopName {
- font-size: 35rpx;
- }
- }
- .payCount {
- color: #f00;
- }
- </style>
|