newGoods.vue 8.1 KB

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