index.vue 14 KB

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