12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004 |
- <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">
- <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>
- </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">
- <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>
- <view class="is_bottom" v-if="is_bottom">
- <text>数据到底了!!</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">
- <view class="qrcode_1_1">
- <uqrcode ref="uqrcode" canvas-id="qrcode" :value="uqrcodeInfo" :options="{ margin:10 }"></uqrcode>
- <view class="txt">
- 店铺二维码
- </view>
- </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 {
- 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'
- }
- ],
- // 数据是否触底
- is_bottom: false,
- scrollTop: 0,
- // 二维码内容
- uqrcodeInfo: ''
- };
- },
- onLoad: async function(e) {
- const that = this;
- let id = '6333d71d32c5f69745f9bd32';
- // if (e && e.id) id = e.id;
- // else id = decodeURIComponent(e.q).split('id=')[1];
- that.$set(that, `id`, id);
- await that.watchLogin();
- await that.search();
- await that.searchOther();
- },
- onShow: function() {},
- onReady: function() {
- // const that = this;
- // that.createQrcode();
- },
- 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();
- }
- },
- // 查询店铺商品
- 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 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
- });
- // 店铺简介时,绘制二维码
- if (index == '2') that.createQrcode();
- },
- // 清空列表
- 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 {
- 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;
- .list {
- background: #fff;
- padding: 2vw;
- border-radius: 5px;
- margin: 0 0 2vw 0;
- break-inside: avoid;
- .image {
- width: 100%;
- height: 50vw;
- }
- .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);
- }
- }
- }
- }
- }
- }
- // 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: 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: #ff0000;
- }
- }
- }
- .second_2 {
- padding: 2vw;
- background-color: var(--f1Color);
- .pubu {
- column-count: 2;
- column-gap: 2vw;
- .list {
- position: relative;
- margin: 0 0 2vw 0;
- padding: 2vw;
- border-radius: 10px;
- background-color: var(--fffColor);
- break-inside: avoid;
- .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);
- }
- }
- }
- }
- }
- // 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);
- }
- }
- }
- .qrcode_1 {
- display: flex;
- justify-content: center;
- text-align: center;
- margin: 5vw 0;
- .qrcode_1_1 {
- padding: 2vw;
- background: red;
- .uqrcode {
- width: 216px !important;
- height: 216px !important;
- }
- // canvas {
- // width: 180px !important;
- // height: 180px !important;
- // }
- .txt {
- margin: 2vw 0 0 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;
- }
- }
- .is_bottom {
- width: 100%;
- text-align: center;
- text {
- padding: 1vw 0;
- display: inline-block;
- }
- }
- </style>
|