yhq.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.showModal({
  106. title: '提示',
  107. content: res.msg,
  108. success: function (res) {
  109. if (res.confirm) {
  110. } else if (res.cancel) {
  111. }
  112. }
  113. });
  114. }
  115. });
  116. }
  117. }
  118. })
  119. }
  120. },
  121. //添加优惠券
  122. gotoAdd(){
  123. uni.navigateTo({
  124. url:'./add'
  125. })
  126. },
  127. //优惠券列表
  128. getList() {
  129. let data = {
  130. shopId: uni.getStorageSync('shopId')
  131. }
  132. this.$Request.get("/admin/coupon/seleteAllCoupon", data).then(res => {
  133. if (res.code == 0) {
  134. this.couponLists = res.data
  135. if (this.page == 1) {
  136. this.couponList = res.data
  137. } else {
  138. this.couponList = [...this.couponList, ...res.data]
  139. }
  140. }
  141. uni.stopPullDownRefresh()
  142. });
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss">
  148. .list {
  149. width: 100%;
  150. // height: 500rpx;
  151. margin-top: 20rpx;
  152. padding-bottom: 200rpx;
  153. .list-box {
  154. width: 686rpx;
  155. height: 100%;
  156. border-radius: 16rpx;
  157. background-color: #ffffff;
  158. margin-bottom: 20rpx;
  159. .yhq-box-list-item {
  160. width: 646rpx;
  161. // background-color: red;
  162. padding: 20rpx 0 20rpx 0;
  163. }
  164. }
  165. }
  166. .button {
  167. width: 100%;
  168. height: 140rpx;
  169. background-color: rgb(241, 241, 241);
  170. position: fixed;
  171. bottom: 0;
  172. z-index: 999;
  173. .button-box {
  174. width: 686rpx;
  175. height: 80rpx;
  176. background-color: #FCD202;
  177. border-radius: 40rpx;
  178. }
  179. }
  180. </style>