coupon.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view>
  3. <navbar v-model="screenHeight" title-color="#ffffff" background="#1b43c4" :iSimmersive="false" :placeholder="true" title="优惠劵"></navbar>
  4. <view class="top">
  5. <text :class="{active: isActive == 1}" @click="changeCoupon(1)">未使用</text>
  6. <text :class="{active: isActive == 2}" @click="changeCoupon(2)">已使用/已过期</text>
  7. </view>
  8. <view class="top-placeholder"></view>
  9. <mescroll-body
  10. ref="mescrollRef"
  11. @init="mescrollInit"
  12. @down="downCallback"
  13. @up="upCallback"
  14. :height="screenHeight+'px'"
  15. >
  16. <view class="list-wrap">
  17. <view class="list-box">
  18. <view class="list-item" v-for="(item, index) in result" :key="index">
  19. <view class="l">
  20. <view>¥<text>{{item.amount}}</text></view>
  21. <view v-if="item.price > 0">满{{item.price}}可用</view>
  22. <view v-else>无门槛</view>
  23. </view>
  24. <view class="m">
  25. <view>{{item.name}}</view>
  26. <view>到期:{{ item.end_time }}</view>
  27. </view>
  28. <view class="r" :class="{'disable': isActive == 2}">
  29. <view @click="go">使用</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </mescroll-body>
  35. </view>
  36. </template>
  37. <script>
  38. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  39. import navbar from "@/components/navbar/navbar";
  40. export default {
  41. mixins: [MescrollMixin],
  42. components: {
  43. navbar
  44. },
  45. data() {
  46. return {
  47. screenHeight: 0,
  48. isActive:1,
  49. result: []
  50. }
  51. },
  52. methods: {
  53. go(){
  54. if(this.isActive == 2){
  55. return ;
  56. }
  57. this.$utils.navigateTo('index/index');
  58. },
  59. changeCoupon(index){
  60. this.page = 1;
  61. this.isActive = index;
  62. this.result = [];
  63. setTimeout(()=>{
  64. this.mescroll.resetUpScroll();
  65. },1200);
  66. },
  67. downCallback(){
  68. setTimeout(()=>{
  69. this.mescroll.resetUpScroll();
  70. },1200);
  71. },
  72. triggerDownScroll(){
  73. this.mescroll.triggerDownScroll();
  74. },
  75. upCallback(page) {
  76. this.$http.getCoupon({
  77. type: this.isActive,
  78. page: page.num
  79. }).then((result)=>{
  80. this.mescroll.endByPage(result.data.list.length, result.data.total);
  81. if(result.status==1){
  82. if(page.num == 1) this.result = [];
  83. this.result = this.result.concat(result.data.list);
  84. }else if(result.status == -1){
  85. this.mescroll.endErr();
  86. }
  87. }).catch(error=>{
  88. this.mescroll.endErr();
  89. });
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .top-placeholder { height: 90rpx; width: 100% }
  96. .top{
  97. width: 100%;
  98. position: fixed;
  99. display: flex;
  100. flex-wrap: nowrap;
  101. flex-direction: row;
  102. height: 90rpx;
  103. line-height: 90rpx;
  104. text-align: center;
  105. background-color: #1b43c4;
  106. font-size: 28rpx;
  107. color: #fff;
  108. z-index: 999999;
  109. text{
  110. width: 50%;
  111. }
  112. text:first-child{
  113. width: 49%;
  114. border-right: 1rpx solid #1b43c4;
  115. }
  116. .active{
  117. color: #fff000;
  118. }
  119. }
  120. .list-wrap{
  121. width: 100%;
  122. margin-top: 20rpx;
  123. .list-item{
  124. width: 92%;
  125. height: 200rpx;
  126. border-radius: 10rpx;
  127. background-color: #fff;
  128. margin: 0 auto 20rpx auto;
  129. font-size: 26rpx;
  130. position: relative;
  131. .l{
  132. position: absolute;
  133. width: 220rpx;
  134. height: 160rpx;
  135. top: 20rpx;
  136. left: 0;
  137. border-right: 1px dashed #ccc;
  138. view{
  139. color: #1b43c4;
  140. display: block;
  141. text-align: center;
  142. height: 60rpx;
  143. line-height: 40rpx;
  144. }
  145. view:first-child{
  146. font-size: 32rpx;
  147. height: 100rpx;
  148. line-height: 120rpx;
  149. color: #1b43c4;
  150. text{
  151. font-size: 50rpx;
  152. font-style: normal;
  153. font-weight: bold;
  154. }
  155. }
  156. }
  157. .m{
  158. padding: 0 110rpx 0 220rpx;
  159. height: 160rpx;
  160. text-align: center;
  161. view{
  162. display: block;
  163. }
  164. view:first-child{
  165. padding-top: 50rpx;
  166. line-height: 50rpx;
  167. font-size: 35rpx;
  168. color: #333;
  169. }
  170. view:last-child{
  171. height: 50rpx;
  172. line-height: 50rpx;
  173. font-size: 28rpx; color: #999;
  174. }
  175. }
  176. .r {
  177. &:before {
  178. z-index: 11;
  179. content: " ";
  180. position: absolute;
  181. top: -16rpx;
  182. left: -16rpx;
  183. width: 32rpx;
  184. height: 24rpx;
  185. background-color: #f6f6f6;
  186. border-radius: 100rpx;
  187. }
  188. &:after {
  189. z-index: 11;
  190. content: " ";
  191. position: absolute;
  192. bottom: -16rpx;
  193. left: -16rpx;
  194. width: 32rpx;
  195. height: 24rpx;
  196. background-color: #f6f6f6;
  197. border-radius: 100rpx;
  198. }
  199. z-index: 1;
  200. position: absolute;
  201. right: 0;
  202. top: 0;
  203. width: 110rpx;
  204. height: 200rpx;
  205. line-height: 200rpx;
  206. float: right;
  207. text-align: center;
  208. background-color: #1b43c4;
  209. background-image: url(~@/static/images/coupon-circle.png);
  210. background-repeat: repeat-y;
  211. background-position: -4rpx center;
  212. background-size: 12rpx;
  213. view{
  214. font-size: 30rpx;
  215. color: #fff;
  216. display: block;
  217. text-align: center;
  218. }
  219. }
  220. .active{
  221. background-color: #6b8df9;
  222. }
  223. .disable{
  224. background-color: #dbdadd;
  225. }
  226. }
  227. }
  228. </style>