couponList.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="container">
  3. <!-- <view class="tab-h flex box-pack-between flex-y-center">
  4. <view :class="['item',active == 1?'active':'']" @click="onChangeTab(1)">
  5. <view class="title">全部</view>
  6. </view>
  7. <view :class="['item',active == 2?'active':'']" @click="onChangeTab(2)">
  8. <view class="title">新人券</view>
  9. </view>
  10. <view :class="['item', active == 3?'active':'']" @click="onChangeTab(3)">
  11. <view class="title">所有品类</view>
  12. </view>
  13. <view :class="['item', active == 4?'active':'']" @click="onChangeTab(4)">
  14. <view class="title">已过期</view>
  15. </view>
  16. </view> -->
  17. <view class="tab-b">
  18. <view class="item" v-for="(item,index) in list" :key="index" @click="toDetail(item.id)">
  19. <image src="../static/images/coupon_bg_1.png" class="coupon-bg" mode="aspectFit"></image>
  20. <view class="content flex flex-nowarp flex-y-center">
  21. <view class="left-bar flex flex-nowarp flex-col flex-x-center flex-y-center">
  22. <view class="money-block flex flex-nowarp flex-x-center flex-y-baseline">
  23. <view class="money text-1" :style="{'font-size':computeFontSize(Number(item.reduce))}">{{Number(item.reduce)}}</view>
  24. <view class="unit">元</view>
  25. </view>
  26. <view class="desc text-1">满{{Number(item.full)}}元可用</view>
  27. </view>
  28. <view class="right-bar">
  29. <view class="title-block flex flex-y-center">
  30. <view class="tips">{{item.type == 1?'满减券':'指定商品'}}</view>
  31. <view class="title text-1">{{item.name}}</view>
  32. </view>
  33. <view class="time">有效期:{{item.start_time}} - {{item.end_time}}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="footer-bar">
  39. <view class="content flex flex-center">
  40. <view class="btn" @click="toAdd">立即添加</view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. store_id:"",
  50. active: 1,
  51. list: [],
  52. page: 1,
  53. is_bottom: false
  54. }
  55. },
  56. onLoad(options) {
  57. this.store_id = uni.getStorageSync("store_id")
  58. this.getData(1)
  59. },
  60. onReachBottom() {
  61. if(!this.is_bottom){
  62. this.getData(this.page+1)
  63. }
  64. },
  65. methods: {
  66. computeFontSize(txt){
  67. txt = txt+''
  68. if(txt.length>5){
  69. return '42rpx'
  70. }else{
  71. return ''
  72. }
  73. },
  74. onChangeTab(index) {
  75. if (index != this.active) {
  76. this.active = index
  77. }
  78. },
  79. getData(page) {
  80. if (page == 1) {
  81. this.list = []
  82. this.page = 1
  83. this.is_bottom = false
  84. }
  85. this.request({
  86. url: 'Smdcshop/coupon_index',
  87. data: {
  88. page,
  89. limit: 10,
  90. store_id: this.store_id
  91. }
  92. }).then(res => {
  93. if (res.code == 200 && res.data.length) {
  94. this.list = this.list.concat(res.data)
  95. this.page = page
  96. } else {
  97. this.is_bottom = true
  98. }
  99. })
  100. },
  101. toDetail(id){
  102. uni.navigateTo({
  103. url:`/saomaDiancan/couponDetail/couponDetail?id=${id}`
  104. })
  105. },
  106. toAdd(){
  107. uni.navigateTo({
  108. url:`/saomaDiancan/editCoupon/editCoupon?store_id=${this.store_id}`
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style>
  115. @import url("../static/css/common.css");
  116. page {
  117. background-color: #F4F5F7;
  118. }
  119. .content{
  120. position: relative;
  121. }
  122. .tab-h {
  123. background-color: #fff;
  124. position: sticky;
  125. top: 0;
  126. z-index: 100
  127. }
  128. .tab-h .item {
  129. padding: 0 30rpx;
  130. height: 88rpx;
  131. position: relative;
  132. }
  133. .tab-h .item .title {
  134. font-size: 28rpx;
  135. line-height: 88rpx;
  136. font-weight: 500;
  137. }
  138. .tab-h .item.active::after {
  139. content: "";
  140. display: block;
  141. height: 4rpx;
  142. width: 40rpx;
  143. border-radius: 2rpx;
  144. background-color: #247EFF;
  145. position: absolute;
  146. bottom: 5rpx;
  147. left: 50%;
  148. transform: translateX(-50%)
  149. }
  150. .tab-h .item.active .title {
  151. font-size: 32rpx;
  152. font-weight: 600;
  153. color: #247EFF;
  154. }
  155. .tab-b {
  156. padding: 30rpx 25rpx 0;
  157. }
  158. .tab-b .item {
  159. margin-bottom: 30rpx;
  160. width: 700rpx;
  161. height: 180rpx;
  162. position: relative;
  163. }
  164. .tab-b .item .coupon-bg {
  165. display: block;
  166. width: 100%;
  167. height: 100%;
  168. position: absolute;
  169. left: 0;
  170. top: 0;
  171. z-index: 0;
  172. }
  173. .tab-b .item .content {
  174. position: relative;
  175. z-index: 10;
  176. }
  177. .tab-b .item .content .left-bar {
  178. flex: none;
  179. width: 200rpx;
  180. height: 180rpx;
  181. text-align: center;
  182. }
  183. .tab-b .item .content .left-bar .money {
  184. font-size: 58rpx;
  185. line-height: 70rpx;
  186. color: #fff;
  187. font-weight: bold;
  188. }
  189. .tab-b .item .content .left-bar .unit {
  190. font-size: 24rpx;
  191. color: #fff;
  192. font-weight: 500;
  193. margin-left: 6rpx;
  194. }
  195. .tab-b .item .content .left-bar .desc {
  196. font-size: 24rpx;
  197. line-height: 33rpx;
  198. margin-top: 16rpx;
  199. color: #fff;
  200. }
  201. .tab-b .item .content .right-bar {
  202. width: 500rpx;
  203. flex: none;
  204. box-sizing: border-box;
  205. height: 180rpx;
  206. padding: 0 25rpx;
  207. }
  208. .tab-b .item .content .right-bar .title-block {
  209. height: 106rpx;
  210. border-bottom: 1rpx dashed #E5E5E5;
  211. }
  212. .tab-b .item .content .right-bar .title-block .tips{
  213. flex:none;
  214. height: 40rpx;
  215. background: linear-gradient(316deg,#ffae2c 1%, #ffbc00 99%);
  216. border-radius: 4rpx;
  217. font-size: 20rpx;
  218. color: #fff;
  219. padding:0 10rpx;
  220. line-height: 40rpx;
  221. margin-right: 16rpx;
  222. }
  223. .tab-b .item .content .right-bar .title-block .title{
  224. font-size: 28rpx;
  225. color: #333;
  226. font-weight: bold;
  227. }
  228. .tab-b .item .content .right-bar .time{
  229. font-size: 24rpx;
  230. color: #999;
  231. height: 73rpx;
  232. line-height: 73rpx;
  233. }
  234. </style>