list.vue 8.6 KB

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