index.vue 12 KB

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