index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. let arr = []
  230. console.log(res,'basa');
  231. res.data.list.forEach(item => {
  232. let cc = false
  233. arr.forEach(itemt => {
  234. if(itemt.uid == item.uid) {
  235. cc = true
  236. }
  237. })
  238. if(!cc) {
  239. arr.push(item)
  240. console.log(item,arr);
  241. }
  242. })
  243. this.jxList = arr
  244. console.log(arr,this.jxList,'dddddd');
  245. })
  246. } catch (e) {
  247. //TODO handle the exception
  248. console.log(e);
  249. }
  250. },
  251. swiperChange() {
  252. },
  253. share() {
  254. // console.log('加载分享');
  255. const that = this;
  256. // 请求获取默认数据
  257. share({}).then(({
  258. data
  259. }) => {
  260. // console.log('分享回调', data);
  261. that.shareData = data.data
  262. });
  263. },
  264. // 首页初始化
  265. loadIndexs() {
  266. const that = this;
  267. // 轮播图
  268. getBannerList().then(
  269. (res) => {
  270. that.imagelist = res.data.list
  271. console.log(res);
  272. }
  273. ).catch(
  274. (res) => {
  275. console.log(res);
  276. }
  277. )
  278. // 获取热门
  279. getShowTemplateList({
  280. is_hot: 1,
  281. pageSize: 3
  282. }).then(
  283. (res) => {
  284. that.rmList = res.data.list.map((res) => {
  285. res.price = +res.price
  286. res.old_price = +res.old_price
  287. return res
  288. })
  289. console.log(res);
  290. }
  291. ).catch(
  292. (res) => {
  293. console.log(res);
  294. }
  295. )
  296. that.getShowTemplateList();
  297. },
  298. // 获取模板列表
  299. getShowTemplateList(source) {
  300. //这里是将订单挂载到tab列表下
  301. let navItem = this.navList;
  302. let state = navItem.state;
  303. if (source === 'tabChange' && navItem.loaded === true) {
  304. //tab切换只有第一次需要加载数据
  305. return;
  306. }
  307. if (navItem.loadingType === 'loading') {
  308. //防止重复加载
  309. return;
  310. }
  311. if (navItem.loadingType === 'noMore') {
  312. //防止重复加载
  313. return;
  314. }
  315. // 修改当前对象状态为加载中
  316. navItem.loadingType = 'loading';
  317. getShowTemplateList({
  318. is_recommend: 1,
  319. page: navItem.page,
  320. pageSize: navItem.limit
  321. })
  322. .then(({
  323. data
  324. }) => {
  325. let arr = data.list.map(e => {
  326. return e;
  327. });
  328. navItem.orderList = navItem.orderList.concat(arr);
  329. navItem.page++;
  330. if (navItem.limit == arr.length) {
  331. //判断是否还有数据, 有改为 more, 没有改为noMore
  332. navItem.loadingType = 'more';
  333. return;
  334. } else {
  335. //判断是否还有数据, 有改为 more, 没有改为noMore
  336. navItem.loadingType = 'noMore';
  337. }
  338. uni.hideLoading();
  339. this.$set(navItem, 'loaded', true);
  340. })
  341. .catch(e => {
  342. console.log(e);
  343. });
  344. },
  345. navTo(url) {
  346. if (url) {
  347. if (url.indexOf('http') > -1) {
  348. // #ifdef H5
  349. window.location.href = url
  350. // #endif
  351. // #ifdef APP
  352. plus.runtime.openURL(url)
  353. // #endif
  354. } else {
  355. uni.navigateTo({
  356. url: url
  357. })
  358. }
  359. }
  360. }
  361. },
  362. };
  363. </script>
  364. <style lang="scss">
  365. page,
  366. .indexBox {
  367. height: auto;
  368. min-height: 100%;
  369. }
  370. .indexBox {
  371. padding-bottom: 50rpx;
  372. }
  373. .top-swiper {
  374. margin: auto;
  375. width: 750rpx;
  376. height: 273rpx;
  377. padding: 0 $page-row-spacing;
  378. background: linear-gradient(to bottom, #ff629f, rgba(255, 255, 255, 1) 80%, rgba(255, 255, 255, 1));
  379. .carousel-item {
  380. border-radius: 20rpx;
  381. .imageitem {
  382. // margin: auto;
  383. width: 690rpx;
  384. height: 273rpx;
  385. }
  386. }
  387. }
  388. .hot-list-box {
  389. padding: $page-row-spacing;
  390. background-color: #FFFFFF;
  391. padding-bottom: 0;
  392. .title-box {
  393. line-height: 1;
  394. .hot {
  395. width: 36rpx;
  396. height: 36rpx;
  397. }
  398. .title {
  399. font-size: $font-lg;
  400. font-weight: bold;
  401. }
  402. .right {
  403. font-size: $font-sm;
  404. color: #999999;
  405. .tip {
  406. width: 15rpx;
  407. height: 25rpx;
  408. }
  409. }
  410. }
  411. .hot-list {
  412. display: flex;
  413. flex-wrap: wrap;
  414. justify-content: space-between;
  415. align-items: flex-start;
  416. padding-top: 30rpx;
  417. padding-bottom: 15rpx;
  418. .item-none {
  419. width: 220rpx;
  420. }
  421. .item {
  422. padding: 13rpx;
  423. width: 220rpx;
  424. border-radius: 10rpx;
  425. border: 2px solid #F65486;
  426. margin-bottom: 16rpx;
  427. line-height: 1;
  428. .hot-title {
  429. color: $font-color-dark;
  430. font-size: $font-base;
  431. padding: 10rpx 0;
  432. }
  433. .hot-image-box {
  434. width: 194rpx;
  435. height: 228rpx;
  436. overflow: hidden;
  437. .hot-image {
  438. width: 100%;
  439. }
  440. }
  441. .hot-money {
  442. .money {
  443. font: $font-lg;
  444. color: #FF3342;
  445. }
  446. .oldmoney {
  447. color: #969696;
  448. font-size: $font-sm;
  449. text-decoration: line-through;
  450. }
  451. }
  452. }
  453. }
  454. .list-box {
  455. display: flex;
  456. flex-wrap: wrap;
  457. justify-content: space-between;
  458. align-items: flex-start;
  459. padding-top: 30rpx;
  460. padding-bottom: 20rpx;
  461. .list {
  462. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  463. border-radius: 15rpx;
  464. margin-bottom: 20rpx;
  465. .list-image-box {
  466. width: 330rpx;
  467. height: 420rpx;
  468. overflow: hidden;
  469. .list-image {
  470. width: 100%;
  471. }
  472. }
  473. .list-content {
  474. padding: 20rpx;
  475. line-height: 1;
  476. .list-title {
  477. color: $font-color-dark;
  478. font-size: $font-base;
  479. margin-bottom: 20rpx;
  480. }
  481. .list-money {
  482. .money {
  483. font: $font-lg;
  484. color: #FF3342;
  485. }
  486. }
  487. }
  488. }
  489. }
  490. }
  491. .sy-top {
  492. position: relative;
  493. height: 100rpx;
  494. width: 100%;
  495. image {
  496. width: 374rpx;
  497. height: 30rpx;
  498. position: absolute;
  499. top: 0;
  500. bottom: 0;
  501. left: 0;
  502. right: 0;
  503. margin: auto;
  504. }
  505. .top-tit {
  506. font-size: 32rpx;
  507. font-weight: bold;
  508. color: #FF478B;
  509. text-align: center;
  510. line-height: 100rpx;
  511. }
  512. }
  513. .bd-btm-item {
  514. border-top: #f2f2f2 1px solid;
  515. flex-direction: column;
  516. width: 330rpx;
  517. height: 520rpx;
  518. &:first-of-type {
  519. border-top: none;
  520. }
  521. margin-bottom: 20rpx;
  522. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(46, 46, 49, 0.06);
  523. border-radius: 20rpx;
  524. .item-info {
  525. flex-direction: column;
  526. justify-content: flex-start;
  527. align-items: flex-start;
  528. width: 100%;
  529. height: 100%;
  530. padding-left: 20rpx;
  531. padding-top: 20rpx;
  532. .item-name {
  533. font-size: 31rpx;
  534. font-weight: bold;
  535. color: #333333;
  536. display: flex;
  537. align-items: center;
  538. justify-content: flex-start;
  539. image {
  540. width: 100rpx;
  541. height: 30rpx;
  542. margin-left: 10rpx;
  543. }
  544. }
  545. .item-zy {
  546. padding: 6rpx 20rpx;
  547. background: #fee7e4;
  548. border-radius: 5rpx;
  549. font-size: 22rpx;
  550. font-weight: 500;
  551. color: #F86859;
  552. margin: 16rpx 0 20rpx;
  553. }
  554. .item-vist,
  555. .item-where {
  556. font-weight: 500;
  557. color: #969696;
  558. }
  559. .item-vist {
  560. font-size: 22rpx;
  561. justify-items: flex-end;
  562. }
  563. .item-where {
  564. font-size: 24rpx;
  565. }
  566. }
  567. .item-img {
  568. flex-shrink: 0;
  569. width: 330rpx;
  570. height: 330rpx;
  571. background-color: #eee;
  572. }
  573. }
  574. .jg {
  575. height: 20rpx;
  576. }
  577. .bd-wrap {
  578. display: flex;
  579. justify-content: space-between;
  580. flex-wrap: wrap;
  581. padding: 30rpx 0;
  582. }
  583. .banner {
  584. image {
  585. width: 691rpx;
  586. margin: auto;
  587. }
  588. padding: 20rpx 0;
  589. }
  590. </style>