猎豆优选小程序

home.vue 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164
  1. <template>
  2. <view class="page-wrap" :style="{'background': `${newNavbarBackground.background}`, 'background-size': `${newNavbarBackground.backgroundSize}`}">
  3. <!-- 剪切板弹框 -->
  4. <clipboard v-if="is_clipbpard" @close="clipbpardClose"></clipboard>
  5. <u-navbar class="navbar-wrap" title=" " :background="newNavbarBackground" :title-size="36" :is-back="false" :title-bold="false" >
  6. <!-- S 搜索 -->
  7. <view class="search-wrap" @click="onClickSearch">
  8. <image class="icon" src="https://ld.726p.com/ldyx_static/imgs/icon-search.png" />
  9. <text class="pl-text">输入商品名或粘贴标题</text>
  10. <view class="search-btn">搜索</view>
  11. </view>
  12. <!-- E 搜索 -->
  13. </u-navbar>
  14. <view class="scroll-view-wrap u-skeleton">
  15. <!-- S "精选"分类显示模块(渲染条件 当前tab为精选) -->
  16. <block>
  17. <!-- S 轮播图 -->
  18. <view v-if="swiperList && swiperList.length" class="swiper-wrap">
  19. <u-swiper
  20. class="u-skeleton-fillet"
  21. :border-radius="16"
  22. :list="swiperList"
  23. name="photo"
  24. mode="round"
  25. bg-color="transparent"
  26. @click="onClickSwiper"
  27. @change="onChangeSwiper"
  28. />
  29. </view>
  30. <!-- E 轮播图 -->
  31. <!-- S 专题入口 -->
  32. <view class="menu-wrap">
  33. <view class="menu-item" v-for="item in menu" :key="item.id" @click="onClickMenu(item)">
  34. <image class="item-icon u-skeleton-fillet" :src="item.img" />
  35. <text class="item-label u-skeleton-fillet">{{ item.name }}</text>
  36. </view>
  37. </view>
  38. <!-- E 专题入口 -->
  39. <!-- 平台tab -->
  40. <view class="platform-wrap" id="platform-wrap" :style="{'top': `${statusBarHeight + navigationBarHeight - 7}px`}">
  41. <view class="platform-tab" v-for="item in platfromList" :key="item.id" @click="onClickPlatfrom(item.id)">
  42. <text class="platfrom-tab-title">{{item.name}}</text>
  43. <view :class="['platfrom-tab-info', platfrom == item.id ? 'platfrom-tab-active' : '']"><text class="note">{{item.note}}</text></view>
  44. </view>
  45. </view>
  46. <!-- 淘宝 天猫 -->
  47. <block v-if="platfrom == 1">
  48. <!-- S 精选列表 -->
  49. <block v-if="goodsList && goodsList.length">
  50. <block v-for="(block, idx) in goodsList" :key="idx">
  51. <!-- S 商品列表 -->
  52. <view v-if="block.type == 1 && block.goods" class="goods-list-wrap">
  53. <horizontalGood :goodInfo="block.goods" path="HomeGoodsType2"></horizontalGood>
  54. </view>
  55. <!-- E 商品列表 -->
  56. <!-- S 商品列表 - 专题组 -->
  57. <view v-else-if="block.type == 2" class="goods-group-wrap" :style="{
  58. 'background-image': `url(${block.adv_background_img})`,
  59. }">
  60. <scroll-view class="scroll-view-group" scroll-x="true">
  61. <!-- 商品 -->
  62. <view v-for="goodsItem in block.goodsList" :key="goodsItem.goods_id" class="goods-item-vertical" @click="onClickGoodsItem(goodsItem)">
  63. <view v-if="user_level > 1 && goodsItem.commission_price > 0" class="commission-wrap">
  64. <text>赚¥{{ goodsItem.commission_price }}</text>
  65. </view>
  66. <image class="goods-item-img" :src="goodsItem.img" />
  67. <view class="title">{{ goodsItem.title }}</view>
  68. <view class="bm-wrap">
  69. <text class="price">¥{{ goodsItem.discount_price }}</text>
  70. <view v-if="goodsItem.coupon_price > 0" class="coupon-wrap">
  71. <text class="label">券</text>
  72. <text class="value">{{ goodsItem.coupon_price }}元</text>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 更多 -->
  77. <view class="goods-item-vertical more-wrap" @click="onClickMore({ id: block.id, name: block.name })">
  78. <view class="more-btn">
  79. <image src="https://ld.726p.com/ldyx_static/imgs/home-more.png" />
  80. <text>更多</text>
  81. </view>
  82. </view>
  83. </scroll-view>
  84. </view>
  85. <!-- E 商品列表 - 专题组 -->
  86. </block>
  87. </block>
  88. <!-- E 精选列表 -->
  89. <!-- S 商品骨架 -->
  90. <view v-else class="goodsListEmpty goods-item-wrap" v-for="item in 3" :key="item">
  91. <view class="lt-wrap">
  92. <image class="goods-item-img u-skeleton-fillet" img-mode="widthFix" border-radius="10" />
  93. </view>
  94. <view class="rt-wrap">
  95. <view class="title u-skeleton-fillet">
  96. <image class="shop-icon" />
  97. <text class="">&nbsp;</text>
  98. </view>
  99. <view class="shop-wrap flex-center-between u-skeleton-fillet">
  100. <view class="flex-center">
  101. <image class="shop-icon" />
  102. <view class="shop-name" >&nbsp;</view>
  103. </view>
  104. <view class="salesVolume"></view>
  105. </view>
  106. <view class="price-wrap u-skeleton-fillet">
  107. <text class="price">&nbsp;</text>
  108. <text class="start-price"></text>
  109. </view>
  110. <view class="btm-wrap u-skeleton-fillet">
  111. <view class="coupon-wrap">
  112. <text class="label">&nbsp;</text>
  113. <text class="value"></text>
  114. </view>
  115. <view class="coupon-wrap commission-wrap">
  116. <text class="label">&nbsp;</text>
  117. <text class="value"></text>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <!-- E 商品骨架 -->
  123. </block>
  124. <!-- 京东 -->
  125. <view class="bg-f5 u-skeleton-fillet">
  126. <view v-if="platfrom == 2" class="goods-list-double-wrap">
  127. <block v-for="(item, idx) in jd.goodsList" >
  128. <verticalGood class="verticalGoodItem" :key="item.goods.goods_id" :goodsItem="item.goods" v-if="item.goods"></verticalGood>
  129. </block>
  130. </view>
  131. </view>
  132. <!-- 拼多多 -->
  133. <view class="bg-f5">
  134. <view v-if="platfrom == 4" class="goods-list-double-wrap">
  135. <block v-for="(item, idx) in pdd.goodsList" >
  136. <verticalGood class="verticalGoodItem" :key="item.goods.goods_id" :goodsItem="item.goods" v-if="item.goods"></verticalGood>
  137. </block>
  138. </view>
  139. </view>
  140. <!-- 抖音 -->
  141. <view class="bg-f5">
  142. <view v-if="platfrom == 3" class="goods-list-double-wrap">
  143. <block v-for="(item, idx) in dy.goodsList" >
  144. <verticalGood class="verticalGoodItem" :key="item.goods_id" :goodsItem="item" v-if="item"></verticalGood>
  145. </block>
  146. </view>
  147. </view>
  148. <!-- 抖音 -->
  149. <view class="bg-f5">
  150. <view v-if="platfrom == 5" class="goods-list-double-wrap">
  151. <block v-for="(item, idx) in wph.goodsList" >
  152. <verticalGood class="verticalGoodItem" :key="item.goods_id" :goodsItem="item" v-if="item" />
  153. </block>
  154. </view>
  155. </view>
  156. </block>
  157. <!-- E "精选"分类显示模块 -->
  158. </view>
  159. <!-- E 滚动区 -->
  160. <!-- 回到顶部 -->
  161. <u-back-top :scroll-top="scroll.scrollTop"></u-back-top>
  162. <!-- #ifdef H5 -->
  163. <icp></icp>
  164. <!-- #endif -->
  165. <!-- S 首屏广告 -->
  166. <firstAdv v-if="isShowFirstAdv" @confirm="onConfirmFirstAdv" @cancel="onCancelFirstAdv" />
  167. <!-- E 首屏广告 -->
  168. <!-- S 联系客服 -->
  169. <wxServiceDialog v-if="isShowWxServiceDialog" :keyword="wxServiceKeyword" @confirm="onConfirmWxServiceDialog" @cancel="onCancelWxServiceDialog" />
  170. <!-- E 联系客服 -->
  171. <!--骨架组件-->
  172. <u-skeleton :loading="swiperListLoading || menuLoading" :animation="true" bgColor="#FFF" />
  173. </view>
  174. </template>
  175. <script>
  176. const app = getApp()
  177. import horizontalGood from '@/components/horizontalGood.vue'
  178. import verticalGood from '@/components/verticalGood.vue'
  179. import jdEliteId from '@/config/jdEliteId.js'
  180. import firstAdv from '@/components/firstAdv.vue'
  181. import wxServiceDialog from '@/components/wxServiceDialog.vue'
  182. export default {
  183. components:{
  184. horizontalGood,
  185. verticalGood,
  186. firstAdv,
  187. wxServiceDialog,
  188. },
  189. data() {
  190. return {
  191. newNavbarBackground:{
  192. background: `url(https://ld.726p.com/tbk/upload/c579f015a49a3f9e066f0ab00ab56f7.png) #ffffff no-repeat`,
  193. backgroundSize: '100% 370rpx',
  194. },
  195. statusBarHeight: app.globalData.statusBarHeight,
  196. navigationBarHeight: app.globalData.navigationBarHeight,
  197. currentTabInfo: { // 当前选中的tab信息
  198. back_img: 'http://imgs.726p.com/tbk/upload/groupImg2019-01-23/182712/kx-5c484180f2cb9.png',
  199. curIdx: 13, // 当前选择的“分类标签”下标
  200. },
  201. swiperList: [], // 轮播图列表(image指定图片路径,也可以通过name属性自定义)
  202. swiperListLoading: true,
  203. currentSwiperInfo: { // 当前选中的swiper信息
  204. photo_bg: '',
  205. curIdx: 0, // 当前选择的“轮播图”下标
  206. },
  207. menu: [
  208. {},{},{},{},{},
  209. {},{},{},{},{},
  210. ], // 精选-专题入口
  211. menuLoading: true,
  212. goodsList: [], // 商品列表
  213. filter: {
  214. loading: false,
  215. hasNext: true,
  216. page: 1,
  217. category_id: 13, // 分类id 默认13 精选
  218. sort: 1, // 排序值:1综合、2销量(高到低)、3价格(低到高)、4价格(高到低)
  219. is_has_coupon: 0, // 是否只取有券商品:0否;1是,默认是0
  220. },
  221. user_level: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').user_level : '', // 当前用户等级
  222. triggered: false,// 下拉刷新
  223. platfromList:[
  224. { id: 1, name: '淘宝', note: '今日推荐' },
  225. // { id: 2, name: '京东', note: '品质优选' },
  226. { id: 4, name: '拼多多', note: '热销爆品' },
  227. // { id: 3, name: '抖音', note: '爆款热播' },
  228. // { id: 5, name: '唯品会', note: '品牌特卖' },
  229. ],
  230. platfrom: 1,
  231. jd: {
  232. elite_index: 0,//每一页一个精选,上拉换下一页精选
  233. elite_name: '',
  234. elite_id: '',
  235. loading: false,
  236. hasNext: true,
  237. page: 1,
  238. page_size: 40,
  239. goodsList: [],
  240. },
  241. pdd: {
  242. hasNext: true,
  243. page: 1,
  244. page_size: 40,
  245. goodsList: [],
  246. },
  247. scroll: {
  248. scrollTop: 0,
  249. platfromSticky: 0,
  250. platfromStickyTop: app.globalData.statusBarHeight + app.globalData.navigationBarHeight - 7,
  251. },
  252. isShowFirstAdv: false, // 是否显示首屏广告
  253. isShowWxServiceDialog: false, // 是否显示微信客服
  254. wxServiceKeyword: '', // 微信客服关键字
  255. dy:{
  256. page: 1,
  257. page_size: 20,
  258. goodsList: [],
  259. loading: false,
  260. hasNext: true,
  261. },
  262. wph:{
  263. page: 1,
  264. page_size: 20,
  265. goodsList: [],
  266. loading: false,
  267. hasNext: true,
  268. },
  269. };
  270. },
  271. watch: {
  272. user_level() { // 监听用户等级变化 => 更新页面列表数据
  273. }
  274. },
  275. async onLoad() {
  276. // 获取渠道版本信息 - 接口header中使用
  277. await app.channelGetVersion()
  278. this.jd.elite_id = jdEliteId[this.jd.elite_index].id;
  279. this.jd.elite_name = jdEliteId[this.jd.elite_index].name;
  280. // // 改变note京东文案
  281. // this.platfromList.forEach((item)=>{
  282. // item.id == 2 ? item.note = this.jd.elite_name : '品质优选'
  283. // })
  284. this.init()
  285. // 判断是否显示首屏广告
  286. this.handleGetFirstAdv()
  287. },
  288. onShow() {
  289. // 获取用户等级
  290. this.user_level = app.handleGetUserLevel()
  291. },
  292. methods: {
  293. async init (){
  294. // 获取"精选-轮播图”数据
  295. this.handleGetSwiperList()
  296. // 获取"精选-专题入口"数据
  297. this.handleGetMenuList()
  298. // 淘宝
  299. if (this.platfrom == 1) {
  300. this.filter.page = 1;
  301. this.goodsList = [];
  302. await this.handleGetGoodsList()
  303. }
  304. // 京东
  305. if(this.platfrom == 2) {
  306. this.jd.page = 1;
  307. await this.getJdGoodsList()
  308. }
  309. // 拼多多
  310. if(this.platfrom == 4) {
  311. this.pdd.page = 1;
  312. await this.getPddGoodsList()
  313. }
  314. // 抖音
  315. if(this.platfrom == 3) {
  316. this.dy.page = 1;
  317. await this.getDyGoodsList()
  318. }
  319. // 唯品会
  320. if(this.platfrom == 5) {
  321. this.wph.page = 1;
  322. await this.getWphGoodsList()
  323. }
  324. uni.stopPullDownRefresh()
  325. },
  326. // 获取 精选 商品列表
  327. async handleGetGoodsList() {
  328. this.filter.category_id = this.currentTabInfo.id
  329. const { hasNext, page, category_id } = this.filter
  330. if (!hasNext) return false;
  331. if (this.filter.loading) return false;
  332. try {
  333. this.filter.loading = true;
  334. const url = this.$api.home_goodsAndStockList
  335. const params = { page, category_id }
  336. const { data: res = {} } = await this.$postJSON(url, params)
  337. this.filter.loading = false;
  338. if (res && res.errno == 0 && Array.isArray(res.rst)) {
  339. if (!res.rst.length) { // 更新"是否有下一页"状态
  340. this.filter.hasNext = false
  341. } else {
  342. this.filter.hasNext = true
  343. this.filter.page++
  344. this.goodsList = [...this.goodsList, ...res.rst]
  345. }
  346. } else {
  347. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  348. }
  349. } catch (error) {
  350. } finally {
  351. }
  352. },
  353. // 精选-专题入口列表
  354. async handleGetMenuList() {
  355. try {
  356. const url = this.$api.home_groupRoundNew
  357. const params = {}
  358. const { data: res = {} } = await this.$postJSON(url, params)
  359. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  360. // 过滤掉“需要跳转http链接”的入口
  361. this.menu = res.rst.data.filter(item => item.show_type == 2)
  362. } else {
  363. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  364. this.menu = []
  365. }
  366. } catch (error) {
  367. this.menu = []
  368. } finally {
  369. this.menuLoading = false
  370. }
  371. },
  372. // 获取轮播图数据
  373. async handleGetSwiperList() {
  374. try {
  375. const url = this.$api.home_bannerlist
  376. const params = {}
  377. const { data: res = {} } = await this.$get(url, params)
  378. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  379. this.swiperList = [...res.rst.data]
  380. this.currentSwiperInfo = res.rst.data[0] ? {...res.rst.data[0]} : {}
  381. } else {
  382. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  383. this.swiperList = []
  384. }
  385. } catch (error) {
  386. this.swiperList = []
  387. } finally {
  388. this.swiperListLoading = false
  389. }
  390. },
  391. // 监听切换轮播图
  392. onChangeSwiper(idx) {
  393. this.currentSwiperInfo = {...this.swiperList[idx], curIdx: idx}
  394. },
  395. // 监听点击轮播图
  396. onClickSwiper(idx) {
  397. this.currentSwiperInfo = {...this.swiperList[idx], curIdx: idx}
  398. if (this.currentSwiperInfo.word) { // 当前轮播图有客服关键字口令 => 显示微信客服引导
  399. this.handleShowWxService(this.currentSwiperInfo.word)
  400. }
  401. },
  402. // 监听点击"精选-专题"入口
  403. onClickMenu(item = {}) {
  404. const { id, name, show_type, url } = item
  405. if (show_type == 2) {
  406. uni.navigateTo({
  407. url: `/pages/subPackages/home/subjectList?id=${id}&title=${encodeURIComponent(name)}&url=${encodeURIComponent(url)}&path=AdvFourListGoodsAction`
  408. })
  409. } else if (show_type == 6) {
  410. uni.navigateTo({
  411. url: `/pages/subPackages/home/jdSubjectList?id=${id}&title=${encodeURIComponent(name)}&url=${encodeURIComponent(url)}&path=AdvFourListGoodsAction`
  412. })
  413. } else {
  414. uni.showToast({ title: '敬请期待', icon: 'none' })
  415. }
  416. },
  417. onClickGoodsItem(goodsItem) {
  418. try{ app.categoryNew_countBuy({type:0,path:'HomeGoodsType2'}) }catch(e){} ; // 数据上报
  419. const { img = '', goods_id = '', coupon_price = '', discount_price = '', price = '', is_coupon = '', commission_rate = '', is_high_commission = '', coupon_end_time = '', coupon_start_time = '' } = goodsItem
  420. uni.navigateTo({
  421. url: `/pages/subPackages/home/goodsDetail?img=${encodeURIComponent(img)}&goods_id=${encodeURIComponent(goods_id)}&coupon_price=${encodeURIComponent(coupon_price)}&discount_price=${encodeURIComponent(discount_price)}&price=${encodeURIComponent(price)}&is_coupon=${encodeURIComponent(is_coupon)}&commission_rate=${encodeURIComponent(commission_rate)}&is_high_commission=${encodeURIComponent(is_high_commission)}&coupon_end_time=${encodeURIComponent(coupon_end_time)}&coupon_start_time=${encodeURIComponent(coupon_start_time)}`
  422. })
  423. },
  424. // 监听点击“搜索”
  425. onClickSearch() {
  426. uni.navigateTo({
  427. url: '/pages/subPackages/home/search',
  428. })
  429. },
  430. // 监听点击“横向列表-更多”
  431. onClickMore({ id, name }) {
  432. if (id) {
  433. uni.navigateTo({
  434. url: `/pages/subPackages/home/subjectList?id=${id}&title=${encodeURIComponent(name)}&path=ListAction`
  435. })
  436. } else {
  437. uni.showToast({ title: '敬请期待', icon: 'none' })
  438. }
  439. },
  440. // 点击平台tab
  441. onClickPlatfrom(id){
  442. if (this.platfrom == id) return;
  443. this.platfrom = id;
  444. if (this.platfrom == 2) { // 京东
  445. if (this.jd.goodsList.length <= 0 || !Array.isArray(this.jd.goodsList)) {
  446. this.jd.page = 1;
  447. this.getJdGoodsList()
  448. }
  449. }else if(this.platfrom == 4){ // 拼多多
  450. if (this.pdd.goodsList.length <= 0 || !Array.isArray(this.pdd.goodsList)) {
  451. this.pdd.page = 1;
  452. this.getPddGoodsList()
  453. }
  454. }else if(this.platfrom == 3){ // 抖音
  455. if (this.dy.goodsList.length <= 0 || !Array.isArray(this.dy.goodsList)) {
  456. this.dy.page = 1;
  457. this.getDyGoodsList()
  458. }
  459. }else if (this.platfrom == 5) { // 唯品会
  460. if (this.wph.goodsList.length <= 0 || !Array.isArray(this.wph.goodsList)) {
  461. this.wph.page = 1;
  462. this.getWphGoodsList()
  463. }
  464. }
  465. // 平台tab已经吸顶,切换平台滚动到固定位置
  466. this.isplatfromSticky().then((flag) => {
  467. if (flag) {
  468. uni.pageScrollTo({
  469. scrollTop: this.scroll.platfromSticky,
  470. duration: 100
  471. });
  472. }
  473. })
  474. },
  475. //拼多多列表
  476. async getPddGoodsList(){
  477. if (!this.pdd.hasNext) return false;
  478. uni.showLoading({ title: '加载中...', mask: true })
  479. const url = this.$api_pdd.goodsList_add_recommend
  480. const params = {
  481. page: this.pdd.page,
  482. page_size: this.pdd.page_size
  483. }
  484. const { data: res = {} } = await this.$get(url, params)
  485. uni.hideLoading()
  486. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  487. if (!res.rst.data.length) { // 更新"是否有下一页"状态
  488. this.pdd.hasNext = false
  489. } else {
  490. this.pdd.hasNext = true
  491. this.pdd.page++
  492. this.pdd.goodsList = this.pdd.goodsList.concat(res.rst.data)
  493. }
  494. } else {
  495. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  496. }
  497. },
  498. // 抖音商品列表
  499. async getDyGoodsList(){
  500. if (!this.dy.hasNext) return false;
  501. if (this.dy.loading) return false;
  502. try {
  503. uni.showLoading({ title: '加载中...', mask: true })
  504. this.dy.loading = true;
  505. const url = this.$api_dy.goodsList
  506. const params = {
  507. page: this.dy.page,
  508. page_size: this.dy.page_size
  509. }
  510. const { data: res = {} } = await this.$postJSON(url,params)
  511. this.dy.loading = false;
  512. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  513. if (!res.rst.data.length) {
  514. this.dy.hasNext = false
  515. } else {
  516. this.dy.pages = res.rst.pageInfo.pages;
  517. this.dy.hasNext = true
  518. this.dy.page++
  519. this.dy.goodsList = [...this.dy.goodsList, ...res.rst.data]
  520. }
  521. } else {
  522. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  523. }
  524. } catch (error) {
  525. } finally {
  526. uni.hideLoading()
  527. }
  528. },
  529. // 唯品会商品列表
  530. async getWphGoodsList(){
  531. if (!this.wph.hasNext) return false;
  532. if (this.wph.loading) return false;
  533. try {
  534. uni.showLoading({ title: '加载中...', mask: true })
  535. this.wph.loading = true;
  536. const url = this.$api_wph.goodsList
  537. const params = {
  538. page: this.wph.page,
  539. page_size: this.wph.page_size
  540. }
  541. const { data: res = {} } = await this.$postJSON(url,params)
  542. this.wph.loading = false;
  543. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  544. if (!res.rst.data.length) {
  545. this.wph.hasNext = false
  546. } else {
  547. this.wph.pages = res.rst.pageInfo.pages;
  548. this.wph.hasNext = true
  549. this.wph.page++
  550. const crtData = res.rst.data.filter(d => d.type == 1).map(d => ({...d.goods})) // 格式化后端反的数据格式
  551. this.wph.goodsList = [...this.wph.goodsList, ...crtData]
  552. }
  553. } else {
  554. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  555. }
  556. } catch (error) {
  557. console.log('error => ', error)
  558. } finally {
  559. uni.hideLoading()
  560. }
  561. },
  562. // 京东指定频道的精选商品
  563. async getJdGoodsList(){
  564. if (!this.jd.hasNext) return false;
  565. if (this.jd.loading) return false;
  566. try {
  567. uni.showLoading({ title: '加载中...', mask: true })
  568. this.jd.loading = true;
  569. const url = this.$api_jd.jd_goodsListByEliteId
  570. const params = {
  571. elite_id: this.jd.elite_id,
  572. page: this.jd.page,
  573. page_size: this.jd.page_size
  574. }
  575. const { data: res = {} } = await this.$postJSON(url, params)
  576. this.jd.loading = false;
  577. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  578. this.jd.pages = res.rst.pageInfo.pages;
  579. if (this.jd.elite_index == 0) {
  580. this.jd.goodsList = res.rst.data;
  581. } else {
  582. this.jd.goodsList = this.jd.goodsList.concat(res.rst.data)
  583. }
  584. this.jd.elite_index++ ;
  585. this.jd.elite_id = jdEliteId[this.jd.elite_index].id;
  586. this.jd.elite_name = jdEliteId[this.jd.elite_index].name;
  587. // // 改变note京东文案
  588. // this.platfromList.forEach((item)=>{
  589. // item.id == 2 ? item.note = this.jd.elite_name : '品质优选'
  590. // })
  591. if (jdEliteId.length <= this.jd.elite_index) {
  592. this.jd.hasNext = false;
  593. } else {
  594. this.jd.hasNext = true;
  595. }
  596. } else {
  597. uni.showToast({ title: res.err || '操作失败', icon: 'none' })
  598. }
  599. } catch (error) {
  600. } finally {
  601. uni.hideLoading()
  602. }
  603. },
  604. // 判断平台tab是否吸顶
  605. isplatfromSticky(){
  606. let _this = this;
  607. return new Promise((resolve) => {
  608. let query = uni.createSelectorQuery().in(this);
  609. query.select('#platform-wrap').boundingClientRect(data => {
  610. if (data.top <= _this.scroll.platfromStickyTop){
  611. resolve(true)
  612. } else {
  613. resolve(false)
  614. }
  615. }).exec();
  616. })
  617. },
  618. // 监听确认活动攻略(微信客服)
  619. onConfirmWxServiceDialog() {
  620. // 关闭弹框
  621. this.onCancelWxServiceDialog()
  622. // 其他业务逻辑(暂无)...
  623. },
  624. // 监听关闭活动攻略(微信客服)
  625. onCancelWxServiceDialog() {
  626. this.isShowWxServiceDialog = false
  627. },
  628. // 判断是否显示首屏广告
  629. handleGetFirstAdv() {
  630. const isFirst = app.handleGetUserIsFirst()
  631. if (!isFirst) return false
  632. this.isShowFirstAdv = true
  633. },
  634. // 监听关闭首屏广告
  635. onCancelFirstAdv() {
  636. app.handleSetUserIsFirst(false)
  637. this.isShowFirstAdv = false
  638. },
  639. // 监听确认首屏广告
  640. onConfirmFirstAdv({ advKeyword }) {
  641. // 关闭广告
  642. this.onCancelFirstAdv()
  643. // 显示微信客服引导
  644. this.handleShowWxService(advKeyword)
  645. },
  646. // 显示微信客服引导
  647. handleShowWxService(keyword) {
  648. this.wxServiceKeyword = keyword
  649. this.isShowWxServiceDialog = true
  650. },
  651. },
  652. onPageScroll(e) {
  653. this.scroll.scrollTop = e.scrollTop;
  654. let _this = this;
  655. // 平台tab吸顶后 滚动的距离
  656. this.isplatfromSticky().then((flag) => {
  657. if (flag && _this.scroll.platfromSticky == 0) { // 吸顶
  658. _this.scroll.platfromSticky = e.scrollTop;
  659. }
  660. })
  661. },
  662. //上拉加载
  663. onReachBottom() {
  664. if (this.platfrom == 1){ // 淘宝
  665. this.handleGetGoodsList()
  666. }
  667. if (this.platfrom == 2) { // 京东
  668. this.getJdGoodsList()
  669. }
  670. if (this.platfrom == 4) { // 拼多多
  671. this.getPddGoodsList()
  672. }
  673. if (this.platfrom == 3) { // 抖音
  674. this.getDyGoodsList()
  675. }
  676. if (this.platfrom == 5) { // 唯品会
  677. this.getWphGoodsList()
  678. }
  679. },
  680. //下拉刷新
  681. onPullDownRefresh(){
  682. this.init()
  683. },
  684. }
  685. </script>
  686. <style lang="scss" scoped>
  687. .page-wrap {
  688. position: relative;
  689. // height: 100vh;
  690. // overflow: hidden;
  691. background-attachment: fixed;
  692. .navbar-wrap {
  693. .search-wrap {
  694. display: flex;
  695. align-items: center;
  696. background-color: #fff;
  697. padding: 10rpx 10rpx 10rpx 20rpx;
  698. border-radius: 40rpx;
  699. width: 480rpx;
  700. margin-left: 20rpx;
  701. box-sizing: border-box;
  702. z-index: 9;
  703. .icon {
  704. margin-right: 20rpx;
  705. width: 27rpx;
  706. height: 27rpx;
  707. }
  708. .pl-text {
  709. font-size: 28rpx;
  710. color: #8A8A8A;
  711. flex:1;
  712. }
  713. .search-btn{
  714. width: 100rpx;
  715. height: 50rpx;
  716. background: linear-gradient(90deg, #FF9048 0%, #FB3F3C 100%);
  717. border-radius: 40rpx;
  718. color: #FFFFFF;
  719. font-size: 24rpx;
  720. text-align: center;
  721. line-height: 50rpx;
  722. }
  723. }
  724. }
  725. .tabs-wrap {
  726. /deep/ .u-tab-bar {
  727. bottom: 6rpx;
  728. }
  729. }
  730. .scroll-view-wrap {
  731. .swiper-wrap {
  732. margin: 20rpx 10rpx 0;
  733. padding: 0 12rpx;
  734. }
  735. .menu-wrap {
  736. margin-top: 12rpx;
  737. background-color: #fff;
  738. padding: 30rpx 0 10rpx;
  739. display: flex;
  740. justify-content: flex-start;
  741. flex-wrap: wrap;
  742. .menu-item {
  743. display: flex;
  744. flex-direction: column;
  745. align-items: center;
  746. margin-bottom: 30rpx;
  747. margin-right: 20rpx;
  748. width: calc((100% - 80rpx) / 5); // 80rpx 是前4个元素的右间距之和(20 * 4)
  749. &:nth-of-type(5n + 0) {
  750. margin-right: 0;
  751. }
  752. .item-icon {
  753. width: 70rpx;
  754. height: 70rpx;
  755. }
  756. .item-label {
  757. margin-top: 10rpx;
  758. font-size: 26rpx;
  759. color: #666;
  760. }
  761. }
  762. }
  763. // .banner-wrap {
  764. // display: flex;
  765. // justify-content: center;
  766. // background-color: #F5F5F5;
  767. // .banner-img {
  768. // width: 748rpx;
  769. // height: 80rpx;
  770. // vertical-align: middle; // 解决图片下边框缝隙问题
  771. // }
  772. // }
  773. .goods-list-wrap {
  774. background-color: #F5F5F5;
  775. padding-bottom: 10rpx;
  776. }
  777. .goods-group-wrap {
  778. background-repeat: no-repeat;
  779. background-size: 100% 100%;
  780. padding: 71rpx 28rpx 10rpx;
  781. margin-bottom: 10rpx;
  782. width: 750rpx;
  783. height: 448rpx;
  784. .scroll-view-group {
  785. margin-top: 6rpx;
  786. white-space: nowrap;
  787. .goods-item-vertical {
  788. position: relative;
  789. padding-bottom: 10rpx;
  790. display: inline-block;
  791. margin-right: 20rpx;
  792. width: 260rpx;
  793. height: 350rpx;
  794. border-radius: 10rpx 10rpx 0 0;
  795. overflow: hidden;
  796. background-color: #fff;
  797. &.more-wrap {
  798. position: relative;
  799. .more-btn {
  800. position: absolute;
  801. top: 50%;
  802. left: 50%;
  803. transform: translate(-50%, -50%);
  804. display: flex;
  805. flex-direction: column;
  806. align-items: center;
  807. image {
  808. width: 150rpx;
  809. height: 150rpx;
  810. }
  811. text {
  812. margin-top: 30rpx;
  813. font-size: 28rpx;
  814. color: #333;
  815. }
  816. }
  817. }
  818. .commission-wrap {
  819. position: absolute;
  820. right: 0;
  821. top: 200rpx;
  822. padding: 2rpx 20rpx;
  823. background-image: url("https://ld.726p.com/ldyx_static/imgs/bg-commission.png");
  824. background-repeat: no-repeat;
  825. background-size: 100% 100%;
  826. color: #fff;
  827. font-size: 20rpx;
  828. z-index: 4;
  829. }
  830. .goods-item-img {
  831. width: 260rpx;
  832. height: 260rpx;
  833. vertical-align: middle; // 解决图片下边框缝隙问题
  834. }
  835. .title {
  836. padding: 0 4rpx;
  837. margin-top: 10rpx;
  838. width: 100%;
  839. font-size: 26rpx;
  840. color: #333;
  841. overflow: hidden;
  842. word-wrap: normal;
  843. white-space: nowrap;
  844. text-overflow: ellipsis;
  845. }
  846. .bm-wrap {
  847. display: flex;
  848. align-items: center;
  849. justify-content: space-between;
  850. padding: 4rpx;
  851. .price {
  852. font-size: 24rpx;
  853. color: #F51400;
  854. }
  855. .coupon-wrap {
  856. display: flex;
  857. align-items: center;
  858. width: 150rpx;
  859. height: 30rpx;
  860. background-image: url("https://ld.726p.com/ldyx_static/imgs/bg-quan-small.png");
  861. background-repeat: no-repeat;
  862. background-size: 100% 100%;
  863. color: #F51400;
  864. font-size: 20rpx;
  865. .label {
  866. width: 50rpx;
  867. text-align: center;
  868. }
  869. .value {
  870. flex: 1;
  871. text-align: center;
  872. }
  873. }
  874. }
  875. }
  876. }
  877. }
  878. .category-wrap {
  879. // margin: 4rpx 14rpx 0;
  880. margin: 10rpx auto 22rpx;
  881. padding: 30rpx 0 10rpx;
  882. display: flex;
  883. justify-content: flex-start;
  884. flex-wrap: wrap;
  885. background-color: #fff;
  886. border-radius: 10rpx;
  887. .category-item {
  888. display: flex;
  889. flex-direction: column;
  890. align-items: center;
  891. margin-bottom: 30rpx;
  892. margin-right: 20rpx;
  893. width: calc((100% - 60rpx) / 4); // 60rpx 是前3个元素的右间距之和(20 * 3)
  894. &:nth-of-type(4n + 0) {
  895. margin-right: 0;
  896. }
  897. .item-icon {
  898. width: 70rpx;
  899. height: 70rpx;
  900. }
  901. .item-label {
  902. margin-top: 10rpx;
  903. font-size: 26rpx;
  904. color: #999;
  905. }
  906. }
  907. }
  908. .sort-wrap {
  909. display: flex;
  910. align-items: center;
  911. justify-content: space-around;
  912. margin: 10rpx auto 0;
  913. padding: 20rpx 10rpx;
  914. border-radius: 10rpx;
  915. font-size: 30rpx;
  916. color: #333;
  917. background-color: #fff;
  918. &.fixed {
  919. position: fixed;
  920. left: 0;
  921. right: 0;
  922. z-index: 9999;
  923. }
  924. .sort-item {
  925. display: flex;
  926. align-items: center;
  927. &.price-wrap {
  928. position: relative;
  929. .btn {
  930. position: absolute;
  931. font-size: 16rpx;
  932. color: #ccc;
  933. &.up {
  934. top: 4rpx;
  935. right: -24rpx;
  936. }
  937. &.down {
  938. bottom: 4rpx;
  939. right: -24rpx;
  940. }
  941. &.highlight {
  942. color: #FF4040;
  943. }
  944. }
  945. }
  946. .sort-img {
  947. margin-left: 10rpx;
  948. width: 28rpx;
  949. height: 28rpx;
  950. }
  951. }
  952. .on {
  953. color: #FF4040;
  954. font-weight: bold;
  955. }
  956. }
  957. .goods-list-double-wrap {
  958. display: flex;
  959. justify-content: space-between;
  960. flex-wrap: wrap;
  961. margin:auto;
  962. .verticalGoodItem{
  963. margin-bottom: 22rpx;
  964. }
  965. }
  966. }
  967. }
  968. .goods-list-double-wrap,.sort-wrap,.category-wrap{
  969. width: 700rpx;
  970. }
  971. .bg-f5{
  972. background-color: #F5F5F5;
  973. }
  974. .platform-wrap{
  975. background-color: #F5F5F5;
  976. display: flex;
  977. justify-content: space-around;
  978. padding: 28rpx 20rpx 16rpx;
  979. position: sticky;
  980. z-index: 9;
  981. .platform-tab{
  982. text-align: center;
  983. width: 35%;
  984. .platfrom-tab-title{
  985. color: #1A1A1A;
  986. font-size: 36rpx;
  987. line-height: 50rpx;
  988. font-weight: bold;
  989. }
  990. .platfrom-tab-info{
  991. color: #999999;
  992. font-size: 24rpx;
  993. line-height: 34rpx;
  994. margin-top: 6rpx;
  995. padding: 0 10rpx;
  996. }
  997. .platfrom-tab-active{
  998. background: #FFD9D9;
  999. border-radius: 10rpx;
  1000. position: relative;
  1001. &::after{
  1002. content: "";
  1003. position: absolute;
  1004. bottom:-26rpx;
  1005. left:0;
  1006. right:0;
  1007. margin:auto;
  1008. width:0;
  1009. height:0;
  1010. border:16rpx solid transparent;
  1011. border-top: 16rpx solid #FFD9D9;
  1012. }
  1013. .note{
  1014. background-image: linear-gradient(90deg, #FF9048 0%, #FB3F3C 100%);
  1015. background-clip: text;
  1016. color: transparent;
  1017. }
  1018. }
  1019. }
  1020. }
  1021. .goodsListEmpty.goods-item-wrap {
  1022. padding: 28rpx;
  1023. display: flex;
  1024. align-items: center;
  1025. background-color: #fff;
  1026. .lt-wrap {
  1027. width: 220rpx;
  1028. height: 220rpx;
  1029. border-radius: 10rpx;
  1030. overflow: hidden;
  1031. .goods-item-img {
  1032. width: 100%;
  1033. height: 100%;
  1034. vertical-align: middle; // 解决图片下边框缝隙问题
  1035. }
  1036. }
  1037. .rt-wrap {
  1038. margin-left: 20rpx;
  1039. flex: 1;
  1040. .title {
  1041. font-size: 30rpx;
  1042. color: #1A1A1A;
  1043. line-height: 42rpx;
  1044. // 超出两行省略号
  1045. word-break: break-all;
  1046. overflow: hidden;
  1047. -webkit-line-clamp: 2;
  1048. text-overflow: ellipsis;
  1049. display: -webkit-box;
  1050. -webkit-box-orient: vertical;
  1051. font-weight: bold;
  1052. .shop-icon{
  1053. width: 30rpx;
  1054. height: 30rpx;
  1055. border-radius: 6rpx;
  1056. display: inline-block;
  1057. margin-right: 6rpx;
  1058. margin-top: -7rpx;
  1059. vertical-align: middle;//解决图片下边框间隙问题
  1060. }
  1061. }
  1062. .shop-wrap {
  1063. margin-top: 8rpx;
  1064. display: flex;
  1065. align-items: center;
  1066. .shop-icon {
  1067. width: 26rpx;
  1068. height: 26rpx;
  1069. vertical-align: middle;//解决图片下边框间隙问题
  1070. }
  1071. .shop-name {
  1072. margin-left: 6rpx;
  1073. font-size: 24rpx;
  1074. line-height: 34rpx;
  1075. color: #AAAAAA;
  1076. flex: 1;
  1077. max-width: 400rpx;
  1078. white-space: nowrap;
  1079. overflow: hidden;
  1080. text-overflow: ellipsis;
  1081. }
  1082. }
  1083. .price-wrap {
  1084. margin-top: 10rpx;
  1085. display: flex;
  1086. align-items: center;
  1087. .price {
  1088. font-size: 36rpx;
  1089. line-height: 50rpx;
  1090. color: #FF4040;
  1091. font-weight: bold;
  1092. }
  1093. .start-price {
  1094. margin-left: 10rpx;
  1095. font-size: 24rpx;
  1096. color: #999999;
  1097. line-height: 34rpx;
  1098. text-decoration: line-through;
  1099. }
  1100. }
  1101. .btm-wrap {
  1102. display: flex;
  1103. align-items: center;
  1104. margin-top: 10rpx;
  1105. .coupon-wrap {
  1106. display: flex;
  1107. align-items: center;
  1108. width: 144rpx;
  1109. height: 36rpx;
  1110. // background-image: url("https://ld.726p.com/ldyx_static/imgs/bg-quan-small.png");
  1111. background-repeat: no-repeat;
  1112. background-size: 100% 100%;
  1113. color: #FF4040;
  1114. font-size: 25rpx;
  1115. line-height: 36rpx;
  1116. .label {
  1117. width: 46rpx;
  1118. text-align: center;
  1119. }
  1120. .value {
  1121. flex: 1;
  1122. text-align: center;
  1123. }
  1124. }
  1125. .commission-wrap {
  1126. // background-image: url("https://ld.726p.com/ldyx_static/imgs/fan.png");
  1127. color: #AE4300;
  1128. margin-left: 12rpx;
  1129. }
  1130. }
  1131. }
  1132. }
  1133. </style>