index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view>
  3. <!-- <view class="coupon_status_list">
  4. <view class="coupon_status_item" :class="requestParam.status==0?'active':''" @click="setStatus(0)"> 全部 </view>
  5. <view class="coupon_status_item" :class="requestParam.status==1?'active':''" @click="setStatus(1)"> 待发货 </view>
  6. <view class="coupon_status_item" :class="requestParam.status==2?'active':''" @click="setStatus(2)"> 已发货 </view>
  7. </view> -->
  8. <view class="to_bottom" v-if="!couponList.length"> -----还没有优惠券啦-----</view>
  9. <view class="coupon_list">
  10. <view class="coupon_item" v-for="(item,index) in couponList" :key="index">
  11. <view class="box_left">
  12. <view class="rebate" v-if="item.rebate_type == 1" > ¥{{item.rebate}}</view>
  13. <view class="rebate" v-if="item.rebate_type == 2" > 打 {{item.rebate}} 折</view>
  14. <view class="rebate" v-if="item.rebate_type == 3" > 赠 <text v-if="item.rebate_scope.length">
  15. {{item.rebate_scope[0].product_name}}
  16. </text> </view>
  17. <view class="std_pay"> 满{{item.std_pay}}</view>
  18. </view>
  19. <view class="box_right">
  20. <view class="coupon_title">
  21. <view class="coupon_name" v-if="item.rebate_type == 1">满减券</view>
  22. <view class="coupon_name" v-if="item.rebate_type == 2">折扣券</view>
  23. <view class="coupon_name" v-if="item.rebate_type == 3">赠品券</view>
  24. <view class="coupon_status" v-if="item.status == 0">未使用</view>
  25. <view class="coupon_status" v-if="item.status == 1">已使用</view>
  26. <view class="coupon_status" v-if="item.status == 2">已暂停</view>
  27. <view class="coupon_status" v-if="item.status == 3">已过期</view>
  28. <view class="coupon_status" v-if="item.status == 4">已作废</view>
  29. </view>
  30. <view class="product_scope">
  31. <text class="" v-if="item.type_id == 1">限定商品可用</text>
  32. <text class="" v-if="item.type_id == 2">全场可用</text>
  33. </view>
  34. <view class="coupon_info">
  35. <view class="coupon_exp">{{item.exp_time}} 到期</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="to_bottom" v-if="isLast"> -----到底啦-----</view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. // 产品列表
  48. couponList:[],
  49. // 请求参数
  50. requestParam:{
  51. page:1,
  52. status:0,
  53. },
  54. // 是否最后一页
  55. isLast:false,
  56. // 是否请求中
  57. isReqing:false,
  58. };
  59. },
  60. onLoad() {
  61. // 登录提示
  62. if( !this.$checkAccess.alterLogin() ) return ;
  63. // 初始化页码为1
  64. this.requestParam.page = 1;
  65. // 是否是最后一页
  66. this.isLast = false;
  67. // 设置请求中
  68. this.isReqing = true;
  69. // 请求列表
  70. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  71. // 设置非请求中
  72. this.isReqing = false;
  73. // 成功结果
  74. if( re.code == 'success' ){
  75. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  76. this.couponList = re.data.data;
  77. }
  78. });
  79. },
  80. onShow() {
  81. // 登录提示
  82. if( !this.$checkAccess.alterLogin() ) return ;
  83. // 没有数据的话,或者请求中,不允许刷新
  84. if( this.couponList.length > 0 || this.isReqing ) return ;
  85. // 设置请求中
  86. this.isReqing = true;
  87. // 请求列表
  88. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  89. // 设置非请求中
  90. this.isReqing = false;
  91. // 成功结果
  92. if( re.code == 'success' ){
  93. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  94. this.couponList = re.data.data;
  95. }
  96. });
  97. },
  98. onPullDownRefresh() {
  99. // 登录提示
  100. if( !this.$checkAccess.alterLogin() ) return ;
  101. // 如果请求中,不允许请求,
  102. if( this.isReqing ) return false;
  103. // 初始化页码为1
  104. this.requestParam.page = 1;
  105. // 是否是最后一页
  106. this.isLast = false;
  107. // 设置请求中
  108. this.isReqing = true;
  109. // 请求列表
  110. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  111. // 设置非请求中
  112. this.isReqing = false;
  113. // 成功结果
  114. if( re.code == 'success' ){
  115. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  116. this.couponList = re.data.data;
  117. }
  118. });
  119. uni.stopPullDownRefresh();
  120. },
  121. onReachBottom() {
  122. // 登录提示
  123. if( !this.$checkAccess.alterLogin() ) return ;
  124. // 如果页码是0,避免第一页重复
  125. if( this.requestParam.page < 1 ) return;
  126. // 最后一页不请求
  127. if( this.isLast ) return;
  128. // 设置请求中
  129. this.isReqing = true;
  130. // 增加一页
  131. this.requestParam.page = this.requestParam.page+1;
  132. // 请求列表
  133. this.$http.request('api/custom_coupon/get_list',this.requestParam).then((re)=>{
  134. // 设置非请求中
  135. this.isReqing = false;
  136. // 成功结果
  137. if( re.code == 'success' ){
  138. if(re.data.last_page <= this.requestParam.page ) this.isLast = true;
  139. // 追加数据
  140. this.couponList.push(...re.data.data);
  141. }
  142. });
  143. },
  144. methods:{
  145. }
  146. }
  147. </script>
  148. <style lang="less">
  149. .coupon_status_list{
  150. display: block;
  151. height: 60rpx;
  152. color: #666666;
  153. line-height: 60rpx;
  154. background: #FFFFFF;
  155. padding: 10rpx 35rpx;
  156. .coupon_status_item{
  157. float: left;
  158. font-size: 28rpx;
  159. padding: 0rpx 20rpx;
  160. }
  161. .coupon_status_item.active{
  162. color: #000000;
  163. font-weight: bold;
  164. }
  165. }
  166. .coupon_list{
  167. display: block;
  168. overflow: hidden;
  169. margin: 10rpx auto;
  170. .coupon_item{
  171. height: 200rpx;
  172. display: block;
  173. background: #FFFFFF;
  174. margin: 10rpx auto;
  175. .box_left{
  176. float: left;
  177. width: 160rpx;
  178. height: 160rpx;
  179. font-size: 20rpx;
  180. text-align: center;
  181. margin-left: 35rpx;
  182. line-height: 60rpx;
  183. margin-top: 20rpx;
  184. background: pink;
  185. .rebate{
  186. width: 120rpx;
  187. height: 60rpx;
  188. margin: 0rpx auto;
  189. line-height: 60rpx;
  190. margin-top: 20rpx;
  191. overflow: hidden;
  192. white-space: nowrap;
  193. text-overflow: ellipsis;
  194. }
  195. }
  196. .box_right{
  197. float: left;
  198. width: 485rpx;
  199. margin-left: 35rpx;
  200. padding-top: 20rpx;
  201. .coupon_title{
  202. width: 485rpx;
  203. max-height: 80rpx;
  204. font-size: 30rpx;
  205. overflow: hidden;
  206. line-height: 40rpx;
  207. padding: 0rpx 0rpx;
  208. .coupon_name{
  209. float: left;
  210. height: 40rpx;
  211. width: 380rpx;
  212. }
  213. .coupon_status{
  214. width: 85rpx;
  215. float: right;
  216. color: #999999;
  217. font-size: 24rpx;
  218. }
  219. }
  220. .product_scope{
  221. width: 485rpx;
  222. height: 80rpx;
  223. color: #999999;
  224. font-size: 24rpx;
  225. overflow: hidden;
  226. line-height: 80rpx;
  227. }
  228. .coupon_info{
  229. width: 485rpx;
  230. max-height: 80rpx;
  231. font-size: 30rpx;
  232. overflow: hidden;
  233. line-height: 40rpx;
  234. padding: 0rpx 0rpx;
  235. .coupon_exp{
  236. float: left;
  237. font-size: 20rpx;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. </style>