submitorder.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="提交订单"
  5. @leftClick="leftClick"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <view class="addr page-wrap u-flex u-row-between">
  11. <view class="left">
  12. <view class="top">
  13. <text class="label" v-if="isDefaultAddr">默认</text>{{theAddr.address}}
  14. </view>
  15. <view class="center">{{theAddr.receiveAdress}}</view>
  16. <view class="bottom">{{theAddr.receiveName}} {{theAddr.receivePhone}}</view>
  17. </view>
  18. <u-icon name="arrow-right" color="#676767" size="20" @click="selectAddr"></u-icon>
  19. </view>
  20. <!-- <view class="payway page-wrap u-flex u-row-between">
  21. <view class="left">支付方式</view>
  22. <view class="u-flex">
  23. 微信支付
  24. <u-icon name="arrow-right" color="#676767" size="20"></u-icon>
  25. </view>
  26. </view> -->
  27. <view class="order-product page-wrap">
  28. <view class="product u-flex" v-for="(item,index) in dataList" :key="item.id">
  29. <u--image :showLoading="true" :src="item.mainImg" width="180rpx" height="180rpx"></u--image>
  30. <view class="text">
  31. <view class="up">
  32. <view class="name ellipsis-2">{{item.goodsName}}</view>
  33. <view class="info">
  34. {{item.specification}}
  35. {{item.unit}}
  36. </view>
  37. </view>
  38. <view class="down u-flex u-row-between">
  39. <view class="left">
  40. <view class="" v-if="vuex_member_info.levelType>1">
  41. <text class="price">¥ <text class="price-num">{{item.vipPrice}}</text></text>
  42. <text class="vip-icon">VIP</text>
  43. <text class="original-price gray line-through">¥ {{item.salePrice}}</text>
  44. </view>
  45. <view class="" v-else>
  46. <text class="price">¥ <text class="price-num">{{item.salePrice}}</text></text>
  47. </view>
  48. </view>
  49. <u-number-box v-model="item.quantity" @change="changeQuantity(index, $event)" integer></u-number-box>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="page-wrap order-reduced">
  55. <view class="reduced-item u-flex u-row-between u-border-bottom">
  56. <view class="left">
  57. <text>优惠券</text>
  58. <text class="label">已选一张</text>
  59. </view>
  60. <view class="right u-flex">
  61. <text class="price red">-¥ <text class="price-num">1000</text></text>
  62. <u-icon name="arrow-right" color="#676767" size="20"></u-icon>
  63. </view>
  64. </view>
  65. <view class="reduced-item integral u-flex u-row-between">
  66. <view class="left">
  67. <text>积分</text>
  68. <text class="num">3676</text>
  69. <text class="tip">满1000可用</text>
  70. </view>
  71. <view class="right u-flex">
  72. <text class="price red" v-if="useIntegral">-¥ <text class="price-num">1000</text></text>
  73. <u-checkbox-group @change="integralCheckboxChange">
  74. <u-checkbox shape="circle" activeColor="#02AB35" name="integral" ></u-checkbox>
  75. </u-checkbox-group>
  76. </view>
  77. </view>
  78. </view>
  79. <view class="page-wrap total">
  80. <view class="total-item u-flex u-row-between u-border-bottom">
  81. <view class="left">
  82. 商品金额
  83. </view>
  84. <view class="right">
  85. ¥2399.00
  86. </view>
  87. </view>
  88. <view class="total-item u-flex u-row-between">
  89. <view class="left">
  90. 运费
  91. <text class="gray">总重:40kg</text>
  92. </view>
  93. <view class="right">
  94. + ¥2399.00
  95. </view>
  96. </view>
  97. </view>
  98. <view class="cart-bottom">
  99. <view class="inner u-flex u-row-between">
  100. <view class="left u-flex">
  101. <view class="total-price">
  102. 待支付:<text class="red">¥4322.00</text>
  103. </view>
  104. </view>
  105. <view class="btn">去结算</view>
  106. </view>
  107. </view>
  108. </view>
  109. </template>
  110. <script>
  111. export default {
  112. data() {
  113. return {
  114. fromPage:'',
  115. useIntegral:false,
  116. dataList:[],
  117. theAddr:{},
  118. isDefaultAddr:false,
  119. }
  120. },
  121. onLoad(page) {
  122. // console.log('page',page);
  123. // console.log('selectGoods',JSON.parse(page.selectGoods));
  124. this.dataList = JSON.parse(page.selectGoods);
  125. },
  126. onShow() {
  127. if(this.fromPage!='addrlist'){
  128. this.getAddrList()
  129. }
  130. },
  131. methods: {
  132. leftClick(e){
  133. console.log('leftClick',e);
  134. },
  135. integralCheckboxChange(e){
  136. this.useIntegral = e[0] && e[0] === 'integral' ? true : false;
  137. },
  138. selectAddr(){
  139. uni.$u.route('/center/addrlist', {
  140. from: 'submitorder'
  141. });
  142. },
  143. getAddrList(){
  144. this.$u.api.addrList().then(res=>{
  145. this.theAddr = res.data.rows;
  146. let defaultAddress;
  147. let firstAddress = res.data.rows[0];
  148. res.data.rows.forEach(address => {
  149. if (address.ifDefault) { // 如果有默认地址标识
  150. defaultAddress = address;
  151. this.isDefaultAddr = true;
  152. }
  153. });
  154. if (!defaultAddress) { // 如果没有默认地址标识
  155. defaultAddress = firstAddress;
  156. }
  157. this.theAddr = defaultAddress;
  158. }).catch(err=>{
  159. console.log('getAddrList',err.data);
  160. })
  161. },
  162. // 改变商品数量
  163. changeQuantity(index, value) {
  164. this.changeQuantityApi(this.dataList[index].id,value.value)
  165. },
  166. changeQuantityApi(id,num){
  167. this.$u.api.updateQuantity({id:id,quantity:num}).then(res=>{
  168. // this.dataList[index].quantity = num
  169. console.log('res',res.data);
  170. }).catch(err=>{
  171. console.log('changeQuantityApi',err.data);
  172. })
  173. },
  174. }
  175. }
  176. </script>
  177. <style>
  178. page{
  179. background-color: #F5F5F5;
  180. /* padding-top: 50px; */
  181. }
  182. </style>
  183. <style lang="scss" scoped>
  184. .page-wrap{
  185. background-color: #fff;
  186. margin-bottom: 20rpx;
  187. }
  188. .addr{
  189. .top{
  190. margin-bottom: 16rpx;
  191. font-size: 26rpx;
  192. color: #999;
  193. .label{
  194. background-color: #FFEBEB;
  195. border: 1px solid #FF5F62;
  196. color: #FF5F62;
  197. padding: 5rpx 20rpx;
  198. border-radius: 30rpx;
  199. margin-right: 10rpx;
  200. }
  201. }
  202. .center{
  203. margin-bottom: 10rpx;
  204. font-size: 30rpx;
  205. color: #333;
  206. line-height: 50rpx;
  207. font-weight: 600;
  208. }
  209. .bottom{
  210. font-size: 30rpx;
  211. color: #666;
  212. }
  213. }
  214. .order-reduced{
  215. .reduced-item{
  216. padding-bottom: 30rpx;
  217. &:not(:last-child){
  218. margin-bottom: 30rpx;
  219. }
  220. .label{
  221. border-radius: 2px;
  222. border: 1px solid #FF3C3F;
  223. margin-left: 20rpx;
  224. font-size: 20rpx;
  225. color: #FF3C3F;
  226. padding: 0 10rpx;
  227. }
  228. }
  229. .integral{
  230. .num{
  231. font-size: 30rpx;
  232. color: #02AB35;
  233. font-weight: 600;
  234. margin-left: 30rpx;
  235. margin-right: 16rpx;
  236. }
  237. .tip{
  238. font-size: 24rpx;
  239. color: #999;
  240. }
  241. .price{
  242. margin-right: 10rpx;
  243. }
  244. }
  245. }
  246. .total{
  247. .total-item{
  248. padding-bottom: 30rpx;
  249. &:not(:last-child){
  250. margin-bottom: 30rpx;
  251. }
  252. .right{
  253. font-weight: 600;
  254. }
  255. }
  256. .gray{
  257. font-size: 24rpx;
  258. margin-left: 15rpx;
  259. }
  260. }
  261. .cart-bottom{
  262. height: 98rpx;
  263. .inner{
  264. position: fixed;
  265. background-color: #fff;
  266. height: 98rpx;
  267. left: 0;
  268. right: 0;
  269. bottom: 0;
  270. padding: 0 20rpx;
  271. .total-price{
  272. font-size: 30rpx;
  273. color: #333;
  274. font-weight: 600;
  275. margin-left: 30rpx;
  276. }
  277. .btn{
  278. height: 80rpx;
  279. line-height: 80rpx;
  280. border-radius: 50rpx;
  281. padding: 0 50rpx;
  282. background-color: #FF3C3F;
  283. color: #fff;
  284. text-align: center;
  285. }
  286. }
  287. }
  288. .product{
  289. .text{
  290. .name{
  291. height: auto;
  292. }
  293. .info{
  294. font-size: 24rpx;
  295. font-weight: 400;
  296. color: #666666;
  297. }
  298. }
  299. }
  300. </style>