couponList.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.useEndTime.split(" ")[0]}}之前使用</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. onPullDownRefresh() {
  47. this.pageIndex = 1
  48. this.isOver = false
  49. this.loadingData = false
  50. this.couponList = []
  51. this.getList('refresh')
  52. },
  53. methods: {
  54. // 新增优惠券
  55. addCoupon() {
  56. uni.navigateTo({
  57. url: '/pagesMain/couponForm'
  58. });
  59. },
  60. // 懒加载
  61. handleLoadMore() {
  62. if (!this.isOver) {
  63. this.pageIndex++
  64. this.getList()
  65. }
  66. },
  67. // 获取列表数据
  68. getList(type) {
  69. this.loadingData = true
  70. NET.request(API.getCouponList, {
  71. pageIndex: this.pageIndex,
  72. pageSize: 10,
  73. }, 'GET').then(res => {
  74. if (type == 'refresh') {
  75. uni.stopPullDownRefresh();
  76. }
  77. this.loadingData = false
  78. this.isOver = res.data.pageInfoResVo.list.length != 10
  79. this.couponList = this.couponList.concat(res.data.pageInfoResVo.list)
  80. }).catch(error => {
  81. this.loadingData = false
  82. this.$refs.uTips.show({
  83. title: error.data.msg,
  84. type: 'warning',
  85. })
  86. })
  87. },
  88. },
  89. }
  90. </script>
  91. <style lang="less" scoped>
  92. page {
  93. width: 100%;
  94. height: 100%;
  95. }
  96. .container {
  97. width: 100%;
  98. height: 100%;
  99. float: left;
  100. box-sizing: border-box;
  101. padding-top: 55px;
  102. padding-bottom: 60px;
  103. background-color: #f7f7f7;
  104. overflow-y: auto;
  105. position: relative;
  106. .coupon-title {
  107. width: 100%;
  108. height: 45px;
  109. float: left;
  110. position: absolute;
  111. top: 0;
  112. box-sizing: border-box;
  113. padding: 13px 15px;
  114. background-color: #FFFFFF;
  115. margin-bottom: 16px;
  116. .title-text {
  117. width: 100%;
  118. height: 100%;
  119. float: left;
  120. font-size: 15px;
  121. font-family: PingFang SC;
  122. color: #333333;
  123. line-height: 18px;
  124. box-sizing: border-box;
  125. padding-left: 6px;
  126. border-left: 2px solid #52A63A;
  127. }
  128. }
  129. .coupon-row {
  130. width: calc(100% - 32px);
  131. height: 105px;
  132. float: left;
  133. margin: 0 16px 10px 16px;
  134. border-radius: 10px;
  135. background: #FFFFFF;
  136. box-shadow: 0px 0px 10px 0px rgba(103, 103, 103, 0.3);
  137. overflow: hidden;
  138. .coupon-left {
  139. width: 107px;
  140. height: 105px;
  141. box-sizing: border-box;
  142. padding-right: 10px;
  143. float: left;
  144. background-size: 107px 105px;
  145. background-position: center;
  146. background-repeat: no-repeat;
  147. background-image: url(@/static/images/couponHead.png);
  148. .coupon-left-price {
  149. width: 100%;
  150. height: 24px;
  151. float: left;
  152. margin: 28px 0 12px 0;
  153. font-size: 24px;
  154. font-family: PingFang SC;
  155. color: #FFFFFF;
  156. line-height: 24px;
  157. text-align: center;
  158. }
  159. .coupon-left-text {
  160. width: 100%;
  161. height: 20px;
  162. float: left;
  163. color: #FFFFFF;
  164. font-size: 12px;
  165. font-family: PingFang SC;
  166. line-height: 20px;
  167. text-align: center;
  168. }
  169. }
  170. .coupon-info {
  171. width: calc(100% - 115px);
  172. height: 100%;
  173. float: right;
  174. box-sizing: border-box;
  175. padding: 12px 0 12px 0;
  176. .coupon-text1 {
  177. width: 100%;
  178. height: 22px;
  179. float: right;
  180. font-size: 15px;
  181. font-family: PingFang SC;
  182. color: #333333;
  183. line-height: 22px;
  184. white-space: nowrap;
  185. text-overflow: ellipsis;
  186. overflow: hidden;
  187. }
  188. .coupon-text2 {
  189. width: 100%;
  190. height: 18px;
  191. float: right;
  192. font-size: 13px;
  193. font-family: PingFang SC;
  194. color: #EB5F2F;
  195. line-height: 18px;
  196. white-space: nowrap;
  197. text-overflow: ellipsis;
  198. overflow: hidden;
  199. }
  200. }
  201. }
  202. /deep/.u-divider {
  203. background-color: transparent !important;
  204. }
  205. .form-handle {
  206. width: 100%;
  207. height: 60px;
  208. position: fixed;
  209. z-index: 10;
  210. padding: 10px 15px 20px 15px;
  211. box-sizing: border-box;
  212. bottom: 0;
  213. background-color: #FFFFFF;
  214. border-top: 1px solid #EEEEEE;
  215. .handle-custom {
  216. background-color: #51A539;
  217. /deep/button {
  218. background-color: #56a83a;
  219. }
  220. /deep/.u-btn--success--disabled {
  221. background-color: #74bd60 !important;
  222. }
  223. }
  224. }
  225. }
  226. </style>