activityList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <view class="spikeListBox">
  3. <JHeader :dark="false" title="会员专区" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="spikeBgBox">
  5. <view class="discountBg">
  6. </view>
  7. <view v-if="shopShowType == false" class="countdown">
  8. 距活动结束剩余<view class="endDate">
  9. <span>{{ hou }}</span><i>:</i><span>{{ min }}</span><i>:</i><span>{{ sec }}</span>
  10. </view>
  11. </view>
  12. <!-- <view class="filterBox" v-else> -->
  13. <!-- <view class="item" :class="selectIndex == 0 ? 'selected' : ''" @click="synthesize"><span>综合</span></view> -->
  14. <!-- <view class="item" :class="selectIndex == 1 ? 'selected' : ''" @click="sales"><span>销量</span></view> -->
  15. <!-- <view class="item" :class="selectIndex == 2 ? 'selected' : ''" @click="priceClick"><span>价格</span></view> -->
  16. <!-- </view> -->
  17. <view id="boxFixed" class="nav-warp">
  18. <view class="shop-list-nav" :class="{ 'is-fixed': isFixed }">
  19. <view class="nav-item-sort" @click="sortTap(1)">
  20. <text class="nav-title" :class="{ 'active': sortIndex == 1 }">综合</text>
  21. </view>
  22. <view class="nav-item-sort" @click="sortTap(2)">
  23. <text class="nav-title" :class="{ 'active': sortIndex == 2 }">价格</text>
  24. <view class="r">
  25. <view class="arrowUp" :class="{ activeUp: type == 1 }"></view>
  26. <view class="arrowDown" :class="{ activeDown: type == 2 }"></view>
  27. </view>
  28. </view>
  29. <view class="nav-item-sort" @click="sortTap(3)">
  30. <text class="nav-title" :class="{ 'active': sortIndex == 3 }">销量</text>
  31. <view class="r">
  32. <view class="arrowUp" :class="{ activeUp: volume == 1 }"></view>
  33. <view class="arrowDown" :class="{ activeDown: volume == 2 }"></view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="spikeList">
  40. <view v-for="(item, index) in discountList" :key="index" class="listItem">
  41. <view class="itemBox">
  42. <img :src="common.seamingImgUrl(item.image)">
  43. </view>
  44. <view class="itemInfo">
  45. <p>{{ item.productName }}</p>
  46. <view class="price">
  47. <view class="currentPrice">
  48. <view class="originalPrice">原价: ¥{{ item.originalPrice }}</view>
  49. <view class="flex-row-plus flex-items-plus">
  50. <view class="iconBox">
  51. <image src="../../../static/images/new-business/shop/memberCenterIcon.png"></image>
  52. </view>
  53. <view class="flex-row-plus flex-items priceInfo">
  54. <label class="fs24">¥</label>
  55. <label class="fs36">{{ item.price }}</label>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="snapUpBtn" @click="gogoodsDetails(item.shopId, item.productId, item.skuId)">
  60. <view class="btnText">立即购买</view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view style="padding-bottom: 45upx;">
  66. <LoadingMore
  67. :status="!isEmpty && !discountList.length
  68. ? 'loading' : !isEmpty && discountList.length && (discountList.length >= discountListTotal) ? 'no-more' : ''"
  69. >
  70. </LoadingMore>
  71. <tui-no-data v-if="isEmpty" :fixed="false" style="margin-top: 60upx;">暂无数据</tui-no-data>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import { T_STORAGE_KEY } from '../../../constant'
  78. import { getMemberProductsCanvasApi } from '../../../api/anotherTFInterface'
  79. export default {
  80. name: 'ActivityList',
  81. data() {
  82. return {
  83. pageType: true,
  84. discountList: [],
  85. discountListTotal: 0,
  86. page: 1,
  87. pageSize: 10,
  88. isEmpty: false,
  89. days: '00',
  90. hou: '00',
  91. min: '00',
  92. sec: '00',
  93. shopId: 0,
  94. shopSeckillId: 0,
  95. type: '', // 价格
  96. volume: '', // 销量
  97. shopShowType: false,
  98. selectIndex: 0,
  99. sortIndex: 1,
  100. isFixed: false,
  101. boxFixedTop: 0
  102. }
  103. },
  104. onPageScroll(res) {
  105. const scrollTop = res.scrollTop // 滚动条偏移量
  106. const offsetTop = this.boxFixedTop // 要滚动到顶部吸附的元素的偏移量
  107. this.isFixed = scrollTop > offsetTop // 如果滚动到顶部了,this.isFixed就为true
  108. },
  109. onReady() {
  110. const query = uni.createSelectorQuery().in(this)
  111. query.select('#boxFixed').boundingClientRect((data) => {
  112. this.boxFixedTop = data.top
  113. })
  114. .exec()
  115. },
  116. onLoad(options) {
  117. if (options.shopId && options.shopDiscountId) {
  118. this.shopShowType = false
  119. this.shopId = options.shopId
  120. this.shopDiscountId = options.shopDiscountId
  121. } else {
  122. this.shopShowType = true
  123. this.shopId = 0
  124. this.shopDiscountId = 0
  125. }
  126. },
  127. onShow() {
  128. this.getMemberList()
  129. },
  130. onReachBottom() {
  131. if (this.discountList.length < this.discountListTotal) {
  132. ++this.page
  133. this.getMemberList(true)
  134. }
  135. },
  136. methods: {
  137. getPercent(num, total) {
  138. num = parseFloat(num)
  139. total = parseFloat(total)
  140. if (isNaN(num) || isNaN(total)) {
  141. return '-'
  142. }
  143. return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0
  144. },
  145. sortTap(index) {
  146. this.page = 1
  147. this.discountList = []
  148. if (index == 1) {
  149. this.type = null
  150. this.volume = null
  151. this.sortIndex = index
  152. } else if (index == 2) {
  153. this.type = this.type != 1 ? 1 : 2
  154. this.volume = null
  155. this.sortIndex = index
  156. } else if (index == 3) {
  157. this.type = null
  158. this.volume = this.volume != 1 ? 1 : 2
  159. this.sortIndex = index
  160. }
  161. this.getMemberList()
  162. },
  163. // synthesize(){
  164. // this.volume =1//销量
  165. // this.type = 1//价格
  166. // this.page = 1
  167. // this.selectIndex = 0
  168. // this.discountList = []
  169. // this.getDiscountDataList()
  170. // },
  171. // sales(){
  172. // //销量
  173. // if(this.volume == 1){
  174. // this.volume = 2
  175. // }else{
  176. // this.volume = 1
  177. // }
  178. // this.type = 1//价格
  179. // this.page = 1
  180. // this.selectIndex = 1
  181. // this.discountList = []
  182. // this.getDiscountDataList()
  183. // },
  184. // priceClick(){
  185. // this.volume =1//销量
  186. // //价格
  187. // if(this.type == 1){
  188. // this.type = 2
  189. // }else{
  190. // this.type = 1
  191. // }
  192. // this.page = 1
  193. // this.selectIndex = 2
  194. // this.discountList = []
  195. // this.getDiscountDataList()
  196. // },
  197. gogoodsDetails(shopId, productId, skuId) {
  198. uni.navigateTo({
  199. url: `/another-tf/another-serve/goodsDetails/index?shopId=${shopId}&productId=${productId}&skuId=${skuId}`
  200. })
  201. },
  202. getMemberList(isLoadmore) {
  203. let param = ''
  204. const storageKey = uni.getStorageSync(T_STORAGE_KEY) || {}
  205. param = {
  206. page: this.page,
  207. pageSize: this.pageSize,
  208. memberLevelId: storageKey.memberLevelId
  209. }
  210. if (this.type) {
  211. param.type = this.type
  212. }
  213. if (this.volume) {
  214. param.volume = this.volume
  215. }
  216. uni.showLoading()
  217. getMemberProductsCanvasApi({
  218. page: this.page,
  219. pageSize: this.pageSize
  220. })
  221. .then((res) => {
  222. this.discountListTotal = res.data.total
  223. if (isLoadmore) {
  224. this.discountList.push(...res.data.list)
  225. } else {
  226. this.discountList = res.data.list
  227. }
  228. this.isEmpty = this.discountList.length === 0
  229. uni.hideLoading()
  230. })
  231. .catch(() => {
  232. uni.hideLoading()
  233. })
  234. },
  235. // 时分秒换算
  236. dateformat(micro_second) {
  237. // 总秒数
  238. const second = Math.floor(micro_second / 1000)
  239. // 天数
  240. const day = Math.floor(second / 3600 / 24)
  241. // 小时
  242. const hr = Math.floor(second / 3600 % 24)
  243. // 分钟
  244. const min = Math.floor(second / 60 % 60)
  245. // 秒
  246. const sec = Math.floor(second % 60)
  247. this.hou = hr + day * 24
  248. this.min = min
  249. this.sec = sec
  250. }
  251. // countDown(){
  252. // let timeOut = setTimeout(() => {
  253. // let hou = parseInt(this.hou+this.days*24);
  254. // let min = parseInt(this.min);
  255. // let sec = parseInt(this.sec);
  256. //
  257. // let netxSec = sec - 1;
  258. // let netxMin = min
  259. // let netxHou = hou;
  260. //
  261. // if (netxHou == 0 && netxMin == 0 && netxSec == -1) {
  262. // clearTimeout(timeOut)
  263. // this.$switchTab('/')
  264. // uni.showToast({
  265. // title:"活动结束",
  266. // duration:2000,
  267. // icon:'none'
  268. // })
  269. // } else {
  270. // if (netxSec == -1) {
  271. // netxSec = 59
  272. // netxMin = netxMin - 1;
  273. // }
  274. // if (netxMin == -1) {
  275. // netxMin = 59
  276. // netxHou = netxHou - 1
  277. // }
  278. // // if (netxHou == -1) {
  279. // // netxHou = 23
  280. // // }
  281. //
  282. // this.hou = this.timeFormat(netxHou),
  283. // this.min = this.timeFormat(netxMin),
  284. // this.sec = this.timeFormat(netxSec),
  285. // this.timeOut = timeOut
  286. // this.countDown();
  287. // }
  288. // }, 1000)
  289. // },
  290. // timeFormat(param) { //小于10的格式化函数
  291. // return param < 10 ? '0' + param : param;
  292. // },
  293. }
  294. }
  295. </script>
  296. <style>
  297. page {
  298. background: #333333;
  299. }
  300. </style>
  301. <style lang="less" scoped>
  302. .spikeListBox {
  303. .discountBg {
  304. width: 100%;
  305. height: 440rpx;
  306. // background: url("../../static/images/origin/memberCenterBg.png") no-repeat center center;
  307. background-size: contain;
  308. position: relative;
  309. }
  310. .selected {
  311. color: #FE6F52;
  312. }
  313. .shopShowTypebox {
  314. height: 80rpx;
  315. background-color: #FFFFFF;
  316. z-index: 9999;
  317. }
  318. .countdown {
  319. display: flex;
  320. justify-content: center;
  321. height: 80upx;
  322. align-items: center;
  323. width: 100%;
  324. color: #CCCCCC;
  325. .endDate {
  326. display: flex;
  327. align-items: center;
  328. margin-left: 20upx;
  329. span {
  330. min-width: 44rpx;
  331. padding: 0 8rpx;
  332. height: 52upx;
  333. line-height: 52upx;
  334. background: #999999;
  335. display: block;
  336. font-size: 26upx;
  337. color: #FFEBC4;
  338. text-align: center;
  339. }
  340. i {
  341. font-size: 26upx;
  342. color: #999999;
  343. font-style: normal;
  344. margin: 0 8upx;
  345. }
  346. }
  347. }
  348. .spikeList {
  349. padding: 20upx 30upx 20upx 30upx;
  350. .listItem {
  351. display: flex;
  352. padding: 30rpx;
  353. margin-bottom: 30upx;
  354. background: #FFFFFF;
  355. &:last-child {
  356. border-bottom: none;
  357. }
  358. .itemBox {
  359. width: 260upx;
  360. height: 260upx;
  361. margin-right: 30upx;
  362. img {
  363. width: 100%;
  364. height: 100%;
  365. }
  366. }
  367. .itemInfo {
  368. flex: 1;
  369. .iconBox {
  370. image {
  371. width: 58rpx;
  372. height: 36rpx;
  373. }
  374. }
  375. p {
  376. font-size: 26upx;
  377. color: #333333;
  378. line-height: 40upx;
  379. height: 115rpx;
  380. margin-bottom: 20upx;
  381. text-overflow: -o-ellipsis-lastline;
  382. overflow: hidden;
  383. text-overflow: ellipsis;
  384. display: -webkit-box;
  385. -webkit-line-clamp: 2;
  386. line-clamp: 2;
  387. -webkit-box-orient: vertical;
  388. }
  389. .number {
  390. color: #C5AA7B;
  391. font-size: 26rpx;
  392. height: 40rpx;
  393. background: #FFFFFF;
  394. border: 2rpx solid #E4E5E6;
  395. font-weight: 400;
  396. display: inline;
  397. padding: 0 5rpx;
  398. }
  399. .originalPrice {
  400. font-size: 24upx;
  401. margin: 20upx 0;
  402. text-decoration: line-through;
  403. color: #CCCCCC;
  404. }
  405. .price {
  406. display: flex;
  407. justify-content: space-between;
  408. align-items: center;
  409. .priceInfo {
  410. font-size: 40rpx;
  411. color: #C83732;
  412. }
  413. .snapUpBtn {
  414. margin-top: 20rpx;
  415. width: 140upx;
  416. height: 84upx;
  417. line-height: 84rpx;
  418. text-align: center;
  419. background: #333333;
  420. opacity: 1;
  421. border-radius: 10rpx;
  422. .btnText {
  423. color: #FFEBC4;
  424. font-weight: 400;
  425. font-size: 24rpx;
  426. }
  427. .uni-progress {
  428. border-radius: 10rpx;
  429. }
  430. }
  431. }
  432. }
  433. }
  434. }
  435. .filterBox {
  436. display: flex;
  437. height: 80upx;
  438. align-items: center;
  439. width: 100%;
  440. background: #FFFFFF;
  441. left: 0;
  442. .item {
  443. flex: 0 0 33.33%;
  444. text-align: center;
  445. }
  446. }
  447. }
  448. .nav-warp {
  449. height: 80rpx;
  450. }
  451. .shop-list-nav {
  452. display: flex;
  453. flex-direction: row;
  454. align-items: center;
  455. height: 80rpx;
  456. line-height: 76rpx;
  457. background-color: #333;
  458. &.is-fixed {
  459. position: fixed;
  460. top: 70rpx;
  461. left: 0;
  462. width: 100%;
  463. z-index: 999;
  464. }
  465. /* #ifdef MP-WEIXIN */
  466. &.is-fixed {
  467. top: 0px;
  468. }
  469. /* #endif */
  470. }
  471. .active {
  472. color: #C5AA7B;
  473. }
  474. .nav-item-sort {
  475. flex: 1;
  476. font-size: 24rpx;
  477. color: #999999;
  478. display: flex;
  479. flex-direction: row;
  480. align-items: center;
  481. justify-content: center;
  482. height: 80rpx;
  483. line-height: 80rpx;
  484. }
  485. .nav-item-sort .r {
  486. display: flex;
  487. flex-direction: column;
  488. align-items: center;
  489. justify-content: center;
  490. margin-left: 5rpx;
  491. .arrowDown {
  492. width: 0;
  493. height: 0;
  494. border-width: 10rpx;
  495. border-style: solid;
  496. border-color: #CCCCCC transparent transparent transparent;
  497. margin-top: 2rpx;
  498. }
  499. .arrowUp {
  500. margin-bottom: 2rpx;
  501. width: 0;
  502. height: 0;
  503. border-width: 10rpx;
  504. border-style: solid;
  505. border-color: transparent transparent #CCCCCC transparent;
  506. }
  507. .activeDown {
  508. border-color: #C5AA7B transparent transparent transparent;
  509. }
  510. .activeUp {
  511. border-color: transparent transparent #C5AA7B transparent;
  512. }
  513. }
  514. </style>