index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <base-drawer mode="bottom" :visible="visible" background-color="transparent" mask maskClosable @close="closeDrawer">
  3. <view class="coupon rd-t-40rpx">
  4. <view class="title">优惠券
  5. <view class="close acea-row row-center-wrapper" @tap="closeDrawer">
  6. <text class="iconfont icon-iconfontguanbi"></text>
  7. </view>
  8. </view>
  9. <view class="search acea-row row-middle" v-if="num !=2">
  10. <text class="iconfont icon-ic_search"></text>
  11. <input class="inputs" placeholder='请输入优惠券名称' placeholder-class='placeholder' confirm-type='search' name="search"
  12. v-model="keyword" @confirm="searchSubmit"></input>
  13. </view>
  14. <view class="list" v-if="couponList.length">
  15. <scroll-view scroll-y="true" style="max-height: 800rpx;min-height: 500rpx;">
  16. <view class="item acea-row row-middle" v-for="(item,index) in couponList" :key="index">
  17. <view class="bg">
  18. <view class="price">¥<text class="num">{{item.coupon_price}}</text></view>
  19. <view class="reduction">满{{item.use_min_price}}可用</view>
  20. </view>
  21. <view class="text">
  22. <view class="name line1">{{item.coupon_title}}</view>
  23. <view class="type" v-if="item.type === 0">通用优惠券</view>
  24. <view class="type" v-if="item.type === 1">品类优惠券</view>
  25. <view class="type" v-if="item.type === 2">商品优惠券</view>
  26. <view class="time" v-if="item.coupon_time">有效期:{{item.coupon_time}}天</view>
  27. <view class="time" v-else>有效期:{{ item.start_use_time | dateFormat }}{{ item.start_use_time ? '-' : '' }}{{ item.end_use_time | dateFormat }}</view>
  28. </view>
  29. <view v-if="num !=2" class="bnt acea-row row-center-wrapper" @click="send(item)">发送</view>
  30. </view>
  31. <view class="tips">没有更多了~</view>
  32. </scroll-view>
  33. </view>
  34. <view class="empty-box" v-else>
  35. <emptyPage title="暂无优惠券~" src="/statics/images/noCoupon.png"></emptyPage>
  36. </view>
  37. </view>
  38. </base-drawer>
  39. </template>
  40. <script>
  41. import emptyPage from '@/components/emptyPage.vue';
  42. import {
  43. getUserCoupon,
  44. postUserUpdateOther
  45. } from "@/api/admin";
  46. export default {
  47. components: {
  48. emptyPage
  49. },
  50. filters: {
  51. dateFormat(time) {
  52. if (!time) return '';
  53. let date = new Date(time * 1000);
  54. let y = date.getFullYear();
  55. let m = date.getMonth() + 1;
  56. m = m < 10 ? ('0' + m) : m;
  57. let d = date.getDate();
  58. d = d < 10 ? ('0' + d) : d;
  59. return y + '/' + m + '/' + d;
  60. }
  61. },
  62. props:{
  63. visible: {
  64. type: Boolean,
  65. default: false,
  66. },
  67. uid: {
  68. type: Number,
  69. default: 0
  70. }
  71. },
  72. data(){
  73. return{
  74. keyword:'',
  75. couponList:[],
  76. num:0, //1用户批量,0单独用户,前两个是发送优惠券;点击获取优惠券时: 2是查看当前用户优惠券,否则获取优惠券
  77. ids:[]
  78. }
  79. },
  80. mounted: function() {},
  81. methods:{
  82. send(item){
  83. postUserUpdateOther(this.num ? this.ids:this.uid,{
  84. type:4,
  85. coupon_id:item.id
  86. }).then(res=>{
  87. this.$util.Tips({
  88. title: res.msg
  89. });
  90. this.$emit('closeDrawer',1);
  91. }).catch(err=>{
  92. this.$util.Tips({
  93. title: err
  94. });
  95. })
  96. },
  97. searchSubmit(){
  98. this.userCoupon();
  99. },
  100. userCoupon(num,ids){
  101. this.num = num;
  102. this.ids = ids;
  103. getUserCoupon({
  104. coupon_title:this.keyword,
  105. uid:this.num==2?this.uid:0
  106. }).then(res=>{
  107. this.couponList = res.data
  108. }).catch(err=>{
  109. this.$util.Tips({
  110. title: err
  111. });
  112. })
  113. },
  114. closeDrawer() {
  115. this.keyword = '';
  116. this.$emit('closeDrawer');
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .empty-box{
  123. padding: 0 20rpx;
  124. margin-bottom: 20rpx;
  125. }
  126. .coupon{
  127. background-color:#F5F5F5;
  128. padding-bottom: 1rpx;
  129. .title{
  130. text-align: center;
  131. height: 108rpx;
  132. line-height: 108rpx;
  133. font-size: 32rpx;
  134. font-family: PingFang SC, PingFang SC;
  135. font-weight: 600;
  136. color: #333333;
  137. position: relative;
  138. padding: 0 30rpx;
  139. .close{
  140. width: 36rpx;
  141. height: 36rpx;
  142. line-height: 36rpx;
  143. background: #EEEEEE;
  144. border-radius: 50%;
  145. position: absolute;
  146. right: 30rpx;
  147. top:38rpx;
  148. .iconfont {
  149. font-weight: 300;
  150. font-size: 20rpx;
  151. }
  152. }
  153. }
  154. .search{
  155. width: 710rpx;
  156. height: 72rpx;
  157. background: #FFFFFF;
  158. border-radius: 50rpx;
  159. padding: 0 34rpx;
  160. margin: 24rpx auto;
  161. &.on{
  162. width: 618rpx;
  163. }
  164. .iconfont{
  165. color: #999;
  166. font-size: 32rpx;
  167. margin-right: 16rpx;
  168. }
  169. .inputs{
  170. font-size: 28rpx;
  171. width: 100%;
  172. height: 100%;
  173. flex: 1;
  174. }
  175. .placeholder{
  176. color: #ccc;
  177. }
  178. }
  179. .list{
  180. padding: 0 20rpx;
  181. .item{
  182. background-color: #fff;
  183. border-radius: 30rpx;
  184. margin-bottom: 20rpx;
  185. .bg{
  186. background-image: url('../../../static/coupon.png');
  187. background-repeat: no-repeat;
  188. background-size: 100% 100%;
  189. width: 188rpx;
  190. height: 170rpx;
  191. font-size: 22rpx;
  192. font-family: PingFang SC, PingFang SC;
  193. font-weight: 400;
  194. color: #FFFFFF;
  195. text-align: center;
  196. padding: 32rpx 0;
  197. .price{
  198. font-size: 28rpx;
  199. font-weight: 600;
  200. .num{
  201. font-size: 52rpx;
  202. font-family:'Regular';
  203. }
  204. }
  205. .reduction{
  206. margin-top: 14rpx;
  207. color: rgba(255, 255, 255, 0.7);
  208. }
  209. }
  210. .text{
  211. margin-left: 20rpx;
  212. font-family: PingFang SC, PingFang SC;
  213. .name{
  214. font-size: 28rpx;
  215. font-weight: 600;
  216. color: #333333;
  217. width: 336rpx;
  218. }
  219. .type{
  220. font-size: 20rpx;
  221. font-weight: 400;
  222. color: #666666;
  223. margin-top: 8rpx;
  224. }
  225. .time{
  226. font-size: 20rpx;
  227. font-weight: 400;
  228. color: #999999;
  229. margin-top: 20rpx;
  230. }
  231. }
  232. .bnt{
  233. width: 112rpx;
  234. height: 52rpx;
  235. background: #E9F2FE;
  236. border-radius: 26rpx;
  237. font-size: 22rpx;
  238. font-family: PingFang SC, PingFang SC;
  239. font-weight: 500;
  240. color: #2A7EFB;
  241. margin-left: 34rpx;
  242. }
  243. }
  244. .tips{
  245. font-size: 26rpx;
  246. font-family: PingFang SC, PingFang SC;
  247. font-weight: 400;
  248. color: #CCCCCC;
  249. text-align: center;
  250. margin: 32rpx 0;
  251. margin-bottom: calc(32rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  252. margin-bottom: calc(32rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  253. }
  254. }
  255. }
  256. </style>