bargainingList.vue 9.0 KB

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