bargain.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view>
  3. <view class="default" v-if="isIframe && !bargList.length">
  4. <text>{{ $t(`砍价模块,暂无数据`) }}</text>
  5. </view>
  6. <view class="combination index-wrapper" v-if="bargList.length && isShow && !isIframe && $permission('bargain')">
  7. <view class="title acea-row row-between-wrapper index-wrapper">
  8. <view class="text">
  9. <view class="name line1">{{ $t(`砍价活动`) }}</view>
  10. <view class="line1">{{ $t(`呼朋唤友来砍价`) }}</view>
  11. </view>
  12. <navigator class="more" url="/pages/activity/goods_combination/index" hover-class="none">
  13. {{ $t(`更多`) }}
  14. <text class="iconfont icon-jiantou"></text>
  15. </navigator>
  16. </view>
  17. <view class="conter">
  18. <scroll-view scroll-x="true" style="white-space: nowrap; vertical-align: middle" show-scrollbar="false">
  19. <view class="itemCon" v-for="(item, index) in bargList" :key="index" @click="bargDetail(item)">
  20. <view class="item">
  21. <view class="pictrue">
  22. <image :src="item.image"></image>
  23. </view>
  24. <view class="name line1">{{ item.title }}</view>
  25. <view class="money">
  26. <view class="x_money">
  27. {{ $t(`¥`) }}
  28. <text class="num">{{ item.min_price }}</text>
  29. </view>
  30. <view class="y_money">{{ $t(`¥`) }}{{ item.ot_price }}</view>
  31. </view>
  32. </view>
  33. </view>
  34. </scroll-view>
  35. </view>
  36. </view>
  37. <view class="combination index-wrapper" v-if="bargList.length && isIframe">
  38. <view class="title acea-row row-between-wrapper index-wrapper">
  39. <view class="text">
  40. <view class="name line1">{{ $t(`砍价活动`) }}</view>
  41. <view class="line1">{{ $t(`呼朋唤友来砍价`) }}</view>
  42. </view>
  43. <navigator class="more">
  44. {{ $t(`更多`) }}
  45. <text class="iconfont icon-jiantou"></text>
  46. </navigator>
  47. </view>
  48. <view class="conter">
  49. <scroll-view scroll-x="true" style="white-space: nowrap; vertical-align: middle" show-scrollbar="false">
  50. <view class="itemCon" v-for="(item, index) in bargList" :key="index" @click="bargDetail(item)">
  51. <view class="item">
  52. <view class="pictrue">
  53. <image :src="item.image"></image>
  54. </view>
  55. <view class="name line1">{{ item.title }}</view>
  56. <view class="money">
  57. <view class="x_money">
  58. <text class="num">{{ item.min_price }}</text>
  59. </view>
  60. <view class="y_money">¥{{ item.ot_price }}</view>
  61. </view>
  62. </view>
  63. </view>
  64. </scroll-view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. let app = getApp();
  71. import { toLogin } from '@/libs/login.js';
  72. import { mapGetters } from 'vuex';
  73. import { goPage } from '@/libs/order.js';
  74. import { getHomeProducts } from '@/api/store.js';
  75. export default {
  76. name: 'bargain',
  77. props: {
  78. dataConfig: {
  79. type: Object,
  80. default: () => {}
  81. }
  82. },
  83. computed: {
  84. ...mapGetters(['isLogin', 'uid'])
  85. },
  86. watch: {
  87. dataConfig: {
  88. immediate: true,
  89. handler(nVal, oVal) {
  90. if (nVal) {
  91. this.isShow = nVal.isShow.val;
  92. this.selectType = nVal.tabConfig.tabVal;
  93. this.$set(this, 'selectId', nVal.selectConfig.activeValue || '');
  94. this.$set(this, 'type', nVal.titleInfo.type);
  95. this.salesOrder = nVal.goodsSort.type == 1 ? 'desc' : '';
  96. this.newsOrder = nVal.goodsSort.type == 2 ? 'news' : '';
  97. this.ids = nVal.ids ? nVal.ids.join(',') : '';
  98. this.numConfig = nVal.numConfig.val;
  99. this.productslist();
  100. }
  101. }
  102. }
  103. },
  104. data() {
  105. return {
  106. bargList: [],
  107. name: this.$options.name, //component组件固定写法获取当前name;
  108. isIframe: app.globalData.isIframe, //判断是前台还是后台;
  109. isShow: true, //判断此模块是否显示;
  110. selectType: 0,
  111. selectId: '',
  112. salesOrder: '',
  113. newsOrder: '',
  114. ids: '',
  115. page: 1,
  116. limit: this.$config.LIMIT,
  117. type: '',
  118. numConfig: 0
  119. };
  120. },
  121. created() {},
  122. mounted() {},
  123. methods: {
  124. // 产品列表
  125. productslist: function () {
  126. let that = this;
  127. let data = {};
  128. if (that.selectType) {
  129. data = {
  130. page: that.page,
  131. limit: that.limit,
  132. type: that.type,
  133. ids: that.ids,
  134. selectType: that.selectType
  135. };
  136. } else {
  137. data = {
  138. page: that.page,
  139. limit: that.numConfig <= that.limit ? that.numConfig : that.limit,
  140. type: that.type,
  141. newsOrder: that.newsOrder,
  142. salesOrder: that.salesOrder,
  143. selectId: that.selectId,
  144. selectType: that.selectType
  145. };
  146. }
  147. getHomeProducts(data)
  148. .then((res) => {
  149. that.bargList = res.data.list;
  150. })
  151. .catch((err) => {
  152. that.$util.Tips({ title: err });
  153. });
  154. },
  155. bargDetail(item) {
  156. goPage(item).then((res) => {
  157. if (!this.isLogin) {
  158. toLogin();
  159. } else {
  160. uni.navigateTo({
  161. url: `/pages/activity/goods_bargain_details/index?id=${item.id}&bargain=${this.uid}`
  162. });
  163. }
  164. });
  165. }
  166. }
  167. };
  168. </script>
  169. <style lang="scss">
  170. .default {
  171. width: 690rpx;
  172. height: 300rpx;
  173. border-radius: 14rpx;
  174. margin: 26rpx auto 0 auto;
  175. background-color: #ccc;
  176. text-align: center;
  177. line-height: 300rpx;
  178. .iconfont {
  179. font-size: 50rpx;
  180. }
  181. }
  182. .combination {
  183. width: 100%;
  184. // height: 288rpx;
  185. background-color: $uni-bg-color;
  186. border-radius: 14rpx;
  187. .conter {
  188. width: 690rpx;
  189. height: 320rpx;
  190. background-color: #ffffff;
  191. border-radius: 12px;
  192. margin: 26rpx auto 0 auto;
  193. .itemCon {
  194. display: inline-block;
  195. width: 174rpx;
  196. margin-right: 24rpx;
  197. .item {
  198. width: 100%;
  199. .pictrue {
  200. width: 100%;
  201. height: 174rpx;
  202. border-radius: 6rpx;
  203. image {
  204. width: 100%;
  205. height: 100%;
  206. border-radius: 6rpx;
  207. }
  208. }
  209. .name {
  210. font-size: 24rpx;
  211. color: #333333;
  212. margin-top: 10rpx;
  213. }
  214. .money {
  215. .y_money {
  216. font-size: 20rpx;
  217. color: #999999;
  218. text-decoration: line-through;
  219. }
  220. .x_money {
  221. color: #fd502f;
  222. font-size: 24rpx;
  223. font-weight: bold;
  224. margin-top: 3rpx;
  225. .num {
  226. font-size: 28rpx;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. }
  234. </style>