index.vue 13 KB

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