index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="pay">
  3. <!-- header -->
  4. <cu-custom isBack bgColor="bg-gradual-blue"><view slot="content">确认订单</view></cu-custom>
  5. <view @click="addressListFunc" class="padding bg-white flex align-center">
  6. <view v-if="Object.keys(value).length>0" style="flex: auto;">
  7. <view class="margin-bottom-sm flex align-center">
  8. <text class="cu-tag text-white round sm margin-right-xs" style="background-color:#ee0a24;">默认</text>
  9. {{value.province}}{{value.city}}{{value.area}}
  10. </view>
  11. <view class="margin-bottom-sm text-bold text-black text-lg">{{value.address}}</view>
  12. <view class=" text-black text-lg">{{value.name}} {{value.tel}}</view>
  13. </view>
  14. <view v-else class="text-grey text-center">
  15. 请挑选收货地址
  16. </view>
  17. <text style="min-width: 40upx;" class="cuIcon-right lg text-gray text-center"></text>
  18. </view>
  19. <view class="padding bg-white margin-tb-sm">
  20. <view class="padding-bottom-sm flex justify-between">
  21. <view class="text-black text-bold">商品清单</view>
  22. <view @click="show = true" class="text-gray flex align-center">
  23. 共{{list.length}}件
  24. <text class="cuIcon-right lg "></text>
  25. </view>
  26. </view>
  27. <scroll-view style="width: 100%;flex-wrap: nowrap;height: 180upx;" class="flex " enable-flex scroll-x="true">
  28. <image
  29. @click="show = true"
  30. class="margin-right"
  31. v-for="(item, index) in list"
  32. :key="index"
  33. style="min-width: 180upx; width: 180upx;height: 180upx;"
  34. :src="item.img | lazyImage"
  35. mode="aspectFit"
  36. ></image>
  37. </scroll-view>
  38. </view>
  39. <!-- footer -->
  40. <view class="footer">
  41. <view class="footer-content flex padding justify-between align-center bg-white">
  42. <view class="flex align-end">
  43. <view class="margin-right-xs text-black">实付款</view>
  44. <view style="transform: translateY(10upx);" class="text-price text-red"><cu-price :value="price" size="52" /></view>
  45. <view class="margin-left">
  46. {{point_price}}积分
  47. </view>
  48. </view>
  49. <button @click="handler" :disabled="!status" class="bg-red cu-btn round "> 提交订单</button>
  50. </view>
  51. </view>
  52. <!-- 工具 -->
  53. <cu-modalC :show.sync="show" custom="2">
  54. <view class="padding text-center text-lg text-black text-bold border">
  55. 商品清单1
  56. <text class="text-sm" style="color:#999">(共{{list.length}}件)</text>
  57. </view>
  58. <cu-scrollView height="50vh">
  59. <view v-for="(item,index) in list" class="flex padding">
  60. <image
  61. class="radius margin-right-sm"
  62. style="width: 160upx;height: 160upx;min-width: 160upx;"
  63. lazy-load="true"
  64. :src="item.img | lazyImage"
  65. mode="aspectFit"
  66. ></image>
  67. <view style="flex:auto" class="content margin-right-sm">
  68. <view class="text-black">{{item.name}}</view>
  69. <view class="flex">
  70. <view v-if="item.type==1" class="text-red">
  71. <cu-price :value="item.price" size="32" />
  72. </view>
  73. <view v-else>
  74. {{item.point_price}}积分
  75. </view>
  76. <view class="bg-orange light text-xs padding-lr-xs">
  77. <text class="cuIcon-vip lg">会员价</text>
  78. <text class="text-price margin-left-xs">{{ item.vip_price }}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </cu-scrollView>
  84. </cu-modalC>
  85. </view>
  86. </template>
  87. <script>
  88. import { mapState, mapActions } from 'vuex';
  89. import api from "./api.js";
  90. export default {
  91. data() {
  92. return {
  93. show: false,
  94. list:[],//商品列表
  95. price:0,
  96. point_price:0,
  97. status:true,
  98. };
  99. },
  100. computed: {
  101. ...mapState(['openid','appId']),
  102. ...mapState('addressDefault', ['value']),
  103. },
  104. onLoad(options) {
  105. let {list}=options;
  106. this.list=JSON.parse(list);
  107. let price=0,point_price=0;
  108. this.list.forEach(item=>(item.type==1 ? price+=item.price*1 : point_price+=item.point_price*1));
  109. this.price=price;
  110. this.point_price=point_price;
  111. },
  112. async onShow(){
  113. await this.requestFunc();
  114. },
  115. methods:{
  116. ...mapActions('addressDefault', ['requestFunc']),
  117. addressListFunc(){
  118. uni.navigateTo({
  119. url:"/loginPages/addressList/index"
  120. })
  121. },
  122. async handler(){
  123. try{
  124. this.status=false;
  125. let list=this.list.map(item=>({id:item.id,count:item.count}));
  126. var result =await api.submit({details:JSON.stringify(list),openid:this.openid,appid:this.appId,address_id:this.value.id});
  127. console.log(result)
  128. }catch(err){
  129. uni.showToast({
  130. title:"支付失败",
  131. icon:"error"
  132. })
  133. }finally{
  134. this.status=true;
  135. }
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss" scoped>
  141. .pay {
  142. .border {
  143. position: relative;
  144. &::after {
  145. content: '';
  146. border-top: 1upx solid #ccc;
  147. position: absolute;
  148. left: 0;
  149. bottom: 0;
  150. transform: scale(1, 0.5);
  151. width: 100%;
  152. }
  153. }
  154. .footer {
  155. height: calc(120rpx + env(safe-area-inset-bottom));
  156. .footer-content {
  157. width: 100vw;
  158. padding-bottom: calc(30upx + env(safe-area-inset-bottom)) !important;
  159. box-sizing: border-box;
  160. position: fixed;
  161. left: 0;
  162. bottom: 0;
  163. z-index: 999;
  164. }
  165. }
  166. }
  167. </style>