exclusiveScroll.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="common_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title="我的专享券" bgColor="#FFFFFF"></cus-header>
  4. <view class="tab adf">
  5. <view class="tab-pre adfacjc" :class="{'active':tidx===0}" @click="changeTab(0,0)">未使用</view>
  6. <view class="tab-pre adfacjc" :class="{'active':tidx===1}" @click="changeTab(1,1)">已使用</view>
  7. <view class="tab-pre adfacjc" :class="{'active':tidx===2}" @click="changeTab(2,-1)">已过期</view>
  8. </view>
  9. <template v-if="list.length">
  10. <view class="list">
  11. <up-list @scrolltolower="scrolltolower" style="height: 100%;">
  12. <up-list-item v-for="(item, index) in list" :key="index">
  13. <view class="box" :style="{'margin-top':index===0?0:'24rpx'}" :class="{'grey':tidx!==0}">
  14. <image class="box-img" src="https://oss.familydaf.cn/sxsnfile/20251218/f442d0b15795416daecc9c1b9496b865.png" v-if="tidx===1"></image>
  15. <image class="box-img" src="https://oss.familydaf.cn/sxsnfile/20251218/4c44c9de5d204e26a212b8aba398ea9b.png" v-if="tidx===2"></image>
  16. <view class="box-top" @click="handleCheck(item,index)">
  17. <template v-if="queryParams.activityId&&tidx===0">
  18. <image class="box-check" v-if="item.check" src="https://oss.familydaf.cn/sxsnfile/20251218/c11b9a1b56f34e1189621f4270f0349a.png"></image>
  19. <image class="box-check" v-else src="https://oss.familydaf.cn/sxsnfile/20251218/2a2f7bdefb474a3e93faa00aef6d0e1f.png"></image>
  20. </template>
  21. <view class="box-top-title">活动专享券</view>
  22. <view class="box-top-tip">{{item?.activityName||''}}</view>
  23. <view class="box-top-date adfacjb">
  24. <view class="box-top-date-left">有效期至{{item?.expiredTime||''}}</view>
  25. <view class="box-top-date-right" v-if="item?.state===0&&!queryParams.activityId" @click="handleUse(item)">立即使用</view>
  26. </view>
  27. </view>
  28. <view class="box-bottom adf" @click="handleExpand(item,index)">
  29. <view class="box-bottom-left">
  30. <view class="h" v-if="!item.select">本券仅限报名指定活动使用,不可用于其他场景</view>
  31. <view class="s" v-else>
  32. <view class="p">1.适用范围:本券仅限报名指定活动使用;</view>
  33. <view class="p">2.使用方式:在报名指定活动时将自动抵扣爱心值;</view>
  34. <view class="p">3.不退不换:券一经使用,不可退还、不可取消;</view>
  35. <view class="p">4.有效期:请于券面标注日期前使用,逾期自动失效。</view>
  36. </view>
  37. </view>
  38. <view class="box-bottom-right">
  39. <up-icon name="arrow-right" color="#CBCBCB" size="32rpx" v-if="!item.select"></up-icon>
  40. <up-icon name="arrow-up" color="#CBCBCB" size="32rpx" v-else></up-icon>
  41. </view>
  42. </view>
  43. </view>
  44. </up-list-item>
  45. </up-list>
  46. </view>
  47. <view class="confirm" v-if="queryParams.activityId&&tidx===0" @click="confirmCheck">确定,已选择{{selectNum}}张专享券</view>
  48. </template>
  49. <view class="dataEmpty" v-else>
  50. <page-empty text='没有券'></page-empty>
  51. </view>
  52. </view>
  53. </template>
  54. <script setup name="">
  55. import CusHeader from '@/components/CusHeader/index.vue'
  56. import PageEmpty from '@/components/pageEmpty/index.vue'
  57. import { ref, getCurrentInstance } from 'vue'
  58. import { onLoad } from '@dcloudio/uni-app'
  59. const { proxy } = getCurrentInstance()
  60. const tidx = ref(0)
  61. const queryParams = ref({
  62. page:1,
  63. limit:10,
  64. activityId:'',
  65. state:0,
  66. userId:''
  67. })
  68. const isOver = ref(false)
  69. const list = ref([])
  70. const selectNum = ref(0)
  71. const changeTab = (index,status) => {
  72. tidx.value = index;
  73. queryParams.value.state = status;
  74. init()
  75. getList()
  76. }
  77. const scrolltolower = () => {
  78. if(isOver.value) return
  79. getList()
  80. }
  81. const handleCheck = (item,index) => {
  82. list.value[index].check = !list.value[index].check;
  83. selectNum.value = list.value.filter(l=>l.check).length;
  84. }
  85. const handleExpand = (item,index) => {
  86. list.value[index].select = !list.value[index].select;
  87. }
  88. const init = () =>{
  89. queryParams.value.page = 1;
  90. isOver.value = false;
  91. list.value = [];
  92. }
  93. const getList = () => {
  94. proxy.$api.get('/core/activity/coupon/page',queryParams.value).then(({data:res})=>{
  95. if(res.code!==0) return proxy.$showToast(res.msg)
  96. list.value = [...list.value,...res.data.list];
  97. list.value.forEach(l=>{
  98. l.select = false;
  99. l.check = false;
  100. l.expiredTime = l.expiredTime&&new Date(l.expiredTime).Format('yyyy.MM.dd hh:mm:ss')
  101. })
  102. queryParams.value.page++;
  103. if(res.data.list.length===0) isOver.value = true;
  104. })
  105. }
  106. const handleUse = item => {
  107. uni.navigateTo({
  108. url:'/pagesHome/activityDetail?id='+item.activityId
  109. })
  110. }
  111. const confirmCheck = () => {
  112. if(list.value.filter(l=>l.check).length===0) return proxy.$showToast('请至少选择一张专享券')
  113. let selectIds = list.value.filter(l=>l.check).map(l=>l.id);
  114. proxy.getOpenerEventChannel().emit('selectTickets',selectIds);
  115. uni.navigateBack();
  116. }
  117. onLoad((options)=>{
  118. queryParams.value.activityId = options?.activityId||'';
  119. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
  120. getList()
  121. })
  122. </script>
  123. <style scoped lang="scss">
  124. .common_page{
  125. padding: 0 0 40rpx;
  126. .tab{
  127. width: 100%;
  128. height: 110rpx;
  129. background: #FFFFFF;
  130. &-pre{
  131. width: 50%;
  132. height: 110rpx;
  133. position: relative;
  134. font-family: PingFangSC, PingFang SC;
  135. font-weight: 400;
  136. font-size: 28rpx;
  137. color: #6B7280;
  138. line-height: 28rpx;
  139. &.active{
  140. font-weight: bold;
  141. font-size: 32rpx;
  142. color: #252525;
  143. line-height: 32rpx;
  144. &::after{
  145. content: '';
  146. width: 120rpx;
  147. height: 6rpx;
  148. background: #252525;
  149. border-radius: 3rpx;
  150. position: absolute;
  151. left: 50%;
  152. margin-left: -60rpx;
  153. bottom: 6rpx;
  154. }
  155. }
  156. }
  157. }
  158. .list{
  159. margin-top: 20rpx;
  160. padding: 0 24rpx;
  161. flex: 1;
  162. overflow: auto;
  163. .box{
  164. position: relative;
  165. &-img{
  166. width: 128rpx;
  167. height: 118rpx;
  168. position: absolute;
  169. top: 0;
  170. right: 0;
  171. }
  172. &-check{
  173. width: 42rpx;
  174. height: 42rpx;
  175. border-radius: 50%;
  176. position: absolute;
  177. top: 30rpx;
  178. right: 30rpx;
  179. }
  180. &-top{
  181. border-radius: 24rpx 24rpx 0 0;
  182. padding: 40rpx 24rpx 24rpx;
  183. background: linear-gradient(90deg,#FBE9CA 50%,#FCF3E4 100%);
  184. &-title{
  185. font-family: PingFang-SC, PingFang-SC;
  186. font-weight: bold;
  187. font-size: 36rpx;
  188. color: #7E541A;
  189. line-height: 36rpx;
  190. }
  191. &-tip{
  192. font-family: PingFangSC, PingFang SC;
  193. font-weight: 400;
  194. font-size: 24rpx;
  195. color: #AA7633;
  196. line-height: 24rpx;
  197. margin-top: 20rpx;
  198. }
  199. &-date{
  200. margin-top: 42rpx;
  201. &-left{
  202. font-family: PingFangSC, PingFang SC;
  203. font-weight: 400;
  204. font-size: 24rpx;
  205. color: #AA7633;
  206. line-height: 40rpx;
  207. }
  208. &-right{
  209. padding: 8rpx 20rpx;
  210. background: #AA7633;
  211. border-radius: 24rpx;
  212. font-family: PingFangSC, PingFang SC;
  213. font-weight: 400;
  214. font-size: 24rpx;
  215. color: #FFFFFF;
  216. line-height: 33rpx;
  217. }
  218. }
  219. }
  220. &-bottom{
  221. border-radius: 0 0 24rpx 24rpx;
  222. background: #FFFFFF;
  223. padding: 16rpx 24rpx;
  224. &-left{
  225. width: calc(100% - 54rpx);
  226. .h{
  227. font-family: PingFangSC, PingFang SC;
  228. font-weight: 400;
  229. font-size: 24rpx;
  230. color: #A4A4A4;
  231. line-height: 40rpx;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. white-space: nowrap;
  235. }
  236. .s{
  237. .p{
  238. font-family: PingFangSC, PingFang SC;
  239. font-weight: 400;
  240. font-size: 24rpx;
  241. color: #A4A4A4;
  242. line-height: 44rpx;
  243. }
  244. }
  245. }
  246. &-right{
  247. width: 32rpx;
  248. height: 32rpx;
  249. padding-top: 4rpx;
  250. }
  251. }
  252. &.grey{
  253. .box-top{
  254. background: #FFFFFF;
  255. &-title{
  256. color: #657588;
  257. }
  258. &-tip,&-date-left{
  259. color: #A4A4A4;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. .confirm{
  266. width: calc(100% - 100rpx);
  267. padding: 0 40rpx;
  268. margin: 40rpx auto 64rpx;
  269. display: inline-block;
  270. height: 90rpx;
  271. background: #B7F358;
  272. border-radius: 45rpx;
  273. font-family: PingFang-SC, PingFang-SC;
  274. font-weight: bold;
  275. font-size: 32rpx;
  276. color: #151B29;
  277. line-height: 90rpx;
  278. text-align: center;
  279. letter-spacing: 2rpx;
  280. }
  281. .empty{
  282. flex: 1;
  283. image{
  284. width: 184rpx;
  285. height: 113rpx;
  286. }
  287. text{
  288. font-family: PingFangSC, PingFang SC;
  289. font-weight: 400;
  290. font-size: 32rpx;
  291. color: #252525;
  292. line-height: 45rpx;
  293. margin-top: 60rpx;
  294. }
  295. }
  296. }
  297. </style>