step1.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false" ><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="确认订单" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. </uni-nav-bar>
  10. </view>
  11. </view>
  12. <view class="div body" v-if="store_final_total_list">
  13. <view class="div block-wrapper"><checkout-address v-if="addAddress" class="address" v-on:onclick="goAddress" :item="store_final_total_list.address_info"></checkout-address></view>
  14. <checkout-store class="section-header" :totalAmount="store_final_total_list.pointprod_arr.pgoods_pointall" :storeCartList="store_final_total_list.pointprod_arr.pointprod_list" @changeMessage="changeMessage"></checkout-store>
  15. </view>
  16. <view class="div bottom-wrapper" v-if="store_final_total_list">
  17. <view class="div amount-wrapper">
  18. <view class="div common-btn ds-button-large" @click="checkout">提交订单</view>
  19. </view>
  20. </view>
  21. </view>
  22. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  23. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  24. </uni-popup>
  25. </member-base>
  26. </template>
  27. <script>
  28. import {getFontSize} from '@/util/common'
  29. import TitleHeader from '../../TitleHeader'
  30. import { urlencode } from '@/util/common'
  31. import MemberBase from '../MemberBase'
  32. import { buyStep1, buyStep2 } from '../../../api/memberPointscart'
  33. import CheckoutAddress from './child/CheckoutAddress'
  34. import CheckoutStore from './child/CheckoutStore'
  35. export default {
  36. name: 'Step1',
  37. components:{
  38. TitleHeader,
  39. MemberBase,
  40. CheckoutAddress,
  41. CheckoutStore
  42. },
  43. mounted(){
  44. // #ifdef MP-WEIXIN
  45. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  46. // #endif
  47. },
  48. computed:{
  49. fontSize(){
  50. return getFontSize()
  51. },
  52. },
  53. data(){
  54. return {
  55. addAddress:false,
  56. navHeight: 0,
  57. dialog:{},
  58. buy_now:0,
  59. cart_id: '',
  60. store_final_total_list: null,
  61. message: ''
  62. }
  63. },
  64. onLoad: function (option) {
  65. this.buy_now=option.buy_now
  66. this.cart_id=option.cart_id ? option.cart_id : ''
  67. },
  68. onShow(){
  69. this.getBuyInfo()
  70. },
  71. methods:{
  72. closeDialog(){
  73. },
  74. confirmDialog(value){
  75. },
  76. // 获取订单信息
  77. getBuyInfo () {
  78. buyStep1(
  79. this.cart_id, this.buy_now ? 0 : 1
  80. ).then((res) => {
  81. if (res.code === 10000) {
  82. this.store_final_total_list = res.result
  83. this.addAddress=true
  84. } else {
  85. }
  86. }).catch(function (error) {
  87. uni.showToast({icon:'none',title: error.message})
  88. })
  89. },
  90. goBack () {
  91. uni.navigateBack({delta:1})
  92. },
  93. goAddress () {
  94. if (this.store_final_total_list.address_info) {
  95. uni.navigateTo({ url: '/pages/member/address/AddressList' })
  96. } else {
  97. this.addAddress=false
  98. uni.navigateTo({ url: '/pages/member/address/AddressForm'+'?'+urlencode( { action: 'add',isFromCheckout: true,goBackLevel: 2 })})
  99. }
  100. },
  101. changeMessage (message) {
  102. this.message = message
  103. },
  104. // 提交订单
  105. checkout () {
  106. let ifcart = this.buy_now ? 0 : 1
  107. let cart_id = this.cart_id
  108. let address_id = this.store_final_total_list.address_info ? this.store_final_total_list.address_info.address_id : 0
  109. let message = this.message
  110. if (!address_id) {
  111. this.dialog={content:'您需要先去添加收货地址'}
  112. this.$refs.confirm.open()
  113. return
  114. }
  115. buyStep2(
  116. cart_id,
  117. ifcart,
  118. address_id,
  119. message
  120. ).then((res) => {
  121. uni.redirectTo({ url: '/pages/member/pointsorder/OrderList' })
  122. }).catch(function (error) {
  123. uni.showToast({icon:'none',title: error.message})
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped lang="scss">
  130. .block-wrapper{background: #fff;padding:0 $pageSpace}
  131. .container {
  132. display: flex;
  133. flex-direction: column;
  134. justify-content: flex-start;
  135. align-items: stretch;
  136. }
  137. .header {
  138. height:2.2rem;
  139. color: #48505d;
  140. font-size:$h1;
  141. background-color: #fff;
  142. padding:0.1rem 0;
  143. border-bottom: 1px solid #e8eaed;
  144. }
  145. .body {
  146. display: flex;
  147. flex-direction: column;
  148. justify-content: flex-start;
  149. align-items: stretch;
  150. margin-bottom:4rem;
  151. }
  152. .address {
  153. }
  154. .goods {
  155. height:4.5rem;
  156. }
  157. .item {
  158. height:2.5rem;
  159. }
  160. .section-header {
  161. margin-top:0.4rem;
  162. }
  163. .section-footer {
  164. margin-bottom:0.4rem;
  165. }
  166. .comment {
  167. height:7rem;
  168. }
  169. .desc {
  170. background-color: #fff;
  171. display: flex;
  172. flex-direction: column;
  173. justify-content: flex-start;
  174. align-items: stretch;
  175. padding-top:0.5rem;
  176. padding-bottom: 0.5rem;
  177. }
  178. .desc-item {
  179. height:1.5rem;
  180. }
  181. .bottom-wrapper {
  182. z-index: 1;
  183. background: #fff;
  184. position: fixed;
  185. left: 0;
  186. right: 0;
  187. bottom: 0;
  188. padding:.5rem 0;
  189. display: flex;
  190. flex-direction: row;
  191. justify-content: flex-start;
  192. align-items: stretch;
  193. }
  194. .amount-wrapper {
  195. flex: 1;
  196. background-color: #fff;
  197. margin:0 $pageSpace;
  198. }
  199. .amount {
  200. flex: 1;
  201. font-size:$h2;
  202. color: $primaryColor;
  203. text-align: right;
  204. padding-right:0.75rem;
  205. }
  206. .submit {
  207. width:7.5rem;
  208. height:2.5rem;
  209. border-radius: 0;
  210. }
  211. </style>