123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <view class="one_1" v-if="barActive=='0'">
- <view class="first">
- <image class="image" :src="info.logo&&info.logo.length>0?info.logo[0].url:''" mode=""></image>
- </view>
- <view class="second">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="list" v-for="(item,index) in shoplist" :key="index">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
- mode=""></image>
- <view class="name">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <text>¥</text>
- <text>{{item.sell_money}}</text>
- </view>
- <view class="btn">
- <button type="default" size="mini" @click="toBuy(item)">购买</button>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <view class="one_3" v-else-if="barActive=='1'">
- <view class="first">
- <input type="text" v-model="searchInfo.name" @blur="toInput" placeholder="搜索商品">
- </view>
- <view class="second">
- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
- <view class="list-scroll-view">
- <view class="second_1">
- <view :class="['list',condActive==index?'activeList':'']"
- v-for="(item,index) in condList" :key="index" @tap="toCond(index,item)">
- <view class="name">
- {{item.name}}
- </view>
- <view class="icon">
- <view class="icon_1">
- <text :class="['iconfont',item.shangActive]"
- v-if="condActive==index&&shang=='1'"></text>
- <text :class="['iconfont',item.shang]" v-else></text>
- </view>
- <view class="icon_1">
- <text :class="['iconfont', item.xiaActive]"
- v-if="condActive==index&&xia=='-1'"></text>
- <text :class="['iconfont', item.xia]" v-else></text>
- </view>
- </view>
- </view>
- </view>
- <view class="second_2">
- <view class="list" v-for="(item,index) in list" :key="index">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
- mode=""></image>
- <view class="sale" v-if="item.is_sale==true">
- <text>已售尽</text>
- </view>
- <view class="name">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <text>¥</text>
- <text>{{item.sell_money}}</text>
- </view>
- <view class="btn">
- <button type="default" size="mini" @click="toBuy(item)">购买</button>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <view class="one_4" v-else-if="barActive=='2'">
- <view class="first">
- <image class="image" :src="info.logo&&info.logo.length>0?info.logo[0].url:''" mode=""></image>
- <view class="name">{{info.name}}</view>
- </view>
- <view class="second">
- <view class="second_1">
- <view class="grade">
- <view>{{info.goods_score||0}}</view>
- 商品
- </view>
- <view class="grade">
- <view>{{info.send_score||0}}</view>
- 发货
- </view>
- <view class="grade">
- <view>{{info.service_score||0}}</view>
- 服务
- </view>
- </view>
- <view class="second_2">
- <view class="second_2_bor">
- <canvas class="qrcode" canvas-id="myQrcode"></canvas>
- </view>
- <view class="txt">
- 店铺二维码
- </view>
- </view>
- </view>
- <view class="collect">
- <text v-if="!collection" @click="toCollect" class="iconfont icon-yduishoucangkongxin"></text>
- <text v-else @click="toCollect" class="iconfont icon-yduishoucangshixin"></text>
- </view>
- </view>
- </view>
- <view class="two">
- <view class="list" v-for="(item,index) in barList" :key="index" @tap="barChange(index,item)">
- <view class="icon">
- <text :class="['iconfont',barActive==index?item.acticon:item.icon]"></text>
- </view>
- <view :class="['name',barActive==index?'activename':'']">
- {{item.name}}
- </view>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- import QRCode from '@/common/weapp-qrcode.js'
- export default {
- components: {},
- data() {
- return {
- user: {},
- id: '',
- barActive: '0',
- barList: [ //底部菜单
- {
- icon: 'icon-shangdian',
- acticon: "icon-shangdian-copy",
- name: '微店首页'
- },
- {
- icon: 'icon-shangpinfenlei',
- acticon: "icon-shangpinfenlei-copy",
- name: '全部商品'
- },
- {
- icon: 'icon-qiyejianjie',
- acticon: "icon-qiyejianjie-copy",
- name: '店铺简介'
- }
- ],
- // 店铺信息
- info: {},
- // 店铺部分商品
- shoplist: [],
- // 收藏
- collection: false,
- // 全部商品
- searchInfo: {},
- list: [],
- total: 0,
- page: 0,
- skip: 0,
- limit: 5,
- condActive: 0,
- shang: '',
- xia: '',
- condList: [ // 筛选
- {
- name: '默认',
- },
- {
- name: '销量',
- shang: 'icon-shangjiantou',
- shangActive: 'icon-shangjiantou-copy',
- xia: 'icon-xiajiantou',
- xiaActive: 'icon-xiajiantou-copy'
- },
- {
- name: '价格',
- shang: 'icon-shangjiantou',
- shangActive: 'icon-shangjiantou-copy',
- xia: 'icon-xiajiantou',
- xiaActive: 'icon-xiajiantou-copy'
- },
- {
- name: '浏览量',
- shang: 'icon-shangjiantou',
- shangActive: 'icon-shangjiantou-copy',
- xia: 'icon-xiajiantou',
- xiaActive: 'icon-xiajiantou-copy'
- }
- ]
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e.id || '');
- await that.watchLogin();
- await that.search();
- await that.searchOther();
- },
- onShow: function() {},
- methods: {
- // 监听用户是否登录
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- that.$set(that, `user`, user);
- },
- fail: function(err) {}
- })
- },
- // 查询信息
- async search() {
- const that = this;
- if (that.id) {
- // 查询店铺信息
- const res = await that.$api(`/shop/${that.id}`, 'GET');
- if (res.errcode == '0') that.$set(that, `info`, res.data);
- let arr = await that.$api(`/storeShop/check`, `GET`, {
- customer: that.user._id,
- shop: that.id
- });
- if (arr.errcode == '0') {
- that.$set(that, `collection`, arr.data)
- }
- // 查询店铺商品
- that.searchShopMarket();
- // 查询全部商品
- that.searchAll();
- // 创建二维码
- that.createQrcode(that.info);
- }
- },
- // 查询店铺商品
- async searchShopMarket() {
- const that = this;
- const res = await that.$api(`/viewGoods/indexGoodsList`, 'GET', {
- shop: that.id,
- skip: 0,
- limit: 20
- })
- if (res.errcode == '0') that.$set(that, `shoplist`, res.data);
- },
- // 查询全部产品
- async searchAll() {
- const that = this;
- let info = {
- shop: that.id,
- skip: that.skip,
- limit: that.limit
- }
- const res = await that.$api(`/viewGoods/indexGoodsList`, `GET`, {
- ...info,
- ...that.searchInfo
- })
- if (res.errcode == '0') {
- let list = [...that.list, ...res.data];
- that.$set(that, `list`, list)
- that.$set(that, `total`, res.total)
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- },
- // 创建二维码
- createQrcode(e) {
- const that = this;
- const url = `${that.$config.serverUrl}/shopinfo?id=${e._id}`;
- var qrcode = new QRCode(`myQrcode`, {
- text: url,
- width: 172.5,
- height: 150,
- padding: 2,
- colorDark: "#000000",
- colorLight: "#ffffff",
- correctLevel: QRCode.CorrectLevel.L,
- });
- },
- // 购买
- toBuy(item) {
- if (item && item._id) {
- uni.navigateTo({
- url: `/pagesHome/order/detail?id=${item._id}`
- })
- }
- },
- // 全部产品-分页
- async toPage() {
- const that = this;
- let list = that.list;
- let limit = that.limit;
- if (that.total > list.length) {
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- let page = that.page + 1;
- that.$set(that, `page`, page)
- let skip = page * limit;
- that.$set(that, `skip`, skip)
- that.searchAll();
- uni.hideLoading();
- } else uni.showToast({
- title: '没有更多数据了'
- });
- },
- // 输入框
- toInput(e) {
- const that = this;
- that.$set(that.searchInfo, `name`, e.detail.value);
- that.clearPage();
- that.searchAll();
- },
- // 筛选
- toCond(index, e) {
- const that = this;
- let condActive = that.condActive;
- that.$set(that, `condActive`, index);
- if (condActive != index && that.xia == '') {
- that.$set(that, `shang`, '0');
- that.$set(that, `xia`, '-1');
- } else if (condActive == index && that.xia == '-1') {
- that.$set(that, `shang`, '1');
- that.$set(that, `xia`, '0');
- } else if (condActive == index && that.shang == '1') {
- that.$set(that, `shang`, '0');
- that.$set(that, `xia`, '-1');
- } else if (condActive = index && that.shang == '1') {
- that.$set(that, `shang`, '0');
- that.$set(that, `xia`, '-1');
- }
- let key = '';
- let value;
- if (index != 0) {
- value = that.shang == '0' ? that.xia : that.shang;
- }
- if (index == 1) {
- key = 'sell_num';
- } else if (index == 2) {
- key = 'sell_money';
- } else if (index == 3) {
- key = 'view_num';
- }
- that.$set(that.searchInfo, `key`, key);
- that.$set(that.searchInfo, `value`, value);
- that.clearPage();
- that.searchAll();
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let user = that.user;
- let shop = that.info;
- if (user && user._id && shop && shop._id) {
- // 商铺是否收藏
- let arr = await that.$api(`/storeShop/check`, `GET`, {
- customer: user._id,
- shop: shop._id
- });
- if (arr.errcode == '0') {
- that.$set(that, `collection`, arr.data)
- }
- }
- },
- // 收藏
- async toCollect() {
- const that = this;
- let user = that.user;
- let shop = that.info;
- if (user && user._id && shop && shop._id) {
- let res = await that.$api(`/storeShop`, `POST`, {
- customer: user._id,
- shop: shop._id
- });
- if (res.errcode == '0') {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- })
- that.$set(that, `collection`, res.data.result)
- }
- } else {
- uni.showToast({
- title: '缺少必要信息,无法收藏',
- icon: 'none'
- })
- }
- },
- // 选择底部菜单
- barChange(index, item) {
- const that = this;
- that.$set(that, `barActive`, index);
- uni.setNavigationBarTitle({
- title: item.name
- });
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 5)
- that.$set(that, `page`, 0)
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- position: relative;
- flex-grow: 1;
- .one_1 {
- display: flex;
- flex-direction: column;
- width: 96vw;
- height: 90vh;
- padding: 2vw;
- background-color: var(--fFB1Color);
- .first {
- margin: 0 0 2vw 0;
- .image {
- width: 100%;
- height: 50vw;
- }
- }
- .second {
- position: relative;
- flex-grow: 1;
- .list {
- margin: 0 2vw 2vw 0;
- background-color: var(--fffColor);
- padding: 2vw;
- width: 43vw;
- border-radius: 5px;
- .image {
- width: 100%;
- height: 49vw;
- margin: 0 0 1vw 0;
- }
- .name {
- font-size: var(--font15Size);
- margin: 0 0 2vw 0;
- }
- .other {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- .money {
- color: var(--ff0Color);
- text:nth-child(1) {
- font-size: var(--font12Size);
- }
- }
- .btn {
- button {
- border-radius: 25px;
- color: var(--fffColor);
- background-color: var(--ff0Color);
- font-size: var(--font12Size);
- }
- }
- }
- }
- .list:nth-child(2n) {
- margin: 0 0 2vw 0;
- }
- }
- }
- .one_2 {
- height: 91vh;
- display: flex;
- flex-direction: row;
- padding: 2vw;
- .first_1 {
- position: relative;
- width: 25vw;
- background-color: #fafafa;
- display: flex;
- flex-direction: column;
- .list {
- text-align: center;
- padding: 2.5vw 0;
- border-bottom: 1px solid var(--f1Color);
- text {
- font-size: var(--font14Size);
- }
- }
- .listActive {
- background-color: var(--fffColor);
- }
- }
- .first_2 {
- padding: 2vw;
- flex-grow: 1;
- position: relative;
- display: flex;
- flex-direction: column;
- .list {
- margin: 0 0 2vw 0;
- padding: 2vw;
- .title {
- font-size: var(--font16Size);
- margin: 0 0 2vw 0;
- }
- .market {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- .marketList {
- text-align: center;
- margin: 0 2vw 2vw 0;
- width: 22vw;
- .image {
- width: 100%;
- height: 15vw;
- }
- .name {
- font-size: var(--font14Size);
- }
- }
- .marketList:nth-child(3n) {
- margin: 0 0 2vw 0;
- }
- }
- }
- }
- }
- .one_3 {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 90vh;
- .first {
- border-bottom: 1px solid var(--f85Color);
- padding: 2vw;
- input {
- padding: 2vw;
- background-color: var(--f1Color);
- font-size: var(--font14Size);
- border-radius: 5px;
- }
- }
- .second {
- position: relative;
- flex-grow: 1;
- .second_1 {
- width: 96vw;
- background-color: var(--fffColor);
- padding: 2vw;
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- .list {
- display: flex;
- flex-direction: row;
- .icon {
- position: relative;
- top: -5px;
- left: 2px;
- .icon_1 {
- height: 10px;
- .iconfont {
- font-size: 12px;
- }
- }
- }
- }
- .activeList {
- .name {
- color: #ff0000;
- }
- }
- }
- .second_2 {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- padding: 2vw 2vw 0 2vw;
- background-color: var(--f1Color);
- .list {
- position: relative;
- width: 43vw;
- margin: 0 2vw 2vw 0;
- padding: 2vw;
- border-radius: 9px;
- background-color: var(--fffColor);
- .image {
- width: 100%;
- height: 40vw;
- }
- .sale {
- position: absolute;
- top: 18vw;
- text-align: center;
- width: 43vw;
- text {
- background-color: #0000005f;
- border-radius: 90px;
- display: inline-block;
- width: 15vw;
- height: 15vw;
- color: var(--fffColor);
- text-align: center;
- line-height: 15vw;
- }
- }
- .name {
- font-size: var(--font16Size);
- margin: 0 0 1vw 0;
- }
- .other {
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- .money {
- font-size: var(--font14Size);
- color: var(--ff0Color);
- text:nth-child(1) {
- font-size: var(--font12Size);
- }
- }
- .other_1 {
- flex-grow: 1;
- margin: 0 0 0 2vw;
- font-size: var(--font12Size);
- color: var(--f85Color);
- }
- .btn {
- button {
- border-radius: 25px;
- color: var(--fffColor);
- background-color: var(--ff0Color);
- font-size: var(--font12Size);
- }
- }
- }
- }
- .list:nth-child(2n) {
- margin: 0 0 2vw 0;
- }
- }
- }
- }
- .one_4 {
- .first {
- display: flex;
- flex-direction: column;
- align-items: center;
- background-color: var(--fFB1Color);
- border-bottom-right-radius: 10vw;
- border-bottom-left-radius: 10vw;
- .image {
- width: 20vw;
- height: 20vw;
- border-radius: 20vw;
- }
- .name {
- margin: 2vw 0;
- font-size: var(--font16Szie);
- font-weight: bold;
- color: var(--mainColor);
- }
- }
- .second {
- margin: 2vw 0;
- .second_1 {
- display: flex;
- justify-content: space-evenly;
- .grade {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: var(--f85Color);
- font-size: var(--font13Size);
- view {
- margin: 1vw 0 0 0;
- color: var(--ff0Color);
- }
- }
- }
- .second_2 {
- display: flex;
- justify-content: center;
- flex-direction: column;
- margin: 15vw 25vw 0 25vw;
- text-align: center;
- background: #b2b2b2;
- padding: 2vw;
- border-radius: 5px;
- .second_2_bor {
- .image {
- width: 100%;
- height: 40vw;
- }
- }
- .txt {
- color: #fff;
- font-size: 14px;
- margin: 2vw 0;
- }
- }
- }
- }
- .collect {
- position: fixed;
- top: 0;
- right: 2vw;
- .iconfont {
- font-size: 25px;
- }
- }
- }
- .two {
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- border-top: 1px solid #f1f1f1;
- .list {
- padding: 1vw 0;
- text-align: center;
- .icon {}
- .name {
- font-size: 12px;
- }
- .activename {
- color: var(--fFB1Color);
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- }
- }
- </style>
|