index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. <template>
  2. <view class="indexBox">
  3. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  4. <swiper-item v-for="item in imagelist" class="carousel-item" @click="navTo(item.url)">
  5. <image class="imageitem" :src="item.img" />
  6. </swiper-item>
  7. </swiper>
  8. <view class="hot-list-box">
  9. <view class="title-box flex">
  10. <view class="flex">
  11. <image class="hot margin-r-10" src="../../static/icon/hot.png" mode="scaleToFill"></image>
  12. <view class="title">
  13. 热门名片
  14. </view>
  15. </view>
  16. <navigator url="/pages/user/model/modelList?ishot=1">
  17. <view class="right flex">
  18. <text class="margin-r-10">
  19. 更多
  20. </text>
  21. <image src="../../static/icon/next1.png" mode="scaleToFill" class="tip"></image>
  22. </view>
  23. </navigator>
  24. </view>
  25. <view class="hot-list">
  26. <view class="item" v-for="item in rmList"
  27. @click="navTo('/pages/user/model/model?mtype=' + item.id+'&type=0')">
  28. <view class="hot-image-box">
  29. <image class="hot-image" :src="item.img" mode="widthFix"></image>
  30. </view>
  31. <view class="hot-title clamp">
  32. {{item.title}}
  33. </view>
  34. <view class="hot-money flex clamp">
  35. <text class="money">
  36. ¥{{item.price}}
  37. </text>
  38. <text class="oldmoney">
  39. {{item.old_price}}
  40. </text>
  41. </view>
  42. </view>
  43. <view class="item-none" v-if="rmList.length<3" v-for="item in (3-rmList.length)">
  44. </view>
  45. </view>
  46. <view class="banner" @click="navTo('/pages/user/model/phb')">
  47. <image src="../../static/img/phb.png" mode="widthFix"></image>
  48. </view>
  49. <view class="title-box flex">
  50. <!-- <view class="flex">
  51. <image class="hot margin-r-10" src="../../static/icon/hot.png" mode="scaleToFill"></image>
  52. <view class="title">
  53. 名片推荐
  54. </view>
  55. </view>
  56. <navigator url="/pages/user/model/modelList?isrecommend=1">
  57. <view class="right flex">
  58. <text class="margin-r-10">
  59. 更多
  60. </text>
  61. <image src="../../static/icon/next1.png" mode="scaleToFill" class="tip"></image>
  62. </view>
  63. </navigator> -->
  64. <view class="sy-top">
  65. <image src="../../static/icon/tj.png" mode=""></image>
  66. <view class="top-tit">
  67. 精选推荐
  68. </view>
  69. </view>
  70. </view>
  71. <view class="list-box">
  72. <view class="list" v-for="(item,index) in navList.orderList"
  73. @click="navTo('/pages/user/model/model?mtype=' + item.id+'&type=0')">
  74. <view class="list-image-box">
  75. <image class="list-image" :src="item.img" mode="widthFix"></image>
  76. </view>
  77. <view class="list-content">
  78. <view class="list-title clamp">
  79. {{item.title}}
  80. </view>
  81. <view class="list-money flex flex-start">
  82. <view class="money">
  83. ¥{{item.price}}
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="title-box flex" v-if="jxList.length > 0">
  90. <view class="flex">
  91. <image class="hot margin-r-10" src="../../static/icon/hot.png" mode="scaleToFill"></image>
  92. <view class="title">
  93. 精选名片推荐
  94. </view>
  95. </view>
  96. </view>
  97. <view class="bd-wrap">
  98. <view class="bd-btm-item flex" v-for="item in jxList" @click="navTo('/pages/user/model/model?uid=' + item.uid + '&mtype=' + item.show_template_id + '&type=2')" v-if="item.name != '影子' && item.name != '测试牛niu' &&item.name != '111'">
  99. <image :src="item.avatar" mode="" class="item-img"></image>
  100. <view class="flex item-info">
  101. <view class="item-name">
  102. {{item.name}}
  103. <image :src="rz" mode="" v-if="item.is_type_audit == 1"></image>
  104. </view>
  105. <view class="item-where">
  106. {{item.age}}岁
  107. </view>
  108. <view class="item-zy">
  109. {{item.user_work_type_title}}
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <view class="title-box flex" v-if="zxList.length > 0">
  115. <view class="flex">
  116. <image class="hot margin-r-10" src="../../static/icon/hot.png" mode="scaleToFill"></image>
  117. <view class="title">
  118. 最新名片推荐
  119. </view>
  120. </view>
  121. </view>
  122. <view class="bd-wrap">
  123. <view class="bd-btm-item flex" v-for="item in zxList" @click="navTo('/pages/user/model/model?uid=' + item.uid + '&mtype=' + item.show_template_id + '&type=2')" v-if="item.name != '影子' && item.name != '测试牛niu' &&item.name != '111'">
  124. <image :src="item.avatar" mode="" class="item-img"></image>
  125. <view class="flex item-info">
  126. <view class="item-name">
  127. {{item.name}}
  128. <image :src="rz" mode="" v-if="item.is_type_audit == 1"></image>
  129. </view>
  130. <view class="item-where">
  131. {{item.age}}岁
  132. </view>
  133. <view class="item-zy">
  134. {{item.user_work_type_title}}
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="footer">
  141. 仅显示50条
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import {
  147. mapState,
  148. mapMutations
  149. } from 'vuex';
  150. import {
  151. share
  152. } from '@/api/wx';
  153. import {
  154. getBannerList,
  155. getShowTemplateList
  156. } from '@/api/model.js';
  157. import {
  158. getWorkerList,
  159. getGoodWorkerList,
  160. getNewWorkerList
  161. } from '@/api/index.js'
  162. export default {
  163. data() {
  164. return {
  165. rz: this.$store.state.baseURL + '/resource/icon/rz.png',
  166. //轮播图
  167. imagelist: [],
  168. // 推荐商品
  169. navList: {
  170. state: 1,
  171. text: '通知',
  172. loadingType: 'more',
  173. orderList: [],
  174. page: 1, //当前页数
  175. limit: 10, //每次信息条数
  176. count: 0, //总消息条数
  177. },
  178. // 热门商品
  179. rmList: [],
  180. jxList: [], //精选列表
  181. zxList:[]
  182. };
  183. },
  184. computed: {
  185. ...mapState('user', ['userInfo']),
  186. },
  187. onLoad: function(option) {
  188. // #ifndef MP
  189. if (option.spread) {
  190. // 存储其他邀请人
  191. uni.setStorageSync('spread', option.spread);
  192. }
  193. // #endif
  194. // #ifdef MP
  195. if (option.scene) {
  196. // 存储小程序邀请人
  197. uni.setStorage({
  198. key: 'spread_code',
  199. data: option.scene
  200. });
  201. }
  202. // #endif
  203. // 加载分享信息
  204. this.share()
  205. },
  206. onShow() {
  207. this.loadIndexs();
  208. this.getWorkerList()
  209. this.getNewWorkerList();
  210. },
  211. onReady() {},
  212. // 滚动到底部
  213. onReachBottom() {
  214. // this.getShowTemplateList();
  215. },
  216. // #ifdef MP
  217. onShareAppMessage(options) {
  218. // 设置菜单中的转发按钮触发转发事件时的转发内容
  219. let pages = getCurrentPages(); //获取加载的页面
  220. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  221. let url = currentPage.route; //当前页面url
  222. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  223. let shareObj = {
  224. title: this.shareData.title, // 默认是小程序的名称(可以写slogan等)
  225. path: this.shareData.query, // 默认是当前页面,必须是以‘/’开头的完整路径
  226. // imageUrl: this.shareData.img,
  227. desc: this.shareData.content,
  228. success: function(res) {
  229. // 转发成功之后的回调
  230. if (res.errMsg == 'shareAppMessage:ok') {}
  231. },
  232. fail: function() {
  233. // 转发失败之后的回调
  234. if (res.errMsg == 'shareAppMessage:fail cancel') {
  235. // 用户取消转发
  236. } else if (res.errMsg == 'shareAppMessage:fail') {
  237. // 转发失败,其中 detail message 为详细失败信息
  238. }
  239. }
  240. };
  241. // 判断是否可以邀请
  242. if (this.userInfo.uid) {
  243. shareObj.path += '&spread=' + this.userInfo.uid;
  244. }
  245. return shareObj;
  246. },
  247. // #endif
  248. methods: {
  249. getWorkerList() {
  250. try {
  251. getGoodWorkerList().then(res => {
  252. let arr = []
  253. // console.log(res,'basa');
  254. res.data.list.forEach(item => {
  255. let cc = false
  256. arr.forEach(itemt => {
  257. if(itemt.uid == item.uid) {
  258. cc = true
  259. }
  260. })
  261. if(!cc) {
  262. arr.push(item)
  263. // console.log(item,arr);
  264. }
  265. })
  266. this.jxList = arr
  267. // console.log(arr,this.jxList,'dddddd');
  268. })
  269. } catch (e) {
  270. //TODO handle the exception
  271. console.log(e);
  272. }
  273. },
  274. // 最新名片
  275. getNewWorkerList() {
  276. try {
  277. getNewWorkerList().then(res => {
  278. let arr = []
  279. // console.log(res,'basa');
  280. res.data.list.forEach(item => {
  281. let cc = false
  282. arr.forEach(itemt => {
  283. if(itemt.uid == item.uid) {
  284. cc = true
  285. }
  286. })
  287. if(!cc) {
  288. arr.push(item)
  289. // console.log(item,arr);
  290. }
  291. })
  292. this.zxList = arr
  293. // console.log(arr,this.jxList,'dddddd');
  294. })
  295. } catch (e) {
  296. //TODO handle the exception
  297. console.log(e);
  298. }
  299. },
  300. swiperChange() {
  301. },
  302. share() {
  303. // console.log('加载分享');
  304. const that = this;
  305. // 请求获取默认数据
  306. share({}).then(({
  307. data
  308. }) => {
  309. // console.log('分享回调', data);
  310. that.shareData = data.data
  311. });
  312. },
  313. // 首页初始化
  314. loadIndexs() {
  315. const that = this;
  316. // 轮播图
  317. getBannerList().then(
  318. (res) => {
  319. that.imagelist = res.data.list
  320. // console.log(res);
  321. }
  322. ).catch(
  323. (res) => {
  324. console.log(res);
  325. }
  326. )
  327. // 获取热门
  328. getShowTemplateList({
  329. is_hot: 1,
  330. pageSize: 3
  331. }).then(
  332. (res) => {
  333. that.rmList = res.data.list.map((res) => {
  334. res.price = +res.price
  335. res.old_price = +res.old_price
  336. return res
  337. })
  338. // console.log(res);
  339. }
  340. ).catch(
  341. (res) => {
  342. console.log(res);
  343. }
  344. )
  345. that.getShowTemplateList();
  346. },
  347. // 获取模板列表
  348. getShowTemplateList(source) {
  349. //这里是将订单挂载到tab列表下
  350. let navItem = this.navList;
  351. let state = navItem.state;
  352. if (source === 'tabChange' && navItem.loaded === true) {
  353. //tab切换只有第一次需要加载数据
  354. return;
  355. }
  356. if (navItem.loadingType === 'loading') {
  357. //防止重复加载
  358. return;
  359. }
  360. if (navItem.loadingType === 'noMore') {
  361. //防止重复加载
  362. return;
  363. }
  364. // 修改当前对象状态为加载中
  365. navItem.loadingType = 'loading';
  366. getShowTemplateList({
  367. is_recommend: 1,
  368. page: navItem.page,
  369. pageSize: navItem.limit
  370. })
  371. .then(({
  372. data
  373. }) => {
  374. let arr = data.list.map(e => {
  375. return e;
  376. });
  377. navItem.orderList = navItem.orderList.concat(arr);
  378. navItem.page++;
  379. if (navItem.limit == arr.length) {
  380. //判断是否还有数据, 有改为 more, 没有改为noMore
  381. navItem.loadingType = 'more';
  382. return;
  383. } else {
  384. //判断是否还有数据, 有改为 more, 没有改为noMore
  385. navItem.loadingType = 'noMore';
  386. }
  387. uni.hideLoading();
  388. this.$set(navItem, 'loaded', true);
  389. })
  390. .catch(e => {
  391. console.log(e);
  392. });
  393. },
  394. navTo(url) {
  395. if (url) {
  396. if (url.indexOf('http') > -1) {
  397. // #ifdef H5
  398. window.location.href = url
  399. // #endif
  400. // #ifdef APP
  401. plus.runtime.openURL(url)
  402. // #endif
  403. } else {
  404. uni.navigateTo({
  405. url: url
  406. })
  407. }
  408. }
  409. }
  410. },
  411. };
  412. </script>
  413. <style lang="scss">
  414. page,
  415. .indexBox {
  416. height: auto;
  417. min-height: 100%;
  418. }
  419. .indexBox {
  420. padding-bottom: 50rpx;
  421. }
  422. .top-swiper {
  423. margin: auto;
  424. width: 750rpx;
  425. height: 273rpx;
  426. padding: 0 $page-row-spacing;
  427. background: linear-gradient(to bottom, #ff629f, rgba(255, 255, 255, 1) 80%, rgba(255, 255, 255, 1));
  428. .carousel-item {
  429. border-radius: 20rpx;
  430. .imageitem {
  431. // margin: auto;
  432. width: 690rpx;
  433. height: 273rpx;
  434. }
  435. }
  436. }
  437. .hot-list-box {
  438. padding: $page-row-spacing;
  439. background-color: #FFFFFF;
  440. padding-bottom: 0;
  441. .title-box {
  442. line-height: 1;
  443. .hot {
  444. width: 36rpx;
  445. height: 36rpx;
  446. }
  447. .title {
  448. font-size: $font-lg;
  449. font-weight: bold;
  450. }
  451. .right {
  452. font-size: $font-sm;
  453. color: #999999;
  454. .tip {
  455. width: 15rpx;
  456. height: 25rpx;
  457. }
  458. }
  459. }
  460. .hot-list {
  461. display: flex;
  462. flex-wrap: wrap;
  463. justify-content: space-between;
  464. align-items: flex-start;
  465. padding-top: 30rpx;
  466. padding-bottom: 15rpx;
  467. .item-none {
  468. width: 220rpx;
  469. }
  470. .item {
  471. padding: 13rpx;
  472. width: 220rpx;
  473. border-radius: 10rpx;
  474. border: 2px solid #F65486;
  475. margin-bottom: 16rpx;
  476. line-height: 1;
  477. .hot-title {
  478. color: $font-color-dark;
  479. font-size: $font-base;
  480. padding: 10rpx 0;
  481. }
  482. .hot-image-box {
  483. width: 194rpx;
  484. height: 228rpx;
  485. overflow: hidden;
  486. .hot-image {
  487. width: 100%;
  488. }
  489. }
  490. .hot-money {
  491. .money {
  492. font: $font-lg;
  493. color: #FF3342;
  494. }
  495. .oldmoney {
  496. color: #969696;
  497. font-size: $font-sm;
  498. text-decoration: line-through;
  499. }
  500. }
  501. }
  502. }
  503. .list-box {
  504. display: flex;
  505. flex-wrap: wrap;
  506. justify-content: space-between;
  507. align-items: flex-start;
  508. padding-top: 30rpx;
  509. padding-bottom: 20rpx;
  510. .list {
  511. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  512. border-radius: 15rpx;
  513. margin-bottom: 20rpx;
  514. .list-image-box {
  515. width: 330rpx;
  516. height: 420rpx;
  517. overflow: hidden;
  518. .list-image {
  519. width: 100%;
  520. }
  521. }
  522. .list-content {
  523. padding: 20rpx;
  524. line-height: 1;
  525. .list-title {
  526. color: $font-color-dark;
  527. font-size: $font-base;
  528. margin-bottom: 20rpx;
  529. }
  530. .list-money {
  531. .money {
  532. font: $font-lg;
  533. color: #FF3342;
  534. }
  535. }
  536. }
  537. }
  538. }
  539. }
  540. .sy-top {
  541. position: relative;
  542. height: 100rpx;
  543. width: 100%;
  544. image {
  545. width: 374rpx;
  546. height: 30rpx;
  547. position: absolute;
  548. top: 0;
  549. bottom: 0;
  550. left: 0;
  551. right: 0;
  552. margin: auto;
  553. }
  554. .top-tit {
  555. font-size: 32rpx;
  556. font-weight: bold;
  557. color: #FF478B;
  558. text-align: center;
  559. line-height: 100rpx;
  560. }
  561. }
  562. .bd-btm-item {
  563. border-top: #f2f2f2 1px solid;
  564. flex-direction: column;
  565. width: 330rpx;
  566. height: 520rpx;
  567. &:first-of-type {
  568. border-top: none;
  569. }
  570. margin-bottom: 20rpx;
  571. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(46, 46, 49, 0.06);
  572. border-radius: 20rpx;
  573. .item-info {
  574. flex-direction: column;
  575. justify-content: flex-start;
  576. align-items: flex-start;
  577. width: 100%;
  578. height: 100%;
  579. padding-left: 20rpx;
  580. padding-top: 20rpx;
  581. .item-name {
  582. font-size: 31rpx;
  583. font-weight: bold;
  584. color: #333333;
  585. display: flex;
  586. align-items: center;
  587. justify-content: flex-start;
  588. image {
  589. width: 100rpx;
  590. height: 30rpx;
  591. margin-left: 10rpx;
  592. }
  593. }
  594. .item-zy {
  595. padding: 6rpx 20rpx;
  596. background: #fee7e4;
  597. border-radius: 5rpx;
  598. font-size: 22rpx;
  599. font-weight: 500;
  600. color: #F86859;
  601. margin: 16rpx 0 20rpx;
  602. }
  603. .item-vist,
  604. .item-where {
  605. font-weight: 500;
  606. color: #969696;
  607. }
  608. .item-vist {
  609. font-size: 22rpx;
  610. justify-items: flex-end;
  611. }
  612. .item-where {
  613. font-size: 24rpx;
  614. }
  615. }
  616. .item-img {
  617. flex-shrink: 0;
  618. width: 330rpx;
  619. height: 330rpx;
  620. background-color: #eee;
  621. }
  622. }
  623. .jg {
  624. height: 20rpx;
  625. }
  626. .bd-wrap {
  627. display: flex;
  628. justify-content: space-between;
  629. flex-wrap: wrap;
  630. padding: 30rpx 0;
  631. }
  632. .banner {
  633. image {
  634. width: 691rpx;
  635. margin: auto;
  636. }
  637. padding: 20rpx 0;
  638. }
  639. .footer{
  640. text-align: center;
  641. color: $font-color-light;
  642. margin-top: 30rpx;
  643. }
  644. </style>