index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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" :style="{'color': getTheme.color}">最低¥
  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" :style="{'color': getTheme.color, 'border-color': getTheme.border}">立即参与</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: [],
  72. args: false,
  73. page: 1,
  74. load: false,
  75. banner_list: null,
  76. title: '砍价',
  77. }
  78. },
  79. // #ifdef MP
  80. onShareAppMessage() {
  81. return this.$shareAppMessage({
  82. title: this.title,
  83. path: '/plugins/bargain/index/index',
  84. params: {}
  85. });
  86. },
  87. // #endif
  88. // #ifdef MP-WEIXIN
  89. onShareTimeline() {
  90. // 分享朋友圈beta
  91. return this.$shareTimeline({
  92. title: this.title
  93. });
  94. },
  95. // #endif
  96. onLoad() { this.$commonLoad.onload();
  97. const self = this;
  98. self.$request({
  99. url: self.$api.bargain.banner,
  100. }).then(info => {
  101. if (info.code === 0) {
  102. self.banner_list = info.data.list;
  103. }
  104. })
  105. // #ifdef MP-WEIXIN
  106. wx.showShareMenu({
  107. menus: ['shareAppMessage', 'shareTimeline']
  108. })
  109. // #endif
  110. },
  111. onShow: function () {
  112. const self = this;
  113. self.$showLoading();
  114. self.$request({
  115. url: self.$api.bargain.goods_list,
  116. }).then(info => {
  117. self.$hideLoading();
  118. if (info.code === 0) {
  119. self.list = info.data.list;
  120. }
  121. self.args = false;
  122. self.page = 1;
  123. }).catch(e => {
  124. self.$hideLoading();
  125. })
  126. },
  127. onReachBottom: function () {
  128. const self = this;
  129. if (self.args || self.load)
  130. return;
  131. self.load = true;
  132. let page = self.page + 1;
  133. self.$request({
  134. url: self.$api.bargain.goods_list,
  135. data: {
  136. page: page,
  137. }
  138. }).then(info => {
  139. if (info.code === 0) {
  140. [self.page, self.args, self.list] = [page, info.data.list.length === 0, self.list.concat(info.data.list)];
  141. }
  142. self.load = false;
  143. });
  144. },
  145. methods: {
  146. goods(data) {
  147. uni.navigateTo({
  148. url: '/plugins/bargain/goods/goods?goods_id=' + data.goods_id,
  149. });
  150. }
  151. }
  152. }
  153. </script>
  154. <style scoped lang="scss">
  155. .list {
  156. height: #{220rpx};
  157. }
  158. .bargain-end {
  159. margin-top: #{16rpx}
  160. }
  161. .bargain-end > view {
  162. padding: #{24rpx};
  163. background: #ffffff;
  164. border-bottom: #{1rpx solid #e2e2e2};
  165. }
  166. .bargain-end >view:last-child {
  167. border-bottom: none;
  168. }
  169. .bargain-left {
  170. position: relative;
  171. image {
  172. width: #{220rpx};
  173. height: #{220rpx};
  174. display: block;
  175. }
  176. .sold-out {
  177. position: absolute;
  178. top: 0;
  179. left: 0;
  180. z-index: 1;
  181. width: #{220rpx};
  182. height: #{220rpx};
  183. background-color: rgba(0,0,0,.5);
  184. }
  185. }
  186. .bargain-right {
  187. margin-left: #{24rpx};
  188. width: 100%;
  189. .bargain-name {
  190. font-size: #{32rpx};
  191. color: #353535;
  192. word-break: break-all;
  193. text-overflow: ellipsis;
  194. display: -webkit-box;
  195. -webkit-box-orient: vertical;
  196. -webkit-line-clamp: 1;
  197. line-height: 1.5;
  198. overflow: hidden;
  199. }
  200. .num {
  201. }
  202. .num > view {
  203. color: #999999;
  204. font-size: #{24rpx};
  205. margin-right: #{16rpx};
  206. }
  207. .avatar {
  208. margin-left: -8rpx;
  209. border: 1px solid #ffffff;
  210. height: #{34rpx};
  211. width: #{34rpx};
  212. border-radius: 50%;
  213. }
  214. .user {
  215. margin-right: #{16rpx};
  216. }
  217. .bargain-original {
  218. font-size: #{24rpx};
  219. color: #999999;
  220. text-decoration: line-through;
  221. }
  222. .min-price {
  223. margin-bottom: #{8rpx};
  224. }
  225. .bargain-price-title {
  226. line-height: 1;
  227. font-size: #{28rpx};
  228. }
  229. .bargain-price {
  230. margin-top: #{16rpx};
  231. font-size: #{48rpx};
  232. }
  233. }
  234. .red-btn {
  235. font-size: #{28rpx};
  236. line-height: #{64rpx};
  237. text-align: center;
  238. height: #{64rpx};
  239. border-radius: #{33rpx};
  240. border: #{1rpx} solid;
  241. width: #{176rpx};
  242. }
  243. </style>