index.vue 13 KB

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