app-good-shop-recommendation.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <view class="app-good-shop-recommendation">
  3. <view class="app-top-title dir-left-nowrap main-between cross-center" v-if="!showGoods && type === 'mch'">
  4. <view class="app-left dir-left-nowrap cross-center">
  5. <icon class="icon" type></icon>
  6. <text>好店推荐</text>
  7. </view>
  8. <view class="app-right dir-left-nowrap cross-center">
  9. <app-jump-button form url="/plugins/mch/list/list">
  10. <text>更多</text>
  11. <icon class="icon" type></icon>
  12. </app-jump-button>
  13. </view>
  14. </view>
  15. <view class="app-content" v-if="!showGoods">
  16. <scroll-view scroll-x class="app-scroll">
  17. <view class="app-item" :style="[{'background-color':`${cardStyle < 3 ? '#ffffff': ''}`,'border': `${cardStyle == 2 ? '2rpx solid #e2e2e2': '0'}`}]"
  18. v-for="(item, index) in list"
  19. :key="index"
  20. >
  21. <app-jump-button arrangement="column" form :url="'/plugins/mch/shop/shop?mch_id=' + item.id">
  22. <image class="app-image" :src="item.picUrl"></image>
  23. <text class="app-name u-line-1">
  24. {{item.name}}
  25. </text>
  26. </app-jump-button>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. <view class="app-goods-shop" v-if="showGoods">
  31. <view class="app-shop" :style="[{'background-color':`${cardStyle < 3 ? '#ffffff': ''}`,'border': `${cardStyle == 2 ? '2rpx solid #e2e2e2': '0'}`}]"
  32. v-for="(item, index) in list" :key="index">
  33. <view class="app-top dir-left-nowrap main-between" @click.stop="jump(item.id)">
  34. <view class="dir-left-nowrap">
  35. <image class="app-image" :src="item.pic_url"></image>
  36. <view class="app-title">
  37. <text class="app-name t-omit-two">{{item.name}}</text>
  38. <view class="app-number-title">
  39. <text class="app-shops">商品数量: {{item.goods_num}}</text>
  40. <text class="app-sell">已售: {{item.order_num}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <view v-if="item.distance" class="box-grow-0 distance" >距离{{item.distance}}</view>
  45. <view class="app-button-jump" v-else>
  46. <app-jump-button form >
  47. <view class="app-button">进店逛逛</view>
  48. </app-jump-button>
  49. </view>
  50. </view>
  51. <view class="app-bottom" v-if="item.goodsList.length !== 0">
  52. <scroll-view class="app-scroll" scroll-x>
  53. <view class="app-item" :style="{marginLeft: number !== 0 ? '8rpx' : '0'}"
  54. v-for="(good, number) in item.goodsList" :key="number">
  55. <view form
  56. @click.native.stop="router_jump(good, item.id)"
  57. >
  58. <image class="app-image" :src="good.picUrl"></image>
  59. <text class="app-price" :style="{'color': theme.color}">¥{{good.price}}</text>
  60. </view>
  61. </view>
  62. </scroll-view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import {mapGetters, mapState} from 'vuex';
  70. export default {
  71. name: "app-good-shop-recommendation",
  72. props: {
  73. showGoods: {
  74. type: Boolean,
  75. default: function () {
  76. return false;
  77. },
  78. required: false
  79. },
  80. cardStyle: {
  81. type: String,
  82. default: function () {
  83. return '1';
  84. },
  85. required: false
  86. },
  87. type: {
  88. type: String,
  89. default() {
  90. return 'mch';
  91. },
  92. required: false
  93. },
  94. backgroundColor: {
  95. type: String,
  96. default() {
  97. return '#fff';
  98. },
  99. required: false
  100. },
  101. theme: {
  102. type: [String, Object],
  103. required: false
  104. },
  105. page_id: {
  106. type: Number,
  107. required: false
  108. },
  109. index: {
  110. type: Number,
  111. required: false
  112. },
  113. is_required: {
  114. type: Boolean,
  115. required: false
  116. },
  117. mch_list: {
  118. type: Array,
  119. required: false
  120. },
  121. coupon_req: {
  122. type: Boolean,
  123. required: false
  124. }
  125. },
  126. computed: {
  127. ...mapGetters('mallConfig',{
  128. getVideo: 'getVideo'
  129. }),
  130. ...mapState({
  131. platform: function(state) {
  132. return state.gConfig.systemInfo.platform;
  133. }
  134. })
  135. },
  136. methods: {
  137. jump(data) {
  138. this.$jump({
  139. url: `/plugins/mch/shop/shop?mch_id=${data}`,
  140. open_type: 'navigate',
  141. });
  142. },
  143. router_jump(data, id) {
  144. // #ifndef MP-BAIDU
  145. if (data.goodsWarehouse.video_url && this.getVideo == 1) {
  146. // #ifdef MP
  147. uni.navigateTo({
  148. url: `/pages/goods/video?goods_id=${data.id}&sign=mch`
  149. });
  150. // #endif
  151. // #ifdef H5
  152. uni.navigateTo({
  153. url: `/plugins/mch/goods/goods?id=${data.id}&mch_id=${id}`,
  154. });
  155. // #endif
  156. } else {
  157. uni.navigateTo({
  158. url: `/plugins/mch/goods/goods?id=${data.id}&mch_id=${id}`,
  159. });
  160. }
  161. // #endif
  162. // #ifdef MP-BAIDU
  163. uni.navigateTo({
  164. url: `/plugins/mch/goods/goods?id=${data.id}&mch_id=${id}`,
  165. });
  166. // #endif
  167. },
  168. loadData() {
  169. this.$request({
  170. url: this.$api.index.extra,
  171. data: {
  172. type: this.page_id === 0 ?'mall' : 'diy',
  173. key: 'mch',
  174. page_id: this.page_id,
  175. index: this.index,
  176. longitude: 0,
  177. latitude: 0
  178. }
  179. }).then(e => {
  180. this.list = e.data;
  181. if (this.page_id === 0) {
  182. let storage = this.$storage.getStorageSync('INDEX_MALL');
  183. storage.home_pages[this.index].list = this.list;
  184. this.$storage.setStorageSync('INDEX_MALL', storage);
  185. }
  186. })
  187. }
  188. },
  189. data() {
  190. return {
  191. list: []
  192. }
  193. },
  194. watch: {
  195. mch_list: {
  196. handler(data) {
  197. if (this.coupon_req) {
  198. this.list = data;
  199. }
  200. },
  201. deep: true
  202. }
  203. },
  204. mounted() {
  205. if (this.coupon_req) {
  206. this.list = this.mch_list;
  207. } else {
  208. if (this.is_required) {
  209. this.loadData();
  210. } else {
  211. let storage = this.$storage.getStorageSync('INDEX_MALL');
  212. this.list = storage.home_pages[this.index].list;
  213. }
  214. }
  215. },
  216. }
  217. </script>
  218. <style scoped lang="scss">
  219. .app-good-shop-recommendation {
  220. width: #{750rpx};
  221. .distance {
  222. align-self: flex-start;
  223. padding-top: #{36rpx};
  224. font-size: #{24rpx};
  225. color: #999999;
  226. float: right;
  227. padding-right: #{50rpx};
  228. }
  229. .app-top-title {
  230. width: #{750rpx};
  231. height: #{80rpx};
  232. border-bottom: #{1rpx} solid #e2e2e2;
  233. background-color: #ffffff;
  234. .icon {
  235. background-size: 100% 100%;
  236. background-repeat: no-repeat;
  237. }
  238. .app-left {
  239. height: #{80rpx};
  240. .icon {
  241. width: #{46rpx};
  242. height: #{46rpx};
  243. background-image: url("../../../static/image/icon/good-shop.png");
  244. margin-left: #{24rpx};
  245. }
  246. text {
  247. font-size: #{26rpx};
  248. color: #ff8831;
  249. margin-left: #{16rpx};
  250. }
  251. }
  252. .app-right {
  253. height: #{80rpx};
  254. .icon {
  255. width: #{12rpx};
  256. height: #{22rpx};
  257. background-image: url("../../../static/image/icon/arrow-right.png");
  258. margin-right: #{24rpx};
  259. }
  260. text {
  261. font-size: #{26rpx};
  262. color: #999999;
  263. margin-right: #{12rpx};
  264. }
  265. }
  266. }
  267. .app-content {
  268. width: #{750rpx};
  269. padding: #{12rpx} 0;
  270. .app-scroll {
  271. width: #{750rpx};
  272. padding-left: #{16rpx};
  273. white-space: nowrap;
  274. height: #{224+20+20+23rpx};
  275. .app-item {
  276. display: inline-block;
  277. width: #{224rpx};
  278. height: #{224+20+20+24rpx};
  279. margin: 0 #{8rpx};
  280. border-radius: #{16rpx};
  281. .app-image {
  282. width: #{224rpx};
  283. height: #{224rpx};
  284. border-top-left-radius: #{16rpx};
  285. border-top-right-radius: #{16rpx};
  286. }
  287. .app-name {
  288. height: #{24+20+20rpx};
  289. /* #ifndef MP-ALIPAY */
  290. width: #{189rpx};
  291. /* #endif */
  292. /* #ifdef MP-ALIPAY */
  293. width: #{195rpx};
  294. /* #endif */
  295. font-size: #{24rpx};
  296. color: #353535;
  297. line-height: #{24+20+20rpx};
  298. display: inline-block;
  299. overflow: hidden;
  300. text-align: center;
  301. }
  302. }
  303. }
  304. }
  305. .app-goods-shop {
  306. width: #{750rpx};
  307. padding: #{20rpx};
  308. .app-shop {
  309. width: #{750-20-20rpx};
  310. padding: 0 #{24rpx};
  311. margin-top: #{20rpx};
  312. margin-bottom: #{20rpx};
  313. overflow: hidden;
  314. border-radius: #{16rpx};
  315. .app-top {
  316. width: #{750-20-20-24-24rpx};
  317. margin: #{24rpx} 0;
  318. .app-image {
  319. width: #{100rpx};
  320. height: #{100rpx};
  321. border-radius: #{8rpx};
  322. }
  323. .app-title {
  324. margin-left: #{24rpx};
  325. margin-top: #{36-24rpx};
  326. width: #{370rpx};
  327. .app-name {
  328. font-size: #{28rpx};
  329. color: #353535;
  330. }
  331. .app-number-title {
  332. margin-top: #{12rpx};
  333. color: #999999;
  334. font-size: #{24rpx};
  335. .app-sell {
  336. margin-left: #{32rpx};
  337. }
  338. }
  339. }
  340. .app-button-jump {
  341. float: right;
  342. margin-right: #{24rpx};
  343. width: #{144rpx};
  344. height: #{64rpx};
  345. margin-top: #{18rpx};
  346. margin-bottom: #{18rpx};
  347. .app-button {
  348. width: #{144rpx};
  349. height: #{64rpx};
  350. text-align: center;
  351. border: #{1rpx} solid #cccccc;
  352. font-size: #{26rpx};
  353. color: #666666;
  354. line-height: #{64rpx};
  355. border-radius: #{40rpx};
  356. }
  357. }
  358. }
  359. .app-bottom {
  360. height: #{210+23rpx};
  361. width: #{750-20-20-24-24rpx};
  362. padding-bottom: #{23rpx};
  363. .app-scroll {
  364. height: #{210rpx};
  365. width: #{750-20-20-24-24rpx};
  366. white-space: nowrap;
  367. margin-bottom: #{23rpx};
  368. .app-item {
  369. /*background-color: red;*/
  370. display: inline-block;
  371. width: #{210rpx};
  372. height: #{210rpx};
  373. margin-left: #{8rpx};
  374. margin-right: #{8rpx};
  375. position: relative;
  376. .app-image {
  377. width: #{210rpx};
  378. height: #{210rpx};
  379. }
  380. .app-price {
  381. position: absolute;
  382. bottom: 0;
  383. left: 0;
  384. width: #{210rpx};
  385. font-size: #{28rpx};
  386. height: #{50rpx};
  387. text-align: center;
  388. background-color: rgba(245, 245, 246, 0.5);
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .app-shop:first-of-type {
  395. margin-top: 0;
  396. }
  397. .app-shop:last-of-type {
  398. margin-bottom: 0;
  399. }
  400. }
  401. }
  402. </style>