Commit f6fe75d1 by 施宇

111

parent 6caf8244
...@@ -31,6 +31,12 @@ Component({ ...@@ -31,6 +31,12 @@ Component({
methods: { methods: {
emitevent:function(){ emitevent:function(){
this.triggerEvent('emitevent') this.triggerEvent('emitevent')
},
previewImage:function(e){
let img = e.currentTarget.dataset.image;
wx.previewImage({
urls: [img]
})
} }
} }
}) })
<!--components/priceItem/priceItem.wxml--> <!--components/priceItem/priceItem.wxml-->
<block> <block>
<wxs module="dateUtil" src="../../utils/timeUtil.wxs"></wxs>
<!-- 询报价展示 --> <!-- 询报价展示 -->
<block wx:if="{{priceType==1}}"> <block wx:if="{{priceType==1}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent"> <view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
...@@ -7,21 +8,33 @@ ...@@ -7,21 +8,33 @@
<view class="row verCenter"> <view class="row verCenter">
<text class="mark xun" wx:if="{{xb==1}}">询</text> <text class="mark xun" wx:if="{{xb==1}}">询</text>
<text class="mark bao" wx:else>报</text> <text class="mark bao" wx:else>报</text>
<text class="name ellipsis">{{item.name}}</text> <text class="name ellipsis">{{item.goods_name||'--'}}</text>
</view> </view>
<block wx:if="{{xb==1}}"> <block wx:if="{{xb==1}}">
<text class="num-bj" wx:if="{{item.count}}">{{item.count}}个报价</text> <text class="num-bj" wx:if="{{item.offer_num}}">{{item.offer_num}}个报价</text>
<text class="no-bj" wx:else>等待报价</text> <text class="no-bj" wx:else>等待报价</text>
</block> </block>
<text class="price" wx:else>¥{{item.price}}</text> <text class="price" wx:else>
<block wx:if="{{!item.price||item.price=='0.00'||item.price=='0'}}">
未回复
</block>
<block wx:else>
<block wx:if="{{item.currency == 1}}">
¥{{item.price}}
</block>
<block wx:else>
${{item.price}}
</block>
</block>
</text>
</view> </view>
<view class="item-middle row verCenter nowrap"> <view class="item-middle row verCenter nowrap">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text> <text class="brand ellipsis"><text>品牌:</text>{{item.brand_name}}</text>
<text class="num bold"><text class="nobold">数量:</text>{{item.num}}PCS</text> <text class="num"><text>数量:</text>{{item.number}} PCS</text>
</view> </view>
<view class="item-footer row bothSide verCenter nowrap"> <view class="item-footer row bothSide verCenter nowrap">
<text class="address ellipsis">备注:{{item.desc}}</text> <text class="address ellipsis">备注:{{item.remark}}</text>
<text class="time">{{item.time}}</text> <text class="time">{{dateUtil.dateFormat(item.add_time*1000)}}</text>
</view> </view>
</view> </view>
</block> </block>
...@@ -107,14 +120,22 @@ ...@@ -107,14 +120,22 @@
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent"> <view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header row verCenter bothSide nowrap"> <view class="item-header row verCenter bothSide nowrap">
<view class="row verCenter"> <view class="row verCenter">
<text class="name ellipsis good-name">{{item.name}}</text> <text class="name ellipsis good-name">{{item.goods_name}}</text>
<text class="icon iconfont iconiconxiantiaoshouji14 good-icon"></text> <block wx:if="{{item.goods_images}}">
<text class="icon iconfont iconiconxiantiaoshouji14 good-icon" catchtap="previewImage" data-image="{{item.goods_images}}"></text>
</block>
</view> </view>
<text class="price">¥{{item.price}}</text> <text class="price">
<block wx:if="{{item.currency == 1}}">
¥{{item.price}}
</block>
<block wx:else>
${{item.price}}
</block></text>
</view> </view>
<view class="item-middle row verCenter nowrap"> <view class="item-middle row verCenter nowrap">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text> <text class="brand ellipsis"><text>品牌:</text>{{item.brand_name}}</text>
<text class="num bold"><text class="nobold">库存: </text>{{item.num}}PCS</text> <text class="num"><text>库存:</text>{{item.stock}} PCS</text>
</view> </view>
</view> </view>
</block> </block>
......
// pages/tab/good/good.js // pages/tab/good/good.js
let arr = [ import { getData } from '../../../utils/util.js';
{ import { apis } from '../../../utils/api.js';
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
}
]
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
priceList:undefined priceList: null,//商品数据
limit: 10,//每页的条数
p: 1,//当前页面
total: 0,
time: "",
key: "",
confirmKey: ""
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
let seft = this; this.getData()
},
wx.showLoading({ bindKeyInput: function (e) {
title: '加载中', this.setData({
key: e.detail.value
}) })
},
bindKeyConfirm: function () {
let key = this.data.key;
this.setData({
confirmKey: key,
priceList: null,
p: 1,
total: 0,
time: "",
});
this.getData();
},
getData: function () {
let me = this;
let token = wx.getStorageSync('access_token')
getData(apis.goodsInfo, {
offset: me.data.limit, p: me.data.p, token: token, 'goods_name/like': me.data.confirmKey
}, function (res) {
if (res.errcode === 0) {
let newArr = [];
if (me.data.p > 1) {
newArr = me.data.priceList;
}
for (let key in res.goods_list) {
newArr.push(res.goods_list[key])
}
if (me.data.p == 1) {
me.setData({
time: newArr[0].update_time
})
}
me.setData({
priceList: newArr,
total: res.total,
});
} else if (res.errcode === 110001 || res.errcode === 103001) {
if (me.data.p == 1) {
me.setData({
priceList: []
})
}
}
setTimeout(() => { }, true)
wx.hideLoading()
seft.setData({ priceList: arr })
}, 2000)
}, },
/** /**
...@@ -73,7 +112,21 @@ Page({ ...@@ -73,7 +112,21 @@ Page({
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
console.log(1111) let allPage = Math.ceil(this.data.total / this.data.limit);
let p = this.data.p;
if (p == allPage) {
wx.showToast({
title: '数据到底啦',
icon: 'none',
duration: 2000
});
return
} else {
this.setData({
p: p + 1
});
this.getData();
}
}, },
/** /**
...@@ -87,7 +140,7 @@ Page({ ...@@ -87,7 +140,7 @@ Page({
url: "/pages/form/good/index", url: "/pages/form/good/index",
}) })
}, },
emitevent:function(){ emitevent: function () {
wx.navigateTo({ wx.navigateTo({
url: "/pages/detail/good/index", url: "/pages/detail/good/index",
}) })
......
<!--pages/tab/good/good.wxml--> <!--pages/tab/good/good.wxml-->
<wxs module="dateUtil" src="../../../utils/timeUtil.wxs"></wxs>
<view class="good-view"> <view class="good-view">
<view class="search-com"> <view class="search-com">
<text class="icon iconfont iconiconxiantiaoshouji8"></text> <text class="icon iconfont iconiconxiantiaoshouji8"></text>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindtap="toSearch"></input> <input placeholder='请输入芯片型号' placeholder-class="placeholderClass" bindinput="bindKeyInput" bindconfirm="bindKeyConfirm"></input>
</view> </view>
<view class="good-total row bothSide verCenter px-hr-bottom"> <view class="good-total row bothSide verCenter px-hr-bottom">
<view class="good-num"> <view class="good-num">
<text>已发布商品: </text> <text>已发布商品: </text>
<text class="num bold">4</text> <text class="num bold">{{total}}</text>
</view> </view>
<text class="time"> <text class="time">
<text>最近更新:</text> <text>最近更新:</text>
<text>2019-05-14 10:40</text> <text>{{dateUtil.dateFormat(time*1000)}}</text>
</text> </text>
</view> </view>
<view class="good-content"> <view class="good-content">
...@@ -19,7 +20,7 @@ ...@@ -19,7 +20,7 @@
<cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image> <cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image>
<view class="h3 bold">未搜索到相关信息</view> <view class="h3 bold">未搜索到相关信息</view>
<view class="p">您还可以发布询价。</view> <view class="p">您还可以发布询价。</view>
<view class="btn-com btn-com-b add-good-btn"> <view class="btn-com btn-com-b add-good-btn" bindtap="fbGood">
<text class="icon iconfont iconiconxiantiaoshouji15"></text> <text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text> <text>新增商品</text>
</view> </view>
......
...@@ -2,14 +2,35 @@ ...@@ -2,14 +2,35 @@
.good-view { .good-view {
min-height: 100%; min-height: 100%;
padding-bottom: 118rpx; padding:180rpx 0 118rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.good-view .search-com {
height: 86rpx;
box-sizing: border-box;
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #fff;
z-index: 2;
}
.good-total { .good-total {
padding: 37rpx 24rpx 24rpx 0; padding: 37rpx 24rpx 24rpx 0;
margin-left: 24rpx; margin-left: 24rpx;
font-size: 22rpx; font-size: 22rpx;
color: #adb6bf; color: #adb6bf;
height: 94rpx;
box-sizing: border-box;
position: fixed;
top: 86rpx;
left: 0;
right: 0;
background-color: #fff;
z-index: 2;
} }
.good-total .good-num { .good-total .good-num {
...@@ -19,25 +40,29 @@ ...@@ -19,25 +40,29 @@
.good-total .good-num .num { .good-total .good-num .num {
color: #515559; color: #515559;
} }
.good-btn-div{
.good-btn-div {
position: fixed; position: fixed;
left:0; left: 0;
bottom:0; bottom: 0;
right:0; right: 0;
background-color: #fff; background-color: #fff;
height:118rpx; height: 118rpx;
} }
.add-good-btn { .add-good-btn {
margin-top:10rpx; margin-top: 10rpx;
} }
.add-good-btn .icon { .add-good-btn .icon {
margin-right: 8rpx; margin-right: 8rpx;
font-size: 32rpx; font-size: 32rpx;
} }
.nodata .p{
margin-top:14rpx; .nodata .p {
margin-top: 14rpx;
} }
.nodata .add-good-btn{
margin-top:40rpx; .nodata .add-good-btn {
margin-top: 40rpx;
} }
// pages/tab/price/price.js // pages/tab/price/price.js
let arr = [ import { getData} from '../../../utils/util.js';
{ import { apis } from '../../../utils/api.js';
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
},
{
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
},
{
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
}
]
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
tabIndex: 1, tabIndex: 1,//导航初始化
xb: 1, xb: 1,//1表示询价 2表示报价
priceList: undefined, priceList: null,//商品数据
limit:10,//每页的条数
p:1,//当前页面
total:1
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
let seft = this; this.getData();
},
wx.showLoading({ getData:function(type){
title: '加载中', let me = this;
let url, token = wx.getStorageSync('access_token')
if(me.data.xb == 1){
url = apis.inquiryInfo
}else{
url = apis.offerinfo
}
getData(url, { offset:me.data.limit, p:me.data.p, token: token},function(res){
if(res.errcode === 0){
let newArr = [];
if(me.data.p > 1 ){
newArr = me.data.priceList;
}
if (me.data.xb == 1){
for(let key in res.inquiry_list){
newArr.push(res.inquiry_list[key])
}
}else{
newArr = newArr.concat(res.data);
};
me.setData({
priceList: newArr,
total:res.total,
});
}else{
if ((me.data.p == 1) && (res.errcode == (105001 || 105015))){
me.setData({
priceList: []
}) })
}
}
},true)
setTimeout(() => {
wx.hideLoading()
seft.setData({ priceList: arr })
}, 2000)
}, },
/** /**
...@@ -61,7 +63,6 @@ Page({ ...@@ -61,7 +63,6 @@ Page({
onReady: function () { onReady: function () {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
...@@ -94,7 +95,22 @@ Page({ ...@@ -94,7 +95,22 @@ Page({
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
let allPage = Math.ceil(this.data.total/this.data.limit);
let p = this.data.p;
if(p == allPage){
wx.showToast({
title: '数据到底啦',
icon: 'none',
duration: 2000
});
return
}else{
this.setData({
p:p+1
});
console.log(this.data.p)
this.getData();
}
}, },
/** /**
...@@ -108,18 +124,22 @@ Page({ ...@@ -108,18 +124,22 @@ Page({
if (i == this.data.tabIndex) { if (i == this.data.tabIndex) {
return return
} else { } else {
if (i == 1) {
this.setData({ this.setData({
priceList:null,
p: 1,
total: 1,
tabIndex: i, tabIndex: i,
priceList: arr, })
xb: 1 if (i == 1) {
this.setData({
xb:1
}); });
this.getData()
} else { } else {
this.setData({ this.setData({
tabIndex: i, xb: 2,
priceList: [],
xb: 2
}); });
this.getData()
} }
......
/* pages/tab/price/price.wxss */ /* pages/tab/price/price.wxss */
.nodata .p {
.price-view {
box-sizing: border-box;
padding-top: 88rpx;
}
.price-view .switch-tab-com {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #fff;
z-index: 2;
}
.nodata .p {
margin-top: 14rpx; margin-top: 14rpx;
} }
.nodata .fb_btn { .nodata .fb_btn {
margin-top:40rpx margin-top: 40rpx;
} }
var regYear = getRegExp("(y+)", "i");
var dateFormat = function (timestamp, format) {
if(!timestamp){
return '--'
}
if (!format) {
format = "yyyy-MM-dd hh:mm:ss";
}
timestamp = parseInt(timestamp);
var realDate = getDate(timestamp);
function timeFormat(num) {
return num < 10 ? '0' + num : num;
}
var date = [
["M+", timeFormat(realDate.getMonth() + 1)],
["d+", timeFormat(realDate.getDate())],
["h+", timeFormat(realDate.getHours())],
["m+", timeFormat(realDate.getMinutes())],
["s+", timeFormat(realDate.getSeconds())],
["q+", Math.floor((realDate.getMonth() + 3) / 3)],
["S+", realDate.getMilliseconds()],
];
var reg1 = regYear.exec(format);
if (reg1) {
format = format.replace(reg1[1], (realDate.getFullYear() + '').substring(4 - reg1[1].length));
}
for (var i = 0; i < date.length; i++) {
var k = date[i][0];
var v = date[i][1];
var reg2 = getRegExp("(" + k + ")").exec(format);
if (reg2) {
format = format.replace(reg2[1], reg2[1].length == 1
? v : ("00" + v).substring(("" + v).length));
}
}
return format;
}
module.exports = {
dateFormat: dateFormat
};
\ No newline at end of file
...@@ -122,8 +122,6 @@ const chooseImg = (num, callback) => { ...@@ -122,8 +122,6 @@ const chooseImg = (num, callback) => {
} }
}) })
}; };
module.exports = { module.exports = {
getData: getData, getData: getData,
postData: postData, postData: postData,
......
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 sign in to comment