app-good-shop-recommendation.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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"></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"></icon>
  12. </app-jump-button>
  13. </view>
  14. </view>
  15. <view class="app-content" :style="[{'background-color':`${temp.data.backgroundColor}`}]" 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. <app-jump-button 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" :class="theme.color">¥{{good.price}}</text>
  60. </app-jump-button>
  61. </view>
  62. </scroll-view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import {mapGetters} 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. },
  79. cardStyle: {
  80. type: String,
  81. default: function () {
  82. return '1';
  83. }
  84. },
  85. type: {
  86. type: String,
  87. default() {
  88. return 'mch';
  89. }
  90. },
  91. backgroundColor: {
  92. type: String,
  93. default() {
  94. return '#fff';
  95. }
  96. },
  97. theme: Object,
  98. page_id: Number,
  99. index: {
  100. type: Number,
  101. },
  102. is_required: Boolean,
  103. mch_list: Array,
  104. coupon_req: Boolean
  105. },
  106. computed: {
  107. ...mapGetters('mallConfig',{
  108. getVideo: 'getVideo'
  109. }),
  110. },
  111. methods: {
  112. jump(data) {
  113. this.$jump({
  114. url: `/plugins/mch/shop/shop?mch_id=${data}`,
  115. open_type: 'navigate',
  116. });
  117. },
  118. router_jump(data, id) {
  119. // #ifndef MP-BAIDU
  120. if (data.goodsWarehouse.video_url && this.getVideo == 1) {
  121. uni.navigateTo({
  122. url: `/pages/goods/video?goods_id=${data.id}&sign=mch`
  123. });
  124. } else {
  125. uni.navigateTo({
  126. url: `/plugins/mch/goods/goods?id=${data.id}&mch_id=${id}`,
  127. });
  128. }
  129. // #endif
  130. // #ifdef MP-BAIDU
  131. uni.navigateTo({
  132. url: `/plugins/mch/goods/goods?id=${data.id}&mch_id=${id}`,
  133. });
  134. // #endif
  135. },
  136. loadData() {
  137. this.$request({
  138. url: this.$api.index.extra,
  139. data: {
  140. type: this.page_id === 0 ?'mall' : 'diy',
  141. key: 'mch',
  142. page_id: this.page_id,
  143. index: this.index,
  144. longitude: 0,
  145. latitude: 0
  146. }
  147. }).then(e => {
  148. this.list = e.data;
  149. if (this.page_id === 0) {
  150. let storage = this.$storage.getStorageSync('INDEX_MALL');
  151. storage.home_pages[this.index].list = this.list;
  152. this.$storage.setStorageSync('INDEX_MALL', storage);
  153. }
  154. })
  155. }
  156. },
  157. data() {
  158. return {
  159. list: []
  160. }
  161. },
  162. watch: {
  163. mch_list: {
  164. handler(data) {
  165. if (this.coupon_req) {
  166. this.list = data;
  167. }
  168. },
  169. deep: true
  170. }
  171. },
  172. mounted() {
  173. if (this.coupon_req) {
  174. this.list = this.mch_list;
  175. } else {
  176. if (this.is_required) {
  177. this.loadData();
  178. } else {
  179. let storage = this.$storage.getStorageSync('INDEX_MALL');
  180. this.list = storage.home_pages[this.index].list;
  181. }
  182. }
  183. },
  184. }
  185. </script>
  186. <style scoped lang="scss">
  187. .app-good-shop-recommendation {
  188. width: #{750rpx};
  189. .distance {
  190. align-self: flex-start;
  191. padding-top: #{36rpx};
  192. font-size: #{24rpx};
  193. color: #999999;
  194. float: right;
  195. padding-right: #{50rpx};
  196. }
  197. .app-top-title {
  198. width: #{750rpx};
  199. height: #{80rpx};
  200. border-bottom: #{1rpx} solid #e2e2e2;
  201. background-color: #ffffff;
  202. .icon {
  203. background-size: 100% 100%;
  204. background-repeat: no-repeat;
  205. }
  206. .app-left {
  207. height: #{80rpx};
  208. .icon {
  209. width: #{46rpx};
  210. height: #{46rpx};
  211. background-image: url("../../../static/image/icon/good-shop.png");
  212. margin-left: #{24rpx};
  213. }
  214. text {
  215. font-size: #{26rpx};
  216. color: #ff8831;
  217. margin-left: #{16rpx};
  218. }
  219. }
  220. .app-right {
  221. height: #{80rpx};
  222. .icon {
  223. width: #{12rpx};
  224. height: #{22rpx};
  225. background-image: url("../../../static/image/icon/arrow-right.png");
  226. margin-right: #{24rpx};
  227. }
  228. text {
  229. font-size: #{26rpx};
  230. color: #999999;
  231. margin-right: #{12rpx};
  232. }
  233. }
  234. }
  235. .app-content {
  236. width: #{750rpx};
  237. padding: #{12rpx} 0;
  238. .app-scroll {
  239. width: #{750rpx};
  240. padding-left: #{16rpx};
  241. white-space: nowrap;
  242. height: #{224+20+20+23rpx};
  243. .app-item {
  244. display: inline-block;
  245. width: #{224rpx};
  246. height: #{224+20+20+24rpx};
  247. margin: 0 #{8rpx};
  248. border-radius: #{16rpx};
  249. .app-image {
  250. width: #{224rpx};
  251. height: #{224rpx};
  252. border-top-left-radius: #{16rpx};
  253. border-top-right-radius: #{16rpx};
  254. }
  255. .app-name {
  256. height: #{24+20+20rpx};
  257. /* #ifndef MP-ALIPAY */
  258. width: #{189rpx};
  259. /* #endif */
  260. /* #ifdef MP-ALIPAY */
  261. width: #{195rpx};
  262. /* #endif */
  263. font-size: #{24rpx};
  264. color: #353535;
  265. line-height: #{24+20+20rpx};
  266. display: inline-block;
  267. overflow: hidden;
  268. text-align: center;
  269. }
  270. }
  271. }
  272. }
  273. .app-goods-shop {
  274. width: #{750rpx};
  275. padding: #{20rpx};
  276. .app-shop {
  277. width: #{750-20-20rpx};
  278. padding: 0 #{24rpx};
  279. margin-top: #{20rpx};
  280. margin-bottom: #{20rpx};
  281. overflow: hidden;
  282. border-radius: #{16rpx};
  283. .app-top {
  284. width: #{750-20-20-24-24rpx};
  285. margin: #{24rpx} 0;
  286. .app-image {
  287. width: #{100rpx};
  288. height: #{100rpx};
  289. border-radius: #{8rpx};
  290. }
  291. .app-title {
  292. margin-left: #{24rpx};
  293. margin-top: #{36-24rpx};
  294. width: #{370rpx};
  295. .app-name {
  296. font-size: #{28rpx};
  297. color: #353535;
  298. }
  299. .app-number-title {
  300. margin-top: #{12rpx};
  301. color: #999999;
  302. font-size: #{24rpx};
  303. .app-sell {
  304. margin-left: #{32rpx};
  305. }
  306. }
  307. }
  308. .app-button-jump {
  309. float: right;
  310. margin-right: #{24rpx};
  311. width: #{144rpx};
  312. height: #{64rpx};
  313. margin-top: #{18rpx};
  314. margin-bottom: #{18rpx};
  315. .app-button {
  316. width: #{144rpx};
  317. height: #{64rpx};
  318. text-align: center;
  319. border: #{1rpx} solid #cccccc;
  320. font-size: #{26rpx};
  321. color: #666666;
  322. line-height: #{64rpx};
  323. border-radius: #{40rpx};
  324. }
  325. }
  326. }
  327. .app-bottom {
  328. height: #{210+23rpx};
  329. width: #{750-20-20-24-24rpx};
  330. padding-bottom: #{23rpx};
  331. .app-scroll {
  332. height: #{210rpx};
  333. width: #{750-20-20-24-24rpx};
  334. white-space: nowrap;
  335. margin-bottom: #{23rpx};
  336. .app-item {
  337. /*background-color: red;*/
  338. display: inline-block;
  339. width: #{210rpx};
  340. height: #{210rpx};
  341. margin-left: #{8rpx};
  342. margin-right: #{8rpx};
  343. position: relative;
  344. .app-image {
  345. width: #{210rpx};
  346. height: #{210rpx};
  347. }
  348. .app-price {
  349. position: absolute;
  350. bottom: 0;
  351. left: 0;
  352. width: #{210rpx};
  353. font-size: #{28rpx};
  354. height: #{50rpx};
  355. text-align: center;
  356. background-color: rgba(245, 245, 246, 0.5);
  357. }
  358. }
  359. }
  360. }
  361. }
  362. .app-shop:first-of-type {
  363. margin-top: 0;
  364. }
  365. .app-shop:last-of-type {
  366. margin-bottom: 0;
  367. }
  368. }
  369. }
  370. </style>