allDiscountCard.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="content">
  3. <!-- 列表 -->
  4. <view class="itemContent">
  5. <view v-for="(item,index) in itemData" :key="index">
  6. <view class="item">
  7. <image src="../../static/img/table_lingqu.png" mode="" class="stateImg" v-if="item.pickNum>0">
  8. <!-- 第一块 -->
  9. <view class="topView">
  10. <view class="leftView">
  11. <view class="moneyView">
  12. <view>¥</view>
  13. <view class="money">{{item.ActMoney}}</view>
  14. </view>
  15. <view class="condition" v-if="item.WhereMoney != 0">满{{item.WhereMoney}}元可用</view>
  16. <view class="condition" v-else>满任意金额可用</view>
  17. </view>
  18. <view class="rightView">
  19. <view class="firstView">
  20. <view class="cardName">{{item.ActName}}</view>
  21. <view class="rightBtn" v-if="item.pickNum<=0" @click="lingqu(item, index)">立即领取
  22. </view>
  23. </view>
  24. <!-- 时间截取 -->
  25. <view class="valid" v-if="item.EndOffsetDays == -1">
  26. {{item.StartTime.slice(0,item.StartTime.length-8)}}至
  27. {{item.EndTime.slice(0,item.EndTime.length-8)}}
  28. </view>
  29. <view class="valid" v-else>领取后 {{item.EndOffsetDays}} 天有效</view>
  30. </view>
  31. </view>
  32. <!-- 第二快 -->
  33. <view class="bottomView">
  34. <view class="shopName" v-if="item.shopNames">适用门店:{{item.shopNames}}</view>
  35. <view class="shopName" v-else>适用门店:全部</view>
  36. <view @click="goDiscountDetail(item)">查看详情</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="bottomViewBtn" v-if="itemData.length!=0">
  42. <view class="saveCar" @click="alllingqu" v-if="allHave==false">一键领取</view>
  43. <view class="saveCar" style="background-color: #FF9566;" v-else>已全部领取</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. allHave: true,
  63. }
  64. },
  65. onLoad(opt) {
  66. this.page = 1
  67. this.myOrderCoupon()
  68. },
  69. methods: {
  70. lingqu(item, index) {
  71. uni.showLoading({
  72. title: '领取中'
  73. })
  74. this.$http('worldKeepCar/keepCarMy/pickTCoupon', {
  75. couponID: item.ID,
  76. }, 'POST').then(res => {
  77. uni.hideLoading();
  78. if (res.code == 0) {
  79. var itemData = this.itemData[index]
  80. itemData.pickNum = 1
  81. console.log('itemData.pickNum', itemData.pickNum);
  82. uni.showToast({
  83. title: '领取成功',
  84. icon: 'success',
  85. duration: 2000
  86. });
  87. }
  88. })
  89. },
  90. alllingqu() {
  91. uni.showLoading({
  92. title: '领取中'
  93. })
  94. this.$http('worldKeepCar/keepCarMy/pickTCouponAll', {
  95. }, 'POST').then(res => {
  96. uni.hideLoading();
  97. if (res.code == 0) {
  98. this.myOrderCoupon()
  99. this.allHave = true
  100. uni.showToast({
  101. title: '领取成功',
  102. icon: 'success',
  103. duration: 2000
  104. });
  105. }
  106. })
  107. },
  108. myOrderCoupon() {
  109. uni.showLoading({
  110. title: '加载中'
  111. })
  112. this.$http('worldKeepCar/keepCarMy/listTCouponPage', {
  113. page: this.page,
  114. limit: 10,
  115. }, 'GET').then(res => {
  116. uni.hideLoading();
  117. var list = res.data.Items
  118. // 处理 undefined和null转为空白字符串
  119. list.forEach((item, index) => {
  120. for (const key in item) {
  121. item[key] = this.$praseStrEmpty(item[key])
  122. }
  123. })
  124. if (this.page == 1) {
  125. this.itemData = list
  126. } else {
  127. this.itemData = this.itemData.concat(list)
  128. }
  129. if (list.length < 10) {
  130. this.noMoreShow = true
  131. } else {
  132. this.noMoreShow = false
  133. }
  134. if (this.itemData.length != 0) {
  135. this.itemData.forEach((item, index) => {
  136. if (item.pickNum <= 0) {
  137. this.allHave = false
  138. }
  139. })
  140. }
  141. })
  142. },
  143. goDiscountDetail(item) {
  144. uni.navigateTo({
  145. url: 'allCardDetail?couponId=' + item.ID,
  146. })
  147. },
  148. },
  149. // 下拉刷新 上拉加载更多
  150. onPullDownRefresh() {
  151. this.page = 1
  152. this.myOrderCoupon()
  153. setTimeout(function() {
  154. uni.stopPullDownRefresh();
  155. }, 1000);
  156. },
  157. onReachBottom() {
  158. this.page++;
  159. this.myOrderCoupon()
  160. },
  161. }
  162. </script>
  163. <style scoped>
  164. .content {
  165. background: #F4F5F7;
  166. min-height: 100vh;
  167. padding-bottom: 120rpx;
  168. }
  169. .itemContent {
  170. padding: 20rpx 24rpx;
  171. }
  172. .item {
  173. margin: 20rpx 0rpx;
  174. background-color: #FFFFFF;
  175. border-radius: 10rpx;
  176. }
  177. .stateImg {
  178. width: 118rpx;
  179. height: 86rpx;
  180. position: absolute;
  181. right: 20rpx;
  182. margin-right: 20rpx;
  183. }
  184. .topView {
  185. display: flex;
  186. justify-content: flex-start;
  187. padding: 22rpx 0rpx;
  188. margin-left: 22rpx;
  189. margin-right: 22rpx;
  190. border-bottom: 1rpx #CCCCCC dashed;
  191. align-items: center;
  192. }
  193. .leftView {
  194. margin-right: 40rpx;
  195. }
  196. .rightView {
  197. flex-grow: 1;
  198. }
  199. .firstView {
  200. display: flex;
  201. justify-content: space-between;
  202. }
  203. .moneyView {
  204. display: flex;
  205. justify-content: flex-start;
  206. color: #FF4F00;
  207. align-items: baseline;
  208. }
  209. .money {
  210. font-size: 56rpx;
  211. }
  212. .condition {
  213. font-size: 22rpx;
  214. color: #999999;
  215. }
  216. .cardName {
  217. font-size: 30rpx;
  218. font-weight: bold;
  219. color: #333333;
  220. margin-top: 10rpx;
  221. margin-bottom: 15rpx;
  222. overflow: hidden;
  223. text-overflow: ellipsis;
  224. white-space: nowrap;
  225. }
  226. .valid {
  227. font-size: 26rpx;
  228. color: #999999;
  229. }
  230. .rightBtn {
  231. width: 153rpx;
  232. height: 56rpx;
  233. line-height: 56rpx;
  234. background: linear-gradient(137deg, #FF630F 0%, #FF450F 100%);
  235. border-radius: 32rpx;
  236. color: #FFFFFF;
  237. font-size: 26rpx;
  238. text-align: center;
  239. }
  240. .bottomView {
  241. display: flex;
  242. justify-content: space-between;
  243. padding: 20rpx 24rpx;
  244. font-size: 24rpx;
  245. color: #666666;
  246. }
  247. .shopName {
  248. width: 80%;
  249. overflow: hidden;
  250. text-overflow: ellipsis;
  251. white-space: nowrap;
  252. }
  253. .bottomViewBtn {
  254. background-color: #FFFFFF;
  255. width: 100%;
  256. height: 120rpx;
  257. position: fixed;
  258. bottom: 0rpx;
  259. padding-bottom: constant(safe-area-inset-bottom);
  260. padding-bottom: env(safe-area-inset-bottom);
  261. }
  262. .saveCar {
  263. background-color: #FF4F00;
  264. margin: 23rpx 30rpx;
  265. height: 74rpx;
  266. line-height: 74rpx;
  267. border-radius: 37rpx;
  268. color: #FFFFFF;
  269. font-size: 30rpx;
  270. font-weight: bold;
  271. text-align: center;
  272. }
  273. .noMore {
  274. text-align: center;
  275. line-height: 50rpx;
  276. color: #999999;
  277. font-size: 28rpx;
  278. }
  279. </style>