index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="coupon">
  3. <view class="tab-group">
  4. <view class="tab" :class="[query.status == 1?'active':'']" @click="handleTab(1)">
  5. 未使用
  6. </view>
  7. <view class="tab" :class="[query.status == 2?'active':'']" @click="handleTab(2)">
  8. 已使用
  9. </view>
  10. </view>
  11. <!-- 列表 -->
  12. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  13. <view class="discounts-item" v-for="(item,index) in list" :key="index" >
  14. <view class="card-content" :class="[query.status == 2?'card-bg':'']">
  15. <view class="info">
  16. <view class="title">
  17. {{item.goodsName}}
  18. </view>
  19. <view class="limit">
  20. {{item.useType | filterType(item)}}
  21. </view>
  22. <view class="desc" :class="[open == index?'open':'']" @click="handleOpen(index,'open')">
  23. 展开详情 <image class="jiantou" src="../../static/jiantou-icon.png" mode=""></image>
  24. </view>
  25. </view>
  26. <view class="btn-box">
  27. <view class="btn" >
  28. {{query.status == 2?'已使用':'未使用'}}
  29. </view>
  30. </view>
  31. <view class="num" v-if="item.buySet == 2">
  32. 剩余领取次数:{{item.useCount}}次
  33. </view>
  34. </view>
  35. <view class="card-desc" v-show="open == index">
  36. <view class="time">
  37. {{item.validType | filterType1(item)}}
  38. </view>
  39. <view class="desc" v-html="item.goodsDescribe">
  40. {{item.goodsDescribe}}
  41. </view>
  42. </view>
  43. </view>
  44. </zs-list>
  45. </view>
  46. </template>
  47. <script>
  48. import {getWhetherCoupon} from '@/api/goods.js'
  49. export default {
  50. data() {
  51. return {
  52. active: 1,
  53. open:999,
  54. status:'more',
  55. query:{
  56. currentPage:1,
  57. pageSize:10,
  58. status:1,//
  59. setMealId:JSON.parse(uni.getStorageSync('userInfo')).setMealId,
  60. userId: JSON.parse(uni.getStorageSync('userInfo')).userId
  61. },
  62. list:[]
  63. }
  64. },
  65. filters: {
  66. filterUseTime: function(val) {
  67. if(val.useType == 0){
  68. return '无限制'
  69. }else if(val.useType == 1){
  70. return val.useStartTime + '-' + val.useEndTime +'可使用'
  71. }else if(val.useType == 2){
  72. return '每周'+val.day
  73. }else if(val.useType == 3){
  74. return '每月'+val.day +'日'
  75. }
  76. },
  77. filterTime: function(val) {
  78. if(val.validType == 1){
  79. return '永久有效'
  80. }else {
  81. return val.validStartTime + '-' + val.validEndTime
  82. }
  83. },
  84. filterType: function(val,item) {
  85. if(val == 1){
  86. return '无使用限制'
  87. }else if(val == 2){
  88. return '使用期至' + item.useEndTime
  89. }else if(val == 3){
  90. return '每周'+ item.day +'可用'
  91. }else if(val == 4){
  92. return '每月'+ item.day +'可用'
  93. }
  94. },
  95. filterType1: function(val,item) {
  96. if(val == 1){
  97. return '有效期:无限制'
  98. }else if(val == 2){
  99. return '有效期:' + item.validStartTime + '-' + item.validEndTime
  100. }
  101. }
  102. },
  103. methods: {
  104. handleOpen(val,open){
  105. if(val === this[open]){
  106. this[open] = 999
  107. }else{
  108. this[open] = val
  109. }
  110. },
  111. handleTab(val) {
  112. this.query.status = val
  113. this.list = []
  114. this.status = 'more'
  115. this.query.currentPage = 1
  116. this.getWhetherCoupon()
  117. },
  118. loadMore(){
  119. this.getWhetherCoupon()
  120. },
  121. getWhetherCoupon(){
  122. this.status = 'loading'
  123. getWhetherCoupon(this.query).then(res=>{
  124. if(res.state == 'Success'){
  125. this.list = this.list.concat(res.content.records)
  126. this.list.length>= res.content.total?this.status = 'noMore':this.status = 'more'
  127. this.query.currentPage++
  128. }
  129. })
  130. }
  131. },
  132. created() {
  133. let info = JSON.parse(uni.getStorageSync('userInfo'))
  134. this.query.userId = info.userId
  135. this.query.setMealId = info.setMealId
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .coupon{
  141. background: #f5f5f5;
  142. height: 100vh;
  143. padding-top: 80rpx;
  144. .tab-group{
  145. display: flex;
  146. align-items: center;
  147. background: #fff;
  148. position: fixed;
  149. height: 80rpx;
  150. top: 0%;
  151. left: 0%;
  152. width: 100%;
  153. z-index: 9;
  154. .tab{
  155. width: 150rpx;
  156. padding: 15rpx 30rpx;
  157. text-align: center;
  158. color: #999999;
  159. font-size: 28rpx;
  160. }
  161. .active{
  162. font-weight: bold;
  163. font-size: 32rpx;
  164. position: relative;
  165. color: #222222;
  166. &::before{
  167. display: block;
  168. content: '';
  169. position: absolute;
  170. left: 50%;
  171. bottom: 0%;
  172. transform: translateX(-50%);
  173. width: 40rpx;
  174. height: 8rpx;
  175. background: linear-gradient(265deg, #FF4A39 0%, #FC8B45 100%);
  176. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255,255,255,0.16);
  177. border-radius: 4rpx 4rpx 4rpx 4rpx;
  178. }
  179. }
  180. }
  181. .discounts-item {
  182. margin: 0 32rpx;
  183. .card-content.card-bg{
  184. background: url('../../static/used-card-bg.png') no-repeat;
  185. background-size: 100% 144rpx;
  186. }
  187. .card-content{
  188. display: flex;
  189. align-items: center;
  190. justify-content: space-between;
  191. background-color: rgb(239, 239, 239);
  192. background: url('../../static/card.png') no-repeat;
  193. background-repeat: no-repeat;
  194. background-size: 100% 144rpx;
  195. border-radius: 16rpx;
  196. height: 144rpx;
  197. padding: 0 30rpx 0 48rpx;
  198. margin-top: 20rpx;
  199. position: relative;
  200. .info {
  201. .title {
  202. color: #0F0F0F;
  203. font-size: 30rpx;
  204. }
  205. .desc{
  206. display: flex;
  207. align-items: center;
  208. font-size: 20rpx;
  209. color: #AAAAAA;
  210. .jiantou{
  211. width: 20rpx;
  212. height: 20rpx;
  213. transform: rotateZ(90deg);
  214. display: block;
  215. margin-left: 10rpx;
  216. transition: transform .3s;
  217. }
  218. }
  219. .open{
  220. .jiantou{
  221. transform: rotateZ(270deg)!important;
  222. }
  223. }
  224. .red{
  225. color: $uni-text-primary!important;
  226. }
  227. .limit{
  228. font-size: 20rpx;
  229. color: #AAAAAA;
  230. margin:10rpx 0;
  231. }
  232. .time {
  233. color: #9a9a9a;
  234. font-size: 24rpx;
  235. margin-top: 15rpx;
  236. }
  237. }
  238. .btn-box{
  239. .btn {
  240. width: 118rpx;
  241. height: 48rpx;
  242. line-height: 48rpx;
  243. text-align: center;
  244. font-size: 24rpx;
  245. background: linear-gradient(90deg, #FEFBF2 0%, #F7D188 100%);
  246. border-radius: 35rpx;
  247. color: #E5452C;
  248. margin-top: 15rpx;
  249. }
  250. }
  251. .num{
  252. position: absolute;
  253. white-space: nowrap;
  254. bottom: 10rpx;
  255. right: 10rpx;
  256. font-size: 18rpx;
  257. color: #FFFFFF;
  258. }
  259. }
  260. .card-desc{
  261. font-size: 20rpx;
  262. color: #AAAAAA;
  263. padding: 20rpx 10rpx;
  264. background: #FFFFFF;
  265. border-radius: 0rpx 0rpx 16rpx 16rpx;
  266. .time{
  267. }
  268. .desc{
  269. margin-top: 22rpx;
  270. }
  271. }
  272. }
  273. .item{
  274. display: flex;
  275. align-items: center;
  276. margin: 30rpx;
  277. background: url('../../static/card.png') no-repeat;
  278. background-size: 100% 100%;
  279. width: 690rpx;
  280. height: 160rpx;
  281. box-sizing: border-box;
  282. padding: 30rpx;
  283. .info{
  284. display: flex;
  285. .left{
  286. width: 160rpx;
  287. display: flex;
  288. flex-direction: column;
  289. align-items: center;
  290. justify-content: space-between;
  291. .price{
  292. font-weight: bold;
  293. color: #222222;
  294. font-size: 36rpx;
  295. }
  296. .limit{
  297. color: #999999;
  298. font-size: 24rpx;
  299. margin-top: 10rpx;
  300. }
  301. }
  302. .right{
  303. padding-left: 30rpx;
  304. display: flex;
  305. flex-direction: column;
  306. justify-content: space-between;
  307. .title{
  308. font-size: 28rpx;
  309. color: #222222;
  310. }
  311. .time{
  312. font-size: 24rpx;
  313. color: #999999;
  314. margin-top: 10rpx;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. </style>