bargainingList.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <s-layout title='砍价列表'>
  3. <view style='background-color: red;height:100vh;'>
  4. <view class='bargain-list'>
  5. <!-- #ifdef H5 -->
  6. <view class='iconfont icon-xiangzuo' @tap='goBack' :style="'top:'+ (state.navH/2) +'rpx'"
  7. v-if="state.returnShow">
  8. </view>
  9. <!-- #endif -->
  10. <!-- 砍价记录的概要 -->
  11. <view class='header'>
  12. <view class="pic">
  13. <view class='swipers'>
  14. <swiper :indicator-dots="state.indicatorDots" :autoplay="state.autoplay" interval="2500"
  15. duration="500" vertical="true" circular="true">
  16. <block v-for="(item,index) in state.bargainSuccessList" :key='index'>
  17. <swiper-item>
  18. <view class="acea-row row-middle" style='display:flex'>
  19. <image :src="item.avatar" class="mr9"></image>
  20. <view class='mr9 nickName'>{{ item.nickname }}</view>
  21. <text class='mr9'>拿了</text>
  22. <view class='line1'>{{ item.activityName }}</view>
  23. </view>
  24. </swiper-item>
  25. </block>
  26. </swiper>
  27. </view>
  28. </view>
  29. <view class="tit">已有{{ state.bargainTotal }}人砍成功</view>
  30. </view>
  31. <!-- 砍价活动列表 -->
  32. <view class='list'>
  33. <block v-for="(item,index) in state.bargainList" :key="index">
  34. <view style='display:flex' class='item acea-row row-between-wrapper'
  35. @tap="openSubscribe('/pages/activity/bargainingDetail?id='+ item.id)">
  36. <view class='pictrue'>
  37. <image :src='item.picUrl'></image>
  38. </view>
  39. <view class='text acea-row row-column-around'>
  40. <view class='name line2'>{{ item.name }}</view>
  41. <view class="acea-row" style="margin-bottom: 14rpx;display:flex">
  42. <s-count-down :tipText="' '" :bgColor="state.bgColor" :dayText="':'" :hourText="':'"
  43. :minuteText="':'" :secondText="' '" :datatime="item.endTime / 1000"
  44. :isDay="true" />
  45. <text class="txt">后结束</text>
  46. </view>
  47. <view v-if="item.stock === 0">
  48. <view style="font-size: 22rpx;"
  49. @tap="openSubscribe('/pages/activity/goods_bargain_details/index?id='+ item.id +'&startBargainUid='+ uid)">
  50. 已售罄</view>
  51. </view>
  52. <view class='money font-color'>最低: ¥<text
  53. class='price'>{{ fen2yuan(item.bargainMinPrice) }}</text></view>
  54. </view>
  55. <view v-if="item.stock > 0" class='cutBnt bg-color'>参与砍价</view>
  56. <view v-if="item.stock === 0" class='cutBnt bg-color-hui'>已售罄</view>
  57. </view>
  58. </block>
  59. <view class='loadingicon acea-row row-center-wrapper' v-if='state.bargainList.length > 0'
  60. style='text-align: center;'>
  61. <text class='loading iconfont icon-jiazai' :hidden='!loading'></text>{{state.loadTitle}}
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </s-layout>
  67. </template>
  68. <script setup>
  69. import {
  70. computed,
  71. reactive
  72. } from 'vue';
  73. import sheep from '@/sheep';
  74. import _ from 'lodash';
  75. import {
  76. onLoad,
  77. onReachBottom
  78. } from '@dcloudio/uni-app';
  79. import {
  80. useDurationTime
  81. } from '@/sheep/hooks/useGoods';
  82. import {
  83. showShareModal
  84. } from '@/sheep/hooks/useModal';
  85. import {
  86. isEmpty
  87. } from 'lodash';
  88. const state = reactive({
  89. navH: '',
  90. returnShow: true,
  91. // ========== 砍价记录概要的相关变量 ==========
  92. bargainTotal: 0,
  93. bargainSuccessList: [],
  94. autoplay: true,
  95. indicatorDots: false,
  96. // ========== 砍价活动的相关变量 ==========
  97. bargainList: [],
  98. page: 1,
  99. limit: 10,
  100. loading: false,
  101. loadend: false,
  102. bgColor: {
  103. 'bgColor': '#E93323',
  104. 'Color': '#fff',
  105. 'width': '44rpx',
  106. 'timeTxtwidth': '16rpx',
  107. 'isDay': true
  108. },
  109. loadTitle: '加载更多',
  110. });
  111. function getBargainHeader() {
  112. sheep.$api.activity.getBargainRecordSummary().then(res => {
  113. state.bargainTotal = res.data.successUserCount;
  114. state.bargainSuccessList = res.data.successList;
  115. }).catch(err => {
  116. return state.$util.Tips({
  117. title: err
  118. });
  119. })
  120. }
  121. function getBargainList() {
  122. if (state.loadend || state.loading) {
  123. return;
  124. }
  125. state.loading = true;
  126. state.loadTitle = '';
  127. sheep.$api.activity.getBargainActivityPage({
  128. pageNo: state.page,
  129. pageSize: state.limit
  130. }).then(res => {
  131. const list = res.data.list;
  132. const bargainList = _.concat(state.bargainList, list);
  133. const loadend = list.length < state.limit;
  134. state.loadend = loadend;
  135. state.loading = false;
  136. state.loadTitle = loadend ? '已全部加载' : '加载更多';
  137. // this.$set(this, 'bargainList', bargainList);
  138. state.bargainList = res.data.list
  139. // this.$set(this, 'page', this.page + 1);
  140. state.page = state.page + 1;
  141. }).catch(res => {
  142. state.loading = false;
  143. state.loadTitle = '加载更多';
  144. });
  145. }
  146. function openSubscribe(e) {
  147. console.log(e)
  148. uni.navigateTo({
  149. url: page,
  150. });
  151. return;
  152. let page = e;
  153. // #ifndef MP
  154. uni.navigateTo({
  155. url: page
  156. });
  157. // #endif
  158. // #ifdef MP
  159. uni.showLoading({
  160. title: '正在加载',
  161. })
  162. openBargainSubscribe().then(res => {
  163. uni.hideLoading();
  164. }).catch((err) => {
  165. uni.hideLoading();
  166. });
  167. // #endif
  168. }
  169. onLoad(function() {
  170. getBargainHeader();
  171. getBargainList();
  172. })
  173. onReachBottom(() => {
  174. getBargainList();
  175. });
  176. // 工具函数
  177. function fen2yuan(price) {
  178. return (price / 100.0).toFixed(2)
  179. }
  180. </script>
  181. <style lang='scss' scoped>
  182. page,
  183. .page-app {
  184. background-color: #e93323 !important;
  185. }
  186. .font-color {
  187. color: red;
  188. }
  189. .mr9 {
  190. margin-right: 9rpx;
  191. }
  192. .swipers {
  193. height: 100%;
  194. width: 76%;
  195. margin: auto;
  196. overflow: hidden;
  197. font-size: 22rpx;
  198. color: #fff;
  199. image {
  200. width: 24rpx;
  201. height: 24rpx;
  202. border-radius: 50%;
  203. overflow: hidden;
  204. }
  205. swiper {
  206. height: 100%;
  207. width: 100%;
  208. overflow: hidden;
  209. }
  210. .line1 {
  211. width: 195rpx;
  212. }
  213. }
  214. .bargain-list .icon-xiangzuo {
  215. font-size: 40rpx;
  216. color: #fff;
  217. position: fixed;
  218. left: 30rpx;
  219. z-index: 99;
  220. transform: translateY(-20%);
  221. height: 100%
  222. }
  223. .bargain-list .header {
  224. /* TODO 芋艿:此处原来采用base64 但是过长编辑到小程序卡死 目前采用网络地址 需解决 */
  225. background-image: url('https://huizhizao-1314830814.cos.ap-shanghai.myqcloud.com/huizhizao-1314830814/bdc8a9210710b83bcd88a14703f440fc7091792706b5cb71b54361488a547298.png');
  226. babackground-repeat: no-repeat;
  227. background-size: 100% 100%;
  228. width: 750rpx;
  229. height: 420rpx;
  230. .acea-row {
  231. height: 50rpx;
  232. line-height: 50rpx;
  233. left: 50rpx;
  234. .nickName {
  235. width: 65rpx;
  236. overflow: hidden;
  237. white-space: nowrap;
  238. }
  239. }
  240. .pic {
  241. width: 478rpx;
  242. height: 50rpx;
  243. margin: 0 auto;
  244. /* TODO 芋艿:此处原来是本地地址小程序不支持,需改为线上 */
  245. background-image: url('https://huizhizao-1314830814.cos.ap-shanghai.myqcloud.com/huizhizao-1314830814/d111ac53e1390618f22fcc03e415bcd584b3f409ae52421aef95c2ab9b02aa30.png');
  246. babackground-repeat: no-repeat;
  247. background-size: 100% 100%;
  248. }
  249. .tit {
  250. color: #FFFFFF;
  251. font-size: 24rpx;
  252. font-weight: 400;
  253. text-align: center;
  254. margin-top: 304rpx;
  255. }
  256. }
  257. .bargain-list .list {
  258. padding: 0 30rpx;
  259. }
  260. .bargain-list .list .item {
  261. position: relative;
  262. height: 250rpx;
  263. background-color: #fff;
  264. border-radius: 14rpx;
  265. margin-bottom: 20rpx;
  266. padding: 30rpx 25rpx;
  267. }
  268. .bargain-list .list .item .pictrue {
  269. width: 190rpx;
  270. height: 190rpx;
  271. }
  272. .bargain-list .list .item .pictrue image {
  273. width: 100%;
  274. height: 100%;
  275. border-radius: 14rpx;
  276. }
  277. .bargain-list .list .item .text {
  278. width: 432rpx;
  279. font-size: 28rpx;
  280. color: #333333;
  281. .txt {
  282. font-size: 22rpx;
  283. margin-left: 4rpx;
  284. color: #666666;
  285. line-height: 36rpx;
  286. }
  287. }
  288. .bargain-list .list .item .text .name {
  289. width: 100%;
  290. height: 68rpx;
  291. line-height: 36rpx;
  292. font-size: 28rpx;
  293. margin-bottom: 26rpx;
  294. }
  295. .bargain-list .list .item .text .num {
  296. font-size: 26rpx;
  297. color: #999;
  298. }
  299. .bargain-list .list .item .text .num .iconfont {
  300. font-size: 35rpx;
  301. margin-right: 7rpx;
  302. }
  303. .bargain-list .list .item .text .money {
  304. font-size: 24rpx;
  305. font-weight: bold;
  306. }
  307. .bargain-list .list .item .text .money .price {
  308. font-size: 38rpx;
  309. }
  310. .bargain-list .list .item .cutBnt {
  311. position: absolute;
  312. width: 162rpx;
  313. height: 52rpx;
  314. border-radius: 50rpx;
  315. font-size: 24rpx;
  316. color: #fff;
  317. text-align: center;
  318. line-height: 52rpx;
  319. right: 24rpx;
  320. bottom: 30rpx;
  321. background: linear-gradient(90deg, #FF7931 0%, #E93323 100%);
  322. }
  323. .bargain-list .list .item .cutBnt .iconfont {
  324. margin-right: 8rpx;
  325. font-size: 30rpx;
  326. }
  327. .bargain-list .list .load {
  328. font-size: 24rpx;
  329. height: 85rpx;
  330. text-align: center;
  331. line-height: 85rpx;
  332. }
  333. </style>