123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <template>
- <view class="content">
- <view class="shopBg">
- <image class="shopBgImg" src="../../static/image/shopBg.png" mode="widthFix"></image>
- <view class="mask">
- </view>
- </view>
- <view class="shopIndex">
- <view class="shopName">
- {{shopDetail.name}}
- </view>
- <view class="shopitem flex" @click="shopLi">
- <image class="iconShop" src="../../static/icon/shopPhone.png" mode="widthFix"></image>
- <text>
- {{shopDetail.phone}}
- </text>
- </view>
- <view class="shopitem flex" @click="openAddress">
- <image class="iconShop" src="../../static/icon/shopAddress.png" mode="widthFix"></image>
- <text>
- {{shopDetail.address+shopDetail.detailed_address}}
- </text>
- </view>
- <image class="shopLogo" :src="shopDetail.image" mode="widthFix"></image>
- </view>
- <view class="tab flex">
- <view class="tabItem" v-for="(item,index) in tagArray" :class="{action:tabCurrentIndex==index}"
- @click="tabGoods(index)">
- {{item.text}}
- <view v-if='tabCurrentIndex==index' class="iconAction">
- </view>
- </view>
- </view>
- <view class="listItem">
- <view class="item flex" v-for="(item,index) in tagArray[tabCurrentIndex].orderList" @click="navTo('/pages/product/product?id='+item.id+'&shopId='+shopId)">
- <view class="imgBox">
- <image class="imgBox" :src="item.image" mode="scaleToFill"></image>
- </view>
- <view class="contentDetail">
- <view class="cartName clamp2">
- {{item.store_name}}
- </view>
- <view class="tip clamp2" >
- {{item.store_info}}
- </view>
- <view class="moneyBox flex">
- <view class="money">
- <text class="font-size-base">¥</text>
- <text>{{item.price}}</text>
- </view>
- <view class="numPp">
- {{item.sales|getNum}}+付款
- </view>
- </view>
- </view>
- </view>
- <uni-load-more :status="tagArray[tabCurrentIndex].loadingType"></uni-load-more>
- </view>
- </view>
- </template>
- <script>
- import {
- loadIndexs,
- } from '@/api/index.js';
- import {
- getProducts
- } from '@/api/product.js';
- export default {
- data() {
- return {
- shopId: '',
- shopDetail: {
- name: '',
- phone: '',
- address: '',
- detailed_address: ''
- },
- tabCurrentIndex: 0, //当前选中的对象
- tagArray: [{
- state: 2,
- text: '国标',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },
- {
- state: 5,
- text: '电摩',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- },{
- state: 6,
- text: '电轻摩',
- loadingType: 'more',
- orderList: [],
- page: 1, //当前页数
- limit: 10 //每次信息条数
- }
- ],
- }
- },
- filters: {
- getNum(num) {
- // 转为字符串
- num += '';
- let nu = num.slice(0, 1);
- for (let i = 0; i < num.length - 1; i++) {
- nu += 0
- }
- return nu
- }
- },
- onLoad(opeion) {
- if (opeion) {
- this.shopId = opeion.id
- }
- // 判断是否有选中的对象
- if(opeion.type){
- this.tabCurrentIndex = (+opeion.type)-1
- }
- this.loadIndexs();
- this.loadData();
- },
- methods: {
- navTo(url) {
- uni.navigateTo({
- url: url
- })
- },
- // 联系商家
- shopLi() {
- uni.makePhoneCall({
- phoneNumber: this.shopDetail.phone //仅为示例
- });
- },
- // 打开地址
- openAddress() {
- uni.openLocation({
- latitude: +this.shopDetail.latitude,
- longitude: +this.shopDetail.longitude,
- complete(e) {
- console.log(e);
- }
- })
- },
- // 加载商店数据
- loadIndexs() {
- loadIndexs({
- store_id: this.shopId
- }).then((e) => {
- this.shopDetail = e.data.store;
- }).catch((e) => {
- console.log(e);
- })
- },
- // 切换
- tabGoods(index) {
- this.tabCurrentIndex = index;
- this.loadData('tabChange');
- },
- // 加载商品数据
- loadData(source) {
- //这里是将订单挂载到tab列表下
- let index = this.tabCurrentIndex;
- let navItem = this.tagArray[index];
- let state = navItem.state;
- if (source === 'tabChange' && navItem.loaded === true) {
- //tab切换只有第一次需要加载数据
- return;
- }
- if (navItem.loadingType === 'loading') {
- //防止重复加载
- return;
- }
- if (navItem.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- navItem.loadingType = 'loading';
- let requestData = {
- page: navItem.page,
- limit: navItem.limit,
- store_id: this.shopId,
- is_car: 1,
- sid:navItem.state
- }
- // // 热门
- // if (index == 0) {
- // requestData.salesOrder = 1
- // }
- // // 新品
- // if (index == 1) {
- // requestData.news = 1
- // }
- getProducts(requestData)
- .then(({
- data
- }) => {
- let arr = data.map(e => {
- return e;
- });
- navItem.orderList = navItem.orderList.concat(arr);
- // console.log(navItem.orderList);
- navItem.page++;
- if (navItem.limit == data.length) {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'more';
- return;
- } else {
- //判断是否还有数据, 有改为 more, 没有改为noMore
- navItem.loadingType = 'noMore';
- }
- uni.hideLoading();
- this.$set(navItem, 'loaded', true);
- })
- .catch(e => {
- console.log(e);
- });
- },
- }
- }
- </script>
- <style lang="scss">
- page,
- .content {
- height: 100%;
- }
- .shopBg {
- position: relative;
- overflow: hidden;
- height: 300rpx;
- .mask {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: rgba($color: #000000, $alpha: 0.15);
- }
- }
- .shopBg {
- .shopBgImg {
- width: 750rpx;
- }
- }
- .tab {
- padding: 0 50rpx;
- height: 100rpx;
- justify-content: flex-start;
- color: $page-color-base;
- .tabItem {
- position: relative;
- font-size: 28rpx;
- margin-right: 90rpx;
- color: $font-color-light;
- &.action {
- font-weight: bold;
- color: $font-color-dark;
- }
- .iconAction {
- width: 100%;
- position: absolute;
- bottom: -15rpx;
- left: 0rpx;
- height: 3px;
- background-color: $color-green;
- }
- }
- }
- .shopIndex {
- padding: 50rpx;
- position: relative;
- border-top-right-radius: 50rpx;
- border-top-left-radius: 50rpx;
- background-color: #FFFFFF;
- margin-top: -50RPX;
- .shopitem {
- justify-content: flex-start;
- font-size: 22rpx;
- color: $font-color-light;
- margin-top: 20rpx;
- }
- .shopName {
- font-size: 36rpx;
- font-weight: bold;
- color: $font-color-dark;
- }
- .shopLogo {
- position: absolute;
- top: -30rpx;
- right: 70rpx;
- border-radius: 20rpx;
- width: 160rpx;
- height: 160rpx;
- }
- .iconShop {
- width: 20rpx;
- margin-right: 10rpx;
- }
- }
- .listItem {
- padding: $page-row-spacing;
- padding-top: 0;
- background-color: #FFFFFF;
- .item {
- height: 240rpx;
- border-bottom: 1px solid $page-color-light;
- .imgBox {
- border: 1px solid $page-color-light;
- width: 200rpx;
- height: 200rpx;
- border-radius: 20rpx;
- }
- }
- .contentDetail {
- padding-left: 20rpx;
- height: 200rpx;
- position: relative;
- flex-grow: 1;
- .tip {
- font-size: 24rpx;
- color: $font-color-light;
- }
- .cartName {
- font-size: $font-base;
- color: $font-color-dark;
- }
- .moneyBox {
- position: absolute;
- bottom: 5rpx;
- left: 20rpx;
- right: 0;
- .money {
- color: $color-green;
- font-size: 44rpx;
- }
- .numPp {
- color: $font-color-light;
- font-size: 24rpx;
- }
- }
- }
- }
- </style>
|