Commit e673e491 authored by 王建威's avatar 王建威

白条专区

parent b91599ea
No preview for this file type
<script>
<script>
import Vue from 'vue';
export default {
onLaunch: function() {
},
onShow: function() {
},
onHide: function() {
// uni.request({
// url: '/uni/api/application/is_login',
// type:'get',
// success: (res) => {
// Vue.prototype.$isLogin = res.data.data;
// }
// });
}
}
</script>
......
......@@ -5,8 +5,7 @@ import { php } from './common/host.js';
Vue.config.productionTip = false
// 加入购物车
let isLogin = 0;
function addCart(spec_id, quantity) {
function addCart(spec_id, quantity, isLogin) {
if(!isLogin) {
uni.showToast({
title: '请先登录',
......@@ -14,7 +13,7 @@ function addCart(spec_id, quantity) {
icon: 'none'
});
setTimeout(() => {
window.location.href = php;
window.location.href = php+'app=member&act=login';
}, 2000);
return
}
......@@ -40,21 +39,12 @@ function addCart(spec_id, quantity) {
});
}
})
}
(function() {
uni.request({
url: '/uni/api/application/is_login',
type:'get',
success: (res) => {
Vue.prototype.$isLogin = res.data.data;
isLogin = res.data.data;
}
});
})()
}
Vue.prototype.$addCart = addCart;
Vue.prototype.$noGoodsImg = '/static/common/shangpinmorentu@2x.png';
Vue.prototype.$noGoodsImg = 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit/shangpinmorentu%402x.png';
Vue.prototype.$defaultPortrait = 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit/default_user_portrait.gif';
Vue.prototype.$defaultClassImg = 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit_shop/20190520/img/5ce2636edf912.png';
App.mpType = 'app'
......
......@@ -89,7 +89,7 @@
"disableHostCheck": true,
"proxy": {
"/uni/api": {
"target": "http://192.168.124.33:6564/",
"target": "http://192.168.50.133:6564/",
"changeOrigin": true,
"secure": false,
"pathRewrite":{"^/uni/api":"api"}
......
......@@ -3,7 +3,7 @@
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app"
"navigationBarTitleText": "白条专区"
}
},
{
......@@ -14,11 +14,14 @@
},
{
"path": "pages/web/Web"
},
{
"path": "pages/detail/Detail"
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarTitleText": "白条专区",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#fbfbfb",
"app-plus": {"titleNView": false}
......
......@@ -9,7 +9,7 @@
<text v-for="(item, index) in cate_list" :key="index" :class="{act: tabIndex === index}" @click="changeTabs(index, item.cate_id)">{{item.cate_name}}</text>
</view>
</view>
<view class="goods_box" v-if="goods_list">
<view class="goods_box" v-if="goods_list instanceof Array">
<view class="goods_item" v-for="(item, index) in goods_list" :key="index">
<image :src="item.default_image || $noGoodsImg" @click="jumpPhpPage(`app=goods&id=${item.goods_id}`)"></image>
<view class="goods_item_info">
......@@ -57,7 +57,6 @@
}
},
onLoad(option) {
this.isLogin = this.$isLogin;
this.firsr_cate_id = option.cate_id_1;
option.current = Number(option.current);
option.pageSize = Number(option.pageSize);
......@@ -95,6 +94,7 @@
this.goods_list = credit_goods_list;
this.cate_list = credit_cates_list;
this.page = page;
this.isLogin = res.data.login_flg;
}
});
},
......@@ -127,6 +127,7 @@
this.goods_list = credit_goods_list;
this.page = page;
!!cb && cb();
console.log(this.goods_list)
}
});
},
......@@ -168,7 +169,7 @@
});
},
addCart(spec_id, quantity) {
this.$addCart(spec_id, quantity)
this.$addCart(spec_id, quantity, this.isLogin);
},
jumpPhpPage(url) {
let link = url ? `${php}${url}` : php;
......@@ -247,6 +248,7 @@
.nodata {
text-align: center;
padding: 40rpx 0;
margin-top: 174rpx;
}
.goods_box {
padding-bottom: 118rpx;
......
<template>
<view>
<view class="search_box">
<uni-icons type="back" size="30" :style="{'position':'relative','top': '-2px'}" @click.native="goBack()"></uni-icons>
<i @click="search"></i>
<input type="text" placeholder="我是要找的商品名" v-model="keyword" @confirm="search">
<view class="category_list">
<text :class="{act: tabIndex === -1}" @click="changeTabs(-1, firsr_cate_id)">全部</text>
<text v-for="(item, index) in cate_list" :key="index" :class="{act: tabIndex === index}" @click="changeTabs(index, item.cate_id)">{{item.cate_name}}</text>
</view>
</view>
<view class="goods_box" v-if="goods_list instanceof Array">
<view class="goods_item" v-for="(item, index) in goods_list" :key="index">
<image :src="item.default_image || $noGoodsImg" @click="jumpPhpPage(`app=goods&id=${item.goods_id}`)"></image>
<view class="goods_item_info">
<p>{{item.goods_name}}</p>
<p>{{item.goods_subname}}</p>
<view class="goods_tag">
<text>限时免息</text>
<!-- <text>9个月账期</text> -->
</view>
<p class="price">
<text>{{isLogin ? '¥' : ''}}</text>{{isLogin ? item.price : '登录显示价格'}}
</p>
</view>
<i class="cart_icon" @click="addCart(item.spec_id, 1)"></i>
</view>
<view class="pageBox">
<uni-pagination ref="pagination" :total="page['total']" current="1" show-icon="true" @change="changePage"></uni-pagination>
</view>
</view>
<view class="nodata" v-else>暂无此类商品</view>
<BottomBar />
</view>
</template>
<script>
import uniIcons from "@/components/uni-icons/uni-icons.vue";
import uniPagination from '@/components/uni-pagination/uni-pagination.vue';
import BottomBar from "@/components/BottomBar/BottomBar.vue";
import { php, go } from '../../common/host.js';
export default {
data() {
return {
goods_list: [],
page: {
total: 0,
current: 1
},
cate_list: [],
firsr_cate_id: '',
cate_id_1: '',
tabIndex: -1,
keyword: '',
isLogin: 0
}
},
onLoad(option) {
this.getData({
current: 1,
pageSize: 10
});
},
onPullDownRefresh() {
if(this.keyword) {
this.search(this.keyword, uni.stopPullDownRefresh);
return
} else if (this.cate_id_1) {
this.changeTabs(this.tabIndex, this.cate_id_1, uni.stopPullDownRefresh);
} else {
this.changeTabs(this.tabIndex, this.firsr_cate_id, uni.stopPullDownRefresh);
}
},
components: {
uniIcons,
uniPagination,
BottomBar
},
methods: {
goBack() {
history.back()
},
getData(params) {
uni.request({
url: '/uni/api/credit_goods/get_credit_all_goods',
method: 'POST',
data: params,
dataType: 'json',
success: (res) => {
const { credit_cates_list, credit_goods_list } = res.data.data,
{ page } = res.data;
this.goods_list = credit_goods_list;
this.cate_list = credit_cates_list;
this.page = page;
this.isLogin = res.data.login_flg;
}
});
},
changeTabs(index, cate_id, cb) {
if(index != -1) {
var params = {
cate_id_1: cate_id+''
};
this.cate_id_1 = cate_id+'';
} else {
var params = {}
this.cate_id_1 = '';
}
this.tabIndex = index;
this.$refs.pagination.parentsChangeCurrent(1);
uni.request({
url: '/uni/api/credit_goods/get_credit_all_goods',
method: 'POST',
data: {
...params,
goods_name: this.keyword,
current: 1,
pageSize: 10
},
dataType: 'json',
success: (res) => {
const { credit_goods_list } = res.data.data,
{ page } = res.data;
this.goods_list = credit_goods_list;
this.page = page;
!!cb && cb();
}
});
},
changePage(data) {
const { current } = data;
uni.request({
url: '/uni/api/credit_goods/get_credit_all_goods',
method: 'POST',
data: {
cate_id_1: this.cate_id_1,
goods_name: this.keywords,
current: current,
pageSize: 10
},
dataType: 'json',
success: (res) => {
const { credit_goods_list } = res.data.data;
this.goods_list = credit_goods_list;
}
});
},
search(keyword, cb) {
uni.request({
url: '/uni/api/credit_goods/get_credit_all_goods',
method: 'POST',
data: {
goods_name: this.keyword,
current: 1,
pageSize: 10
},
dataType: 'json',
success: (res) => {
const { credit_goods_list } = res.data.data,
{ page } = res.data;
this.goods_list = credit_goods_list;
this.page = page;
!!cb && cb();
this.tabIndex = -1;
this.$refs.pagination.parentsChangeCurrent(1);
}
});
},
addCart(spec_id, quantity) {
this.$addCart(spec_id, quantity, this.isLogin);
},
jumpPhpPage(url) {
let link = url ? `${php}${url}` : php;
window.location.href = link;
}
}
}
</script>
<style lang="less" scoped>
.search_box {
background: url(../../static/category/2641581405726_.pic.png) no-repeat;
background-position: 100% 100%;
position: fixed;
width: 100%;
left: 0;
top: 0;
z-index: 10;
i {
display: inline-block;
width: 60rpx;
height: 60rpx;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAMAAACfWMssAAAAulBMVEUhISEiIiIjIyMsLCwtLS0vLy86OjpAQEBISEhMTExPT09SUlJaWlppaWl0dHR4eHh5eXmOjo6Tk5OYmJienp7AwMDJycnNxGbNxWjOxWjOxWrPxmvPxm7Qx3DQyHPRyXTRynbV1dXW1tbX0IrX0YvY0YvY0ozb1Zbb1pjc3Nzl5eXm4rvm4rzo6Ojp5cTp5sXq6urr6Mzr6M3s7Ozt6tLt69Xu69bv7+/w7tzx8fH19O/19e/39/X4+Phd4ycQAAABNklEQVRIx+3XyVKDQBCA4R8JEBJZBWTcIrjvUdS4zfu/lodErYhVA11lTukbFB80MNM9w/ZXHN1/6B7Bgh0/6X4xh5NbrSXw7E1L4M6V1hK496hF8OBFy6DQafQarhAWWZpmRV9YxQ4AOHHVAzahxXdYYdMV1h6AGyVJ5AJ4dTdYD4BgkWEVAIO6C2w8sPOf49wGr+kAQ7CXnlDbEJphZUG+fCoHqzLCGILf1wQQG6EDrbtX4JhgAW77fVwoDDCDqA0jyAwwhaQNE0j/C4pTFX8c8e+QDwDxkBMP8j+nlXUpm8gwnklKB8CoERSriyHgTwXlceoDwxtBQW5GgC9pAbMxbIh6x+umtbXujyuA4gXSRLokU/vCRaBSu9ciWJZlef4uhOXhnSRVpZRSp89CqNTJQ6/twycM+aPLaun/FQAAAABJRU5ErkJggg==) no-repeat;
background-size: 100% 100%;
margin-left: 20rpx;
position: relative;
top: 8rpx;
}
input {
display: inline-block;
vertical-align: middle;
width: 590rpx;
height: 60rpx;
line-height: 60rpx;
font-size: 28rpx;
margin: 14rpx 0 40rpx 0;
background: #F8F8F8;
border-radius: 0 30rpx 30rpx 0;
}
.category_list {
display: block;
white-space: nowrap;
overflow: scroll;
width: 94.6%;
margin-left: 2.7%;
padding-bottom: 8rpx;
text {
font-size: 28rpx;
line-height: 40rpx;
margin-right: 68rpx;
}
text:last-child {
margin-right: 0;
}
text.act {
font-size: 32rpx;
line-height: 44rpx;
position: relative;
font-weight: 500;
}
text.act:after {
width: 52rpx;
height: 4rpx;
background: #212121;
position: absolute;
left: 50%;
bottom: -8rpx;
margin-left: -26rpx;
content: '';
}
}
.category_list::-webkit-scrollbar {
display: none;
}
}
.nodata {
text-align: center;
padding: 40rpx 0;
margin-top: 174rpx;
}
.goods_box {
padding-bottom: 118rpx;
margin-top: 174rpx;
.pageBox {
text-align: center;
}
.goods_item {
position: relative;
width: 100%;
box-sizing: border-box;
padding: 32rpx 88rpx 32rpx 20rpx;
background: #fff;
display: flex;
justify-content: space-between;
.cart_icon {
position: absolute;
right: 88rpx;
bottom: 32rpx;
width: 56rpx;
height: 56rpx;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAAAAACN7WTCAAABfElEQVRIx2P4TyZgGNU4qnFUIxEafx87+eYvORqvVFRUbiTLxstTSktW/yHHj7/2FRa9ICtw/kzM2wa2/MTmzZs2gTAEbL3yi0Co7sye/A9IfcpGBVlZU/7i1/g4o/gryObzEJtgdm4uyliDX+PXgpQn2Ly0LaUNv8Z/PYl7sGlcnTiRQMpZETsXm8aJccsJaDwTXfULU9/3ouiDBDS+j4z5jKnxU3T4IwIaf+SFXMXUeCsk+jOh3NEfuBpT4+bAwl+ENK7x68bUOMOvl2B+vOmd8h1d7F+F9xKCGj/5e75DF/sc6X6MoMbfOS7oiv6/dnF5SbjomODYhV4O7HIM+ExY4z5b+1lr1gPBurVr16xZs3rVipnetpV/CWv8XmiFAbzuElPKfd4wpb8PCPr7+yeAwMRJK14Mt5L822ZQmJ6FhOOHTSDOub/EaFwVCwYfwJxFYHbcR2I03stJTk5OgqaC6xkgTjdRNv7//R0I/sEKaWTOaI08qnHoaQQAAyi97TBEkioAAAAASUVORK5CYII=) no-repeat;
background-size: 100% 100%;
}
image {
width: 240rpx;
height: 240rpx;
margin-right: 24rpx;
}
.goods_item_info {
width: 402rpx;
position: relative;
p:nth-of-type(1) {
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: 30rpx;
line-height: 42rpx;
margin-bottom: 10rpx;
}
p:nth-of-type(2) {
width: 100%;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
font-size: 22rpx;
color: #7C7C7C;
}
.goods_tag {
display: block;
text {
display: inline-block;
vertical-align: middle;
border: 1px solid #C7B64E;
color: #C7B64E;
height: 36rpx;
line-height: 36rpx;
padding: 0 12rpx;
border-radius: 18rpx;
font-size: 22rpx;
margin-right: 8rpx;
}
}
.price {
font-size: 40rpx;
line-height: 40rpx;
margin-top: 26rpx;
text {
font-size: 28rpx;
}
}
}
}
}
</style>
......@@ -31,17 +31,17 @@
</view>
<view class="flex classbox">
<view class="class_item" v-for="(item, index) in credit_cates_list" :key="index" @click="jumpSecondPage(item.cate_id, 1, 10)">
<image :src="item.goods_list[0]['default_image']"></image>
<image :src="item.goods_list[0]['default_image'] || $defaultClassImg"></image>
<text class="class_name">{{item.cate_name}}</text>
</view>
</view>
</view>
<view class="part_two">
<view>
<image class="portrait" :src="portrait"></image>
<image class="portrait" :src="portrait || $defaultPortrait"></image>
<text class="user_name">{{user_name}}</text>
</view>
<text class="go_credit" @click="jumpGoPage()"><text>我的白条</text><i class="go_credit_icon"></i></text>
<text class="go_credit" @click="isLogin ? (credit_flg ? jumpGoPage() : jumpGoPage('/introduce')) : jumpPhpPage('app=member&act=login')"><text>我的白条</text><i class="go_credit_icon"></i></text>
</view>
<view class="part_three">
<view class="part_three_top">
......@@ -49,7 +49,7 @@
<p>谛宝多多 账期无忧</p>
<p>最高可享12期免息</p>
</view>
<text class="go_detail" @click="jumpGoPage('/introduce')">查看详情<i class="go_credit_icon"></i></text>
<text class="go_detail" @click="isLogin ? (credit_flg ? jumpDetailPage() : jumpGoPage('/introduce')) : jumpPhpPage('app=member&act=login')">查看详情<i class="go_credit_icon"></i></text>
</view>
<view class="part_three_bottom">
<view class="hot_goods" v-for="(item, index) in credit_goods_list" :key="index">
......@@ -102,11 +102,11 @@
portrait: '',
current: 0,
keyword: '',
isLogin: 0
isLogin: 0,
credit_flg: 0
}
},
onLoad() {
this.isLogin = this.$isLogin;
onLoad() {
this.getData();
},
components: {
......@@ -128,6 +128,11 @@
url: `/pages/category/Category?cate_id_1=${cate_id}&current=${current}&pageSize=${pageSize}`
});
},
jumpDetailPage() {
uni.navigateTo({
url: `/pages/detail/Detail`
});
},
getData() {
uni.request({
url: '/uni/api/credit_goods/get_credit_index_goods',
......@@ -136,8 +141,14 @@
success: (res) => {
this.credit_cates_list = res.data.data.credit_cates_list;
this.credit_goods_list = res.data.data.credit_goods_list;
this.user_name = res.data.data.user_name;
this.portrait = res.data.data.portrait;
this.isLogin = res.data.login_flg;
this.credit_flg = res.data.credit_flg;
if(res.data.data.user_name) {
this.user_name = res.data.data.user_name;
}
if(res.data.data.portrait) {
this.portrait = res.data.data.portrait;
}
}
})
},
......@@ -150,7 +161,7 @@
window.location.href = link;
},
addCart(spec_id, quantity) {
this.$addCart(spec_id, quantity)
this.$addCart(spec_id, quantity, this.isLogin);
}
}
};
......@@ -173,6 +184,10 @@
justify-content: space-between;
padding: 24rpx;
box-sizing: border-box;
position: fixed;
width: 100%;
background-color: #fff;
z-index: 11;
}
.search_view {
width: 380rpx;
......@@ -239,7 +254,7 @@
height: 678rpx;
background: url(https://dbc-static.oss-cn-beijing.aliyuncs.com/credit/2611581321921_.pic_hd.png) no-repeat;
background-size: 100% 100%;
padding-top: 0.5px;
padding-top: 180rpx;
}
.main_content {
width: 93.6%;
......@@ -287,12 +302,14 @@
.class_item {
flex:0 0 25%;
margin-bottom: 32rpx;
text-align: center;
}
image {
display: block;
width: 100rpx;
height: 96rpx;
border-radius: 50%;
margin: 0 auto;
}
.class_name {
font-size: 22rpx;
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment