newGoods.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="">
  3. <view class="index-wrapper" :style="colorStyle">
  4. <view class='wrapper' v-if="isShow && firstList.length">
  5. <view class='title acea-row row-between-wrapper'>
  6. <view class='text'>
  7. <view class='name line1'>
  8. {{titleInfo[0].val}}
  9. <!-- <text class='new font-color'>NEW~</text> -->
  10. </view>
  11. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  12. </view>
  13. <view class='more' @click="gopage(titleInfo[2].val)">
  14. 更多
  15. <text class='iconfont icon-jiantou'></text>
  16. </view>
  17. </view>
  18. <view class='newProducts'>
  19. <scroll-view class="scroll-view_x" scroll-x style="width:auto;overflow:hidden;">
  20. <block v-for="(item,index) in firstList" :key='index'>
  21. <view class='item' @click="goDetail(item)">
  22. <view class='img-box'>
  23. <image :src='item.image'></image>
  24. <text class="pictrue_log_medium pictrue_log_class"
  25. v-if="item.activity && item.activity.type ==='1'">
  26. 秒杀
  27. </text>
  28. <text class="pictrue_log_medium pictrue_log_class"
  29. v-if="item.activity && item.activity.type === '2'">
  30. 砍价
  31. </text>
  32. <text class="pictrue_log_medium pictrue_log_class"
  33. v-if="item.activity && item.activity.type === '3'">
  34. 拼团
  35. </text>
  36. </view>
  37. <view class='pro-info line1'>{{item.store_name}}</view>
  38. <view class='money font-color'>¥{{item.price}}</view>
  39. </view>
  40. </block>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. <view class='wrapper' v-if="!isShow && isIframe && firstList.length">
  45. <view class='title acea-row row-between-wrapper'>
  46. <view class='text'>
  47. <view class='name line1'>
  48. {{titleInfo[0].val}}
  49. </view>
  50. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  51. </view>
  52. <view class='more' @click="gopage(titleInfo[2].val)">
  53. 更多
  54. <text class='iconfont icon-jiantou'></text>
  55. </view>
  56. </view>
  57. <view class='newProducts'>
  58. <scroll-view class="scroll-view_x" scroll-x style="width:auto;overflow:hidden;">
  59. <block v-for="(item,index) in firstList" :key='index'>
  60. <view class='item' @click="goDetail(item)">
  61. <view class='img-box'>
  62. <image :src='item.image'></image>
  63. <text class="pictrue_log_medium pictrue_log_class"
  64. v-if="item.activity && item.activity.type ==='1'">
  65. 秒杀
  66. </text>
  67. <text class="pictrue_log_medium pictrue_log_class"
  68. v-if="item.activity && item.activity.type === '2'">
  69. 砍价
  70. </text>
  71. <text class="pictrue_log_medium pictrue_log_class"
  72. v-if="item.activity && item.activity.type === '3'">
  73. 拼团
  74. </text>
  75. </view>
  76. <view class='pro-info line1'>{{item.store_name}}</view>
  77. <view class='money font-color'>¥{{item.price}}</view>
  78. </view>
  79. </block>
  80. </scroll-view>
  81. </view>
  82. </view>
  83. <view class='wrapper' v-if="isIframe && !firstList.length">
  84. <view class='title acea-row row-between-wrapper'>
  85. <view class='text'>
  86. <view class='name line1'>
  87. {{titleInfo[0].val}}
  88. </view>
  89. <view class='line1 txt-btn'>{{titleInfo[1].val}}</view>
  90. </view>
  91. <view class='more' @click="gopage(titleInfo[2].val)">
  92. 更多
  93. <text class='iconfont icon-jiantou'></text>
  94. </view>
  95. </view>
  96. <view class='newProducts'>
  97. <view class="empty-img">首发新品,暂无数据</view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. let app = getApp()
  105. import {
  106. goPage,
  107. goShopDetail
  108. } from '@/libs/order.js'
  109. import {
  110. mapState,
  111. mapGetters
  112. } from 'vuex';
  113. import {
  114. getHomeProducts
  115. } from '@/api/store.js';
  116. import colors from "@/mixins/color";
  117. export default {
  118. name: 'goodList',
  119. mixins: [colors],
  120. props: {
  121. dataConfig: {
  122. type: Object,
  123. default: () => {}
  124. }
  125. },
  126. computed: {
  127. ...mapGetters(['uid']),
  128. },
  129. watch: {
  130. dataConfig: {
  131. immediate: true,
  132. handler(nVal, oVal) {
  133. if (nVal) {
  134. this.isShow = nVal.isShow.val;
  135. this.selectType = nVal.tabConfig.tabVal;
  136. this.$set(this, 'selectId', nVal.selectConfig.activeValue);
  137. this.$set(this, 'type', nVal.selectSortConfig.activeValue);
  138. this.salesOrder = nVal.goodsSort.type == 1 ? 'desc' : '';
  139. this.newsOrder = nVal.goodsSort.type == 2 ? 'news' : '';
  140. this.ids = nVal.ids ? nVal.ids.join(',') : '';
  141. this.numConfig = nVal.numConfig.val;
  142. this.titleInfo = nVal.titleInfo.list;
  143. this.productslist();
  144. }
  145. }
  146. }
  147. },
  148. created() {},
  149. mounted() {},
  150. data() {
  151. return {
  152. firstList: [],
  153. firstInfo: "多个优质商品最新上架",
  154. name: this.$options.name,
  155. isShow: true,
  156. isIframe: app.globalData.isIframe,
  157. selectType: 0,
  158. selectId: '',
  159. salesOrder: '',
  160. newsOrder: '',
  161. ids: '',
  162. page: 1,
  163. limit: this.$config.LIMIT,
  164. type: '',
  165. numConfig: 0,
  166. titleInfo: []
  167. }
  168. },
  169. methods: {
  170. // 产品列表
  171. productslist: function() {
  172. let that = this;
  173. let data = {};
  174. if (that.selectType) {
  175. data = {
  176. page: that.page,
  177. limit: that.limit,
  178. type: that.type,
  179. ids: that.ids,
  180. selectType: that.selectType
  181. }
  182. } else {
  183. data = {
  184. page: that.page,
  185. limit: that.numConfig <= that.limit ? that.numConfig : that.limit,
  186. type: that.type,
  187. newsOrder: that.newsOrder,
  188. salesOrder: that.salesOrder,
  189. selectId: that.selectId,
  190. selectType: that.selectType
  191. }
  192. }
  193. getHomeProducts(data).then(res => {
  194. that.firstList = res.data.list;
  195. }).catch(err => {
  196. that.$util.Tips({
  197. title: err
  198. });
  199. });
  200. },
  201. gopage(url) {
  202. goPage().then(res => {
  203. uni.navigateTo({
  204. url: url
  205. })
  206. })
  207. },
  208. goDetail(item) {
  209. goPage().then(res => {
  210. goShopDetail(item, this.uid).then(res => {
  211. uni.navigateTo({
  212. url: `/pages/goods_details/index?id=${item.id}`
  213. })
  214. })
  215. })
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss">
  221. .index-wrapper {
  222. background-color: $uni-bg-color;
  223. margin: $uni-index-margin-row $uni-index-margin-col;
  224. border-radius: $uni-border-radius-index;
  225. }
  226. .title {
  227. .text {
  228. display: flex;
  229. .name {
  230. font-size: $uni-index-title-font-size;
  231. font-weight: bold;
  232. }
  233. .txt-btn {
  234. display: flex;
  235. align-items: flex-end;
  236. margin-bottom: 8rpx;
  237. margin-left: 12rpx;
  238. }
  239. }
  240. }
  241. .wrapper .newProducts {
  242. white-space: nowrap;
  243. padding: 0rpx 20rpx 0rpx 20rpx;
  244. margin: 20rpx 0;
  245. }
  246. .wrapper .newProducts .item {
  247. display: inline-block;
  248. width: 240rpx;
  249. margin-right: 20rpx;
  250. border-radius: 20rpx;
  251. }
  252. .wrapper .newProducts .item:nth-last-child(1) {
  253. margin-right: 0;
  254. }
  255. .wrapper .newProducts .item .img-box {
  256. width: 100%;
  257. height: 240rpx;
  258. position: relative;
  259. }
  260. .wrapper .newProducts .item .img-box image {
  261. width: 100%;
  262. height: 100%;
  263. border-radius: 12rpx 12rpx 0 0;
  264. }
  265. .wrapper .newProducts .item .pro-info {
  266. font-size: 28rpx;
  267. color: #333;
  268. text-align: center;
  269. padding: 19rpx 10rpx 0 10rpx;
  270. }
  271. .wrapper .newProducts .item .money {
  272. padding: 0 10rpx 18rpx 10rpx;
  273. text-align: center;
  274. font-size: 26rpx;
  275. font-weight: bold;
  276. }
  277. .empty-img {
  278. width: 640rpx;
  279. height: 300rpx;
  280. border-radius: 14rpx;
  281. margin: 26rpx auto 0 auto;
  282. background-color: #ccc;
  283. text-align: center;
  284. line-height: 300rpx;
  285. .iconfont {
  286. font-size: 50rpx;
  287. }
  288. }
  289. .font-color {
  290. color: var(--view-priceColor);
  291. }
  292. </style>