couponList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view class="container">
  3. <view class="coupon-title">
  4. <view class="title-text">已发放的优惠卷</view>
  5. </view>
  6. <view class="coupon-row" v-for="(item, index) in couponList" :key="index">
  7. <view class="coupon-left">
  8. <view class="coupon-left-price"><text style="font-size: 16px;">¥</text>{{item.discountAmount}}</view>
  9. <view class="coupon-left-text">满减金额</view>
  10. </view>
  11. <view class="coupon-info">
  12. <view class="coupon-text1">{{item.couponName}}</view>
  13. <view class="coupon-text1" style="margin-bottom: 4px;">满{{item.fullAmount}}减{{item.discountAmount}}</view>
  14. <view class="coupon-text2">{{'仅限用于' + item.name + '的店铺'}}</view>
  15. <view class="coupon-text2" style="color: #999999;">有效期:{{item.publishStartTime}}~{{item.useEndTime}}</view>
  16. </view>
  17. </view>
  18. <u-divider :color="isOver ? '#909399' : '#51A539'" :border-color="isOver ? '#909399' : '#51A539'" @click="handleLoadMore()">
  19. <u-loading mode="circle" v-if="loadingData"></u-loading>{{loadingData ? '加载中' : (isOver ? '没有更多了' : '点击加载更多')}}
  20. </u-divider>
  21. <view class="form-handle">
  22. <u-button type="success" shape="circle" :ripple="true" @click="addCoupon" class="handle-custom">发放优惠卷</u-button>
  23. </view>
  24. <u-top-tips ref="uTips"></u-top-tips>
  25. </view>
  26. </template>
  27. <script>
  28. const NET = require('@/utils/request')
  29. const API = require('@/config/api')
  30. export default {
  31. data() {
  32. return {
  33. pageIndex: 1,
  34. isOver: false,
  35. loadingData: false,
  36. couponList: [],
  37. }
  38. },
  39. onShow() {
  40. this.pageIndex = 1
  41. this.isOver = false
  42. this.loadingData = false
  43. this.couponList = []
  44. this.getList()
  45. },
  46. methods: {
  47. // 新增优惠券
  48. addCoupon() {
  49. uni.navigateTo({
  50. url: '/pagesMain/couponForm'
  51. });
  52. },
  53. // 懒加载
  54. handleLoadMore() {
  55. if (!this.isOver) {
  56. this.pageIndex++
  57. this.getList()
  58. }
  59. },
  60. // 获取列表数据
  61. getList() {
  62. this.loadingData = true
  63. NET.request(API.getCouponList, {
  64. pageIndex: this.pageIndex,
  65. pageSize: 10,
  66. }, 'GET').then(res => {
  67. this.loadingData = false
  68. this.isOver = res.data.pageInfoResVo.list.length != 10
  69. this.couponList = this.couponList.concat(res.data.pageInfoResVo.list)
  70. }).catch(error => {
  71. this.loadingData = false
  72. this.$refs.uTips.show({
  73. title: error.data.msg,
  74. type: 'warning',
  75. })
  76. })
  77. },
  78. },
  79. }
  80. </script>
  81. <style lang="less" scoped>
  82. page {
  83. width: 100%;
  84. height: 100%;
  85. }
  86. .container {
  87. width: 100%;
  88. height: 100%;
  89. float: left;
  90. box-sizing: border-box;
  91. padding-top: 55px;
  92. padding-bottom: 60px;
  93. background-color: #f7f7f7;
  94. overflow-y: auto;
  95. position: relative;
  96. .coupon-title {
  97. width: 100%;
  98. height: 45px;
  99. float: left;
  100. position: absolute;
  101. top: 0;
  102. box-sizing: border-box;
  103. padding: 13px 15px;
  104. background-color: #FFFFFF;
  105. margin-bottom: 16px;
  106. .title-text {
  107. width: 100%;
  108. height: 100%;
  109. float: left;
  110. font-size: 15px;
  111. font-family: PingFang SC;
  112. color: #333333;
  113. line-height: 18px;
  114. box-sizing: border-box;
  115. padding-left: 6px;
  116. border-left: 2px solid #52A63A;
  117. }
  118. }
  119. .coupon-row {
  120. width: calc(100% - 32px);
  121. height: 105px;
  122. float: left;
  123. margin: 0 16px 10px 16px;
  124. border-radius: 10px;
  125. background: #FFFFFF;
  126. box-shadow: 0px 0px 10px 0px rgba(103, 103, 103, 0.3);
  127. overflow: hidden;
  128. .coupon-left {
  129. width: 107px;
  130. height: 105px;
  131. box-sizing: border-box;
  132. padding-right: 10px;
  133. float: left;
  134. background-size: 107px 105px;
  135. background-position: center;
  136. background-repeat: no-repeat;
  137. background-image: url(@/static/images/couponHead.png);
  138. .coupon-left-price {
  139. width: 100%;
  140. height: 24px;
  141. float: left;
  142. margin: 28px 0 12px 0;
  143. font-size: 24px;
  144. font-family: PingFang SC;
  145. color: #FFFFFF;
  146. line-height: 24px;
  147. text-align: center;
  148. }
  149. .coupon-left-text {
  150. width: 100%;
  151. height: 20px;
  152. float: left;
  153. color: #FFFFFF;
  154. font-size: 12px;
  155. font-family: PingFang SC;
  156. line-height: 20px;
  157. text-align: center;
  158. }
  159. }
  160. .coupon-info {
  161. width: calc(100% - 115px);
  162. height: 100%;
  163. float: right;
  164. box-sizing: border-box;
  165. padding: 12px 0 12px 0;
  166. .coupon-text1 {
  167. width: 100%;
  168. height: 22px;
  169. float: right;
  170. font-size: 15px;
  171. font-family: PingFang SC;
  172. color: #333333;
  173. line-height: 22px;
  174. white-space: nowrap;
  175. text-overflow: ellipsis;
  176. overflow: hidden;
  177. }
  178. .coupon-text2 {
  179. width: 100%;
  180. height: 18px;
  181. float: right;
  182. font-size: 13px;
  183. font-family: PingFang SC;
  184. color: #EB5F2F;
  185. line-height: 18px;
  186. white-space: nowrap;
  187. text-overflow: ellipsis;
  188. overflow: hidden;
  189. }
  190. }
  191. }
  192. /deep/.u-divider{
  193. background-color: transparent!important;
  194. }
  195. .form-handle {
  196. width: 100%;
  197. height: 60px;
  198. position: absolute;
  199. z-index: 10;
  200. padding: 10px 15px 20px 15px;
  201. box-sizing: border-box;
  202. bottom: 0;
  203. background-color: #FFFFFF;
  204. border-top: 1px solid #EEEEEE;
  205. .handle-custom {
  206. background-color: #51A539;
  207. }
  208. }
  209. }
  210. </style>