usableDiscountCard.vue 4.7 KB

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