index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  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" @blur="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 || '');
  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.clearPage();
  279. that.searchAll();
  280. },
  281. // 筛选
  282. toCond(index, e) {
  283. const that = this;
  284. let condActive = that.condActive;
  285. that.$set(that, `condActive`, index);
  286. if (condActive != index && that.xia == '') {
  287. that.$set(that, `shang`, '0');
  288. that.$set(that, `xia`, '-1');
  289. } else if (condActive == index && that.xia == '-1') {
  290. that.$set(that, `shang`, '1');
  291. that.$set(that, `xia`, '0');
  292. } else if (condActive == index && that.shang == '1') {
  293. that.$set(that, `shang`, '0');
  294. that.$set(that, `xia`, '-1');
  295. } else if (condActive = index && that.shang == '1') {
  296. that.$set(that, `shang`, '0');
  297. that.$set(that, `xia`, '-1');
  298. }
  299. let key = '';
  300. let value;
  301. if (index != 0) {
  302. value = that.shang == '0' ? that.xia : that.shang;
  303. }
  304. if (index == 1) {
  305. key = 'sell_num';
  306. } else if (index == 2) {
  307. key = 'sell_money';
  308. } else if (index == 3) {
  309. key = 'view_num';
  310. }
  311. that.$set(that.searchInfo, `key`, key);
  312. that.$set(that.searchInfo, `value`, value);
  313. that.clearPage();
  314. that.searchAll();
  315. },
  316. // 收藏
  317. toCollect() {
  318. const that = this;
  319. that.collection = !that.collection;
  320. if (that.collection == true) {
  321. uni.showToast({
  322. title: `收藏成功`,
  323. icon: 'none'
  324. })
  325. } else {
  326. uni.showToast({
  327. title: `取消成功`,
  328. icon: 'none'
  329. })
  330. }
  331. },
  332. // 选择底部菜单
  333. barChange(index, item) {
  334. const that = this;
  335. that.$set(that, `barActive`, index);
  336. uni.setNavigationBarTitle({
  337. title: item.name
  338. });
  339. },
  340. // 清空列表
  341. clearPage() {
  342. const that = this;
  343. that.$set(that, `list`, [])
  344. that.$set(that, `skip`, 0)
  345. that.$set(that, `limit`, 5)
  346. that.$set(that, `page`, 0)
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. .main {
  353. display: flex;
  354. flex-direction: column;
  355. width: 100vw;
  356. height: 100vh;
  357. .one {
  358. position: relative;
  359. flex-grow: 1;
  360. .one_1 {
  361. display: flex;
  362. flex-direction: column;
  363. width: 96vw;
  364. height: 90vh;
  365. padding: 2vw;
  366. background-color: var(--fFB1Color);
  367. .first {
  368. margin: 0 0 2vw 0;
  369. .image {
  370. width: 100%;
  371. height: 50vw;
  372. }
  373. }
  374. .second {
  375. position: relative;
  376. flex-grow: 1;
  377. .list {
  378. margin: 0 2vw 2vw 0;
  379. background-color: var(--fffColor);
  380. padding: 2vw;
  381. width: 43vw;
  382. border-radius: 5px;
  383. .image {
  384. width: 100%;
  385. height: 49vw;
  386. margin: 0 0 1vw 0;
  387. }
  388. .name {
  389. font-size: var(--font15Size);
  390. margin: 0 0 2vw 0;
  391. }
  392. .other {
  393. display: flex;
  394. flex-direction: row;
  395. justify-content: space-between;
  396. .money {
  397. color: var(--ff0Color);
  398. text:nth-child(1) {
  399. font-size: var(--font12Size);
  400. }
  401. }
  402. .btn {
  403. button {
  404. border-radius: 25px;
  405. color: var(--fffColor);
  406. background-color: var(--ff0Color);
  407. font-size: var(--font12Size);
  408. }
  409. }
  410. }
  411. }
  412. .list:nth-child(2n) {
  413. margin: 0 0 2vw 0;
  414. }
  415. }
  416. }
  417. .one_2 {
  418. height: 91vh;
  419. display: flex;
  420. flex-direction: row;
  421. padding: 2vw;
  422. .first_1 {
  423. position: relative;
  424. width: 25vw;
  425. background-color: #fafafa;
  426. display: flex;
  427. flex-direction: column;
  428. .list {
  429. text-align: center;
  430. padding: 2.5vw 0;
  431. border-bottom: 1px solid var(--f1Color);
  432. text {
  433. font-size: var(--font14Size);
  434. }
  435. }
  436. .listActive {
  437. background-color: var(--fffColor);
  438. }
  439. }
  440. .first_2 {
  441. padding: 2vw;
  442. flex-grow: 1;
  443. position: relative;
  444. display: flex;
  445. flex-direction: column;
  446. .list {
  447. margin: 0 0 2vw 0;
  448. padding: 2vw;
  449. .title {
  450. font-size: var(--font16Size);
  451. margin: 0 0 2vw 0;
  452. }
  453. .market {
  454. display: flex;
  455. flex-direction: row;
  456. flex-wrap: wrap;
  457. .marketList {
  458. text-align: center;
  459. margin: 0 2vw 2vw 0;
  460. width: 22vw;
  461. .image {
  462. width: 100%;
  463. height: 15vw;
  464. }
  465. .name {
  466. font-size: var(--font14Size);
  467. }
  468. }
  469. .marketList:nth-child(3n) {
  470. margin: 0 0 2vw 0;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .one_3 {
  477. display: flex;
  478. flex-direction: column;
  479. width: 100vw;
  480. height: 90vh;
  481. .first {
  482. border-bottom: 1px solid var(--f85Color);
  483. padding: 2vw;
  484. input {
  485. padding: 2vw;
  486. background-color: var(--f1Color);
  487. font-size: var(--font14Size);
  488. border-radius: 5px;
  489. }
  490. }
  491. .second {
  492. position: relative;
  493. flex-grow: 1;
  494. .second_1 {
  495. width: 96vw;
  496. background-color: var(--fffColor);
  497. padding: 2vw;
  498. display: flex;
  499. flex-direction: row;
  500. justify-content: space-around;
  501. .list {
  502. display: flex;
  503. flex-direction: row;
  504. .icon {
  505. position: relative;
  506. top: -5px;
  507. left: 2px;
  508. .icon_1 {
  509. height: 10px;
  510. .iconfont {
  511. font-size: 12px;
  512. }
  513. }
  514. }
  515. }
  516. .activeList {
  517. .name {
  518. color: #ff0000;
  519. }
  520. }
  521. }
  522. .second_2 {
  523. display: flex;
  524. flex-direction: row;
  525. flex-wrap: wrap;
  526. padding: 2vw 2vw 0 2vw;
  527. background-color: var(--f1Color);
  528. .list {
  529. position: relative;
  530. width: 43vw;
  531. margin: 0 2vw 2vw 0;
  532. padding: 2vw;
  533. border-radius: 9px;
  534. background-color: var(--fffColor);
  535. .image {
  536. width: 100%;
  537. height: 40vw;
  538. }
  539. .sale {
  540. position: absolute;
  541. top: 18vw;
  542. text-align: center;
  543. width: 43vw;
  544. text {
  545. background-color: #0000005f;
  546. border-radius: 90px;
  547. display: inline-block;
  548. width: 15vw;
  549. height: 15vw;
  550. color: var(--fffColor);
  551. text-align: center;
  552. line-height: 15vw;
  553. }
  554. }
  555. .name {
  556. font-size: var(--font16Size);
  557. margin: 0 0 1vw 0;
  558. }
  559. .other {
  560. display: flex;
  561. flex-direction: row;
  562. justify-content: space-between;
  563. .money {
  564. font-size: var(--font14Size);
  565. color: var(--ff0Color);
  566. text:nth-child(1) {
  567. font-size: var(--font12Size);
  568. }
  569. }
  570. .other_1 {
  571. flex-grow: 1;
  572. margin: 0 0 0 2vw;
  573. font-size: var(--font12Size);
  574. color: var(--f85Color);
  575. }
  576. .btn {
  577. button {
  578. border-radius: 25px;
  579. color: var(--fffColor);
  580. background-color: var(--ff0Color);
  581. font-size: var(--font12Size);
  582. }
  583. }
  584. }
  585. }
  586. .list:nth-child(2n) {
  587. margin: 0 0 2vw 0;
  588. }
  589. }
  590. }
  591. }
  592. .one_4 {
  593. .first {
  594. display: flex;
  595. flex-direction: column;
  596. align-items: center;
  597. background-color: var(--fFB1Color);
  598. border-bottom-right-radius: 10vw;
  599. border-bottom-left-radius: 10vw;
  600. .image {
  601. width: 20vw;
  602. height: 20vw;
  603. border-radius: 20vw;
  604. }
  605. .name {
  606. margin: 2vw 0;
  607. font-size: var(--font16Szie);
  608. font-weight: bold;
  609. color: var(--mainColor);
  610. }
  611. }
  612. .second {
  613. margin: 2vw 0;
  614. .second_1 {
  615. display: flex;
  616. justify-content: space-evenly;
  617. .grade {
  618. display: flex;
  619. flex-direction: column;
  620. align-items: center;
  621. color: var(--f85Color);
  622. font-size: var(--font13Size);
  623. view {
  624. margin: 1vw 0 0 0;
  625. color: var(--ff0Color);
  626. }
  627. }
  628. }
  629. .second_2 {
  630. display: flex;
  631. justify-content: center;
  632. flex-direction: column;
  633. margin: 15vw 25vw 0 25vw;
  634. text-align: center;
  635. background: #b2b2b2;
  636. padding: 2vw;
  637. border-radius: 5px;
  638. .second_2_bor {
  639. .image {
  640. width: 100%;
  641. height: 40vw;
  642. }
  643. }
  644. .txt {
  645. color: #fff;
  646. font-size: 14px;
  647. margin: 2vw 0;
  648. }
  649. }
  650. }
  651. }
  652. .collect {
  653. position: fixed;
  654. top: 0;
  655. right: 2vw;
  656. .iconfont {
  657. font-size: 25px;
  658. }
  659. }
  660. }
  661. .two {
  662. display: flex;
  663. flex-direction: row;
  664. justify-content: space-around;
  665. border-top: 1px solid #f1f1f1;
  666. .list {
  667. padding: 1vw 0;
  668. text-align: center;
  669. .icon {}
  670. .name {
  671. font-size: 12px;
  672. }
  673. .activename {
  674. color: var(--fFB1Color);
  675. }
  676. }
  677. }
  678. }
  679. .scroll-view {
  680. position: absolute;
  681. top: 0;
  682. left: 0;
  683. right: 0;
  684. bottom: 0;
  685. .list-scroll-view {
  686. display: flex;
  687. flex-direction: row;
  688. flex-wrap: wrap;
  689. }
  690. }
  691. </style>