index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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(addressValue).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. {{addressValue.province}}{{addressValue.city}}{{addressValue.area}}
  10. </view>
  11. <view class="margin-bottom-sm text-bold text-black text-lg">{{addressValue.address}}</view>
  12. <view class=" text-black text-lg">{{addressValue.name}} {{addressValue.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. <view class="cu-form-group align-start">
  40. <view class="title">买家留言</view>
  41. <textarea placeholder-style="z-index:1;" :value="notes" @input="e=>notes=e.detail.value" maxlength="100" placeholder="请输入买家留言(可选)" cols="30" rows="10"></textarea>
  42. </view>
  43. <!-- footer -->
  44. <view class="footer">
  45. <view class="footer-content flex padding justify-between align-center bg-white">
  46. <view class="flex align-end">
  47. <view class="margin-right-xs text-black">实付款</view>
  48. <view style="transform: translateY(10upx);" class="text-price text-red"><cu-price :value="price" size="52" /></view>
  49. <view class="margin-left">
  50. {{point_price}}积分
  51. </view>
  52. </view>
  53. <button @click="handler" :disabled="!status" class="bg-red cu-btn round "> 提交订单</button>
  54. </view>
  55. </view>
  56. <!-- 工具 -->
  57. <cu-modalC :show.sync="show" custom="2">
  58. <view class="padding text-center text-lg text-black text-bold border">
  59. 商品清单
  60. <text class="text-sm" style="color:#999">(共{{list.length}}件)</text>
  61. </view>
  62. <cu-scrollView height="50vh">
  63. <view v-for="(item,index) in list" class="flex padding">
  64. <image
  65. class="radius margin-right-sm"
  66. style="width: 160upx;height: 160upx;min-width: 160upx;"
  67. lazy-load="true"
  68. :src="item.img | lazyImage"
  69. mode="aspectFit"
  70. ></image>
  71. <view style="flex:auto;position: relative;" class="content margin-right-sm">
  72. <view class="text-black">{{item.name}}</view>
  73. <view class="flex align-center">
  74. <view v-if="item.type==1" class="text-red">
  75. <cu-price :value="item.price" size="32" />
  76. </view>
  77. <view v-else>
  78. {{item.point_price}}积分
  79. </view>
  80. <view v-if="item.vip_price" class="bg-orange light text-xs padding-lr-xs">
  81. <text class="cuIcon-vip lg">会员价</text>
  82. <text class="text-price margin-left-xs">{{ item.vip_price }}</text>
  83. </view>
  84. </view>
  85. <view style="position: absolute;bottom: 0;right: 0;">
  86. x{{item.count}}
  87. </view>
  88. </view>
  89. </view>
  90. </cu-scrollView>
  91. </cu-modalC>
  92. </view>
  93. </template>
  94. <script>
  95. import { mapState, mapActions } from 'vuex';
  96. import {requestPayment} from "@/common/device/index.js";
  97. import api from "./api.js";
  98. export default {
  99. data() {
  100. return {
  101. show: false,
  102. list:[],//商品列表
  103. price:0,
  104. notes:"",
  105. point_price:0,
  106. status:true,
  107. };
  108. },
  109. computed: {
  110. ...mapState(['openid','appId']),
  111. ...mapState('addressDefault', ['addressValue']),
  112. },
  113. onLoad(options) {
  114. let {list}=options;
  115. this.list=JSON.parse(list);
  116. let price=0,point_price=0;
  117. this.list.forEach(item=>(item.type==1 ? price+=item.price*1 : point_price+=item.point_price*1));
  118. this.price=price;
  119. this.point_price=point_price;
  120. },
  121. async onShow(){
  122. await this.requestFunc();
  123. },
  124. methods:{
  125. ...mapActions('addressDefault', ['requestFunc']),
  126. addressListFunc(){
  127. uni.navigateTo({
  128. url:"/loginPages/addressList/index"
  129. })
  130. },
  131. async handler(){
  132. try{
  133. this.status=false;
  134. let list=this.list.map(item=>({id:item.id,count:item.count}));
  135. var result =await api.submit({details:JSON.stringify(list),notes:this.notes,openid:this.openid,appid:this.appId,address_id:this.addressValue.id});
  136. console.log(result)
  137. // result=await requestPayment();
  138. }catch(err){
  139. uni.showToast({
  140. title:"支付失败",
  141. icon:"error"
  142. })
  143. }finally{
  144. this.status=true;
  145. }
  146. }
  147. }
  148. };
  149. </script>
  150. <style lang="scss" scoped>
  151. .pay {
  152. .border {
  153. position: relative;
  154. &::after {
  155. content: '';
  156. border-top: 1upx solid #ccc;
  157. position: absolute;
  158. left: 0;
  159. bottom: 0;
  160. transform: scale(1, 0.5);
  161. width: 100%;
  162. }
  163. }
  164. .footer {
  165. height: calc(120rpx + env(safe-area-inset-bottom));
  166. .footer-content {
  167. width: 100vw;
  168. padding-bottom: calc(30upx + env(safe-area-inset-bottom)) !important;
  169. box-sizing: border-box;
  170. position: fixed;
  171. left: 0;
  172. bottom: 0;
  173. z-index: 999;
  174. }
  175. }
  176. }
  177. </style>