newGoods.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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. uni.navigateTo({
  209. url: url
  210. })
  211. })
  212. },
  213. goDetail(item) {
  214. goPage().then(res => {
  215. goShopDetail(item, this.uid).then(res => {
  216. uni.navigateTo({
  217. url: `/pages/goods_details/index?id=${item.id}`
  218. })
  219. })
  220. })
  221. },
  222. }
  223. }
  224. </script>
  225. <style lang="scss">
  226. .index-wrapper {
  227. background-color: $uni-bg-color;
  228. margin: $uni-index-margin-row $uni-index-margin-col;
  229. border-radius: $uni-border-radius-index;
  230. }
  231. .title {
  232. .text {
  233. display: flex;
  234. .name {
  235. font-size: $uni-index-title-font-size;
  236. font-weight: bold;
  237. }
  238. .txt-btn {
  239. display: flex;
  240. align-items: flex-end;
  241. margin-bottom: 8rpx;
  242. margin-left: 12rpx;
  243. }
  244. }
  245. }
  246. .wrapper .newProducts {
  247. white-space: nowrap;
  248. padding: 0rpx 20rpx 0rpx 20rpx;
  249. margin: 20rpx 0;
  250. }
  251. .wrapper .newProducts .item {
  252. display: inline-block;
  253. width: 200rpx;
  254. margin-right: 20rpx;
  255. border-radius: 20rpx;
  256. }
  257. .wrapper .newProducts .item:nth-last-child(1) {
  258. margin-right: 0;
  259. }
  260. .wrapper .newProducts .item .img-box {
  261. width: 100%;
  262. height: 200rpx;
  263. position: relative;
  264. }
  265. .wrapper .newProducts .item .img-box image {
  266. width: 100%;
  267. height: 100%;
  268. border-radius: 12rpx 12rpx 0 0;
  269. }
  270. .wrapper .newProducts .item .img-box {
  271. /deep/,
  272. /deep/image,
  273. /deep/.easy-loadimage,
  274. /deep/uni-image {
  275. width: 100%;
  276. height: 200rpx;
  277. border-radius: 12rpx 12rpx 0 0;
  278. }
  279. }
  280. .wrapper .newProducts .item .pro-info {
  281. font-size: 28rpx;
  282. color: #333;
  283. text-align: center;
  284. padding: 19rpx 10rpx 0 10rpx;
  285. }
  286. .wrapper .newProducts .item .money {
  287. padding: 0 10rpx 18rpx 10rpx;
  288. text-align: center;
  289. font-size: 30rpx;
  290. font-weight: bold;
  291. .rmb {
  292. font-weight: bold;
  293. color: var(--view-priceColor);
  294. font-size: 10px;
  295. }
  296. }
  297. .empty-img {
  298. width: 640rpx;
  299. height: 300rpx;
  300. border-radius: 14rpx;
  301. margin: 26rpx auto 0 auto;
  302. background-color: #ccc;
  303. text-align: center;
  304. line-height: 300rpx;
  305. .iconfont {
  306. font-size: 50rpx;
  307. }
  308. }
  309. .font-color {
  310. color: var(--view-priceColor);
  311. }
  312. </style>