popular.vue 7.4 KB

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