Commit 5d7aa8b0 by 施宇

3213

parent 1b9e15ba
......@@ -118,7 +118,6 @@ image {
.nodata .img {
width: 600rpx;
height: 393rpx;
margin: 0 auto;
}
......
......@@ -5,7 +5,7 @@ Page({
* 页面的初始数据
*/
data: {
isShowSwitch:false
isShowSwitch:false,
},
/**
......
......@@ -10,31 +10,31 @@
<view class="form-item row verCenter">
<text class="form-item-title">*型号</text>
<view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass"></input>
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass" type="text"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text>
<view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass"></input>
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass" type="text"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text>
<view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass"></input>
<input placeholder="请输入封装" placeholder-class="placeholderClass" type="text"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*数量</text>
<view class="form-item-right">
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass"></input>
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass" type="number"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*报价</text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass"></input>
<input placeholder="请输入单价" placeholder-class="placeholderClass" type="number"></input>
<view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text>
<text class="icon iconfont iconbianzu1"></text>
......@@ -51,10 +51,10 @@
<view class="form-item-right">
<radio-group>
<label>
<radio value="1" checked/>现货
<radio value="1"/>现货
</label>
<label>
<radio value="2" checked/>期货
<radio value="2"/>期货
</label>
</radio-group>
</view>
......@@ -62,7 +62,7 @@
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*时间</text>
<view class="form-item-right">
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass"></input>
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text"></input>
</view>
</view>
<view class="form-hr"></view>
......
// pages/form/xj/index.js
import { getData, chooseImg } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({
/**
* 页面的初始数据
*/
data: {
isShowSwitch: false
isShowSwitch: false,
isShowTime: false,
imgUrl:null,
},
formSubmit: function (e) {
console.log(e)
},
radioChange(e) {
let val = e.detail.value;
this.setData({
isShowTime: val == 1?false:true
})
},
uploadImg:function(){
let me = this;
chooseImg(apis.ossupload, 1, function(url){
me.setData({
imgUrl:url
})
})
},
deleteImg:function(){
this.setData({
imgUrl: null
})
},
/**
* 生命周期函数--监听页面加载
*/
......
......@@ -8,70 +8,82 @@
<text class="icon iconfont iconiconxiantiaoshouji13 close-icon"></text>
</view>
<view class="upload-view column verCenter">
<view class="upload column verCenter rowCenter">
<view class="upload column verCenter rowCenter" bindtap="uploadImg" wx:if="{{!imgUrl}}">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text class="upload-text">上传图片</text>
</view>
<view class="text">据说上传图片更容易让人报价</view>
</view>
<view class="form-item row verCenter">
<text class="form-item-title">*型号</text>
<view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass"></input>
<view class="hasImg" wx:else>
<cover-image src="{{imgUrl}}"></cover-image>
<text class="icon iconfont iconiconxiantiaoshouji7 deleteImg" bindtap="deleteImg"></text>
</view>
<view class="text">据说上传图片更容易让人报价</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text>
<view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass"></input>
<form bindsubmit="formSubmit">
<view class="form-item row verCenter">
<text class="form-item-title">*型号</text>
<view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass" type="text" name="goods_name"></input>
</view>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text>
<view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass"></input>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text>
<view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass" type="text" name="brand_name"></input>
</view>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*数量</text>
<view class="form-item-right">
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass"></input>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text>
<view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass" type="text" name="encap"></input>
</view>
</view>
</view>
<view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*价格</text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass"></input>
<view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text>
<text class="icon iconfont iconbianzu1"></text>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*数量</text>
<view class="form-item-right">
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass" type="number" name="number"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*价格</text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass" type="number" name="price"></input>
<view class="price-type" bindtap="switchPrice">
<text class="price-value">RMB</text>
<text class="icon iconfont iconbianzu1"></text>
</view>
</view>
<view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view>
<view class="price-li px-hr-top">USD</view>
</view>
</view>
<view class="price-ul {{isShowSwitch?'show':''}}">
<view class="price-li active">RMB</view>
<view class="price-li px-hr-top">USD</view>
<view class="form-item row verCenter px-hr-top qx-item">
<text class="form-item-title">*货期</text>
<view class="form-item-right">
<radio-group name="hq" bindchange="radioChange">
<label>
<radio value="1" checked/>现货
</label>
<label>
<radio value="2" />期货
</label>
</radio-group>
</view>
</view>
</view>
<view class="form-item row verCenter px-hr-top qx-item">
<text class="form-item-title">*货期</text>
<view class="form-item-right">
<radio-group>
<label>
<radio value="1" checked/>现货
</label>
<label>
<radio value="2" checked/>期货
</label>
</radio-group>
<view class="form-item row verCenter px-hr-top" wx:if="{{isShowTime}}">
<text class="form-item-title">*时间</text>
<view class="form-item-right">
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text" name="day"></input>
</view>
</view>
</view>
<view class="form-hr"></view>
<view class="form-item row px-hr-bottom">
<text class="form-item-title">备注</text>
<view class="form-item-right">
<textarea placeholder="请输入备注" placeholder-class="placeholderClass" maxlength="-1" />
<view class="form-hr"></view>
<view class="form-item row px-hr-bottom">
<text class="form-item-title">备注</text>
<view class="form-item-right">
<textarea placeholder="请输入备注" placeholder-class="placeholderClass" maxlength="-1" name="remark" />
</view>
</view>
</view>
<view class="btn-com btn-com-b hf-btn">发布询价</view>
<button class="btn-com btn-com-b hf-btn" form-type="submit">发布询价</button>
</form>
</view>
\ No newline at end of file
......@@ -28,7 +28,10 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
let storageKeys = wx.getStorageSync('storageKeys') || [];
this.setData({
historyList:storageKeys
})
},
/**
......@@ -90,5 +93,11 @@ Page({
})
}
},
deleteHistory:function(){
this.setData({
historyList: []
});
wx.removeStorageSync('storageKeys')
}
})
\ No newline at end of file
......@@ -18,15 +18,10 @@
<view class="ls_search" wx:if="{{historyList.length}}">
<view class="title_view row bothSide verCenter">
<text class="title beforeLine">搜索历史</text>
<text class="icon iconfont iconiconxiantiaoshouji7" ></text>
<text class="icon iconfont iconiconxiantiaoshouji7" bindtap="deleteHistory"></text>
</view>
<view class="rm_ls_content row">
<view class="search-item">LM358</view>
<view class="search-item">TJA1027</view>
<view class="search-item">贴片电阻330k</view>
<view class="search-item">PFB0824GHE</view>
<view class="search-item">T6738-4K</view>
<view class="search-item">ECW-FA2J155J</view>
<view class="search-item" wx:for="{{historyList}}" wx:key="*this">{{item}}</view>
</view>
</view>
......
......@@ -14,26 +14,45 @@ Page({
p: 1,//当前页面
total: 1,
key: "",
confirmKey:"",
confirmKey: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let key = options.key;
this.setData({
key: key,
confirmKey:key
confirmKey: key
});
this.getData()
this.storageKey(key)
this.getData();
},
bindKeyInput: function (e) {
this.setData({
key: e.detail.value
})
},
storageKey: function (key) {
let storageKeys = wx.getStorageSync('storageKeys') || [];
if (!storageKeys.length) {
storageKeys.push(key);
} else {
let index = storageKeys.indexOf(key);
if (index == -1) {
if (storageKeys.length > 9) {
storageKeys.pop()
}
storageKeys.unshift(key)
} else {
storageKeys.splice(index, 1);
storageKeys.unshift(key)
}
}
wx.setStorageSync('storageKeys', storageKeys)
},
bindKeyConfirm: function () {
let val = this.data.key;
if (!val.length) {
......@@ -55,6 +74,7 @@ Page({
total: 1,
confirmKey: val
});
this.storageKey(val)
this.getData()
}
},
......
// pages/tab/home/home.js
import { getData } from '../../../utils/util.js';
import { apis } from '../../../utils/api.js';
Page({
/**
......@@ -6,21 +8,163 @@ Page({
*/
data: {
priceList: null,
xjList:null,
xjList: [],
animation: {},
translateY: 0,
tabIndex: 1,
xb: 1,//1表示询价 2表示报价
limit: 10,//每页的条数
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getTopData();
this.getData();
},
getTopData: function () {
let me = this;
let token = wx.getStorageSync('access_token') || ''
getData(apis.inquirySearch, 'get', {
"offset": 10,
"p": 1,
"add_time/order": "desc",
"token": token
}, function (res) {
let newArr = [];
if (res.errcode === 0) {
if (res.total == 0) {
me.setData({
xjList: []
})
} else {
for (let key in res.inquiry_list) {
newArr.push(res.inquiry_list[key])
};
let nowDate = Date.parse(new Date());
for(let i=0;i<newArr.length;i++){
let etime = newArr[i].add_time*1000;
let usedTime = me.interval(nowDate-etime);
newArr[i].usedTime = usedTime
}
me.setData({
xjList: newArr
});
let arrLen = newArr.length;
if (!arrLen || arrLen < 3) {
me.setData({
animation: {}
})
} else {
let allHeight = (arrLen - 2) * 30;
let interVal = setInterval(() => {
let translateY = me.data.translateY;
if (translateY + allHeight == 0) {
console.log('到底啦');
// clearInterval(interVal);
// let arr = me.data.xjList.concat();
// let arr1 = arr.splice(arrLen-2,arrLen);
// arr = arr1.concat(arr);
me.setData({
// xjList:arr,
translateY: 0
})
me.translateYAnimation();
} else {
me.setData({
translateY: translateY - 30
});
me.translateYAnimation();
}
}, 2000)
}
}
} else {
me.setData({
xjList: []
})
}
}, false)
},
getData: function () {
let me = this;
let url, token = wx.getStorageSync('access_token')
if (!token) {
this.setData({
priceList: []
});
return
} else {
if (me.data.xb == 1) {
url = apis.inquiryInfo
} else {
url = apis.offerinfo
}
getData(url, 'get', { offset: me.data.limit, p: 1, token: token }, function (res) {
if (res.errcode === 0) {
let newArr = [];
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,
});
} else {
me.setData({
priceList: []
})
}
}, true)
}
},
interval: function (usedTime){
let days = Math.floor(usedTime / (24 * 3600 * 1000));
//计算出小时数
let leave1 = usedTime % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
let hours = Math.floor(leave1 / (3600 * 1000));
//计算相差分钟数
let leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
let minutes = Math.floor(leave2 / (60 * 1000));
if(days){
return days + "天前";
}else{
if (hours){
if(minutes){
return hours + "小时" + minutes + "分钟前";
}else{
return hours + "小时前";
}
}else{
if (minutes) {
return minutes + "分钟前";
} else {
return '刚刚';
}
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
translateYAnimation: function () {
let animation = wx.createAnimation({
duration: 1000,
timingFunction: 'ease',
delay: 1000
});
animation.translateY(this.data.translateY).step();
this.setData({
animation: animation.export()
});
},
onReady: function () {
},
......@@ -57,7 +201,7 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
......@@ -66,7 +210,31 @@ Page({
onShareAppMessage: function () {
},
toSearch:function(){
switchTab: function (e) {
let i = e.currentTarget.dataset.index;
if (i == this.data.tabIndex) {
return
} else {
this.setData({
priceList: null,
tabIndex: i,
})
if (i == 1) {
this.setData({
xb: 1
});
} else {
this.setData({
xb: 2,
});
}
this.getData();
}
},
toSearch: function () {
wx.navigateTo({
url: '/pages/search/index/index',
})
......@@ -76,7 +244,7 @@ Page({
url: "/pages/form/xj/index"
})
},
fbGood:function(){
fbGood: function () {
wx.navigateTo({
url: "/pages/form/good/index",
})
......
......@@ -23,22 +23,19 @@
<text class="text">积分兑换</text>
</view>
</view>
<view class="advs">
<view class="advs" wx:if="{{xjList.length}}">
<view class="px-hr-top">
<view class=" row bothSide verCenter advs-content-parent">
<view class="advs-content">
<view class="adv row verCenter">
<text class="adv-mark">询价</text>
<text class="adv-num ellipsis">STM32F103CR22D</text>
<text class="adv-time">2分钟前</text>
</view>
<view class="adv row verCenter">
<text class="adv-mark">询价</text>
<text class="adv-num ellipsis">STM32F103CR22DSTM32F103CR22DSTM32F103CR22DSTM32F103CR22DSTM32F103CR22D</text>
<text class="adv-time">2分钟前</text>
<view class="advs-ul" animation="{{animation}}">
<view class="adv row verCenter" wx:for="{{xjList}}" wx:key="*this">
<text class="adv-mark">询价</text>
<text class="adv-num ellipsis">{{item.goods_name||'--'}}</text>
<text class="adv-time">{{item.usedTime}}</text>
</view>
</view>
</view>
<view class="more-item">
<view class="more-item" bindtap="toQd">
<text class="icon iconfont iconiconxiantiaoshouji6"></text>
</view>
</view>
......@@ -46,15 +43,29 @@
</view>
<view class="my-price">
<view class="price-title">
<!-- <view class="price-title">
<view class="price-title-content row bothSide verCenter px-hr-bottom ">
<text class="xb-t beforeLine">我的询报价</text>
<text class="icon iconfont iconiconxiantiaoshouji5"></text>
</view>
</view> -->
<view class="switch-tab-com row">
<view bindtap="switchTab" class="{{tabIndex == 1&&'active'}}" data-index="1">
<text>我的询价</text>
<text class="active-bg"></text>
</view>
<view bindtap="switchTab" class="{{tabIndex == 2&&'active'}}" data-index="2">
<text>我的报价</text>
<text class="active-bg"></text>
</view>
</view>
<view class="price-content">
<view wx:if="{{priceList&&priceList.length==0}}">暂无数据</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="1" ></priceItem>
<view wx:if="{{priceList&&priceList.length==0}}" class="nodata">
<cover-image src="/res/images/imgs/noxb.png" class="img" style="width:500rpx;"></cover-image>
<view class="h3 bold">暂无询报价信息</view>
<view class="p" style="color:#61A0F2;padding-top:20rpx;">您还可以发布询价。</view>
</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="1" xb="{{xb}}"></priceItem>
</view>
</view>
</view>
......
......@@ -64,17 +64,20 @@
.advs-content-parent {
margin-right: 24rpx;
padding: 29rpx 0 30rpx;
padding: 15rpx 0;
}
.advs-content {
flex: 1;
max-height:60px;
box-sizing: border-box;
overflow: hidden;
white-space: nowrap;
position: relative;
}
.adv {
margin-bottom: 25rpx;
/* margin-bottom: 25rpx; */
height:30px;
margin-right: 29rpx;
}
......@@ -83,23 +86,23 @@
}
.adv-mark {
font-size: 24rpx;
font-size: 12px;
color: #61a0f2;
background: #f0f6fa;
border-radius: 2rpx;
height: 36rpx;
line-height: 36rpx;
height: 18px;
line-height: 18px;
padding: 0 19rpx;
}
.adv-num {
font-size: 28rpx;
font-size: 14px;
color: #515559;
margin-left: 24rpx;
}
.adv-time {
font-size: 24rpx;
font-size: 12px;
color: #8a9299;
margin-left: 27rpx;
}
......
......@@ -51,59 +51,9 @@
"current": 0,
"list": [
{
"id": 0,
"name": "pages/person/login/index",
"pathName": "pages/person/login/index",
"query": "",
"scene": null
},
{
"id": 1,
"name": "pages/list/bj/index",
"pathName": "pages/list/bj/index",
"query": "inquiryItemsId=156386385200578",
"scene": null
},
{
"id": 2,
"name": "pages/tab/me/me",
"pathName": "pages/tab/me/me",
"query": "",
"scene": null
},
{
"id": 2,
"name": "pages/person/setting/index",
"pathName": "pages/person/setting/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/detail/xj/index",
"pathName": "pages/detail/xj/index",
"query": "inquiryItemsId=156335056150058&offerId=156335275965152 ",
"scene": null
},
{
"id": -1,
"name": "pages/search/index/index",
"pathName": "pages/search/index/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/search/result/index",
"pathName": "pages/search/result/index",
"query": "key=lm358&type=1",
"scene": null
},
{
"id": -1,
"name": "pages/detail/good/index",
"pathName": "pages/detail/good/index",
"query": "goodId=156039271518289&type=2",
"name": "pages/form/xj/index",
"pathName": "pages/form/xj/index",
"scene": null
}
]
......
......@@ -26,9 +26,11 @@
.tip-c {
font-size: 24rpx;
}
.tip-c .pc-url{
color:#61A0F2;
.tip-c .pc-url {
color: #61a0f2;
}
.form-item {
margin-left: 24rpx;
padding: 27rpx 0;
......@@ -113,26 +115,49 @@ textarea {
.price-ul .price-li.active {
color: #0d84d1;
}
.hf-btn .icon {
margin-right: 8rpx;
font-size: 32rpx;
}
.upload-view{
margin:20rpx 0;
.upload-view {
margin: 20rpx 0;
}
.upload-view .upload{
height:220rpx;
width:220rpx;
background-color: #F0F6FA;
color:#8A9299;
.upload-view .upload {
height: 220rpx;
width: 220rpx;
background-color: #f0f6fa;
color: #8a9299;
font-size: 24rpx;
}
.upload-view .upload .icon{
font-size: 80rpx;
margin-bottom:20rpx;
.upload-view .upload .icon {
font-size: 80rpx;
margin-bottom: 20rpx;
}
.upload-view .text{
color:#ADB6BF;
.upload-view .text {
color: #adb6bf;
font-size: 22rpx;
margin-top:25rpx;
}
\ No newline at end of file
margin-top: 25rpx;
}
.hasImg {
height: 220rpx;
width: 220rpx;
position: relative;
}
.hasImg img{
height:100%;
width:100%;
}
.deleteImg{
font-size:48rpx !important;
color:#EA1717;
position: absolute;
top:0;
right:0;
transform: translate(30%,-30%)
}
......@@ -74,27 +74,44 @@ const getData = (url, type, param, callBack, loading, isheader) => {
};
//上传文件
const uploadFile = (paths, callBack) => {
let gUrl = getApp().globalUrl;
showLoading('正在上传', true)
const uploadFile = (url,paths,callBack) => {
wx.showLoading({
title: '上传中',
mask:true
})
for (var i = 0; i < paths.length; i++) {
wx.uploadFile({
url: gUrl.baseUrl + gUrl.uploadImg,
url: url,
filePath: paths[i],
name: 'file',
name: 'upload',
formData: { token: wx.getStorageSync('access_token'), source: 2},
header: {
"Content-Type": "multipart/form-data"
},
success: (res) => {
var data = JSON.parse(res.data);
if (data.suc == 'y') {
callBack({
imgSrc: data.data.file.url,
image_id: data.data.file.image_id
})
var data = JSON.parse(res.data);
if (data.errcode == 103200) {
wx.showToast({
title: '上传成功',
icon: 'none',
duration: 2000
});
callBack(data.data[0])
} else {
showModal(data.msg);
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
}
},
fail: () => {
showModal("上传图片失败!");
fail: (e) => {
console.log(e)
wx.showToast({
title: '上传失败',
icon: 'none',
duration: 2000
});
},
complete: () => {
wx.hideLoading();
......@@ -103,16 +120,14 @@ const uploadFile = (paths, callBack) => {
}
};
const chooseImg = (num, callback) => {
const chooseImg = (url,num, callback) => {
wx.chooseImage({
count: num,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
var arr = [];
uploadFile(res.tempFilePaths, (rtn) => {
arr.push(rtn)
if (arr.length === res.tempFilePaths.length) {
callback(arr)
}
uploadFile(url,res.tempFilePaths, (rtn) => {
callback(rtn)
})
}
})
......
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