Commit f6fe75d1 by 施宇

111

parent 6caf8244
......@@ -31,6 +31,12 @@ Component({
methods: {
emitevent:function(){
this.triggerEvent('emitevent')
},
previewImage:function(e){
let img = e.currentTarget.dataset.image;
wx.previewImage({
urls: [img]
})
}
}
})
<!--components/priceItem/priceItem.wxml-->
<block>
<wxs module="dateUtil" src="../../utils/timeUtil.wxs"></wxs>
<!-- 询报价展示 -->
<block wx:if="{{priceType==1}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
......@@ -7,21 +8,33 @@
<view class="row verCenter">
<text class="mark xun" wx:if="{{xb==1}}">询</text>
<text class="mark bao" wx:else>报</text>
<text class="name ellipsis">{{item.name}}</text>
<text class="name ellipsis">{{item.goods_name||'--'}}</text>
</view>
<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>
</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 class="item-middle row verCenter nowrap">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text>
<text class="num bold"><text class="nobold">数量:</text>{{item.num}}PCS</text>
<text class="brand ellipsis"><text>品牌:</text>{{item.brand_name}}</text>
<text class="num"><text>数量:</text>{{item.number}} PCS</text>
</view>
<view class="item-footer row bothSide verCenter nowrap">
<text class="address ellipsis">备注:{{item.desc}}</text>
<text class="time">{{item.time}}</text>
<text class="address ellipsis">备注:{{item.remark}}</text>
<text class="time">{{dateUtil.dateFormat(item.add_time*1000)}}</text>
</view>
</view>
</block>
......@@ -107,14 +120,22 @@
<view class="price-item" wx:for="{{priceList}}" wx:key="*this" bindtap="emitevent">
<view class="item-header row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="name ellipsis good-name">{{item.name}}</text>
<text class="icon iconfont iconiconxiantiaoshouji14 good-icon"></text>
<text class="name ellipsis good-name">{{item.goods_name}}</text>
<block wx:if="{{item.goods_images}}">
<text class="icon iconfont iconiconxiantiaoshouji14 good-icon" catchtap="previewImage" data-image="{{item.goods_images}}"></text>
</block>
</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 class="item-middle row verCenter nowrap">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text>
<text class="num bold"><text class="nobold">库存: </text>{{item.num}}PCS</text>
<text class="brand ellipsis"><text>品牌:</text>{{item.brand_name}}</text>
<text class="num"><text>库存:</text>{{item.stock}} PCS</text>
</view>
</view>
</block>
......
// pages/tab/good/good.js
let arr = [
{
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
}
]
import { getData } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
priceList:undefined
priceList: null,//商品数据
limit: 10,//每页的条数
p: 1,//当前页面
total: 0,
time: "",
key: "",
confirmKey: ""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let seft = this;
wx.showLoading({
title: '加载中',
this.getData()
},
bindKeyInput: function (e) {
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();
setTimeout(() => {
wx.hideLoading()
seft.setData({ priceList: arr })
}, 2000)
},
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: []
})
}
}
}, true)
},
/**
......@@ -73,7 +112,21 @@ Page({
* 页面上拉触底事件的处理函数
*/
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({
url: "/pages/form/good/index",
})
},
emitevent:function(){
emitevent: function () {
wx.navigateTo({
url: "/pages/detail/good/index",
})
......
<!--pages/tab/good/good.wxml-->
<wxs module="dateUtil" src="../../../utils/timeUtil.wxs"></wxs>
<view class="good-view">
<view class="search-com">
<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 class="good-total row bothSide verCenter px-hr-bottom">
<view class="good-num">
<text>已发布商品: </text>
<text class="num bold">4</text>
<text class="num bold">{{total}}</text>
</view>
<text class="time">
<text>最近更新:</text>
<text>2019-05-14 10:40</text>
<text>{{dateUtil.dateFormat(time*1000)}}</text>
</text>
</view>
<view class="good-content">
......@@ -19,7 +20,7 @@
<cover-image src="/res/images/imgs/nodata.png" class="img"></cover-image>
<view class="h3 bold">未搜索到相关信息</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>新增商品</text>
</view>
......
......@@ -2,14 +2,35 @@
.good-view {
min-height: 100%;
padding-bottom: 118rpx;
padding:180rpx 0 118rpx;
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 {
padding: 37rpx 24rpx 24rpx 0;
margin-left: 24rpx;
font-size: 22rpx;
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 {
......@@ -19,25 +40,29 @@
.good-total .good-num .num {
color: #515559;
}
.good-btn-div{
.good-btn-div {
position: fixed;
left:0;
bottom:0;
right:0;
left: 0;
bottom: 0;
right: 0;
background-color: #fff;
height:118rpx;
height: 118rpx;
}
.add-good-btn {
margin-top:10rpx;
margin-top: 10rpx;
}
.add-good-btn .icon {
margin-right: 8rpx;
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;
}
\ No newline at end of file
// pages/tab/price/price.js
let arr = [
{
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"
}
]
import { getData} from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
tabIndex: 1,
xb: 1,
priceList: undefined,
tabIndex: 1,//导航初始化
xb: 1,//1表示询价 2表示报价
priceList: null,//商品数据
limit:10,//每页的条数
p:1,//当前页面
total:1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let seft = this;
wx.showLoading({
title: '加载中',
})
setTimeout(() => {
wx.hideLoading()
seft.setData({ priceList: arr })
}, 2000)
this.getData();
},
getData:function(type){
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)
},
/**
......@@ -61,7 +63,6 @@ Page({
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
......@@ -94,7 +95,22 @@ Page({
* 页面上拉触底事件的处理函数
*/
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({
if (i == this.data.tabIndex) {
return
} else {
this.setData({
priceList:null,
p: 1,
total: 1,
tabIndex: i,
})
if (i == 1) {
this.setData({
tabIndex: i,
priceList: arr,
xb: 1
xb:1
});
this.getData()
} else {
this.setData({
tabIndex: i,
priceList: [],
xb: 2
xb: 2,
});
this.getData()
}
......
/* pages/tab/price/price.wxss */
.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;
}
.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) => {
}
})
};
module.exports = {
getData: getData,
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