index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <app-layout>
  3. <app-swiper :height="280" :list="banner_list" :autoplay="true" name="pic_url"></app-swiper>
  4. <view class="bargain-end">
  5. <view v-for="(v,k) in list" class="dir-left-nowrap" :key="k">
  6. <view class="bargain-left">
  7. <image load-lazy :src="v.cover_pic"></image>
  8. <view v-if="v.stock == 0" class="sold-out">
  9. <image :src="appSetting.is_use_stock == '1' ? appImg.plugins_out : appSetting.sell_out_pic"></image>
  10. </view>
  11. </view>
  12. <view @click="goods(v)" class="bargain-right">
  13. <view class="dir-top-nowrap list">
  14. <view class="bargain-name box-grow-0">{{v.name}}</view>
  15. <view class="dir-left-nowrap num box-grow-1 cross-center">
  16. <view class="dir-left-nowrap user box-grow-0">
  17. <block v-for="(v1,k1) in v.user_list" :key="k1" v-if="k1 < 3">
  18. <image class="avatar" :src="v1.avatar" load-lazy></image>
  19. </block>
  20. </view>
  21. <view class="box-grow-1">{{v.sales}}人已参与</view>
  22. </view>
  23. <view class="dir-left-nowrap cross-bottom box-grow-0 min-price">
  24. <view class="box-grow-1 dir-top-nowrap">
  25. <view class="bargain-original">¥{{v.price}}</view>
  26. <view class="bargain-price-title" :class="getTheme + '-m-text ' + getTheme">最低¥
  27. <text class="bargain-price">{{v.min_price}}</text>
  28. </view>
  29. </view>
  30. <view v-if="v.status == 0 || v.stock == 0">
  31. <app-button width="180" font-size="28" background="#cdcdcd" height="64" color="#FFFFFF"
  32. round
  33. disabled>下次再来
  34. </app-button>
  35. </view>
  36. <view v-else class="box-grow-0">
  37. <view class="red-btn" :class="getTheme + '-m-text ' + getTheme + '-m-border ' + getTheme">立即参与</view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <app-load-text v-if="load"></app-load-text>
  44. </view>
  45. <view>
  46. <common-buttom :theme="getTheme" status="index"></common-buttom>
  47. </view>
  48. </app-layout>
  49. </template>
  50. <script>
  51. import appSwiper from "../../../components/page-component/app-swiper/app-swiper.vue";
  52. import commonButtom from "../common-buttom.vue";
  53. import appIphoneX from '../../../components/basic-component/app-iphone-x/app-iphone-x.vue';
  54. import appEmptyBottom from '../../../components/basic-component/app-empty-bottom/app-empty-bottom.vue';
  55. import { mapState, mapGetters } from 'vuex';
  56. export default {
  57. name: "index",
  58. components: {appSwiper, commonButtom, appEmptyBottom, appIphoneX},
  59. computed: {
  60. ...mapGetters('mallConfig',{
  61. getVideo: 'getVideo',
  62. getTheme: 'getTheme',
  63. }),
  64. ...mapState({
  65. appImg: state => state.mallConfig.__wxapp_img.mall,
  66. appSetting: state => state.mallConfig.mall.setting,
  67. })
  68. },
  69. data() {
  70. return {
  71. list: null,
  72. args: false,
  73. page: 1,
  74. load: false,
  75. banner_list: null,
  76. title: '砍价',
  77. }
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. return this.$shareAppMessage({
  84. title: this.title,
  85. path: '/plugins/bargain/index/index',
  86. params: {}
  87. });
  88. },
  89. // #ifdef MP-WEIXIN
  90. onShareTimeline() {
  91. // 分享朋友圈beta
  92. return this.$shareTimeline({
  93. title: this.title,
  94. query: {
  95. } // 此处填写页面的参数
  96. });
  97. },
  98. // #endif
  99. /**
  100. * 生命周期函数--监听页面加载
  101. */
  102. onLoad: function () {
  103. const self = this;
  104. self.$request({
  105. url: self.$api.bargain.banner,
  106. }).then(info => {
  107. if (info.code === 0) {
  108. self.banner_list = info.data.list;
  109. }
  110. })
  111. // #ifdef MP-WEIXIN
  112. wx.showShareMenu({
  113. menus: ['shareAppMessage', 'shareTimeline']
  114. })
  115. // #endif
  116. },
  117. onShow: function () {
  118. const self = this;
  119. self.$showLoading();
  120. self.$request({
  121. url: self.$api.bargain.goods_list,
  122. }).then(info => {
  123. self.$hideLoading();
  124. if (info.code === 0) {
  125. self.list = info.data.list;
  126. }
  127. self.args = false;
  128. self.page = 1;
  129. }).catch(e => {
  130. self.$hideLoading();
  131. })
  132. },
  133. onReachBottom: function () {
  134. const self = this;
  135. if (self.args || self.load)
  136. return;
  137. self.load = true;
  138. let page = self.page + 1;
  139. self.$request({
  140. url: self.$api.bargain.goods_list,
  141. data: {
  142. page: page,
  143. }
  144. }).then(info => {
  145. if (info.code === 0) {
  146. [self.page, self.args, self.list] = [page, info.data.list.length === 0, self.list.concat(info.data.list)];
  147. }
  148. self.load = false;
  149. });
  150. },
  151. methods: {
  152. goods(data) {
  153. uni.navigateTo({
  154. url: '/plugins/bargain/goods/goods?goods_id=' + data.goods_id,
  155. });
  156. }
  157. }
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. .list {
  162. height: #{220rpx};
  163. }
  164. .bargain-end {
  165. margin-top: #{16rpx}
  166. }
  167. .bargain-end > view {
  168. padding: #{24rpx};
  169. background: #ffffff;
  170. border-bottom: #{1rpx solid #e2e2e2};
  171. }
  172. .bargain-end >view:last-child {
  173. border-bottom: none;
  174. }
  175. .bargain-left {
  176. position: relative;
  177. image {
  178. width: #{220rpx};
  179. height: #{220rpx};
  180. display: block;
  181. }
  182. .sold-out {
  183. position: absolute;
  184. top: 0;
  185. left: 0;
  186. z-index: 1;
  187. width: #{220rpx};
  188. height: #{220rpx};
  189. background-color: rgba(0,0,0,.5);
  190. }
  191. }
  192. .bargain-right {
  193. margin-left: #{24rpx};
  194. width: 100%;
  195. .bargain-name {
  196. font-size: #{32rpx};
  197. color: #353535;
  198. word-break: break-all;
  199. text-overflow: ellipsis;
  200. display: -webkit-box;
  201. -webkit-box-orient: vertical;
  202. -webkit-line-clamp: 1;
  203. line-height: 1.5;
  204. overflow: hidden;
  205. }
  206. .num {
  207. }
  208. .num > view {
  209. color: #999999;
  210. font-size: #{24rpx};
  211. margin-right: #{16rpx};
  212. }
  213. .avatar {
  214. margin-left: -8rpx;
  215. border: 1px solid #ffffff;
  216. height: #{34rpx};
  217. width: #{34rpx};
  218. border-radius: 50%;
  219. }
  220. .user {
  221. margin-right: #{16rpx};
  222. }
  223. .bargain-original {
  224. font-size: #{24rpx};
  225. color: #999999;
  226. text-decoration: line-through;
  227. }
  228. .min-price {
  229. margin-bottom: #{8rpx};
  230. }
  231. .bargain-price-title {
  232. line-height: 1;
  233. font-size: #{28rpx};
  234. }
  235. .bargain-price {
  236. margin-top: #{16rpx};
  237. font-size: #{48rpx};
  238. }
  239. }
  240. .red-btn {
  241. font-size: #{28rpx};
  242. line-height: #{64rpx};
  243. text-align: center;
  244. height: #{64rpx};
  245. border-radius: #{33rpx};
  246. border: #{1rpx} solid;
  247. width: #{176rpx};
  248. }
  249. </style>