You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

464 lines
12 KiB

3 months ago
  1. <template>
  2. <view :data-theme="theme">
  3. <view class="pageInfo">
  4. <skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
  5. ></skeleton>
  6. <view class='bargain-list skeleton' :style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
  7. <!-- #ifdef H5 -->
  8. <view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+ (navH/2) +'rpx'" v-if="returnShow">
  9. </view>
  10. <!-- #endif -->
  11. <view class='header skeleton-rect' :style="{backgroundImage:'url('+imgHost+backBg+')'}" v-show="imgHost">
  12. <view class="pic">
  13. <view class='swipers skeleton-rect'>
  14. <swiper :indicator-dots="indicatorDots" :autoplay="autoplay" interval="2500" duration="500" vertical="true"
  15. circular="true">
  16. <block v-for="(item,index) in bargainSuccessList" :key='index'>
  17. <swiper-item >
  18. <view class="acea-row row-middle">
  19. <image :src="item.avatar" class="mr9"></image>
  20. <view class='mr9 nickName'>{{$util.formatName(item.nickName)}}</view>
  21. <text class='mr9'>拿了</text>
  22. <view class='line1'>{{item.title}}</view>
  23. </view>
  24. </swiper-item>
  25. </block>
  26. </swiper>
  27. </view>
  28. </view>
  29. <view class="tit" v-show="bargainTotal > 0">已有{{bargainTotal}}人砍成功</view>
  30. </view>
  31. <view class='list' v-if="bargainList.length">
  32. <block v-for="(item,index) in bargainList" :key="index">
  33. <view class='item acea-row row-between-wrapper'
  34. @tap="openSubscribe('/pages/activity/goods_bargain_details/index?id='+ item.id +'&startBargainUid='+ uid)">
  35. <view class='pictrue skeleton-rect'>
  36. <image :src='item.image'></image>
  37. </view>
  38. <view class='text acea-row row-column-around'>
  39. <view class='name line2 skeleton-rect'>{{item.title}}</view>
  40. <view v-if="item.quota>0" class="acea-row skeleton-rect" style="margin-bottom: 14rpx;">
  41. <countDown :tipText="' '" :bgColor="bgColor" :dayText="':'" :hourText="':'"
  42. :minuteText="':'" :secondText="' '" :datatime="item.stopTime/1000" :isDay="true"
  43. ></countDown>
  44. <text class="txt">后结束</text>
  45. </view>
  46. <view v-if="new Date().getTime()- item.stopTime >=0">
  47. <view style="font-size: 22rpx;" @tap='currentBargainUser'>已结束</view>
  48. </view>
  49. <view v-if="item.quota==0">
  50. <view style="font-size: 22rpx;" @tap='currentBargainUser'>已售罄</view>
  51. </view>
  52. <!-- <view class='num'><text class='iconfont icon-pintuan'></text>{{item.countPeopleAll}}人正在参与
  53. </view> -->
  54. <view class='money skeleton-rect'>最低: <text :style="[{'font-size':item.minPrice.length>=7?'32rpx':'38rpx'}]" class='price'>{{item.minPrice}}</text></view>
  55. </view>
  56. <view v-if="item.quota>0" class='cutBnt bg_color'>参与砍价</view>
  57. <view v-if="item.quota==0" class='cutBnt bg-color-hui'>已售罄</view>
  58. </view>
  59. </block>
  60. <view class='loadingicon acea-row row-center-wrapper' v-if='bargainList.length > 0' style="color: #fff;">
  61. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  62. </view>
  63. </view>
  64. <view v-else class="flex-center no_shop">
  65. <image :src="urlDomain+'crmebimage/perset/staticImg/noShopper.png'" mode="aspectFit" style="width: 400rpx;"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. let app = getApp();
  73. import {
  74. getBargainList,
  75. bargainHeaderApi
  76. } from '@/api/activity.js';
  77. import {
  78. openBargainSubscribe
  79. } from '@/utils/SubscribeMessage.js';
  80. import countDown from '@/components/countDown';
  81. import {
  82. toLogin
  83. } from '@/libs/login.js';
  84. import {
  85. mapGetters
  86. } from "vuex";
  87. import animationType from '@/utils/animationType.js'
  88. export default {
  89. components: {
  90. countDown
  91. },
  92. data() {
  93. return {
  94. urlDomain: this.$Cache.get("imgHost"),
  95. showSkeleton: true, //骨架屏显示隐藏
  96. isNodes: 0, //控制什么时候开始抓取元素节点,只要数值改变就重新抓取
  97. bgColor: {
  98. 'bgColor': '#E93323',
  99. 'Color': '#fff',
  100. 'width': '44rpx',
  101. 'timeTxtwidth': '16rpx',
  102. 'isDay': true
  103. },
  104. bargainList: [],
  105. page: 1,
  106. limit: 10,
  107. loading: false,
  108. loadend: false,
  109. navH: '',
  110. isAuto: false, //没有授权的不会自动授权
  111. isShowAuth: false, //是否隐藏授权
  112. returnShow: true,
  113. loadTitle: '加载更多',
  114. bargainSuccessList: [],
  115. bargainTotal: 0,
  116. indicatorDots: false,
  117. autoplay: true,
  118. theme:app.globalData.theme,
  119. imgHost:'',
  120. backBg:'crmebimage/perset/bargain_header/bargain_header1.jpg',
  121. navBgColor:'#e93323'
  122. };
  123. },
  124. computed: mapGetters(['isLogin', 'uid']),
  125. watch: {
  126. isLogin: {
  127. handler: function(newV, oldV) {
  128. if (newV) {
  129. this.getBargainList();
  130. this.getBargainHeader();
  131. }
  132. },
  133. deep: true
  134. }
  135. },
  136. onLoad: function(options) {
  137. let that = this;
  138. that.$set(that,'imgHost',that.$Cache.get('imgHost'));
  139. switch (app.globalData.theme) {
  140. case 'theme1':
  141. that.backBg = 'crmebimage/perset/bargain_header/bargain_header1.jpg';
  142. that.bgColor.bgColor = '#e93323';
  143. that.navBgColor = '#e93323';
  144. break;
  145. case 'theme2':
  146. that.backBg = 'crmebimage/perset/bargain_header/bargain_header2.jpg';
  147. that.bgColor.bgColor = '#FE5C2D';
  148. that.navBgColor = '#FE5C2D';
  149. break;
  150. case 'theme3':
  151. that.backBg = 'crmebimage/perset/bargain_header/bargain_header3.jpg';
  152. that.bgColor.bgColor = '#42CA4D';
  153. that.navBgColor = '#42CA4D';
  154. break;
  155. case 'theme4':
  156. that.backBg = 'crmebimage/perset/bargain_header/bargain_header4.jpg';
  157. that.bgColor.bgColor = '#1DB0FC';
  158. that.navBgColor = '#1DB0FC';
  159. break;
  160. case 'theme5':
  161. that.backBg = 'crmebimage/perset/bargain_header/bargain_header5.jpg';
  162. that.bgColor.bgColor = '#FF448F';
  163. that.navBgColor = '#FF448F';
  164. break;
  165. }
  166. uni.setNavigationBarColor({
  167. frontColor: '#ffffff',
  168. backgroundColor:that.navBgColor,
  169. });
  170. setTimeout(() => {
  171. this.isNodes++;
  172. }, 500);
  173. var pages = getCurrentPages();
  174. this.returnShow = pages.length === 1 ? false : true;
  175. uni.setNavigationBarTitle({
  176. title: "砍价列表"
  177. })
  178. this.navH = app.globalData.navHeight;
  179. this.getBargainList();
  180. this.getBargainHeader();
  181. },
  182. methods: {
  183. getBargainHeader: function() {
  184. bargainHeaderApi().then(res => {
  185. this.bargainTotal = res.data.bargainTotal;
  186. this.bargainSuccessList = res.data.bargainSuccessList;
  187. }).catch(err => {
  188. return this.$util.Tips({
  189. title: err
  190. });
  191. })
  192. },
  193. // 授权关闭
  194. authColse: function(e) {
  195. this.isShowAuth = e
  196. },
  197. goBack: function() {
  198. uni.switchTab({
  199. url:'/pages/index/index'
  200. })
  201. },
  202. openSubscribe: function(e) {
  203. let page = e;
  204. // #ifndef MP
  205. uni.navigateTo({
  206. animationType: animationType.type, animationDuration: animationType.duration,
  207. url: page
  208. });
  209. // #endif
  210. // #ifdef MP
  211. uni.showLoading({
  212. title: '正在加载',
  213. })
  214. openBargainSubscribe().then(res => {
  215. uni.hideLoading();
  216. uni.navigateTo({
  217. url: page,
  218. });
  219. }).catch((err) => {
  220. uni.hideLoading();
  221. });
  222. // #endif
  223. },
  224. getBargainList: function() {
  225. let that = this;
  226. if (that.loadend) return;
  227. if (that.loading) return;
  228. that.loading = true;
  229. that.loadTitle = '';
  230. getBargainList({
  231. page: that.page,
  232. limit: that.limit
  233. }).then(function(res) {
  234. let list = res.data.list;
  235. let bargainList = that.$util.SplitArray(list, that.bargainList);
  236. let loadend = list.length < that.limit;
  237. that.loadend = loadend;
  238. that.loading = false;
  239. // #ifdef H5
  240. that.setShare();
  241. // #endif
  242. that.loadTitle = loadend ? '已全部加载' : '加载更多';
  243. that.$set(that, 'bargainList', bargainList);
  244. that.$set(that, 'page', that.page + 1);
  245. setTimeout(() => {
  246. that.showSkeleton = false
  247. }, 1000)
  248. }).catch(res => {
  249. that.loading = false;
  250. that.loadTitle = '加载更多';
  251. });
  252. },
  253. setShare: function() {
  254. this.$wechat.isWeixin() &&
  255. this.$wechat.wechatEvevt([
  256. "updateAppMessageShareData",
  257. "updateTimelineShareData",
  258. "onMenuShareAppMessage",
  259. "onMenuShareTimeline"
  260. ], {
  261. desc: this.bargainList[0].title,
  262. title: this.bargainList[0].title,
  263. link: location.href,
  264. imgUrl:this.bargainList[0].image
  265. }).then(res => {
  266. }).catch(err => {
  267. console.log(err);
  268. });
  269. },
  270. },
  271. onReachBottom: function() {
  272. this.getBargainList();
  273. },
  274. }
  275. </script>
  276. <style lang="scss">
  277. page {
  278. @include main_bg_color(theme);
  279. min-height: 100%;
  280. }
  281. </style>
  282. <style lang="scss" scoped>
  283. .pageInfo{
  284. /* #ifdef MP || APP-PLUS */
  285. @include main_bg_color(theme);
  286. /* #endif */
  287. }
  288. .mr9{
  289. margin-right: 9rpx;
  290. }
  291. .swipers {
  292. height: 100%;
  293. width: 76%;
  294. margin: auto;
  295. overflow: hidden;
  296. font-size: 22rpx;
  297. color: #fff;
  298. image{
  299. width: 24rpx;
  300. height: 24rpx;
  301. border-radius: 50%;
  302. overflow: hidden;
  303. }
  304. swiper {
  305. height: 100%;
  306. width: 100%;
  307. overflow: hidden;
  308. }
  309. .line1{
  310. width: 195rpx;
  311. }
  312. }
  313. .bargain-list .icon-xiangzuo {
  314. font-size: 40rpx;
  315. color: #fff;
  316. position: fixed;
  317. left: 30rpx;
  318. z-index: 99;
  319. transform: translateY(-20%);
  320. }
  321. .bargain-list .header {
  322. // @include bargain-list-header(theme);
  323. babackground-repeat: no-repeat;
  324. background-size: 100% 100%;
  325. width: 750rpx;
  326. height: 420rpx;
  327. .acea-row{
  328. height: 50rpx;
  329. line-height: 50rpx;
  330. left: 50rpx;
  331. .nickName{
  332. width: 65rpx;
  333. overflow: hidden;
  334. white-space: nowrap;
  335. }
  336. }
  337. .pic {
  338. width: 478rpx;
  339. height: 50rpx;
  340. margin: 0 auto;
  341. }
  342. .tit {
  343. color: #FFFFFF;
  344. font-size: 24rpx;
  345. font-weight: 400;
  346. text-align: center;
  347. margin-top: 304rpx;
  348. }
  349. }
  350. .bargain-list .list {
  351. padding: 0 30rpx;
  352. }
  353. .bargain-list .list .item {
  354. position: relative;
  355. height: 250rpx;
  356. background-color: #fff;
  357. border-radius: 14rpx;
  358. margin-bottom: 20rpx;
  359. padding: 30rpx 25rpx;
  360. }
  361. .bargain-list .list .item .pictrue {
  362. width: 190rpx;
  363. height: 190rpx;
  364. }
  365. .bargain-list .list .item .pictrue image {
  366. width: 100%;
  367. height: 100%;
  368. border-radius: 14rpx;
  369. }
  370. .bargain-list .list .item .text {
  371. width: 432rpx;
  372. font-size: 28rpx;
  373. color: #333333;
  374. .txt{
  375. font-size: 22rpx;
  376. margin-left: 4rpx;
  377. color: #666666;
  378. line-height: 36rpx;
  379. }
  380. }
  381. .bargain-list .list .item .text .name {
  382. width: 100%;
  383. height: 68rpx;
  384. line-height: 36rpx;
  385. font-size: 28rpx;
  386. margin-bottom: 26rpx;
  387. }
  388. .bargain-list .list .item .text .num {
  389. font-size: 26rpx;
  390. color: #999;
  391. }
  392. .bargain-list .list .item .text .num .iconfont {
  393. font-size: 35rpx;
  394. margin-right: 7rpx;
  395. }
  396. .bargain-list .list .item .text .money {
  397. font-size: 24rpx;
  398. font-weight: bold;
  399. @include price_color(theme);
  400. }
  401. .bargain-list .list .item .text .money .price {
  402. font-size: 38rpx;
  403. }
  404. .bargain-list .list .item .cutBnt {
  405. position: absolute;
  406. width: 162rpx;
  407. height: 52rpx;
  408. border-radius: 50rpx;
  409. font-size: 24rpx;
  410. color: #fff;
  411. text-align: center;
  412. line-height: 52rpx;
  413. right: 24rpx;
  414. bottom: 30rpx;
  415. }
  416. .bg_color{
  417. @include linear-gradient(theme);
  418. }
  419. .bg-color-hui{
  420. background-color: #CDCBCC;
  421. }
  422. .bargain-list .list .item .cutBnt .iconfont {
  423. margin-right: 8rpx;
  424. font-size: 30rpx;
  425. }
  426. .bargain-list .list .load {
  427. font-size: 24rpx;
  428. height: 85rpx;
  429. text-align: center;
  430. line-height: 85rpx;
  431. }
  432. .flex-center{
  433. display: flex;
  434. justify-content: center;
  435. align-items: center;
  436. }
  437. .no_shop{
  438. margin: 0 30rpx 0;
  439. height: 700rpx;
  440. border-radius: 10rpx;
  441. background-color: #fff;
  442. }
  443. .bargain-list{
  444. min-height: 100vh;
  445. }
  446. </style>