discountCard.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="content">
  3. <view class="topTab">
  4. <!-- tab -->
  5. <view class="tab">
  6. <view class="tabLine" :class="{tabActive:tabIndex==1}" @click="tabClick(1)">未使用</view>
  7. <view class="tabLine" :class="{tabActive:tabIndex==2}" @click="tabClick(2)">已使用</view>
  8. <view class="tabLine" :class="{tabActive:tabIndex==3}" @click="tabClick(3)">已过期</view>
  9. </view>
  10. </view>
  11. <!-- 列表 -->
  12. <view class="itemContent">
  13. <view v-for="(item,index) in itemData" :key="index">
  14. <view class="item">
  15. <image src="../../static/img/icon_yishiyong.png" mode="" class="stateImg" v-if="tabIndex==2">
  16. </image>
  17. <image src="../../static/img/icon_yiguoqi.png" mode="" class="stateImg" v-if="tabIndex==3"></image>
  18. <!-- 第一块 -->
  19. <view class="topView">
  20. <view class="leftView">
  21. <view class="moneyView">
  22. <view>¥</view>
  23. <view class="money">{{item.ActMoney}}</view>
  24. </view>
  25. <view class="condition" v-if="item.WhereMoney != 0">满{{item.WhereMoney}}元可用</view>
  26. <view class="condition" v-else>满任意金额可用</view>
  27. </view>
  28. <view class="rightView">
  29. <view class="cardName">{{item.ActName}}</view>
  30. <!-- 时间截取 -->
  31. <view class="valid">有效期:{{item.StartTime.slice(0,item.StartTime.length-8)}}至
  32. {{item.EndTime.slice(0,item.EndTime.length-8)}}
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 第二快 -->
  37. <view class="bottomView">
  38. <view class="shopNamesView" v-if="item.shopNames">适用门店:{{item.shopNames}}</view>
  39. <view class="shopNamesView" v-else>适用门店:全部</view>
  40. <view @click="goDiscountDetail(item)">查看详情</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 上拉 加载更多 -->
  46. <view class="noMore" v-if="noMoreShow">没有更多数据</view>
  47. <!-- 无数据空白页 -->
  48. <nodata v-if="itemData.length==0"></nodata>
  49. </view>
  50. </template>
  51. <script>
  52. import nodata from '../../components/nodata/nodata.vue'
  53. export default {
  54. components: {
  55. nodata,
  56. },
  57. data() {
  58. return {
  59. itemData: [],
  60. page: 1,
  61. noMoreShow: false,
  62. tabIndex: 1,
  63. }
  64. },
  65. onLoad(opt) {
  66. this.page = 1
  67. this.getItemData()
  68. },
  69. methods: {
  70. tabClick(num) {
  71. this.tabIndex = num;
  72. this.page = 1;
  73. this.getItemData()
  74. },
  75. goDiscountDetail(item) {
  76. uni.navigateTo({
  77. url: 'discountDetail?couponId=' + item.ID,
  78. })
  79. },
  80. getItemData() {
  81. uni.showLoading({
  82. title: '加载中'
  83. })
  84. var usedState = ''
  85. if (this.tabIndex == 1) {
  86. usedState = 0
  87. }
  88. if (this.tabIndex == 2) {
  89. usedState = 1
  90. }
  91. var expireState = ''
  92. if (this.tabIndex == 3) {
  93. expireState = 1
  94. }
  95. let url = 'worldKeepCar/keepCarMy/listTCouponMemberPage',
  96. params = {
  97. page: this.page,
  98. limit: 20,
  99. usedState: usedState,
  100. expireState: expireState,
  101. }
  102. this.$http(url, params, 'GET').then(res => {
  103. uni.hideLoading();
  104. var list = res.data.Items
  105. // 处理 undefined和null转为空白字符串
  106. list.forEach((item, index) => {
  107. for (const key in item) {
  108. item[key] = this.$praseStrEmpty(item[key])
  109. }
  110. })
  111. if (this.page == 1) {
  112. this.itemData = list
  113. } else {
  114. this.itemData = this.itemData.concat(list)
  115. }
  116. if (list.length < 10) {
  117. this.noMoreShow = true
  118. } else {
  119. this.noMoreShow = false
  120. }
  121. })
  122. },
  123. },
  124. // 下拉刷新 上拉加载更多
  125. onPullDownRefresh() {
  126. this.page = 1
  127. this.getItemData()
  128. //this.getItemData()
  129. setTimeout(function() {
  130. uni.stopPullDownRefresh();
  131. }, 1000);
  132. },
  133. onReachBottom() {
  134. this.page++;
  135. this.getItemData()
  136. },
  137. }
  138. </script>
  139. <style scoped>
  140. .content {
  141. background: #F4F5F7;
  142. min-height: 100vh;
  143. }
  144. .topTab {
  145. background: #FFFFFF;
  146. position: fixed;
  147. width: 100%;
  148. height: 92rpx;
  149. z-index: 99;
  150. }
  151. .tab {
  152. background: #FFFFFF;
  153. display: flex;
  154. justify-content: space-around;
  155. line-height: 90rpx;
  156. height: 90rpx;
  157. width: 100%;
  158. }
  159. .tabLine {
  160. text-align: center;
  161. }
  162. .tabActive {
  163. color: #FF4F00;
  164. border-bottom: 4rpx solid #FF4F00;
  165. }
  166. .itemContent {
  167. padding: 100rpx 20rpx 24rpx;
  168. }
  169. .item {
  170. margin: 20rpx 0rpx;
  171. background-color: #FFFFFF;
  172. border-radius: 10rpx;
  173. }
  174. .stateImg {
  175. width: 118rpx;
  176. height: 86rpx;
  177. position: absolute;
  178. right: 20rpx;
  179. margin-right: 20rpx;
  180. }
  181. .topView {
  182. display: flex;
  183. justify-content: flex-start;
  184. padding: 22rpx 0rpx;
  185. margin-left: 22rpx;
  186. margin-right: 22rpx;
  187. border-bottom: 1rpx #CCCCCC dashed;
  188. align-items: center;
  189. }
  190. .leftView,
  191. .rightView {
  192. margin-right: 40rpx;
  193. }
  194. .moneyView {
  195. display: flex;
  196. justify-content: flex-start;
  197. color: #FF4F00;
  198. align-items: baseline;
  199. }
  200. .money {
  201. font-size: 56rpx;
  202. }
  203. .condition {
  204. font-size: 22rpx;
  205. color: #999999;
  206. }
  207. .cardName {
  208. font-size: 30rpx;
  209. font-weight: bold;
  210. color: #333333;
  211. margin-top: 10rpx;
  212. margin-bottom: 15rpx;
  213. }
  214. .valid {
  215. font-size: 26rpx;
  216. color: #999999;
  217. }
  218. .bottomView {
  219. display: flex;
  220. justify-content: space-between;
  221. padding: 20rpx 24rpx;
  222. font-size: 24rpx;
  223. color: #666666;
  224. }
  225. .shopNamesView{
  226. width: 80%;
  227. overflow: hidden;
  228. text-overflow: ellipsis;
  229. white-space: nowrap;
  230. }
  231. .noMore {
  232. text-align: center;
  233. line-height: 50rpx;
  234. color: #999999;
  235. font-size: 28rpx;
  236. }
  237. </style>