coupon-item.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view class="special-item-page">
  3. <scroll-view class="list-wrap" scroll-y>
  4. <view class="item" v-for="item in couponList" :key="item.couponId" @click="handItem(item)">
  5. <view class="cover">
  6. <image class="icon" :src="item.imgUrl"/>
  7. </view>
  8. <view class="cont">
  9. <view class="row">
  10. <view class="name">{{item.couponName}}</view>
  11. <view class="date">{{item.startDate|formatDate('MM.dd')}} ~ {{item.endDate|formatDate('MM.dd')}}</view>
  12. </view>
  13. <view class="row">
  14. <view class="desc">
  15. {{item.rmk || ''}}
  16. </view>
  17. <view v-if="item.status==1" class="status">进行中</view>
  18. <view v-else class="status-unused">停止</view>
  19. </view>
  20. </view>
  21. </view>
  22. </scroll-view>
  23. <view class="add-coupon-item">
  24. <view class="add" @click="addSpecialItem">添加优惠券</view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {mapState} from 'vuex';
  30. export default {
  31. data () {
  32. return {
  33. getStoreCouponListUrl: '/coupon/getStoreCouponList',
  34. couponList: []
  35. }
  36. },
  37. computed: {
  38. ...mapState(['storeInfo'])
  39. },
  40. methods: {
  41. handItem(item) {
  42. uni.navigateTo({
  43. url: '/pages/activity/coupon-item-info?id=' + item.couponId
  44. });
  45. },
  46. addSpecialItem () {
  47. uni.navigateTo({
  48. url: '/pages/activity/coupon-item-edit'
  49. });
  50. },
  51. getStoreCouponList() {
  52. uni.showLoading({
  53. title: '加载中'
  54. });
  55. var dateStr = (new Date()).getTime();
  56. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  57. this.requst({
  58. url: this.getStoreCouponListUrl,
  59. data: {
  60. timestamp: dateStr,
  61. sign: sign,
  62. storeId: this.storeInfo.storeId,
  63. couponType: 2,
  64. },
  65. success: res => {
  66. this.couponList = res.data.list;
  67. uni.hideLoading();
  68. },
  69. fail: (e) => {
  70. console.log("接口调用失败:" + JSON.stringify(e));
  71. uni.hideLoading();
  72. },
  73. })
  74. }
  75. },
  76. onShow () {
  77. this.getStoreCouponList();
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .special-item-page {
  83. width: 100vw;
  84. height: 100vh;
  85. background-color: #f5f5f5;
  86. overflow: hidden;
  87. }
  88. .list-wrap {
  89. height: calc(100vh - 140rpx - env(safe-area-inset-bottom));
  90. height: calc(100vh - 140rpx - constant(safe-area-inset-bottom));
  91. margin-top: 20rpx;
  92. .item {
  93. margin-bottom: 20rpx;
  94. background-color: #fff;
  95. padding: 40rpx;
  96. box-sizing: border-box;
  97. @include flexStart;
  98. }
  99. .cover {
  100. min-width: 60rpx;
  101. width: 60rpx;
  102. height: 60rpx;
  103. margin-right: 40rpx;
  104. border-radius: 50%;
  105. overflow: hidden;
  106. @include flexCenter;
  107. box-shadow: 0 0 10rpx pink;
  108. }
  109. .icon {
  110. width: 42rpx;
  111. height: 42rpx;
  112. }
  113. .cont {
  114. width: calc(100% - 100rpx);
  115. font-size: $font-base;
  116. }
  117. .row {
  118. width: 100%;
  119. @include between;
  120. margin-bottom: 10rpx;
  121. }
  122. .name {
  123. color: $text-color;
  124. width: calc(100% - 240rpx);
  125. overflow: hidden;
  126. text-overflow: ellipsis;
  127. white-space: nowrap;
  128. word-break: break-all;
  129. }
  130. .date {
  131. width: 240rpx;
  132. text-align: right;
  133. }
  134. .desc {
  135. color: $desc-color;
  136. }
  137. .status {
  138. width: 240rpx;
  139. text-align: right;
  140. color: $uni-color-button;
  141. }
  142. .status-unused {
  143. width: 240rpx;
  144. text-align: right;
  145. color: $theme-color;
  146. }
  147. }
  148. .add-coupon-item {
  149. width: 100vw;
  150. @include flexCenter;
  151. margin-top: 40rpx;
  152. .add {
  153. width: 80vw;
  154. height: 80rpx;
  155. border-radius: 40rpx;
  156. background-color: $theme-color;
  157. color: #fff;
  158. @include flexCenter;
  159. }
  160. }
  161. </style>