index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1" v-if="barActive=='0'">
  6. <view class="first">
  7. <image class="image" :src="info.logo&&info.logo.length>0?info.logo[0].url:''" mode=""></image>
  8. </view>
  9. <view class="second">
  10. <scroll-view scroll-y="true" class="scroll-view">
  11. <view class="list-scroll-view">
  12. <view class="list" v-for="(item,index) in shoplist" :key="index">
  13. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
  14. <view class="name">
  15. {{item.name}}
  16. </view>
  17. <view class="other">
  18. <view class="money">
  19. <text>¥</text>
  20. <text>{{item.sell_money}}</text>
  21. </view>
  22. <view class="btn">
  23. <button type="default" size="mini" @click="toBuy(item)">购买</button>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </scroll-view>
  29. </view>
  30. </view>
  31. <view class="one_3" v-else-if="barActive=='1'">
  32. <view class="first">
  33. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索商品">
  34. </view>
  35. <view class="second">
  36. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  37. <view class="list-scroll-view">
  38. <view class="second_1">
  39. <view :class="['list',condActive==index?'activeList':'']" v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
  40. <view class="name">
  41. {{item.name}}
  42. </view>
  43. <view class="icon">
  44. <view class="icon_1">
  45. <text :class="['iconfont',item.shangActive]" v-if="condActive==index&&shang=='1'"></text>
  46. <text :class="['iconfont',item.shang]" v-else></text>
  47. </view>
  48. <view class="icon_1">
  49. <text :class="['iconfont', item.xiaActive]" v-if="condActive==index&&xia=='-1'"></text>
  50. <text :class="['iconfont', item.xia]" v-else></text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="second_2">
  56. <view class="list" v-for="(item,index) in list" :key="index">
  57. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode=""></image>
  58. <view class="sale" v-if="item.is_sale==true">
  59. <text>已售尽</text>
  60. </view>
  61. <view class="name">
  62. {{item.name}}
  63. </view>
  64. <view class="other">
  65. <view class="money">
  66. <text>¥</text>
  67. <text>{{item.sell_money}}</text>
  68. </view>
  69. <view class="btn">
  70. <button type="default" size="mini" @click="toBuy(item)">购买</button>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </view>
  79. <view class="one_4" v-else-if="barActive=='2'">
  80. <view class="first">
  81. <image class="image" :src="info.logo&&info.logo.length>0?info.logo[0].url:''" mode=""></image>
  82. <view class="name">{{info.name}}</view>
  83. </view>
  84. <view class="second">
  85. <view class="second_1">
  86. <view class="grade">
  87. <view>{{info.goods_score||0}}</view>
  88. 商品
  89. </view>
  90. <view class="grade">
  91. <view>{{info.send_score||0}}</view>
  92. 发货
  93. </view>
  94. <view class="grade">
  95. <view>{{info.service_score||0}}</view>
  96. 服务
  97. </view>
  98. </view>
  99. <view class="second_2">
  100. <view class="second_2_bor">
  101. <image class="image" :src="info.qrcode&&info.qrcode.length>0?info.qrcode[0].url:''" mode=""></image>
  102. </view>
  103. <view class="txt">
  104. 店铺二维码
  105. </view>
  106. </view>
  107. </view>
  108. <view class="collect">
  109. <text v-if="!collection" @click="toCollect" class="iconfont icon-yduishoucangkongxin"></text>
  110. <text v-else @click="toCollect" class="iconfont icon-yduishoucangshixin"></text>
  111. </view>
  112. </view>
  113. </view>
  114. <view class="two">
  115. <view class="list" v-for="(item,index) in barList" :key="index" @tap="barChange(index,item)">
  116. <view class="icon">
  117. <text :class="['iconfont',barActive==index?item.acticon:item.icon]"></text>
  118. </view>
  119. <view :class="['name',barActive==index?'activename':'']">
  120. {{item.name}}
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </mobile-frame>
  126. </template>
  127. <script>
  128. export default {
  129. data() {
  130. return {
  131. id: '',
  132. barActive: '0',
  133. barList: [ //底部菜单
  134. {
  135. icon: 'icon-shangdian',
  136. acticon: "icon-shangdian-copy",
  137. name: '微店首页'
  138. },
  139. {
  140. icon: 'icon-shangpinfenlei',
  141. acticon: "icon-shangpinfenlei-copy",
  142. name: '全部商品'
  143. },
  144. {
  145. icon: 'icon-qiyejianjie',
  146. acticon: "icon-qiyejianjie-copy",
  147. name: '店铺简介'
  148. }
  149. ],
  150. // 店铺信息
  151. info: {},
  152. // 店铺部分商品
  153. shoplist: [],
  154. // 收藏
  155. collection: false,
  156. // 全部商品
  157. searchInfo: {},
  158. list: [],
  159. total: 0,
  160. page: 0,
  161. skip: 0,
  162. limit: 5,
  163. condActive: 0,
  164. shang: '',
  165. xia: '',
  166. condList: [ // 筛选
  167. {
  168. name: '默认',
  169. },
  170. {
  171. name: '销量',
  172. shang: 'icon-shangjiantou',
  173. shangActive: 'icon-shangjiantou-copy',
  174. xia: 'icon-xiajiantou',
  175. xiaActive: 'icon-xiajiantou-copy'
  176. },
  177. {
  178. name: '价格',
  179. shang: 'icon-shangjiantou',
  180. shangActive: 'icon-shangjiantou-copy',
  181. xia: 'icon-xiajiantou',
  182. xiaActive: 'icon-xiajiantou-copy'
  183. },
  184. {
  185. name: '浏览量',
  186. shang: 'icon-shangjiantou',
  187. shangActive: 'icon-shangjiantou-copy',
  188. xia: 'icon-xiajiantou',
  189. xiaActive: 'icon-xiajiantou-copy'
  190. }
  191. ]
  192. };
  193. },
  194. onLoad: function(e) {
  195. const that = this;
  196. that.$set(that, `id`, e.id || '6333d71d32c5f69745f9bd32');
  197. that.search()
  198. },
  199. onShow: function() {},
  200. methods: {
  201. // 查询信息
  202. async search() {
  203. const that = this;
  204. if (that.id) {
  205. // 查询店铺信息
  206. const res = await that.$api(`/shop/${that.id}`, 'GET');
  207. if (res.errcode == '0') that.$set(that, `info`, res.data);
  208. // 查询店铺商品
  209. that.searchShopMarket();
  210. // 查询全部商品
  211. that.searchAll();
  212. }
  213. },
  214. // 查询店铺商品
  215. async searchShopMarket() {
  216. const that = this;
  217. const res = await that.$api(`/viewGoods/indexGoodsList`, 'GET', {
  218. shop: that.id,
  219. skip: 0,
  220. limit: 20
  221. })
  222. if (res.errcode == '0') that.$set(that, `shoplist`, res.data);
  223. },
  224. // 查询全部产品
  225. async searchAll() {
  226. const that = this;
  227. let info = {
  228. shop: that.id,
  229. skip: that.skip,
  230. limit: that.limit
  231. }
  232. const res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
  233. ...info,
  234. ...that.searchInfo
  235. })
  236. if (res.errcode == '0') {
  237. let list = [...that.list, ...res.data];
  238. that.$set(that, `list`, list)
  239. that.$set(that, `total`, res.total)
  240. } else {
  241. uni.showToast({
  242. title: res.errmsg,
  243. });
  244. }
  245. },
  246. // 购买
  247. toBuy(item) {
  248. if (item && item._id) {
  249. uni.navigateTo({
  250. url: `/pagesHome/order/detail?id=${item._id}`
  251. })
  252. }
  253. },
  254. // 全部产品-分页
  255. async toPage() {
  256. const that = this;
  257. let list = that.list;
  258. let limit = that.limit;
  259. if (that.total > list.length) {
  260. uni.showLoading({
  261. title: '加载中',
  262. mask: true
  263. })
  264. let page = that.page + 1;
  265. that.$set(that, `page`, page)
  266. let skip = page * limit;
  267. that.$set(that, `skip`, skip)
  268. that.searchAll();
  269. uni.hideLoading();
  270. } else uni.showToast({
  271. title: '没有更多数据了'
  272. });
  273. },
  274. // 输入框
  275. toInput(e) {
  276. const that = this;
  277. that.$set(that.searchInfo, `name`, e.detail.value);
  278. that.searchAll();
  279. },
  280. // 筛选
  281. toCond(index, e) {
  282. const that = this;
  283. let condActive = that.condActive;
  284. that.$set(that, `condActive`, index);
  285. if (condActive != index && that.xia == '') {
  286. that.$set(that, `shang`, '0');
  287. that.$set(that, `xia`, '-1');
  288. } else if (condActive == index && that.xia == '-1') {
  289. that.$set(that, `shang`, '1');
  290. that.$set(that, `xia`, '0');
  291. } else if (condActive == index && that.shang == '1') {
  292. that.$set(that, `shang`, '0');
  293. that.$set(that, `xia`, '-1');
  294. } else if (condActive = index && that.shang == '1') {
  295. that.$set(that, `shang`, '0');
  296. that.$set(that, `xia`, '-1');
  297. }
  298. let key = '';
  299. let value;
  300. if (index != 0) {
  301. value = that.shang == '0' ? that.xia : that.shang;
  302. }
  303. if (index == 1) {
  304. key = 'sell_num';
  305. } else if (index == 2) {
  306. key = 'sell_money';
  307. } else if (index == 3) {
  308. key = 'view_num';
  309. }
  310. that.$set(that.searchInfo, `key`, key);
  311. that.$set(that.searchInfo, `value`, value);
  312. that.searchAll();
  313. },
  314. // 收藏
  315. toCollect() {
  316. const that = this;
  317. that.collection = !that.collection;
  318. if (that.collection == true) {
  319. uni.showToast({
  320. title: `收藏成功`,
  321. icon: 'none'
  322. })
  323. } else {
  324. uni.showToast({
  325. title: `取消成功`,
  326. icon: 'none'
  327. })
  328. }
  329. },
  330. // 选择底部菜单
  331. barChange(index, item) {
  332. const that = this;
  333. that.$set(that, `barActive`, index);
  334. uni.setNavigationBarTitle({
  335. title: item.name
  336. });
  337. },
  338. }
  339. }
  340. </script>
  341. <style lang="scss">
  342. .main {
  343. display: flex;
  344. flex-direction: column;
  345. width: 100vw;
  346. height: 100vh;
  347. .one {
  348. position: relative;
  349. flex-grow: 1;
  350. .one_1 {
  351. display: flex;
  352. flex-direction: column;
  353. width: 96vw;
  354. height: 90vh;
  355. padding: 2vw;
  356. background-color: var(--fFB1Color);
  357. .first {
  358. margin: 0 0 2vw 0;
  359. .image {
  360. width: 100%;
  361. height: 50vw;
  362. }
  363. }
  364. .second {
  365. position: relative;
  366. flex-grow: 1;
  367. .list {
  368. margin: 0 2vw 2vw 0;
  369. background-color: var(--fffColor);
  370. padding: 2vw;
  371. width: 43vw;
  372. border-radius: 5px;
  373. .image {
  374. width: 100%;
  375. height: 49vw;
  376. margin: 0 0 1vw 0;
  377. }
  378. .name {
  379. font-size: var(--font15Size);
  380. margin: 0 0 2vw 0;
  381. }
  382. .other {
  383. display: flex;
  384. flex-direction: row;
  385. justify-content: space-between;
  386. .money {
  387. color: var(--ff0Color);
  388. text:nth-child(1) {
  389. font-size: var(--font12Size);
  390. }
  391. }
  392. .btn {
  393. button {
  394. border-radius: 25px;
  395. color: var(--fffColor);
  396. background-color: var(--ff0Color);
  397. font-size: var(--font12Size);
  398. }
  399. }
  400. }
  401. }
  402. .list:nth-child(2n) {
  403. margin: 0 0 2vw 0;
  404. }
  405. }
  406. }
  407. .one_2 {
  408. height: 91vh;
  409. display: flex;
  410. flex-direction: row;
  411. padding: 2vw;
  412. .first_1 {
  413. position: relative;
  414. width: 25vw;
  415. background-color: #fafafa;
  416. display: flex;
  417. flex-direction: column;
  418. .list {
  419. text-align: center;
  420. padding: 2.5vw 0;
  421. border-bottom: 1px solid var(--f1Color);
  422. text {
  423. font-size: var(--font14Size);
  424. }
  425. }
  426. .listActive {
  427. background-color: var(--fffColor);
  428. }
  429. }
  430. .first_2 {
  431. padding: 2vw;
  432. flex-grow: 1;
  433. position: relative;
  434. display: flex;
  435. flex-direction: column;
  436. .list {
  437. margin: 0 0 2vw 0;
  438. padding: 2vw;
  439. .title {
  440. font-size: var(--font16Size);
  441. margin: 0 0 2vw 0;
  442. }
  443. .market {
  444. display: flex;
  445. flex-direction: row;
  446. flex-wrap: wrap;
  447. .marketList {
  448. text-align: center;
  449. margin: 0 2vw 2vw 0;
  450. width: 22vw;
  451. .image {
  452. width: 100%;
  453. height: 15vw;
  454. }
  455. .name {
  456. font-size: var(--font14Size);
  457. }
  458. }
  459. .marketList:nth-child(3n) {
  460. margin: 0 0 2vw 0;
  461. }
  462. }
  463. }
  464. }
  465. }
  466. .one_3 {
  467. display: flex;
  468. flex-direction: column;
  469. width: 100vw;
  470. height: 90vh;
  471. .first {
  472. border-bottom: 1px solid var(--f85Color);
  473. padding: 2vw;
  474. input {
  475. padding: 2vw;
  476. background-color: var(--f1Color);
  477. font-size: var(--font14Size);
  478. border-radius: 5px;
  479. }
  480. }
  481. .second {
  482. position: relative;
  483. flex-grow: 1;
  484. .second_1 {
  485. width: 96vw;
  486. background-color: var(--fffColor);
  487. padding: 2vw;
  488. display: flex;
  489. flex-direction: row;
  490. justify-content: space-around;
  491. .list {
  492. display: flex;
  493. flex-direction: row;
  494. .icon {
  495. position: relative;
  496. top: -5px;
  497. left: 2px;
  498. .icon_1 {
  499. height: 10px;
  500. .iconfont {
  501. font-size: 12px;
  502. }
  503. }
  504. }
  505. }
  506. .activeList {
  507. .name {
  508. color: #ff0000;
  509. }
  510. }
  511. }
  512. .second_2 {
  513. display: flex;
  514. flex-direction: row;
  515. flex-wrap: wrap;
  516. padding: 2vw 2vw 0 2vw;
  517. background-color: var(--f1Color);
  518. .list {
  519. position: relative;
  520. width: 43vw;
  521. margin: 0 2vw 2vw 0;
  522. padding: 2vw;
  523. border-radius: 9px;
  524. background-color: var(--fffColor);
  525. .image {
  526. width: 100%;
  527. height: 40vw;
  528. }
  529. .sale {
  530. position: absolute;
  531. top: 18vw;
  532. text-align: center;
  533. width: 43vw;
  534. text {
  535. background-color: #0000005f;
  536. border-radius: 90px;
  537. display: inline-block;
  538. width: 15vw;
  539. height: 15vw;
  540. color: var(--fffColor);
  541. text-align: center;
  542. line-height: 15vw;
  543. }
  544. }
  545. .name {
  546. font-size: var(--font16Size);
  547. margin: 0 0 1vw 0;
  548. }
  549. .other {
  550. display: flex;
  551. flex-direction: row;
  552. justify-content: space-between;
  553. .money {
  554. font-size: var(--font14Size);
  555. color: var(--ff0Color);
  556. text:nth-child(1) {
  557. font-size: var(--font12Size);
  558. }
  559. }
  560. .other_1 {
  561. flex-grow: 1;
  562. margin: 0 0 0 2vw;
  563. font-size: var(--font12Size);
  564. color: var(--f85Color);
  565. }
  566. .btn {
  567. button {
  568. border-radius: 25px;
  569. color: var(--fffColor);
  570. background-color: var(--ff0Color);
  571. font-size: var(--font12Size);
  572. }
  573. }
  574. }
  575. }
  576. .list:nth-child(2n) {
  577. margin: 0 0 2vw 0;
  578. }
  579. }
  580. }
  581. }
  582. .one_4 {
  583. .first {
  584. display: flex;
  585. flex-direction: column;
  586. align-items: center;
  587. background-color: var(--fFB1Color);
  588. border-bottom-right-radius: 10vw;
  589. border-bottom-left-radius: 10vw;
  590. .image {
  591. width: 20vw;
  592. height: 20vw;
  593. border-radius: 20vw;
  594. }
  595. .name {
  596. margin: 2vw 0;
  597. font-size: var(--font16Szie);
  598. font-weight: bold;
  599. color: var(--mainColor);
  600. }
  601. }
  602. .second {
  603. margin: 2vw 0;
  604. .second_1 {
  605. display: flex;
  606. justify-content: space-evenly;
  607. .grade {
  608. display: flex;
  609. flex-direction: column;
  610. align-items: center;
  611. color: var(--f85Color);
  612. font-size: var(--font13Size);
  613. view {
  614. margin: 1vw 0 0 0;
  615. color: var(--ff0Color);
  616. }
  617. }
  618. }
  619. .second_2 {
  620. display: flex;
  621. justify-content: center;
  622. flex-direction: column;
  623. margin: 15vw 25vw 0 25vw;
  624. text-align: center;
  625. background: #b2b2b2;
  626. padding: 2vw;
  627. border-radius: 5px;
  628. .second_2_bor {
  629. .image {
  630. width: 100%;
  631. height: 40vw;
  632. }
  633. }
  634. .txt {
  635. color: #fff;
  636. font-size: 14px;
  637. margin: 2vw 0;
  638. }
  639. }
  640. }
  641. }
  642. .collect {
  643. position: fixed;
  644. top: 0;
  645. right: 2vw;
  646. .iconfont {
  647. font-size: 25px;
  648. }
  649. }
  650. }
  651. .two {
  652. display: flex;
  653. flex-direction: row;
  654. justify-content: space-around;
  655. border-top: 1px solid #f1f1f1;
  656. .list {
  657. padding: 1vw 0;
  658. text-align: center;
  659. .icon {}
  660. .name {
  661. font-size: 12px;
  662. }
  663. .activename {
  664. color: var(--fFB1Color);
  665. }
  666. }
  667. }
  668. }
  669. .scroll-view {
  670. position: absolute;
  671. top: 0;
  672. left: 0;
  673. right: 0;
  674. bottom: 0;
  675. .list-scroll-view {
  676. display: flex;
  677. flex-direction: row;
  678. flex-wrap: wrap;
  679. }
  680. }
  681. </style>