index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div>
  3. <div class="quan_list">
  4. <div class="quan_container shadow bg-white" v-for="(item,index) in couponData" :key="index">
  5. <van-row gutter="9">
  6. <van-col span="12" offset="1">
  7. <div class="padding-top-sm">
  8. <text class="title text-lg text-bold">{{ item.name }}</text>
  9. </div>
  10. <view class="padding-top-xs" v-if="item.type==2">
  11. <text class="text-sm">满{{ item.full }}可用</text>
  12. </view>
  13. <view :class="item.type==2?'padding-top-xs':'padding-top-xl'">
  14. <text class="text-xs">有效期:{{item.start_time}}~{{item.end_time}}</text>
  15. </view>
  16. </van-col>
  17. <van-col span="9" offset="1" >
  18. <div class="padding-top-sm text-lg padding-bottom-xl margin-bottom-xs">
  19. <view class="subtitle text-bold">可抵扣&nbsp;
  20. <text class="text-red">¥{{ item.reduce }}</text>
  21. </view>
  22. </div>
  23. </van-col>
  24. <div class="cartLeft"></div>
  25. <van-row gutter="9">
  26. <van-col span="12" offset="1">
  27. </van-col>
  28. <van-col span="9" offset="1" >
  29. <text class="text-sm text-grey rule">使用规则</text>
  30. </van-col>
  31. </van-row>
  32. </van-row>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { formatTimeAnother } from "../../../utils/index.js";
  39. export default {
  40. data() {
  41. return {
  42. couponData: {},
  43. deliver:{}
  44. };
  45. },
  46. onLoad(options) {
  47. let $params = JSON.parse(options.deliver);
  48. console.log("参数",$params)
  49. this.$fly.get("https://testapi.shuimuai.com/coupon/choose-coupon?price=" +$params.price+"&goods_id=" +$params.goods_id)
  50. .then((res)=>{
  51. console.log('优惠券',res.data.data)
  52. let $data = res.data.data
  53. this.couponData = $data
  54. this.couponData.forEach(($val, $index) => {
  55. $val['start_time'] = formatTimeAnother($val['start_time'])
  56. $val['end_time'] = formatTimeAnother($val['end_time'])
  57. if($val['type']==3){
  58. $val["reduce"] = Math.round(($params.price-$params.price*$val["discount"])*100)/100
  59. }else if($val['type']==2){
  60. $val["reduce"] = $val["reduce"]
  61. }else if($val['type']==4){
  62. $val["reduce"] = $val["random"]
  63. }
  64. })
  65. })
  66. .catch((err)=>{
  67. console.log(err)
  68. })
  69. },
  70. }
  71. </script>
  72. <style scoped>
  73. .quan_container {
  74. background-image: url("https://img.shuimuai.com/pic_payCoupon.png");
  75. background-position: center;
  76. background-size: 100% 100%;
  77. width: 340px;
  78. height: 115px;
  79. margin: 10px auto;
  80. }
  81. .cartLeft{
  82. width: 85%;
  83. margin: 10px auto;
  84. height: 82px;
  85. border-bottom: 1rpx dashed #a7a8a8;
  86. }
  87. .rule{
  88. text-decoration: underline;
  89. }
  90. </style>