integral_settlement.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view class="integral-settlement">
  3. <view class="settlement-main">
  4. <router-link to="/bundle/pages/user_address/user_address?type=1">
  5. <view class="address flex contain">
  6. <image class="icon-md m-r-20" src="/static/images/icon_address.png"></image>
  7. <view class="flex-1 m-r-20">
  8. <view class="black md" v-if="!address.contact">设置收货地址</view>
  9. <view v-else>
  10. <text class="name md m-r-10">{{address.contact}}</text>
  11. <text class="phone md">{{address.telephone}}</text>
  12. <view class="area sm m-t-10 lighter">
  13. {{address.province}} {{address.city}} {{address.district}} {{address.address}}
  14. </view>
  15. </view>
  16. </view>
  17. <u-icon name="arrow-right"></u-icon>
  18. </view>
  19. </router-link>
  20. <view class="order-goods contain">
  21. <view class="flex goods">
  22. <u-image :src="goods.image" border-radius="10" width="160" height="160"></u-image>
  23. <view class="goods-info flex-1 m-l-20">
  24. <view class="goods-name line-2">{{ goods.name }}</view>
  25. <view class="flex row-between">
  26. <view class="goods-price primary m-t-10">
  27. <price-format :show-subscript="false" :first-size="36" :second-size="24"
  28. :price="goods.need_integral" />
  29. <text class="xs">券</text>
  30. <block v-if="goods.exchange_way === 2">
  31. <text>+</text>
  32. <price-format :show-subscript="false" :first-size="36" :second-size="24"
  33. :price="goods.need_money" />
  34. <text class="xs">元</text>
  35. </block>
  36. </view>
  37. <view class="lighter">×{{orderInfo.total_num}}</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="buyer-message">
  42. <u-field v-model="remark" type="textarea" :border-bottom="false" :auto-height="false" label="买家留言"
  43. placeholder="请添加备注(150字以内)" maxlength="150" :field-style="{ height: '240rpx' }">
  44. </u-field>
  45. </view>
  46. </view>
  47. <view class="total-goods contain">
  48. <view class="flex row-between ">
  49. <view>商品总额</view>
  50. <view class="primary">
  51. <price-format :show-subscript="false" :first-size="36" :second-size="24"
  52. :price="orderInfo.order_integral" />
  53. <text class="xs">券</text>
  54. <block v-if="orderInfo.exchange_way === 2">
  55. <text>+</text>
  56. <price-format :show-subscript="false" :first-size="36" :second-size="24"
  57. :price="orderInfo.goods_price" />
  58. <text class="xs">元</text>
  59. </block>
  60. </view>
  61. </view>
  62. <view class="flex row-between m-t-20">
  63. <view>运费</view>
  64. <view>
  65. <price-format :first-size="28" :subscript-size="24" :second-size="24"
  66. :price="orderInfo.shipping_price" />
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="settlement-footer bg-white flex row-between">
  72. <view class="all-price lg flex">
  73. <text>合计:</text>
  74. <view class="primary">
  75. <price-format :show-subscript="false" :first-size="36" :second-size="24"
  76. :price="orderInfo.order_integral" />
  77. <text class="xs">券</text>
  78. <block v-if="orderInfo.order_amount > 0">
  79. <text>+</text>
  80. <price-format :show-subscript="false" :first-size="36" :second-size="24"
  81. :price="orderInfo.order_amount" />
  82. <text class="xs">元</text>
  83. </block>
  84. </view>
  85. </view>
  86. <button type="primary" class="br60" size="md" hover-class="none" @tap="orderBuy">
  87. 提交订单
  88. </button>
  89. </view>
  90. <loading-view v-show="showLoading" :background-color="hasBg ? '#fff' : ''"></loading-view>
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. integralSettlement,
  96. integralSubmitOrder
  97. } from '@/api/activity'
  98. export default {
  99. data() {
  100. return {
  101. showLoading: true,
  102. hasBg: true,
  103. address: {},
  104. goods: {},
  105. orderInfo: {},
  106. addressId: '',
  107. remark: ''
  108. }
  109. },
  110. methods: {
  111. // 订单信息
  112. getOrderInfo() {
  113. integralSettlement({
  114. id: this.goodsId,
  115. num: this.count,
  116. address_id: this.addressId
  117. }).then(res => {
  118. if (res.code == 1) {
  119. const {
  120. address,
  121. goods
  122. } = res.data
  123. this.address = address
  124. this.orderInfo = res.data
  125. this.goods = goods
  126. }
  127. }).finally(() => {
  128. this.showLoading = false
  129. })
  130. },
  131. // 提交订单
  132. orderBuy() {
  133. this.hasBg = false
  134. this.showLoading = true
  135. const address_id = this.addressId || this.address.id
  136. integralSubmitOrder({
  137. id: this.goodsId,
  138. num: this.count,
  139. address_id,
  140. user_remark: this.remark
  141. }).then(res => {
  142. if (res.code == 1) {
  143. const {
  144. type,
  145. order_id
  146. } = res.data
  147. if (!this.orderInfo.need_pay) {
  148. this.$Router.replace({
  149. path: '/pages/pay_result/pay_result',
  150. query: {
  151. id: order_id,
  152. from: type
  153. }
  154. })
  155. return
  156. }
  157. uni.$on('payment', params => {
  158. setTimeout(() => {
  159. if (params.result) {
  160. this.$Router.replace({
  161. path: '/pages/pay_result/pay_result',
  162. query: {
  163. id: params.order_id,
  164. from: params.from
  165. }
  166. })
  167. } else {
  168. this.$Router.replace({
  169. path: '/bundle/pages/exchange_order/exchange_order',
  170. query: {
  171. id: params.order_id,
  172. from: params.from
  173. }
  174. })
  175. }
  176. }, 1 * 1000)
  177. })
  178. this.$Router.push({
  179. path: '/pages/payment/payment',
  180. query: {
  181. order_id: order_id,
  182. from: type
  183. }
  184. })
  185. }
  186. }).finally(() => {
  187. setTimeout(() => {
  188. this.showLoading = false
  189. }, 200)
  190. })
  191. }
  192. },
  193. onLoad(options) {
  194. uni.$on("selectaddress", (e) => {
  195. this.addressId = e.id
  196. })
  197. },
  198. onUnload() {
  199. uni.$off("selectaddress")
  200. uni.$off("payment")
  201. },
  202. onShow() {
  203. const {
  204. count,
  205. id
  206. } = this.$Route.query
  207. this.goodsId = id
  208. this.count = count
  209. this.getOrderInfo()
  210. }
  211. }
  212. </script>
  213. <style lang="scss">
  214. .integral-settlement {
  215. overflow: hidden;
  216. padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
  217. .contain {
  218. background-color: #fff;
  219. border-radius: 14rpx;
  220. margin: 20rpx 20rpx 0;
  221. }
  222. .settlement-main {
  223. .address {
  224. min-height: 164rpx;
  225. padding: 20rpx 24rpx;
  226. }
  227. .order-goods {
  228. .goods {
  229. padding: 30rpx 24rpx;
  230. border-bottom: $-solid-border;
  231. .goods-info {
  232. .goods-name {
  233. line-height: 40rpx;
  234. height: 80rpx;
  235. }
  236. }
  237. }
  238. .buyer-message {}
  239. }
  240. .total-goods {
  241. padding: 20rpx 24rpx;
  242. }
  243. }
  244. .settlement-footer {
  245. position: fixed;
  246. bottom: 0;
  247. left: 0;
  248. right: 0;
  249. height: 100rpx;
  250. padding: 0 30rpx;
  251. box-sizing: content-box;
  252. padding-bottom: env(safe-area-inset-bottom);
  253. }
  254. }
  255. </style>