yhq.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view>
  3. <view class="list flex justify-center flex-wrap">
  4. <view class="list-box flex justify-center flex-wrap" v-for="(item,index) in couponList" :key="index">
  5. <view class="yhq-box-list-item" >
  6. <view class="yhq-box-list-item-t flex align-center justify-between" style="border-bottom: 1px dashed #e5e5e5;padding-bottom: 26rpx;">
  7. <view class="yhq-box-list-item-t-l flex align-center">
  8. <image :src="item.couponPicture?item.couponPicture:'../../static/logo.png'" style="width: 120rpx;height: 120rpx;border-radius: 16rpx;" mode=""></image>
  9. <view class="" style="margin-left: 20rpx;">
  10. <view class="" style="font-weight: bold;">
  11. <text>{{item.couponName}}</text>(满{{item.minMoney}}元使用)
  12. </view>
  13. <view class="" style="color: gray;font-size: 24rpx;margin-top: 10rpx;">
  14. 购买后{{item.endDate}}天内使用
  15. </view>
  16. </view>
  17. </view>
  18. <view class="yhq-box-list-item-t-r" style="font-size: 32rpx;color: red;">
  19. <text style="font-size: 24rpx;font-weight: bold;">¥</text>
  20. {{item.money}}
  21. </view>
  22. </view>
  23. <view class="yhq-box-list-item-b flex justify-end align-center" style="margin-top: 26rpx;">
  24. <view class="" @click="updata(1,item)" style="padding: 5rpx 20rpx 5rpx 20rpx;border-radius: 24rpx;border: 1rpx solid gray;color: gray;">
  25. 编辑
  26. </view>
  27. <view class="" @click="updata(2,item)" style="padding: 5rpx 20rpx 5rpx 20rpx;border-radius: 24rpx;border: 1rpx solid red;color: red;margin-left: 20rpx;">
  28. 删除
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
  34. </view>
  35. <!-- 添加优惠券 -->
  36. <view class="button flex justify-center align-center">
  37. <view class="button-box flex justify-center align-center" @click="gotoAdd()">
  38. 添加优惠券
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. couponList: [],
  48. couponLists: [],
  49. limit: 10,
  50. page: 1,
  51. status: 'loadmore',
  52. iconType: 'flower',
  53. loadText: {
  54. loadmore: '轻轻上拉',
  55. loading: '努力加载中',
  56. nomore: '实在没有了'
  57. },
  58. };
  59. },
  60. onPullDownRefresh() {
  61. this.page = 1
  62. this.getList()
  63. },
  64. onReachBottom() {
  65. if(this.couponLists.length==10){
  66. this.page += 1
  67. this.status = 'loading'
  68. this.getList()
  69. }else{
  70. this.status = 'nomore'
  71. }
  72. },
  73. onShow() {
  74. this.page = 1
  75. this.getList()
  76. },
  77. onLoad() {
  78. this.getList()
  79. },
  80. methods: {
  81. //1:编辑 2:删除
  82. updata(type,item){
  83. if(type==1){
  84. uni.navigateTo({
  85. url:'./edit?info='+JSON.stringify(item)
  86. })
  87. }else{
  88. let that = this
  89. uni.showModal({
  90. title:'提示',
  91. content:'是否删除该优惠券?',
  92. complete(ret) {
  93. if(ret.confirm){
  94. let data = {
  95. couponId:item.couponId
  96. }
  97. that.$Request.postT("/admin/coupon/deleteCoupon", data).then(res => {
  98. if (res.code == 0) {
  99. uni.showToast({
  100. title:'已删除'
  101. })
  102. that.page = 1
  103. that.getList()
  104. }else{
  105. uni.showToast({
  106. title:res.msg,
  107. icon:'none'
  108. })
  109. }
  110. });
  111. }
  112. }
  113. })
  114. }
  115. },
  116. //添加优惠券
  117. gotoAdd(){
  118. uni.navigateTo({
  119. url:'./add'
  120. })
  121. },
  122. //优惠券列表
  123. getList() {
  124. let data = {
  125. shopId: uni.getStorageSync('shopId')
  126. }
  127. this.$Request.get("/admin/coupon/seleteAllCoupon", data).then(res => {
  128. if (res.code == 0) {
  129. this.couponLists = res.data
  130. if (this.page == 1) {
  131. this.couponList = res.data
  132. } else {
  133. this.couponList = [...this.couponList, ...res.data]
  134. }
  135. }
  136. uni.stopPullDownRefresh()
  137. });
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss">
  143. .list {
  144. width: 100%;
  145. // height: 500rpx;
  146. margin-top: 20rpx;
  147. padding-bottom: 200rpx;
  148. .list-box {
  149. width: 686rpx;
  150. height: 100%;
  151. border-radius: 16rpx;
  152. background-color: #ffffff;
  153. margin-bottom: 20rpx;
  154. .yhq-box-list-item {
  155. width: 646rpx;
  156. // background-color: red;
  157. padding: 20rpx 0 20rpx 0;
  158. }
  159. }
  160. }
  161. .button {
  162. width: 100%;
  163. height: 140rpx;
  164. background-color: rgb(241, 241, 241);
  165. position: fixed;
  166. bottom: 0;
  167. z-index: 999;
  168. .button-box {
  169. width: 686rpx;
  170. height: 80rpx;
  171. background-color: #FCD202;
  172. border-radius: 40rpx;
  173. }
  174. }
  175. </style>