Commit 314e96ea by 施宇

213123

parents
//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
})
\ No newline at end of file
{
"pages": [
"pages/tab/home/home",
"pages/tab/price/price",
"pages/tab/message/message",
"pages/tab/good/good",
"pages/tab/me/me"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"tabBar": {
"color": "#8A9299",
"selectedColor": "#0D84D1",
"borderStyle": "white",
"backgroundColor": "#fff",
"list": [
{
"pagePath": "pages/tab/home/home",
"text": "首页",
"iconPath": "/res/images/icons/home-icon.png",
"selectedIconPath": "/res/images/icons/home-icon-act.png"
},
{
"pagePath": "pages/tab/price/price",
"text": "询报价",
"iconPath": "/res/images/icons/price-icon.png",
"selectedIconPath": "/res/images/icons/price-icon-act.png"
},
{
"pagePath": "pages/tab/message/message",
"text": "消息",
"iconPath": "/res/images/icons/msg-icon.png",
"selectedIconPath": "/res/images/icons/msg-icon-act.png"
},
{
"pagePath": "pages/tab/good/good",
"text": "商品",
"iconPath": "/res/images/icons/good-icon.png",
"selectedIconPath": "/res/images/icons/good-icon-act.png"
},
{
"pagePath": "pages/tab/me/me",
"text": "我的",
"iconPath": "/res/images/icons/me-icon.png",
"selectedIconPath": "/res/images/icons/me-icon-act.png"
}
]
},
"sitemapLocation": "sitemap.json"
}
\ No newline at end of file
/**app.wxss**/
/**app.wxss**/
page {
font-size: 16px;
font-family: PingFangSC-Regular;
}
image {
vertical-align: middle;
}
.column {
display: flex;
flex-direction: column;
}
.row {
display: flex;
flex-direction: row;
}
/* 两侧对齐 */
.bothSide {
justify-content: space-between;
}
/* 平均分布 */
.avarage {
justify-content: space-around;
}
/* 水平居中 */
.rowCenter {
justify-content: center;
}
/* 垂直居中 */
.verCenter {
align-items: center;
}
/*复用样式*/
.px-hr-top {
border-top: 1px solid #f5f9fc;
}
.px-hr-bottom {
border-bottom: 1px solid #f5f9fc;
}
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
// components/priceItem/priceItem.js
Component({
/**
* 组件的属性列表
*/
options: {
styleIsolation: 'apply-shared'
},
properties: {
priceList:{
type:Array
}
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--components/priceItem/priceItem.wxml-->
<block>
<view class="price-item" wx:for="{{priceList}}" wx:key="*this">
<view class="item-header px-hr-bottom row verCenter bothSide">
<view class="row verCenter">
<text class="mark bao" wx:if="{{item.type==1}}">报</text>
<text class="mark xun" wx:else>询</text>
<text class="name ellipsis">{{item.name}}</text>
</view>
<text class="price">¥{{item.price}}</text>
</view>
<view class="item-middle row verCenter">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand}}</text>
<text class="num"><text>数量:</text>{{item.num}}PCS</text>
</view>
<view class="item-footer row bothSide verCenter ">
<text class="address ellipsis">备注:{{item.desc}}</text>
<text class="time">{{item.time}}</text>
</view>
</view>
</block>
\ No newline at end of file
/* components/priceItem/priceItem.wxss */
.price-item {
padding-left: 24rpx;
}
.item-header {
padding: 29rpx 23rpx 21rpx 0;
}
.item-header .row {
overflow: hidden;
white-space: nowrap;
}
.item-header .mark {
border-radius: 2px;
font-size: 12px;
color: #fff;
padding: 2rpx 10rpx;
margin-right: 24rpx;
}
.bao {
background: #eaa217;
}
.xun {
background: #61a0f2;
}
.item-header .name, .item-header .price {
font-weight: 600;
font-family: PingFangSC-Semibold;
}
.item-header .name {
color: #515559;
margin-right: 24rpx;
}
.item-header .price {
font-size: 14px;
color: #ea1717;
}
.item-middle {
padding: 15rpx 23rpx 15rpx 0;
overflow: hidden;
white-space: nowrap;
}
.item-middle .brand, .item-middle .num {
font-size: 13px;
color: #515559;
}
.item-middle .num {
margin-left: 62rpx;
}
.item-middle .brand text, .item-middle .num text {
color: #8a9299;
}
.item-footer {
padding: 0 23rpx 24rpx 0;
overflow: hidden;
white-space: nowrap;
}
.item-footer .address {
color: #8A9299;
font-size: 13px;
}
.item-footer .time {
color: #ADB6BF;
font-size: 11px;
}
// pages/tab/good/good.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/tab/good/good.wxml-->
<text>pages/tab/good/good.wxml</text>
/* pages/tab/good/good.wxss */
\ No newline at end of file
// pages/tab/home/home.js
let arr = [
{
type: 2,
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
},
{
type: 1,
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
},
{
type: 2,
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
},
{
type: 1,
name: "STM32F407ZGT6",
price: "100.012",
brand: "Texas InstrumentsTexas",
num: "100,000",
desc: "深圳地区原装现货深圳地区原装现货",
time: "05-10 10:15"
}
]
Page({
/**
* 页面的初始数据
*/
data: {
priceList: undefined,
isGet:false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let seft = this;
wx.showLoading({
title: '加载中',
})
setTimeout(()=>{
wx.hideLoading()
seft.setData({ priceList: arr })
},2000)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if(this.data.isGet){
return
}else{
wx.showLoading({
title: '加载中',
})
this.setData({ isGet: true });
let arr = this.data.priceList.concat(this.data.priceList);
let seft = this;
setTimeout(() => {
wx.hideLoading();
seft.setData({ priceList: arr, isBottom: false, isGet:false })
}, 2000)
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {"priceItem": "/components/priceItem/priceItem"},
"navigationBarTitleText":"IC业务助手",
"navigationBarBackgroundColor":"#0D84D1",
"navigationBarTextStyle":"white",
"backgroundColor":"#0d84d1"
}
\ No newline at end of file
<!--pages/tab/home/home.wxml-->
<view class="home-view">
<view class="search-section">
<cover-image class="search-icon" src="/res/images/icons/search-icon.png"></cover-image>
<input placeholder='请输入芯片型号' placeholder-class="placeholderClass"></input>
</view>
<view class="home-content">
<view class="home-function bothSide row">
<view class="function-item column verCenter">
<cover-image src="/res/images/icons/home-s-1.png" class="img"></cover-image>
<text class="text">发布询价</text>
</view>
<view class="function-item column verCenter">
<cover-image src="/res/images/icons/home-s-2.png" class="img"></cover-image>
<text class="text">抢单专区</text>
</view>
<view class="function-item column verCenter">
<cover-image src="/res/images/icons/home-s-3.png" class="img"></cover-image>
<text class="text">发布商品</text>
</view>
<view class="function-item column verCenter">
<cover-image src="/res/images/icons/home-s-4.png" class="img"></cover-image>
<text class="text">积分兑换</text>
</view>
</view>
<view class="advs">
<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>
<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>
<view class="more-item">
<cover-image src="/res/images/icons/more-adv.png" class="img"></cover-image>
</view>
</view>
</view>
</view>
<view class="my-price">
<view class="price-title">
<view class="price-title-content row bothSide verCenter px-hr-bottom ">
<text>我的询报价</text>
<cover-image src="/res/images/icons/home-refresh-icon.png" class="img"></cover-image>
</view>
</view>
<view class="price-content">
<view wx:if="{{priceList&&priceList.length==0}}">暂无数据</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}"></priceItem>
</view>
</view>
</view>
</view>
\ No newline at end of file
/* pages/tab/home/home.wxss */
.home-view {
padding-top: 146rpx;
}
.home-view .search-section {
background-color: #0d84d1;
padding: 29rpx 24rpx 55rpx;
position: absolute;
top: 0;
left: 0;
right: 0;
}
.search-section .search-icon {
position: absolute;
height: 40rpx;
width: 40rpx;
top: 53rpx;
left: 49rpx;
}
.search-section input {
background: #fff;
height: 88rpx;
border-radius: 8rpx;
box-shadow: 0px 8px 20px 0px rgba(39, 67, 85, 0.5);
padding: 0 18rpx 0 83rpx;
box-sizing: border-box;
}
.search-section .placeholderClass {
font-family: PingFangSC-Regular, sans-serif;
color: #515559;
font-size: 16px;
}
.home-content {
background: #fff;
border-top-left-radius: 20rpx;
border-top-right-radius: 20rpx;
position: relative;
}
.home-function {
padding: 32rpx 50rpx;
}
.function-item .img {
height: 100rpx;
width: 100rpx;
}
.function-item .text {
font-size: 13px;
color: #8a9299;
margin-top: 11rpx;
}
.advs {
margin-top: 9rpx;
padding-left: 24rpx;
border-bottom: 10rpx solid #f5f9fc;
}
.advs-content-parent {
margin-right: 24rpx;
padding: 29rpx 0 30rpx;
}
.advs-content {
flex: 1;
overflow: hidden;
white-space: nowrap;
}
.adv {
margin-bottom: 25rpx;
margin-right: 29rpx;
}
.adv:last-child {
margin: 0;
}
.adv-mark {
font-size: 12px;
color: #61a0f2;
background: #f0f6fa;
border-radius: 2rpx;
height: 36rpx;
line-height: 36rpx;
padding: 0 19rpx;
}
.adv-num {
font-size: 14px;
color: #515559;
margin-left: 24rpx;
}
.adv-time {
font-size: 12px;
color: #8a9299;
margin-left: 27rpx;
}
.more-item {
flex: 0 1 40rpx;
}
.price-title {
height: 88rpx;
font-size: 14px;
font-family: PingFangSC-Semibold;
font-weight: 600;
color: #515559;
padding-left: 25rpx;
}
.price-title-content {
height: 100%;
padding-right: 25rpx;
}
.price-title text::before {
content: "";
background: #1177b9;
display: inline-block;
vertical-align: middle;
margin-right: 17rpx;
height: 30rpx;
width: 2px;
}
.my-price .img {
height: 40rpx;
width: 40rpx;
}
// pages/tab/me/me.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/tab/me/me.wxml-->
<text>pages/tab/me/me.wxml</text>
/* pages/tab/me/me.wxss */
\ No newline at end of file
// pages/tab/message/message.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/tab/message/message.wxml-->
<text>pages/tab/message/message.wxml</text>
/* pages/tab/message/message.wxss */
\ No newline at end of file
// pages/tab/price/price.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/tab/price/price.wxml-->
<text>pages/tab/price/price.wxml</text>
/* pages/tab/price/price.wxss */
\ No newline at end of file
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"autoAudits": false,
"coverView": true
},
"compileType": "miniprogram",
"libVersion": "2.7.0",
"appid": "wx69781f444d83d9ff",
"projectname": "ichunt",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
\ No newline at end of file
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}
\ No newline at end of file
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : '0' + n
}
module.exports = {
formatTime: formatTime
}
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