allDiscountCard.vue 6.6 KB

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