123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one">
- <view class="one_1" v-if="barActive=='0'">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="one_1_1">
- <image class="image" :src="info.logo&&info.logo.length>0?info.logo[0].url:''" mode="">
- </image>
- </view>
- <view class="one_1_2">
- <view class="pubu">
- <view class="list" v-for="(item,index) in shoplist" :key="index" @tap="toBuy(item)">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
- mode=""></image>
- <view class="name textOver">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <view class="money_1">
- <text>¥</text><text>{{item.sell_money||0}}</text>
- </view>
- <view class="money_2">
- <text>¥</text><text>{{item.flow_money||0}}</text>
- </view>
- </view>
- </view>
- <view class="other" v-if="item.p_act">
- <text class="act" v-for="(tag,index) in item.p_act" :key="index">{{tag}}</text>
- </view>
- <view class="other" v-if="item.leader_price">
- <view class="leader">
- <text>会员价</text><text>¥</text><text>{{item.leader_price||0}}</text>
- </view>
- </view>
- <view class="acttags">
- <text v-for="i in item.actTagsShow" :key="i">{{i.label}}</text>
- </view>
- </view>
- </view>
- </view>
- </scroll-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" @scroll="toScroll">
- <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="pubu">
- <view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
- <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 textOver">
- {{item.name}}
- </view>
- <view class="other">
- <view class="money">
- <view class="money_1">
- <text>¥</text><text>{{item.sell_money||0}}</text>
- </view>
- <view class="money_2">
- <text>¥</text><text>{{item.flow_money||0}}</text>
- </view>
- </view>
- </view>
- <view class="other">
- <text class="act" v-for="(tag,index) in item.p_act"
- :key="index">{{tag}}</text>
- </view>
- <view class="other" v-if="item.leader_price">
- <view class="leader">
- <text>会员价</text><text>¥</text><text>{{item.leader_price||0}}</text>
- </view>
- </view>
- <view class="acttags">
- <text v-for="i in item.actTagsShow" :key="i">{{i.label}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="is_bottom" v-if="is_bottom">
- <text>{{config.bottom_title}}</text>
- </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||5}}</view>
- 商品
- </view>
- <view class="grade">
- <view>{{info.send_score||5}}</view>
- 发货
- </view>
- <view class="grade">
- <view>{{info.service_score||5}}</view>
- 服务
- </view>
- </view>
- <view class="qrcode_1">
- <uqrcode ref="uqrcode" canvas-id="qrcode" :value="uqrcodeInfo"
- :options="{ margin:10,backgroundColor:'#f1f1f1' }">
- </uqrcode>
- <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>
- export default {
- data() {
- return {
- // 系统设置
- config: {},
- 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: 10,
- condActive: 0,
- shang: '',
- xia: '',
- condList: [ // 筛选
- ],
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- // 二维码内容
- uqrcodeInfo: ''
- };
- },
- onLoad: async function(e) {
- const that = this;
- let id = '';
- if (e && e.id) id = e.id;
- else id = decodeURIComponent(e.q).split('id=')[1];
- that.$set(that, `id`, id);
- that.searchConfig();
- await that.searchOther();
- await that.watchLogin();
- await that.search();
- },
- onPullDownRefresh: async function() {
- const that = this;
- that.clearPages();
- await that.search();
- uni.stopPullDownRefresh();
- },
- methods: {
- // 查询基本设置
- searchConfig() {
- const that = this;
- uni.getStorage({
- key: 'config',
- success: function(res) {
- if (res.data) that.$set(that, `config`, res.data)
- },
- fail: function(err) {
- console.log(err);
- }
- })
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let config = that.$config;
- if (config) {
- // 筛选条件
- that.$set(that, `condList`, config.condList)
- }
- 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)
- }
- }
- },
- // 监听用户是否登录
- 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();
- }
- },
- // 查询店铺商品
- 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() {
- const that = this;
- if (that.id) {
- const url = `${that.$config.serverUrl}/shopinfo?id=${that.id}`;
- that.$set(that, `uqrcodeInfo`, url);
- that.$refs.uqrcode.make({
- enableDelay: true
- })
- .then(res => {
- console.log(res);
- })
- .finally(() => {
- console.log('2');
- })
- }
- },
- // 购买
- 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 that.$set(that, `is_bottom`, true)
- },
- toScroll(e) {
- const that = this;
- let up = that.scrollTop;
- that.$set(that, `scrollTop`, e.detail.scrollTop);
- let num = Math.sign(up - e.detail.scrollTop);
- if (num == 1) that.$set(that, `is_bottom`, false);
- },
- // 输入框
- 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 value;
- if (index != 0) {
- value = that.shang == '0' ? that.xia : that.shang;
- }
- if (index == 1) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `sell_num`, value);
- } else if (index == 2) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `sell_money`, value);
- } else if (index == 3) {
- that.$set(that, `searchInfo`, {})
- that.$set(that.searchInfo, `view_num`, value);
- }
- that.clearPage();
- that.searchAll();
- },
- // 收藏
- 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
- });
- // 店铺简介时,绘制二维码
- if (index == '2') that.createQrcode();
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- that.$set(that, `page`, 0)
- },
- // 清空总列表
- clearPages() {
- const that = this;
- that.$set(that, `info`, {})
- that.$set(that, `shoplist`, [])
- that.$set(that, `list`, [])
- that.$set(that, `skip`, 0)
- that.$set(that, `limit`, 6)
- 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 {
- height: 92vh;
- background-color: var(--fFB1Color);
- .one_1_1 {
- padding: 2vw;
- .image {
- width: 100%;
- height: 50vw;
- }
- }
- .one_1_2 {
- padding: 0 2vw 2vw 2vw;
- .pubu {
- // column-count: 2;
- // column-gap: 2vw;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .list {
- // break-inside: avoid;
- position: relative;
- width: 43vw;
- background: #fff;
- padding: 2vw;
- border-radius: 5px;
- margin: 0 0 2vw 0;
- .image {
- width: 100%;
- height: 50vw;
- }
- .name {
- font-size: var(--font15Size);
- }
- .other {
- display: flex;
- flex-direction: row;
- padding: 1vw 0 0 0;
- .money {
- display: flex;
- .money_1 {
- color: var(--fFB1Color);
- font-size: 12px;
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- .money_2 {
- font-size: 12px;
- margin: 0 0 0 2vw;
- color: var(--f99Color);
- text {
- text-decoration: line-through;
- }
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- }
- .leader {
- font-size: 12px;
- text-align: center;
- color: #23B67A;
-
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- .act {
- font-size: 12px;
- color: #FFA500;
- border: 1px solid #FFA500;
- border-radius: 5px;
- padding: 0 1vw;
- margin: 0 1vw 0 0;
- }
- }
- .acttags {
- position: absolute;
- top: 2vw;
- width: 93%;
- text {
- display: inline-block;
- background-color: var(--fFB1Color);
- color: #fff;
- border-radius: 1vw;
- padding: 0.5vw;
- font-size: 12px;
- margin: 0 1vw 0 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: 92vh;
- .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: var(--fFB1Color);
- }
- }
- }
- .second_2 {
- padding: 2vw;
- background-color: var(--f1Color);
- .pubu {
- // column-count: 2;
- // column-gap: 2vw;
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- .list {
- // break-inside: avoid;
- width: 43vw;
- position: relative;
- margin: 0 0 2vw 0;
- padding: 2vw;
- border-radius: 10px;
- 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);
- }
- .other {
- display: flex;
- flex-direction: row;
- padding: 1vw 0 0 0;
- .money {
- display: flex;
- .money_1 {
- color: var(--fFB1Color);
- font-size: 12px;
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- .money_2 {
- font-size: 12px;
- margin: 0 0 0 2vw;
- color: var(--f99Color);
- text {
- text-decoration: line-through;
- }
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
- }
- .leader {
- font-size: 12px;
- text-align: center;
- color: #23B67A;
-
- text:last-child {
- font-size: 16px;
- padding: 0 0 0 1vw;
- }
- }
-
- .act {
- font-size: 12px;
- color: #FFA500;
- border: 1px solid #FFA500;
- border-radius: 5px;
- padding: 0 1vw;
- margin: 0 1vw 0 0;
- }
- }
- .acttags {
- position: absolute;
- top: 2vw;
- width: 93%;
- text {
- display: inline-block;
- background-color: var(--fFB1Color);
- color: #fff;
- border-radius: 1vw;
- padding: 0.5vw;
- font-size: 12px;
- margin: 0 1vw 0 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;
- position: relative;
- .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(--fFB1Color);
- }
- }
- }
- .qrcode_1 {
- .uqrcode {
- top: 10vw;
- left: 20%;
- }
- .txt {
- margin: 2vw 0 0 0;
- position: absolute;
- text-align: center;
- width: 100vw;
- bottom: -22vw;
- }
- }
- }
- }
- .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;
- }
- }
- .is_bottom {
- text-align: center;
- width: 100%;
- text {
- padding: 2vw 0;
- display: inline-block;
- color: #858585;
- font-size: 14px;
- }
- }
- </style>
|