index.vue 13 KB

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