order.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="order">
  3. <view class="address">
  4. <van-cell icon="user-circle-o" :border="false" is-link @click="goAddress">
  5. <template #title>
  6. <view class="top">
  7. 姓名:<text>{{defaultArr === '' ? '' : addressList[0].receiver + " " + addressList[0].mobile}}</text>
  8. </view>
  9. <div class="bottom">
  10. 地址:<text>{{defaultArr === '' ? "默认收货地址" : defaultArr}}</text>
  11. </div>
  12. </template>
  13. </van-cell>
  14. </view>
  15. <!-- 分割线 -->
  16. <van-divider hairline customStyle="border:3px solid #eee;" />
  17. <!-- 商品信息 -->
  18. <view v-for="(item,index) in shopCartInfo.shopCartOrders" :key="index">
  19. <view v-for="(item1,index1) in item.shopCartItemDiscounts[0].shopCartItems" :key="index1">
  20. <view class="main">
  21. <text class="shop-name">{{item.shopName}}</text>
  22. <van-card
  23. :num="item1.prodCount"
  24. :price="item1.price"
  25. :desc="item1.skuName"
  26. :title="item1.prodName"
  27. :thumb="item1.pic"
  28. >
  29. <template #footer>
  30. <van-stepper :value="item1.prodCount" disabled integer />
  31. <view class="goods">邮费:{{item.transfee}}元</view>
  32. </template>
  33. </van-card>
  34. </view>
  35. </view>
  36. <!-- 订单 -->
  37. <van-cell-group>
  38. <van-field
  39. :value="item.remarks"
  40. placeholder="请输入备注信息"
  41. :border="false"
  42. @change="onChange"
  43. label="订单备注"
  44. />
  45. </van-cell-group>
  46. <!-- 优惠劵 -->
  47. <van-cell title="优惠劵" :border="false" is-link />
  48. </view>
  49. <!-- 分割线 -->
  50. <van-divider hairline customStyle="border:9px solid #eee;" />
  51. <!-- 订单信息 -->
  52. <view class="prod">
  53. <van-cell-group>
  54. <van-cell title="总金额" :value="shopCartInfo.total">
  55. <template #default>
  56. <div> ¥{{ shopCartInfo.total }}</div>
  57. </template>
  58. </van-cell>
  59. <van-cell title="优惠金额" :value="shopCartInfo.orderReduce" />
  60. <van-cell title="优惠金额" :value="shopCartInfo.orderReduce" />
  61. <van-cell title="商品总数" :value="shopCartInfo.totalCount" />
  62. <van-cell title="支付金额">
  63. <template #default>
  64. <div class="money-total-count">合计: ¥{{ shopCartInfo.actualTotal }}</div>
  65. </template>
  66. </van-cell>
  67. </van-cell-group>
  68. </view>
  69. <!-- 提交 -->
  70. <van-submit-bar :price="shopCartInfo.actualTotal * 100" button-text="提交订单" @submit="onSubmit" />
  71. <!-- 弹出框 -->
  72. <van-dialog id="van-dialog" />
  73. </view>
  74. </template>
  75. <script>
  76. import {addressList} from '@/api/address.js'
  77. import {confirm} from '@/api/detail.js'
  78. import {pay,submit} from '@/api/order.js'
  79. import {Dialog} from '@/wxcomponents/dist/dialog/dialog';
  80. export default {
  81. data() {
  82. return {
  83. comfirm:{},
  84. addressList:[],
  85. defaultArr:"",
  86. shopCartInfo:[],
  87. submitData: {
  88. orderShopParam: []
  89. }
  90. }
  91. },
  92. onShow() {
  93. this.comfirm = JSON.parse(uni.getStorageSync("confirm"))
  94. this.init();
  95. },
  96. methods:{
  97. async init() {
  98. this.addressList = await addressList();
  99. for(const key in this.addressList) {
  100. if(Object.hasOwnProperty.call(this.addressList,key)) {
  101. if(this.addressList[key].commonAddr === 1) {
  102. this.comfirm.addrId = this.addressList[key].addrId;
  103. const result = this.addressList[key];
  104. this.defaultArr = result.province + "" + result.city + "" + result.area + "" + result.addr;
  105. }
  106. }
  107. }
  108. confirm(this.comfirm).then(res => {
  109. res.shopCartOrders.map(item => item.remarks = "")
  110. this.shopCartInfo = res;
  111. })
  112. },
  113. async onSubmit() {
  114. let cartInfo = this.shopCartInfo.shopCartOrders;
  115. for(var i=0;i<cartInfo.length;i++) {
  116. this.submitData.orderShopParam.push({
  117. shopId: cartInfo[i].shopId,
  118. remarks: cartInfo[i].remarks
  119. })
  120. }
  121. const result = await submit(this.submitData);
  122. const payMain = await pay({
  123. orderNumbers: result.orderNumbers,
  124. payType: 1
  125. })
  126. uni.showModal({
  127. title: '支付成功',
  128. content: '恭喜您支付已完成',
  129. success: function (res) {
  130. uni.switchTab({
  131. url:"/pages/my/my"
  132. })
  133. }
  134. })
  135. },
  136. goAddress() {
  137. uni.navigateTo({
  138. url:"/pages/address/address"
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss">
  145. .prod {
  146. padding-bottom: 130rpx;
  147. }
  148. .money-total-count {
  149. color: red;
  150. }
  151. </style>