usableDiscountCard.vue 5.2 KB

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