exclusiveScroll.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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://transcend.ringzle.com/xiaozhi-app/profile/2025/10/09/4320f839-19f2-484f-a827-f2b403bb00ff.png" v-if="tidx===1"></image>
  15. <image class="box-img" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/10/09/106a02e0-e979-42a5-979b-0d934d6690f6.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://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/87b5b244-d14f-43cd-991b-4ac9f48d909e.png"></image>
  19. <image class="box-check" v-else src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/b8a5cabd-57f8-4ad7-9677-f6372423c50a.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 = res.data.list;
  97. list.value.forEach(l=>{
  98. l.select = false;
  99. l.check = false;
  100. })
  101. queryParams.value.page++;
  102. if(res.data.list.length===0) isOver.value = true;
  103. })
  104. }
  105. const handleUse = item => {
  106. uni.navigateTo({
  107. url:'/pagesHome/activityDetail?id='+item.activityId
  108. })
  109. }
  110. const confirmCheck = () => {
  111. if(list.value.filter(l=>l.check).length===0) return proxy.$showToast('请至少选择一张专享券')
  112. let selectIds = list.value.filter(l=>l.check).map(l=>l.id);
  113. proxy.getOpenerEventChannel().emit('selectTickets',selectIds);
  114. uni.navigateBack();
  115. }
  116. onLoad((options)=>{
  117. queryParams.value.activityId = options?.activityId||'';
  118. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
  119. getList()
  120. })
  121. </script>
  122. <style scoped lang="scss">
  123. .common_page{
  124. padding: 0 0 40rpx;
  125. .tab{
  126. width: 100%;
  127. height: 110rpx;
  128. background: #FFFFFF;
  129. &-pre{
  130. width: 50%;
  131. height: 110rpx;
  132. position: relative;
  133. font-family: PingFangSC, PingFang SC;
  134. font-weight: 400;
  135. font-size: 28rpx;
  136. color: #6B7280;
  137. line-height: 28rpx;
  138. &.active{
  139. font-weight: bold;
  140. font-size: 32rpx;
  141. color: #252525;
  142. line-height: 32rpx;
  143. &::after{
  144. content: '';
  145. width: 120rpx;
  146. height: 6rpx;
  147. background: #252525;
  148. border-radius: 3rpx;
  149. position: absolute;
  150. left: 50%;
  151. margin-left: -60rpx;
  152. bottom: 6rpx;
  153. }
  154. }
  155. }
  156. }
  157. .list{
  158. margin-top: 20rpx;
  159. padding: 0 24rpx;
  160. flex: 1;
  161. overflow: auto;
  162. .box{
  163. position: relative;
  164. &-img{
  165. width: 128rpx;
  166. height: 118rpx;
  167. position: absolute;
  168. top: 0;
  169. right: 0;
  170. }
  171. &-check{
  172. width: 42rpx;
  173. height: 42rpx;
  174. border-radius: 50%;
  175. position: absolute;
  176. top: 30rpx;
  177. right: 30rpx;
  178. }
  179. &-top{
  180. border-radius: 24rpx 24rpx 0 0;
  181. padding: 40rpx 24rpx 24rpx;
  182. background: linear-gradient(90deg,#FBE9CA 50%,#FCF3E4 100%);
  183. &-title{
  184. font-family: PingFang-SC, PingFang-SC;
  185. font-weight: bold;
  186. font-size: 36rpx;
  187. color: #7E541A;
  188. line-height: 36rpx;
  189. }
  190. &-tip{
  191. font-family: PingFangSC, PingFang SC;
  192. font-weight: 400;
  193. font-size: 24rpx;
  194. color: #AA7633;
  195. line-height: 24rpx;
  196. margin-top: 20rpx;
  197. }
  198. &-date{
  199. margin-top: 42rpx;
  200. &-left{
  201. font-family: PingFangSC, PingFang SC;
  202. font-weight: 400;
  203. font-size: 24rpx;
  204. color: #AA7633;
  205. line-height: 40rpx;
  206. }
  207. &-right{
  208. padding: 8rpx 20rpx;
  209. background: #AA7633;
  210. border-radius: 24rpx;
  211. font-family: PingFangSC, PingFang SC;
  212. font-weight: 400;
  213. font-size: 24rpx;
  214. color: #FFFFFF;
  215. line-height: 33rpx;
  216. }
  217. }
  218. }
  219. &-bottom{
  220. border-radius: 0 0 24rpx 24rpx;
  221. background: #FFFFFF;
  222. padding: 16rpx 24rpx;
  223. &-left{
  224. width: calc(100% - 54rpx);
  225. .h{
  226. font-family: PingFangSC, PingFang SC;
  227. font-weight: 400;
  228. font-size: 24rpx;
  229. color: #A4A4A4;
  230. line-height: 40rpx;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. white-space: nowrap;
  234. }
  235. .s{
  236. .p{
  237. font-family: PingFangSC, PingFang SC;
  238. font-weight: 400;
  239. font-size: 24rpx;
  240. color: #A4A4A4;
  241. line-height: 44rpx;
  242. }
  243. }
  244. }
  245. &-right{
  246. width: 32rpx;
  247. height: 32rpx;
  248. padding-top: 4rpx;
  249. }
  250. }
  251. &.grey{
  252. .box-top{
  253. background: #FFFFFF;
  254. &-title{
  255. color: #657588;
  256. }
  257. &-tip,&-date-left{
  258. color: #A4A4A4;
  259. }
  260. }
  261. }
  262. }
  263. }
  264. .confirm{
  265. width: calc(100% - 100rpx);
  266. padding: 0 40rpx;
  267. margin: 40rpx auto 64rpx;
  268. display: inline-block;
  269. height: 90rpx;
  270. background: #B7F358;
  271. border-radius: 45rpx;
  272. font-family: PingFang-SC, PingFang-SC;
  273. font-weight: bold;
  274. font-size: 32rpx;
  275. color: #151B29;
  276. line-height: 90rpx;
  277. text-align: center;
  278. letter-spacing: 2rpx;
  279. }
  280. .empty{
  281. flex: 1;
  282. image{
  283. width: 184rpx;
  284. height: 113rpx;
  285. }
  286. text{
  287. font-family: PingFangSC, PingFang SC;
  288. font-weight: 400;
  289. font-size: 32rpx;
  290. color: #252525;
  291. line-height: 45rpx;
  292. margin-top: 60rpx;
  293. }
  294. }
  295. }
  296. </style>