index.vue 16 KB

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