order.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. console.log(this.comfirm,'common111')
  95. this.init();
  96. },
  97. methods:{
  98. async init() {
  99. this.addressList = await addressList();
  100. for(const key in this.addressList) {
  101. if(Object.hasOwnProperty.call(this.addressList,key)) {
  102. if(this.addressList[key].commonAddr === 1) {
  103. this.comfirm.addrId = this.addressList[key].addrId;
  104. const result = this.addressList[key];
  105. this.defaultArr = result.province + "" + result.city + "" + result.area + "" + result.addr;
  106. }
  107. }
  108. }
  109. console.log(this.comfirm,"走进来1")
  110. confirm(this.comfirm).then(res => {
  111. console.log("走进来2")
  112. console.log(res,'结果')
  113. res.shopCartOrders.map(item => item.remarks = "")
  114. this.shopCartInfo = res;
  115. })
  116. },
  117. async onSubmit() {
  118. let cartInfo = this.shopCartInfo.shopCartOrders;
  119. for(var i=0;i<cartInfo.length;i++) {
  120. this.submitData.orderShopParam.push({
  121. shopId: cartInfo[i].shopId,
  122. remarks: cartInfo[i].remarks
  123. })
  124. }
  125. const result = await submit(this.submitData);
  126. console.log(result,'结果1')
  127. const payMain = await pay({
  128. orderNumbers: result.orderNumbers,
  129. payType: 1
  130. })
  131. uni.showModal({
  132. title: '支付成功',
  133. content: '恭喜您支付已完成',
  134. success: function (res) {
  135. uni.switchTab({
  136. url:"/pages/my/my"
  137. })
  138. }
  139. })
  140. },
  141. goAddress() {
  142. uni.navigateTo({
  143. url:"/pages/address/address"
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. .prod {
  151. padding-bottom: 130rpx;
  152. }
  153. .money-total-count {
  154. color: red;
  155. }
  156. </style>