index.vue 14 KB

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