36 changed files with 2738 additions and 421 deletions
Unified View
Diff Options
-
1app.js
-
5app.wxss
-
13components/city-change/README.md
-
190components/city-change/index.js
-
47components/city-change/index.wxml
-
125components/city-change/index.wxss
-
161components/free-input/index.js
-
4components/free-input/index.json
-
32components/free-input/index.wxml
-
78components/free-input/index.wxss
-
24pages/agent/fragment/index.js
-
4pages/agent/index/index.json
-
4pages/agent/index/index.wxml
-
31pages/article/fragment/index.js
-
8pages/article/fragment/index.wxml
-
143pages/goods/fragment/index.js
-
15pages/goods/fragment/index.json
-
41pages/goods/fragment/index.wxml
-
1pages/goods/fragment/index.wxss
-
1535pages/home/city-select/city.js
-
90pages/home/city-select/index.js
-
2pages/home/city-select/index.json
-
51pages/home/city-select/index.wxml
-
70pages/home/city-select/index.wxss
-
109pages/index/index.js
-
3pages/index/index.json
-
8pages/index/index.wxml
-
130pages/moment/fragment/index.js
-
6pages/moment/fragment/index.json
-
31pages/moment/fragment/index.wxml
-
34pages/moment/fragment/index.wxss
-
118pages/purchase/fragment/index.js
-
11pages/purchase/fragment/index.json
-
30pages/purchase/fragment/index.wxml
-
1pages/purchase/fragment/index.wxss
-
3pages/purchase/index/index.wxml
@ -1,13 +0,0 @@ |
|||||
<city-change styles='max-height:100%;' bindcitytap='cityTap'></city-change> wxml页面引用 |
|
||||
注意: |
|
||||
1.需要引用组件的index.json中需要 |
|
||||
"usingComponents": { |
|
||||
"city-change":"/components/city-change/index" |
|
||||
} |
|
||||
|
|
||||
2.在index.js中可以添加以下方法以便于获取回调 |
|
||||
cityTap(e){ |
|
||||
const cityName=e.detail.cityname;//城市名 |
|
||||
const cityId=e.detail.cityId;//城市行政编号 |
|
||||
wx.navigateBack(); |
|
||||
}, |
|
||||
@ -1,190 +0,0 @@ |
|||||
import qqmap from '../../utils/map'; |
|
||||
import region2 from '../../utils/region2' |
|
||||
const app = getApp() |
|
||||
Component({ |
|
||||
properties: { |
|
||||
styles: { //这个是可以自定义最外层的view的样式
|
|
||||
type: String, |
|
||||
value: '', |
|
||||
observer: function (newval, oldval) { |
|
||||
// 监听改变
|
|
||||
console.log(newval, oldval); |
|
||||
} |
|
||||
}, |
|
||||
|
|
||||
}, |
|
||||
data: { |
|
||||
//下面是字母排序
|
|
||||
letter: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"], |
|
||||
cityListId: '', |
|
||||
//下面是城市列表信息,这里只是模拟数据
|
|
||||
citylist:region2, |
|
||||
//下面是热门城市数据,模拟数据
|
|
||||
newcity: [{"id":110100,"cityName":"北京"}, {"id":310100,"cityName":"上海"}, {"id":440100,"cityName":"广州"},{"id":440300,"cityName":"深圳"}],//若还需要添加则在region2中查找
|
|
||||
// citySel: '全国',
|
|
||||
locateCity: '', |
|
||||
touchEndy:0, |
|
||||
rightheight:0, |
|
||||
topHeight:0, |
|
||||
dialogIsShow:false, |
|
||||
chooseCity:null,//缓存的城市
|
|
||||
}, |
|
||||
attached() { |
|
||||
var that=this |
|
||||
this.data.topHeight=app.globalData.CustomBar |
|
||||
wx.getStorage({ |
|
||||
key: 'city', |
|
||||
success: function(res){ |
|
||||
if(res.data.cityName){ |
|
||||
that.setData({ |
|
||||
chooseCity:res.data.cityName |
|
||||
}) |
|
||||
}else{ |
|
||||
that.setData({ |
|
||||
chooseCity:'' |
|
||||
}) |
|
||||
} |
|
||||
}, |
|
||||
fail: function(res) { |
|
||||
that.setData({ |
|
||||
chooseCity:'' |
|
||||
}) |
|
||||
} |
|
||||
}); |
|
||||
var query = this.createSelectorQuery() |
|
||||
query.select('#rightSortHeight').boundingClientRect(function (res) { |
|
||||
console.log(res); |
|
||||
that.setData({ |
|
||||
rightheight:res.height |
|
||||
}) |
|
||||
}).exec(); |
|
||||
}, |
|
||||
methods: { |
|
||||
//点击城市
|
|
||||
cityTap(e) { |
|
||||
const val = e.currentTarget.dataset.val || '', |
|
||||
types = e.currentTarget.dataset.types || '', |
|
||||
Index = e.currentTarget.dataset.index || '', |
|
||||
that = this; |
|
||||
let city = this.data.citySel; |
|
||||
let cityId='' |
|
||||
switch (types) { |
|
||||
case 'locate': |
|
||||
//定位内容
|
|
||||
city = this.data.locateCity; |
|
||||
break; |
|
||||
case 'national': |
|
||||
//全国
|
|
||||
city = '全国'; |
|
||||
break; |
|
||||
case 'new': |
|
||||
//热门城市
|
|
||||
city = val.cityName; |
|
||||
cityId=val.id |
|
||||
break; |
|
||||
case 'list': |
|
||||
//城市列表
|
|
||||
city = val.cityName; |
|
||||
cityId=val.id |
|
||||
break; |
|
||||
} |
|
||||
if (city) { |
|
||||
var cityData={ |
|
||||
cityName: city, |
|
||||
cityId:cityId |
|
||||
} |
|
||||
wx.setStorage({ |
|
||||
key: 'city', |
|
||||
data: cityData |
|
||||
}) //点击后给父组件可以通过bindcitytap事件,获取到cityname的值,这是子组件给父组件传值和触发事件的方法
|
|
||||
this.triggerEvent('citytap', { |
|
||||
cityname: city, |
|
||||
cityId:cityId |
|
||||
}); |
|
||||
} else { |
|
||||
console.log('还没有'); |
|
||||
this.getLocate(); |
|
||||
} |
|
||||
|
|
||||
}, |
|
||||
//点击城市字母
|
|
||||
letterTap(e) { |
|
||||
const Item = e.currentTarget.dataset.item; |
|
||||
this.setData({ |
|
||||
cityListId: Item |
|
||||
}); |
|
||||
this.titleDialog(Item) |
|
||||
|
|
||||
}, |
|
||||
//调用定位
|
|
||||
getLocate(){ |
|
||||
let that=this; |
|
||||
new qqmap().getLocateInfo().then(function (val) {//这个方法在另一个文件里,下面有贴出代码
|
|
||||
console.log(val); |
|
||||
if (val.indexOf('市') !== -1) {//这里是去掉“市”这个字
|
|
||||
console.log(val.indexOf('市') - 1); |
|
||||
val = val.slice(0, val.indexOf('市')); |
|
||||
console.log(val); |
|
||||
} |
|
||||
that.setData({ |
|
||||
locateCity: val, |
|
||||
}); |
|
||||
//把获取的定位和获取的时间放到本地存储
|
|
||||
wx.setStorageSync('locatecity', { city: val, time: new Date().getTime() }); |
|
||||
}); |
|
||||
}, |
|
||||
//开始触摸事件
|
|
||||
touchStart: function (e) { |
|
||||
this.data.touchEndy = e.touches[0].pageY-this.data.topHeight; |
|
||||
}, |
|
||||
touchMove: function (e) { |
|
||||
this.data.touchEndy = e.touches[0].pageY-this.data.topHeight; |
|
||||
var lindex = parseInt(this.data.touchEndy / this.data.rightheight * 26);//根据前面分析获取手指触摸位置在letters中的index值
|
|
||||
var value = this.data.letter[lindex]; |
|
||||
this.titleDialog(value) |
|
||||
|
|
||||
}, |
|
||||
touchEnd: function (e) { |
|
||||
var lindex = parseInt(this.data.touchEndy / this.data.rightheight * 26);//根据前面分析获取手指触摸位置在letters中的index值
|
|
||||
var value = this.data.letter[lindex]; |
|
||||
if(value){ |
|
||||
this.setData({ |
|
||||
cityListId: value |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
this.titleDialog(value) |
|
||||
|
|
||||
}, |
|
||||
titleDialog: function (value) { |
|
||||
if(value){ |
|
||||
this.setData({ |
|
||||
dialongValue:value, |
|
||||
dialogIsShow:true |
|
||||
}) |
|
||||
setTimeout(() => { |
|
||||
this.setData({ |
|
||||
dialongValue:null, |
|
||||
dialogIsShow:false |
|
||||
}) |
|
||||
}, 1500); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
}, |
|
||||
}, |
|
||||
ready() { |
|
||||
console.log(getApp()); |
|
||||
let that = this, |
|
||||
cityOrTime = wx.getStorageSync('locatecity')||{}, |
|
||||
time = new Date().getTime(), |
|
||||
city=''; |
|
||||
if (!cityOrTime.time||(time - cityOrTime.time > 1800000)){//每隔30分钟请求一次定位
|
|
||||
this.getLocate(); |
|
||||
}else{//如果未满30分钟,那么直接从本地缓存里取值
|
|
||||
that.setData({ |
|
||||
locateCity: cityOrTime.city |
|
||||
}) |
|
||||
} |
|
||||
}, |
|
||||
}) |
|
||||
@ -1,47 +0,0 @@ |
|||||
<view class='city_box' style='{{styles}}'> |
|
||||
<view class='city_left'> |
|
||||
<scroll-view scroll-y style='width:100%;height:85vh;' scroll-with-animation scroll-into-view="{{cityListId}}"> |
|
||||
<view class='city_locate'> |
|
||||
<view data-types='locate' catchtap='cityTap'> |
|
||||
<text class='city_locate_title'>自动定位</text> |
|
||||
<text class='city_locate_text' style='color:#33b9ff;'>{{locateCity||'点击定位'}}</text> |
|
||||
</view> |
|
||||
<view> |
|
||||
<text class='city_locate_title'>选择城市</text> |
|
||||
<text class='city_locate_text' style='{{!locateCity&&"color:#33b9ff;"}}'>{{chooseCity}}</text> |
|
||||
</view> |
|
||||
</view> |
|
||||
|
|
||||
<!-- <view class="top"> |
|
||||
<view class="topsearch"> |
|
||||
<view class="frame"> |
|
||||
<input value="{{shoopingtext}}" bindinput="shoppinginput"></input> |
|
||||
</view> |
|
||||
<text bindtap="search">搜索</text> |
|
||||
</view> |
|
||||
</view> --> |
|
||||
|
|
||||
<view class='new_city'> |
|
||||
<view class='new_city_title'>热门城市</view> |
|
||||
<view class='new_city_box'> |
|
||||
<text class='new_city_text' wx:for='{{newcity}}' wx:key='this' data-types='new' catchtap='cityTap' |
|
||||
data-val='{{item}}'>{{item.cityName}}</text> |
|
||||
</view> |
|
||||
</view> |
|
||||
<view class='city_list_box'> |
|
||||
<block wx:for='{{citylist}}' wx:key='this' wx:for-item='letterItem' wx:for-index='letterIndex'> |
|
||||
<view class='city_first_letter' id='{{letterItem.letter}}'>{{letterItem.letter}}</view> |
|
||||
<text class='city_name' wx:for='{{letterItem.data}}' wx:key='this' data-types='list' |
|
||||
catchtap='cityTap' data-index='{{index}}' data-val='{{item}}'>{{item.cityName}}</text> |
|
||||
</block> |
|
||||
</view> |
|
||||
</scroll-view> |
|
||||
</view> |
|
||||
<view class='city_right' id="rightSortHeight"> |
|
||||
<text class='letter_item' wx:for='{{letter}}' wx:key='this' catchtap='letterTap' data-item='{{item}}' |
|
||||
bindtouchstart='touchStart' bindtouchmove='touchMove' bindtouchend='touchEnd'>{{item}}</text> |
|
||||
</view> |
|
||||
</view> |
|
||||
<view class='cu-dialog show-dialog' wx:if="{{dialogIsShow && dialongValue!=null}}"> |
|
||||
<text>{{dialongValue}}</text> |
|
||||
</view> |
|
||||
@ -1,125 +0,0 @@ |
|||||
.city_box { |
|
||||
height: 100%; |
|
||||
background: #fff; |
|
||||
display: flex; |
|
||||
} |
|
||||
|
|
||||
.city_left { |
|
||||
flex: 1; |
|
||||
} |
|
||||
|
|
||||
.city_right { |
|
||||
width: 60rpx; |
|
||||
display: flex; |
|
||||
flex-direction: column; |
|
||||
justify-content: space-around; |
|
||||
} |
|
||||
|
|
||||
.letter_item { |
|
||||
flex: 1; |
|
||||
display: block; |
|
||||
font-size: 24rpx; |
|
||||
color: #33B9FF; |
|
||||
text-align: center; |
|
||||
} |
|
||||
|
|
||||
.city_locate{ |
|
||||
display: flex; |
|
||||
justify-content: space-between; |
|
||||
padding: 10rpx 20rpx 10rpx 20rpx; |
|
||||
} |
|
||||
.national { |
|
||||
height: 80rpx; |
|
||||
line-height: 80rpx; |
|
||||
border-bottom: 1px solid #efefef; |
|
||||
font-size: 28rpx; |
|
||||
color: #333; |
|
||||
padding-left: 25rpx; |
|
||||
} |
|
||||
|
|
||||
.city_locate_title { |
|
||||
color: #999; |
|
||||
margin-right: 20rpx; |
|
||||
} |
|
||||
|
|
||||
.new_city { |
|
||||
background: #efefef; |
|
||||
font-size: 28rpx; |
|
||||
} |
|
||||
|
|
||||
.new_city_title { |
|
||||
line-height: 50rpx; |
|
||||
color: #999; |
|
||||
padding-left: 25rpx; |
|
||||
margin-bottom: 20rpx; |
|
||||
} |
|
||||
|
|
||||
.new_city_box { |
|
||||
display: flex; |
|
||||
flex-wrap: wrap; |
|
||||
} |
|
||||
|
|
||||
.new_city_text { |
|
||||
width: 200rpx; |
|
||||
text-align: center; |
|
||||
line-height: 70rpx; |
|
||||
background: #fff; |
|
||||
border-radius: 35rpx; |
|
||||
margin: 0 0 22rpx 22rpx; |
|
||||
} |
|
||||
|
|
||||
.city_first_letter { |
|
||||
line-height: 40rpx; |
|
||||
height: 40rpx; |
|
||||
padding-left: 25rpx; |
|
||||
font-size: 28rpx; |
|
||||
background: #eee; |
|
||||
color: #999; |
|
||||
} |
|
||||
|
|
||||
.city_name { |
|
||||
display: block; |
|
||||
line-height: 80rpx; |
|
||||
height: 80rpx; |
|
||||
border-bottom: 1px solid #efefef; |
|
||||
font-size: 28rpx; |
|
||||
color: #333; |
|
||||
padding-left: 25rpx; |
|
||||
} |
|
||||
|
|
||||
.show-dialog { |
|
||||
width: 10vh; |
|
||||
height: 10vh; |
|
||||
position: absolute; |
|
||||
top: 50vh; |
|
||||
left: 40vw; |
|
||||
|
|
||||
background: white; |
|
||||
color: #1296DB; |
|
||||
font-size: 100rpx; |
|
||||
font-weight: bold; |
|
||||
position: fixed; |
|
||||
padding-top: 30rpx; |
|
||||
padding-bottom: 30rpx; |
|
||||
text-align: center; |
|
||||
box-shadow:0px 2px 5px 5px gray; |
|
||||
} |
|
||||
|
|
||||
.top { |
|
||||
width: 100%; |
|
||||
background-color: #f7f7f7; |
|
||||
} |
|
||||
|
|
||||
.topsearch { |
|
||||
width: 97%; |
|
||||
display: flex; |
|
||||
padding: 3% 0; |
|
||||
align-items: center; |
|
||||
} |
|
||||
|
|
||||
.frame { |
|
||||
background-color: white; |
|
||||
width: 90%; |
|
||||
border-radius: 20rpx; |
|
||||
padding: 0 3%; |
|
||||
} |
|
||||
@ -0,0 +1,161 @@ |
|||||
|
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
/** |
||||
|
* 组件的属性列表 |
||||
|
*/ |
||||
|
properties: { |
||||
|
// 整个背景颜色
|
||||
|
bgColor:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
value:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
// 输入框样式
|
||||
|
inputStyle:{ |
||||
|
type:String, |
||||
|
value:'0' |
||||
|
}, |
||||
|
color:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
// 输入框背景颜色
|
||||
|
inputBg:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
// 输入框圆角
|
||||
|
radius:{ |
||||
|
type:String, |
||||
|
value:'8000rpx' |
||||
|
}, |
||||
|
password:{ |
||||
|
type:Boolean, |
||||
|
value:false |
||||
|
}, |
||||
|
// text、number、idcard、digit
|
||||
|
type:{ |
||||
|
type:String, |
||||
|
value:'text' |
||||
|
}, |
||||
|
// 头部icon
|
||||
|
prefixIcon:{ |
||||
|
type:String, |
||||
|
value:'search' |
||||
|
}, |
||||
|
// 尾部icon
|
||||
|
suffixIcon:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
// 输入框定位
|
||||
|
position:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
// 键盘右下角文本
|
||||
|
// send、search、next、go、done
|
||||
|
confirmType:{ |
||||
|
type:String, |
||||
|
value:'done' |
||||
|
}, |
||||
|
// 提示词
|
||||
|
placeholder:{ |
||||
|
type:String, |
||||
|
value:'请输入内容' |
||||
|
}, |
||||
|
// 是否显示关闭按钮
|
||||
|
close:{ |
||||
|
type:Boolean, |
||||
|
value:false |
||||
|
}, |
||||
|
// 是否禁用
|
||||
|
disabled:{ |
||||
|
type:Boolean, |
||||
|
value:false |
||||
|
}, |
||||
|
// 额外按钮
|
||||
|
extreaWord:{ |
||||
|
type:String, |
||||
|
value:'' |
||||
|
}, |
||||
|
// 额外按钮颜色
|
||||
|
extreaColor:{ |
||||
|
type:String, |
||||
|
value:'#0081ff' |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 组件的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* 组件的方法列表 |
||||
|
*/ |
||||
|
methods: { |
||||
|
// 输入变化
|
||||
|
getInput(e){ |
||||
|
this.data.value = e.detail.value |
||||
|
this.setData({ |
||||
|
value:e.detail.value |
||||
|
}) |
||||
|
this.triggerEvent("input", { value: e.detail.value }) |
||||
|
}, |
||||
|
// 聚焦输入框变化
|
||||
|
getFocus(e){ |
||||
|
this.data.value = e.detail.value |
||||
|
this.setData({ |
||||
|
value:e.detail.value |
||||
|
}) |
||||
|
this.triggerEvent("focus", { |
||||
|
value: e.detail.value |
||||
|
}) |
||||
|
}, |
||||
|
// 失焦
|
||||
|
getBlur(e){ |
||||
|
this.data.value = e.detail.value |
||||
|
this.setData({ |
||||
|
value:e.detail.value |
||||
|
}) |
||||
|
this.triggerEvent("blur", { |
||||
|
value: e.detail.value |
||||
|
},{}) |
||||
|
}, |
||||
|
// 聚焦输入框变化
|
||||
|
getConfirm(e){ |
||||
|
this.data.value = e.detail.value |
||||
|
this.setData({ |
||||
|
value:e.detail.value |
||||
|
}) |
||||
|
this.triggerEvent("confirm", { |
||||
|
value: e.detail.value |
||||
|
}) |
||||
|
}, |
||||
|
// 额外按钮
|
||||
|
extreaBtn(){ |
||||
|
this.triggerEvent("extrea", { |
||||
|
value: this.data.value |
||||
|
},{}) |
||||
|
}, |
||||
|
// 关闭
|
||||
|
close(){ |
||||
|
this.setData({ |
||||
|
value:'' |
||||
|
}) |
||||
|
this.triggerEvent("close", { |
||||
|
value: '' |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
@ -1,6 +1,6 @@ |
|||||
{ |
{ |
||||
"component": true, |
"component": true, |
||||
"usingComponents": { |
"usingComponents": { |
||||
"wux-dialog": "/components/dialog/index" |
|
||||
|
|
||||
} |
} |
||||
} |
|
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
<view class='box' style="position:{{position}};background:{{bgColor}};"> |
||||
|
<view class="{{inputStyle == 0?'inputStyle':'inputStyles'}} {{inputStyle == 1 &&disabled?'disabled':''}}" style="border-radius:{{radius}};background:{{inputBg}};"> |
||||
|
<!-- 前置图标 --> |
||||
|
<view style="margin: 2px 0 0 0.8em;" wx:if="{{prefixIcon}}"> |
||||
|
<text class="cuIcon-search text-gray" style="font-size:16px;padding-top: 8rpx;"></text> |
||||
|
</view> |
||||
|
<input type="{{type}}" |
||||
|
style="color:{{color}}" |
||||
|
placeholder-style="color:{{color}}" |
||||
|
confirm-type="{{confirmType}}" |
||||
|
placeholder="{{placeholder}}" |
||||
|
value="{{value}}" |
||||
|
bindinput="getInput" |
||||
|
bindfocus="getFocus" |
||||
|
bindblur="getBlur" |
||||
|
bindconfirm="getConfirm" |
||||
|
password="{{password}}" |
||||
|
disabled="{{disabled}}" |
||||
|
class="input"/> |
||||
|
<!-- 删除 --> |
||||
|
<view class="deleStyle" wx:if="{{value && close}}" bindtap="close"> |
||||
|
<text class="cuIcon-close text-gray" style="font-size:16px;"></text> |
||||
|
</view> |
||||
|
<!-- 后置图标 --> |
||||
|
<view style="padding: 0 20rpx;" wx:if="{{suffixIcon}}" > |
||||
|
<!-- <slot name='suffix' ></slot> --> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view class="extreaBtn" wx:if='{{extreaWord}}' style="color:{{extreaColor}}" bindtap="extreaBtn"> |
||||
|
<text>{{extreaWord}}</text> |
||||
|
</view> |
||||
|
</view> |
||||
@ -0,0 +1,78 @@ |
|||||
|
.box{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: space-between; |
||||
|
height: 100rpx; |
||||
|
width: 100%; |
||||
|
top: 0; |
||||
|
left: 0; |
||||
|
z-index: 99; |
||||
|
/* padding: 0 20rpx; */ |
||||
|
} |
||||
|
.inputStyle{ |
||||
|
position: relative; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-items: center; |
||||
|
background: #f5f5f5; |
||||
|
line-height: 32px; |
||||
|
height: 64rpx; |
||||
|
font-size: 24rpx; |
||||
|
color: #333333; |
||||
|
flex: 1; |
||||
|
overflow: hidden; |
||||
|
margin: 0 30rpx; |
||||
|
} |
||||
|
.inputStyles{ |
||||
|
position: relative; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-items: center; |
||||
|
/* background: #f5f5f5; */ |
||||
|
line-height: 32px; |
||||
|
border: 2rpx solid #dcdfe6; |
||||
|
height: 64rpx; |
||||
|
font-size: 24rpx; |
||||
|
color: #333333; |
||||
|
flex: 1; |
||||
|
overflow: hidden; |
||||
|
margin: 0 30rpx; |
||||
|
} |
||||
|
.disabled{ |
||||
|
background-color: #f5f7fa; |
||||
|
border-color: #e4e7ed; |
||||
|
color: #c0c4cc; |
||||
|
cursor: not-allowed; |
||||
|
} |
||||
|
.iconStyle{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
} |
||||
|
.slot{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
} |
||||
|
.input{ |
||||
|
flex: 1; |
||||
|
padding:0 30rpx 0 0.5em; |
||||
|
height: 64rpx; |
||||
|
line-height: 64rpx; |
||||
|
font-size: 26rpx; |
||||
|
background-color: transparent; |
||||
|
} |
||||
|
.deleStyle{ |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: center; |
||||
|
/* background:#e1e1e1; */ |
||||
|
width: 26rpx; |
||||
|
height: 26rpx; |
||||
|
margin: 0 20rpx; |
||||
|
/* border: 2rpx solid rgb(139, 138, 138); */ |
||||
|
border-radius: 50%; |
||||
|
} |
||||
|
.extreaBtn{ |
||||
|
text-align: center; |
||||
|
margin-right: 30rpx; |
||||
|
} |
||||
@ -1,6 +1,6 @@ |
|||||
{ |
{ |
||||
"usingComponents": { |
"usingComponents": { |
||||
"focus": "/pages/agent/focus-fragment/index", |
|
||||
"factory": "/pages/agent/factory-fragment/index" |
|
||||
|
"focus": "/pages/purchase/fragment/index", |
||||
|
"factory": "/pages/goods/fragment/index" |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,143 @@ |
|||||
|
// pages/agent/index/index.js
|
||||
|
import { paperCategoryList, getMiniProxyList } from "../../api/ztb" |
||||
|
const app = getApp() |
||||
|
const statusList = [1, 2] |
||||
|
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
height: app.globalData.fragmentHeight - 90, |
||||
|
kg: app.globalData.kg, |
||||
|
loading: true, |
||||
|
requesting: false, |
||||
|
finished: false, |
||||
|
cateList: [], |
||||
|
cateScroll: false, |
||||
|
tabiList: [], |
||||
|
pageIndex: 0, |
||||
|
top: 0, |
||||
|
orderList: [], |
||||
|
form: { |
||||
|
firstCategoryId: '', |
||||
|
bidType: statusList[0], |
||||
|
pageNum: 1, |
||||
|
pageSize:15 |
||||
|
}, |
||||
|
firstShow: false |
||||
|
}, |
||||
|
methods: { |
||||
|
onRestart: function(){ |
||||
|
if (!this.data.firstShow) { |
||||
|
this.setData({ height: app.globalData.fragmentHeight - 90, kg: app.globalData.kg }) |
||||
|
this.fetchCateList() |
||||
|
this.fetchGoodsList() |
||||
|
} |
||||
|
this.data.firstShow = true |
||||
|
}, |
||||
|
fetchCateList: function(){ |
||||
|
paperCategoryList({ type: 1 }).then(result => { |
||||
|
var tabList = ['全部'] |
||||
|
var size = 0 |
||||
|
for (let index = 0; index < result.data.length; index++) { |
||||
|
tabList.push(result.data[index].name) |
||||
|
size += result.data[index].name.length |
||||
|
} |
||||
|
this.data.cateList = result.data |
||||
|
this.setData({ tabiList: tabList, cateScroll: size > 14 }) |
||||
|
}) |
||||
|
}, |
||||
|
onCategoryChange: function ({detail}) { |
||||
|
if(this.data.pageIndex == Number(detail.index)){ |
||||
|
return |
||||
|
} |
||||
|
this.data.pageIndex = Number(detail.index) |
||||
|
if(this.data.pageIndex == 0){ |
||||
|
this.data.form.firstCategoryId = '' |
||||
|
} else { |
||||
|
this.data.form.firstCategoryId = this.data.cateList[this.data.pageIndex - 1].id |
||||
|
} |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
onTabChange: function (e) { |
||||
|
if (this.data.form.bidType == Number(e.currentTarget.dataset.index)) { |
||||
|
return |
||||
|
} |
||||
|
var tabIndex = Number(e.currentTarget.dataset.index) |
||||
|
// this.data.form.bidType = statusList[this.data.tabIndex]
|
||||
|
this.data.form.firstCategoryId = '' |
||||
|
this.setData({ pageIndex: 0, ['form.bidType']: tabIndex }) |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
// 下拉刷新...
|
||||
|
onRefreshList: function () { |
||||
|
if (this.data.requesting) { |
||||
|
return |
||||
|
} |
||||
|
this.setData({ |
||||
|
orderList: [], |
||||
|
['form.pageNum']: 1, |
||||
|
loading: true, |
||||
|
finished: false |
||||
|
}) |
||||
|
this.fetchGoodsList() |
||||
|
}, |
||||
|
// 获取特价列表
|
||||
|
fetchGoodsList: function () { |
||||
|
if (this.data.requesting || this.data.finished) { |
||||
|
return |
||||
|
} |
||||
|
if (this.data.loading) { |
||||
|
this.data.requesting = true |
||||
|
} else { |
||||
|
this.setData({ requesting: true }) |
||||
|
} |
||||
|
getMiniProxyList(this.data.form).then(result => { |
||||
|
if (result.data.records.length) { |
||||
|
var respList = result.data.records |
||||
|
let nowList = `orderList[${this.data.orderList.length}]` |
||||
|
var num = result.data.current |
||||
|
var finished = result.data.current >= result.data.pages |
||||
|
if(this.data.form.pageNum == 1){ |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
top: 0, |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} else { |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} |
||||
|
} else { |
||||
|
this.setData({ finished: true, requesting: false, loading: false }) |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
this.setData({ requesting: false, finished: true, loading: false }) |
||||
|
}) |
||||
|
}, |
||||
|
lookItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
||||
|
}, |
||||
|
offerGood: function(e){ |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/mall/detail/index?id=' + item.id }) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}) |
||||
@ -0,0 +1,15 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"wux-skeleton": "/components/skeleton/index", |
||||
|
"wux-skeleton-avatar": "/components/skeleton-avatar/index", |
||||
|
"wux-skeleton-paragraph": "/components/skeleton-paragraph/index", |
||||
|
"wux-row": "/components/row/index", |
||||
|
"wux-col": "/components/col/index", |
||||
|
"refresh-view": "/components/refresher/index", |
||||
|
"wux-button": "/components/button/index", |
||||
|
"wux-tabi": "/components/tabi/index", |
||||
|
"wux-image": "/components/image/index", |
||||
|
"wux-divider": "/components/divider/index", |
||||
|
"product-item": "/pages/mall/product-item/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
<!--pages/agent/index/index.wxml--> |
||||
|
<wxs module="formate" src="../../../pages/formate.wxs"></wxs> |
||||
|
<view class="bg-white" style="height:90rpx;border-bottom: 2rpx solid #eee"> |
||||
|
<wux-tabi scroll="{{cateScroll}}" tab-data="{{tabiList}}" tab-index="{{pageIndex}}" bind:change="onCategoryChange"></wux-tabi> |
||||
|
</view> |
||||
|
|
||||
|
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchGoodsList"> |
||||
|
<view class="bg-white list-empty" style="height:{{ height }}rpx" wx:if="{{!orderList.length}}"> |
||||
|
<view class="load-spinner text-gray" style="margin-bottom:24px" wx:if="{{loading}}" /> |
||||
|
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
||||
|
<view class="text-empty"> |
||||
|
<text wx:if="{{loading}}">正在加载</text> |
||||
|
<view wx:else> |
||||
|
<view wx:if="{{form.bidType == 2}}"> |
||||
|
<view>竞价商品发布中,</view> |
||||
|
<view>先去一口价专区逛逛吧。</view> |
||||
|
</view> |
||||
|
<view wx:else>暂无数据</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view wx:else> |
||||
|
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> |
||||
|
<view wx:for="{{pageItem}}" wx:key="index"> |
||||
|
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{pageIndex != 0 || index != 0 }}"> |
||||
|
<wux-divider show-text="{{ false }}"></wux-divider> |
||||
|
</view> |
||||
|
<product-item item="{{item}}"></product-item> |
||||
|
</view> |
||||
|
</view> |
||||
|
<!--加载更多的UI--> |
||||
|
<view wx:if="{{form.pageNum > 1}}" style="padding:20rpx"> |
||||
|
<wux-divider> |
||||
|
<view class="loadmore"> |
||||
|
<text class="icon--refresher" wx:if="{{!finished}}"></text> |
||||
|
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
||||
|
</view> |
||||
|
</wux-divider> |
||||
|
</view> |
||||
|
</view> |
||||
|
</refresh-view> |
||||
@ -0,0 +1 @@ |
|||||
|
/* pages/agent/index/index.wxss */ |
||||
1535
pages/home/city-select/city.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -1,17 +1,101 @@ |
|||||
// pages/home/about/index.js
|
// pages/home/about/index.js
|
||||
|
const util = require('../../../utils/util') |
||||
|
const event = require('../../../utils/event') |
||||
|
const city = require("./city.js") |
||||
|
const app = getApp() |
||||
|
|
||||
Page({ |
Page({ |
||||
|
|
||||
/** |
/** |
||||
* 页面的初始数据 |
* 页面的初始数据 |
||||
*/ |
*/ |
||||
data: { |
data: { |
||||
|
|
||||
|
value: '', |
||||
|
height: app.globalData.fragmentHeight - 100, |
||||
|
localCity:'',//当前定位城市
|
||||
|
hotCity: ['北京', '上海', '广州', '深圳', '杭州', '长沙', '武汉', '厦门', '西安', '昆明', '成都', '重庆'], // 热门城市
|
||||
|
lists:[],//城市列表
|
||||
|
searchResult:[],//查找列表
|
||||
|
titleHeight: 240, |
||||
|
indexHeight: 0, |
||||
|
itemHeight: 0, |
||||
|
scrollViewId: '', // scroll-view滚动到的子元素的id 锚点
|
||||
|
touchmove: false, // 是否在索引表上滑动
|
||||
|
touchmoveIndex: -1 |
||||
}, |
}, |
||||
|
|
||||
/** |
/** |
||||
* 生命周期函数--监听页面加载 |
* 生命周期函数--监听页面加载 |
||||
*/ |
*/ |
||||
onLoad: function (options) { |
onLoad: function (options) { |
||||
|
|
||||
|
var height = app.globalData.fragmentHeight - 100 |
||||
|
this.data.indexHeight = height - 48 |
||||
|
var titleHeight = this.px2rpx(app.globalData.CustomBar) + 116 |
||||
|
var itemHeight = parseInt(this.data.indexHeight / 25) |
||||
|
this.setData({ height, itemHeight, indexHeight: this.data.indexHeight, titleHeight,lists: city.list }) |
||||
|
}, |
||||
|
getInputValue(e){ |
||||
|
this.setData({ value:e.detail.value },()=>{ |
||||
|
this.searchCity() |
||||
|
}) |
||||
|
}, |
||||
|
closeInput(e){ |
||||
|
this.setData({ value: '' }) |
||||
|
}, |
||||
|
searchCity(){ |
||||
|
let result = [] |
||||
|
city.list.forEach((item1, index1) => { |
||||
|
item1.data.forEach((item2, index2) => { |
||||
|
if (item2.keyword.indexOf(this.data.value.toLocaleUpperCase()) !== -1) { |
||||
|
result.push(item2) |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
this.setData({ searchResult: result }) |
||||
|
}, |
||||
|
rpx2px: function(rpx) { |
||||
|
return rpx / 750 * app.globalData.windowWidth |
||||
|
}, |
||||
|
px2rpx: function(px) { |
||||
|
return px * 750 / app.globalData.windowWidth |
||||
|
}, |
||||
|
touchStart: function(e) { |
||||
|
this.setData({ touchmove: true }) |
||||
|
let pageY = this.px2rpx(e.touches[0].pageY) |
||||
|
let index = Math.floor((pageY - this.data.titleHeight) / this.data.itemHeight) |
||||
|
let item = this.data.lists[index] |
||||
|
if (item) { |
||||
|
this.setData({ scrollViewId: item.letter == '#' ? 'E_' : item.letter, touchmoveIndex: index }) |
||||
|
} |
||||
|
}, |
||||
|
touchMove: function(e) { |
||||
|
let pageY = this.px2rpx(e.touches[0].pageY) |
||||
|
let index = Math.floor((pageY - this.data.titleHeight) / this.data.itemHeight) |
||||
|
let item = this.data.lists[index] |
||||
|
if (item) { |
||||
|
this.setData({ scrollViewId: item.letter == '#' ? 'E_' : item.letter, touchmoveIndex: index }) |
||||
|
} |
||||
|
}, |
||||
|
touchEnd: function() { |
||||
|
this.setData({ touchmove: false, touchmoveIndex: -1 }) |
||||
|
}, |
||||
|
lookItem: function(e){ |
||||
|
var item = null |
||||
|
if(util.isEmpty(this.data.value)){ |
||||
|
if(!util.isEmpty(e.currentTarget.dataset.page)){ |
||||
|
item = this.data.lists[e.currentTarget.dataset.page].data[e.currentTarget.dataset.index] |
||||
|
} else { |
||||
|
item = this.data.hotCity[e.currentTarget.dataset.index] |
||||
|
} |
||||
|
} else { |
||||
|
item = this.data.searchResult[e.currentTarget.dataset.index] |
||||
|
} |
||||
|
if(app.nowLocation) { |
||||
|
app.nowLocation.cityName = item.cityName.replace('市', '') |
||||
|
app.nowLocation.cityCode = item.code |
||||
|
} else { |
||||
|
app.nowLocation = { cityName: item.cityName.replace('市', ''), cityCode: item.code } |
||||
|
} |
||||
|
event.emit('EventMessage', { what: 444, desc: 'nowLocation' }) |
||||
|
wx.navigateBack() |
||||
} |
} |
||||
}) |
}) |
||||
@ -1,6 +1,6 @@ |
|||||
{ |
{ |
||||
"usingComponents": { |
"usingComponents": { |
||||
"wux-cell-group": "/components/cell-group/index", |
|
||||
|
"free-input":"/components/free-input/index", |
||||
"wux-cell": "/components/cell/index" |
"wux-cell": "/components/cell/index" |
||||
} |
} |
||||
} |
} |
||||
@ -1,10 +1,47 @@ |
|||||
<!--pages/home/about/index.wxml--> |
<!--pages/home/about/index.wxml--> |
||||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
||||
<view slot="content">关于纸通宝</view> |
|
||||
|
<view slot="content">城市选择</view> |
||||
</cu-custom> |
</cu-custom> |
||||
|
|
||||
<view style="height:32rpx"></view> |
|
||||
<wux-cell-group> |
|
||||
<wux-cell title="纸通宝平台交易规则" is-link url="/pages/html/rules/index"></wux-cell> |
|
||||
<wux-cell title="商品交易风险提示书" is-link url="/pages/html/risk/index"> </wux-cell> |
|
||||
</wux-cell-group> |
|
||||
|
<view class="bg-white"> |
||||
|
<free-input value="{{value}}" placeholder="请输入城市首字母或者城市名称" bind:input="getInputValue" |
||||
|
bind:close="closeInput" close="{{true}}"></free-input> |
||||
|
</view> |
||||
|
<scroll-view scroll-y scroll-into-view="{{scrollViewId}}" style="height:{{height}}rpx"> |
||||
|
<!-- 查询城市 --> |
||||
|
<view wx:if="{{value}}"> |
||||
|
<view class="bg-white" wx:for="{{searchResult}}" style="padding: 0rpx 32rpx" wx:key="index"> |
||||
|
<view class="solid-bottom" style="padding: 24rpx 0rpx;" bindtap="lookItem" data-index="{{index}}">{{item.cityName}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<view wx:else> |
||||
|
<view class="bg-white" style="padding: 0rpx 32rpx;"> |
||||
|
<view class="text-gray text-sm">定位城市</view> |
||||
|
<view class="flex align-center" style="padding: 12rpx 0;"> |
||||
|
<!-- <free-icon name="map-filling" size="20" color="#0081ff"></free-icon> --> |
||||
|
<text>{{localCity}}</text> |
||||
|
</view> |
||||
|
</view> |
||||
|
<!-- 热门城市 --> |
||||
|
<view class=""> |
||||
|
<view class="text-sm text-gray" style="padding: 12rpx 32rpx;">热门城市</view> |
||||
|
<view class="city-names bg-white"> |
||||
|
<view class="city-name-item" wx:for="{{hotCity}}" wx:key="index" bindtap="lookItem" data-index="{{index}}">{{item}}</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
<!-- 列表 --> |
||||
|
<view> |
||||
|
<block wx:for="{{lists}}" wx:for-index="pageIndex" wx:key="pageIndex" wx:for-item="pageItem" wx:if="{{pageItem.data[0]}}"> |
||||
|
<view class="text-gray" style="padding: 12rpx 32rpx;" id="{{pageItem.letter}}">{{pageItem.letter}}</view> |
||||
|
<view class="bg-white" style="padding: 0rpx 32rpx" wx:for="{{pageItem.data}}" wx:key="index"> |
||||
|
<view class="solid-bottom" style="padding: 24rpx 0rpx;" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem">{{item.cityName}}</view> |
||||
|
</view> |
||||
|
</block> |
||||
|
</view> |
||||
|
</view> |
||||
|
</scroll-view> |
||||
|
<!-- 右侧定位 --> |
||||
|
<view wx:if="{{!value}}" class="list-bar" style="height:{{indexHeight}}rpx;top:{{titleHeight}}rpx" |
||||
|
catchtouchstart="touchStart" catchtouchmove="touchMove" catchtouchend="touchEnd" catchtouchcancel="touchEnd"> |
||||
|
<text wx:for="{{lists}}" wx:key="index" class="list-text" style="height:{{itemHeight}}rpx;color:{{index == touchmoveIndex ? '#008AFF' : '#333333'}}">{{item.letter}}</text> |
||||
|
</view> |
||||
|
<view class="list-alert" wx:if="{{touchmove && lists[touchmoveIndex].letter}}">{{lists[touchmoveIndex].letter}}</view> |
||||
@ -1 +1,69 @@ |
|||||
/* pages/home/about/index.wxss */ |
|
||||
|
/* pages/home/about/index.wxss */ |
||||
|
.list-bar{ |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
align-items: center; |
||||
|
justify-content: flex-start; |
||||
|
z-index: 19; |
||||
|
position: absolute; |
||||
|
right: 0; |
||||
|
width: 60rpx; |
||||
|
} |
||||
|
.list-text{ |
||||
|
font-size: 22rpx; |
||||
|
} |
||||
|
.list-alert{ |
||||
|
position: absolute; |
||||
|
z-index: 20; |
||||
|
width: 160rpx; |
||||
|
height: 160rpx; |
||||
|
left: 50%; |
||||
|
top: 50%; |
||||
|
margin-left: -80rpx; |
||||
|
margin-top: -80rpx; |
||||
|
border-radius: 80rpx; |
||||
|
text-align: center; |
||||
|
line-height: 160rpx; |
||||
|
font-size: 70rpx; |
||||
|
color: #fff; |
||||
|
background-color: rgba(0, 0, 0, 0.5); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
.city-names { |
||||
|
display: flex; |
||||
|
flex-wrap: wrap; |
||||
|
justify-content: space-between; |
||||
|
align-content: space-between; |
||||
|
/* width: 630rpx; */ |
||||
|
padding: 12rpx 90rpx 26rpx 30rpx; |
||||
|
} |
||||
|
.city-name-item { |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
width: 140rpx; |
||||
|
height: 56rpx; |
||||
|
margin-top: 16rpx; |
||||
|
/* border: solid 1rpx #ccc; */ |
||||
|
border-radius: 28rpx; |
||||
|
font-size: 28rpx; |
||||
|
color: #333; |
||||
|
position: relative; |
||||
|
} |
||||
|
.city-name-item::before { |
||||
|
content: ""; |
||||
|
position: absolute; |
||||
|
width: 200%; |
||||
|
height: 200%; |
||||
|
-webkit-transform-origin: 0 0; |
||||
|
transform-origin: 0 0; |
||||
|
-webkit-transform: scale(0.5, 0.5); |
||||
|
transform: scale(0.5, 0.5); |
||||
|
-webkit-box-sizing: border-box; |
||||
|
box-sizing: border-box; |
||||
|
left: 0; |
||||
|
top: 0; |
||||
|
border-radius: 56rpx; |
||||
|
border: 1px solid #ccc; |
||||
|
} |
||||
@ -1,10 +1,11 @@ |
|||||
{ |
{ |
||||
"usingComponents": { |
"usingComponents": { |
||||
"mall": "/pages/mall/index/index", |
|
||||
|
"mall": "/pages/moment/fragment/index", |
||||
"article": "/pages/article/fragment/index", |
"article": "/pages/article/fragment/index", |
||||
"agent": "/pages/agent/fragment/index", |
"agent": "/pages/agent/fragment/index", |
||||
"home": "/pages/home/index/index", |
"home": "/pages/home/index/index", |
||||
"wux-image": "/components/image/index", |
"wux-image": "/components/image/index", |
||||
|
"wux-dialog": "/components/dialog/index", |
||||
"wux-popup": "/components/popup/index" |
"wux-popup": "/components/popup/index" |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,130 @@ |
|||||
|
// pages/message/index.js
|
||||
|
import { getFactoryPrice, getSuccessNotices } from "../../api/ztb" |
||||
|
const event = require('../../../utils/event') |
||||
|
const util = require('../../../utils/util') |
||||
|
const app = getApp() |
||||
|
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
properties:{ |
||||
|
cityName: { //这个是可以自定义最外层的view的样式
|
||||
|
type: String, |
||||
|
value: '' |
||||
|
} |
||||
|
}, |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
height: app.globalData.safeFragmentHeight - 270, |
||||
|
kg: app.globalData.kg, |
||||
|
firstShow: false, |
||||
|
noticeList: [], |
||||
|
tabList: [ '推荐', '关注', '全部' , '资讯'], |
||||
|
tabIndex: 0, |
||||
|
}, |
||||
|
lifetimes: { |
||||
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||||
|
attached: function () { |
||||
|
event.on('EventMessage', this, this.onEvent) |
||||
|
}, |
||||
|
detached: function () { |
||||
|
event.remove('EventMessage', this) |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
onRestart: function () { |
||||
|
if(!this.data.firstShow){ |
||||
|
this.setData({ |
||||
|
height: app.globalData.safeFragmentHeight - 270, |
||||
|
StatusBar: app.globalData.StatusBar || 40, |
||||
|
customHeight: app.globalData.customHeight, |
||||
|
tabIndex: 0, |
||||
|
firstShow: true |
||||
|
}) |
||||
|
this.fetchAgentList() |
||||
|
} |
||||
|
this.data.firstShow = true |
||||
|
if(!this.data.noticeList.length){ |
||||
|
this.fetchNoticeList() |
||||
|
} |
||||
|
}, |
||||
|
onEvent: function (message) { |
||||
|
console.log('mall>>index>>onEvent', message) |
||||
|
if (message.what == 10 && app.globalData.isVIP == 1) { |
||||
|
// this.setData({ token: app.globalData.token })
|
||||
|
// this.onRefreshList()
|
||||
|
} else if(message.what == 1001){ |
||||
|
this.setData({ kg: app.globalData.kg }) |
||||
|
} else if(message.what == 888){ |
||||
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) |
||||
|
this.fetchAgentList() |
||||
|
} else if(message.what == 444){ |
||||
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false, cityName: app.nowLocation.cityName }) |
||||
|
this.fetchAgentList() |
||||
|
} |
||||
|
}, |
||||
|
chooseCity: function(){ |
||||
|
wx.navigateTo({url: `/pages/home/city-select/index?type=1` }) |
||||
|
}, |
||||
|
searchList: function(){ |
||||
|
|
||||
|
}, |
||||
|
postList: function(){ |
||||
|
|
||||
|
}, |
||||
|
onTabChange: function({detail}){ |
||||
|
if(this.data.tabIndex == Number(detail.index)){ |
||||
|
return |
||||
|
} |
||||
|
this.fetchAgentList() |
||||
|
}, |
||||
|
fetchNoticeList: function(){ |
||||
|
if (this.data.loopRequesting) { |
||||
|
return |
||||
|
} |
||||
|
this.data.loopRequesting = true |
||||
|
getSuccessNotices().then(result => { |
||||
|
this.data.loopRequesting = false |
||||
|
this.data.noticeList = [] |
||||
|
if(result.data && result.data.length){ |
||||
|
for (let index = 0; index < result.data.length; index++) { |
||||
|
this.data.noticeList.push(result.data[index].msg) |
||||
|
} |
||||
|
this.setData({noticeList: this.data.noticeList}) |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
this.data.loopRequesting = false |
||||
|
}) |
||||
|
}, |
||||
|
//*************************************************fetchAgentList************************************************//
|
||||
|
fetchAgentList: function () { |
||||
|
if (this.data.requesting || this.data.finished) { |
||||
|
return |
||||
|
} |
||||
|
if (this.data.loading) { |
||||
|
this.data.requesting = true |
||||
|
} else { |
||||
|
this.setData({ requesting: true }) |
||||
|
} |
||||
|
getFactoryPrice(this.data.form).then(result => { |
||||
|
if (result.data.records.length) { |
||||
|
var respList = result.data.records |
||||
|
let nowList = `orderList[${this.data.orderList.length}]` |
||||
|
var num = result.data.current |
||||
|
var finished = result.data.current >= result.data.pages |
||||
|
this.setData({ [nowList]: respList, ['form.pageNum']: (num + 1), finished, requesting: false, loading: false }) |
||||
|
} else { |
||||
|
this.setData({ requesting: false, finished: true, loading: false }) |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
//异常回调
|
||||
|
this.setData({ requesting: false, finished: true, loading: false }) |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}) |
||||
@ -0,0 +1,6 @@ |
|||||
|
{ |
||||
|
"component": true, |
||||
|
"usingComponents": { |
||||
|
"wux-tabi": "/components/tabi/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
<!--pages/message/index.wxml--> |
||||
|
<wxs module="formate" src="../../../pages/formate.wxs"></wxs> |
||||
|
<view class="cu-custom top-bg" style="height:{{customHeight}}rpx;z-index: 99;"> |
||||
|
<view class="cu-bar fixed " style="height:{{customHeight}}rpx;padding-top:{{StatusBar}}rpx;border-bottom:none"> |
||||
|
<view class="flex flex-center" style="margin-left: 32rpx;width: 100%;"> |
||||
|
<view class="flex flex-center" catchtap="chooseCity"> |
||||
|
<text class="text-white text-lg">{{cityName}}</text> |
||||
|
<text class="cuIcon-unfold text-white" style="font-size:16px;padding-top: 8rpx;margin-left: 8rpx;"></text> |
||||
|
</view> |
||||
|
<view class="bg-white flex flex-center" style="margin-left:24rpx;flex: 1;border-radius: 16rpx;height: 60rpx;" catchtap="searchList"> |
||||
|
<text class="cuIcon-search text-gray" style="font-size:12px;margin-left: 24rpx;padding-top: 4rpx;"></text> |
||||
|
<text class="text-gray text-sm" style="flex: 1;margin-left: 8rpx">输入纸名/品名/纸厂/规格</text> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
</view> |
||||
|
|
||||
|
<view class="bg-white flex flex-center" style="height:80rpx;padding:16rpx 24rpx;"> |
||||
|
<text class="cuIcon-notification text-yellow" style="font-size:36rpx;"></text> |
||||
|
<swiper vertical="{{true}}" autoplay="{{true}}" circular="{{true}}" interval="3000" class="tui-swiper"> |
||||
|
<swiper-item wx:for="{{noticeList}}" wx:key="index" class="flex flex-center" catchtouchmove="stopTouchMove" style="justify-content: flex-start"> |
||||
|
<view class="flex flex-justify" style="width: 100%;height: 100%;"> |
||||
|
<view class="tui-news-item">{{item}}</view> |
||||
|
<text class="cuIcon-right text-black" style="font-size:16px;margin-left: 8rpx;"></text> |
||||
|
</view> |
||||
|
</swiper-item> |
||||
|
</swiper> |
||||
|
</view> |
||||
|
<view class="bg-white" style="height:90rpx;border-bottom:2rpx solid #f3f3f3;border-top:2rpx solid #f3f3f3" wx:if="{{firstShow}}"> |
||||
|
<wux-tabi tab-data="{{tabList}}" tab-index="{{tabIndex}}" scroll="{{false}}" bind:change="onTabChange"></wux-tabi> |
||||
|
</view> |
||||
@ -0,0 +1,34 @@ |
|||||
|
.top-bg{ |
||||
|
background-image: linear-gradient(127deg, rgba(0,122,255,0.67) 0%, rgba(13,100,227,0.95) 100%); |
||||
|
} |
||||
|
|
||||
|
.banner{ |
||||
|
border-radius: 16rpx; |
||||
|
} |
||||
|
|
||||
|
.banner-left{ |
||||
|
margin-left: 24rpx; |
||||
|
border-radius: 16rpx; |
||||
|
} |
||||
|
|
||||
|
.item-content { |
||||
|
background: rgba(255, 255, 255, 1); |
||||
|
padding:32rpx |
||||
|
} |
||||
|
|
||||
|
.tui-swiper { |
||||
|
margin-left: 8rpx; |
||||
|
font-size: 26rpx; |
||||
|
height: 60rpx; |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.tui-news-item { |
||||
|
line-height: 56rpx; |
||||
|
padding-top: 4rpx; |
||||
|
white-space: nowrap; |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
color: #555; |
||||
|
text-align: center; |
||||
|
} |
||||
@ -0,0 +1,118 @@ |
|||||
|
// pages/goods/index/index.js
|
||||
|
import { paperCategoryList, getProductList } from "../../api/ztb" |
||||
|
const event = require('../../../utils/event') |
||||
|
const app = getApp() |
||||
|
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
|
/** |
||||
|
* 页面的初始数据 |
||||
|
*/ |
||||
|
data: { |
||||
|
height: app.globalData.fragmentHeight, |
||||
|
kg: app.globalData.kg, |
||||
|
loading: true, |
||||
|
requesting: false, |
||||
|
finished: false, |
||||
|
cateList: [], |
||||
|
cateScroll: false, |
||||
|
top: 0, |
||||
|
orderList: [], |
||||
|
form: { |
||||
|
firstCategoryId: '', |
||||
|
pageNum: 1, |
||||
|
pageSize:15 |
||||
|
} |
||||
|
}, |
||||
|
lifetimes: { |
||||
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||||
|
attached: function () { |
||||
|
event.on('EventMessage', this, this.onEvent) |
||||
|
}, |
||||
|
detached: function () { |
||||
|
event.remove('EventMessage', this) |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
onRestart: function(){ |
||||
|
if (!this.data.firstShow) { |
||||
|
this.setData({ height: app.globalData.fragmentHeight, kg: app.globalData.kg }) |
||||
|
this.fetchCateList() |
||||
|
this.fetchGoodsList() |
||||
|
} |
||||
|
this.data.firstShow = true |
||||
|
}, |
||||
|
fetchCateList: function(){ |
||||
|
paperCategoryList({ type: 1 }).then(result => { |
||||
|
var cateList = [{id: '', name: '全部'}].concat(result.data) |
||||
|
this.setData({ cateList: cateList, cateScroll: cateList.length >= 5 }) |
||||
|
}) |
||||
|
}, |
||||
|
onCategoryChange: function (e) { |
||||
|
if (this.data.form.firstCategoryId == e.detail.key) { |
||||
|
return |
||||
|
} |
||||
|
this.setData({ ['form.firstCategoryId']: e.detail.key }) |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
// 下拉刷新...
|
||||
|
onRefreshList: function () { |
||||
|
if (this.data.requesting) { |
||||
|
return |
||||
|
} |
||||
|
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) |
||||
|
this.fetchGoodsList() |
||||
|
}, |
||||
|
// 获取特价列表
|
||||
|
fetchGoodsList: function () { |
||||
|
if (this.data.requesting || this.data.finished) { |
||||
|
return |
||||
|
} |
||||
|
if (this.data.loading) { |
||||
|
this.data.requesting = true |
||||
|
} else { |
||||
|
this.setData({ requesting: true }) |
||||
|
} |
||||
|
getProductList(this.data.form).then(result => { |
||||
|
//成功回调
|
||||
|
if (result.data.records.length) { |
||||
|
var respList = result.data.records |
||||
|
let nowList = `orderList[${this.data.orderList.length}]` |
||||
|
var num = result.data.current |
||||
|
var finished = result.data.current >= result.data.pages |
||||
|
if(this.data.form.pageNum == 1){ |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
top: 0, |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} else { |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
total: result.data.total, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} |
||||
|
} else { |
||||
|
this.setData({ finished: true, requesting: false, loading: false }) |
||||
|
} |
||||
|
}).catch(err => { |
||||
|
this.setData({ requesting: false, loading: false }) |
||||
|
}) |
||||
|
}, |
||||
|
lookItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/purchase/detail/index?id=' + item.id }) |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"usingComponents": { |
||||
|
"wux-skeleton": "/components/skeleton/index", |
||||
|
"wux-skeleton-avatar": "/components/skeleton-avatar/index", |
||||
|
"wux-skeleton-paragraph": "/components/skeleton-paragraph/index", |
||||
|
"refresh-view": "/components/refresher/index", |
||||
|
"wux-image": "/components/image/index", |
||||
|
"wux-divider": "/components/divider/index", |
||||
|
"purchase-item": "/pages/mall/purchase-item/index" |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
<!--pages/goods/index/index.wxml--> |
||||
|
<wxs module="formate" src="../../../pages/formate.wxs"></wxs> |
||||
|
|
||||
|
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchGoodsList"> |
||||
|
<view class="bg-white list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}"> |
||||
|
<view class="load-spinner text-gray" style="margin-bottom:24px" wx:if="{{loading}}" /> |
||||
|
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
||||
|
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view> |
||||
|
</view> |
||||
|
<view wx:else> |
||||
|
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{orderList}}" wx:key="pageIndex"> |
||||
|
<view wx:for="{{pageItem}}" wx:key="index"> |
||||
|
<view class="bg-white" style="padding: 0rpx 32rpx" wx:if="{{pageIndex != 0 || index != 0 }}"> |
||||
|
<wux-divider show-text="{{ false }}"></wux-divider> |
||||
|
</view> |
||||
|
<!-- <wux-divider show-text="{{ false }}" wx:if="{{pageIndex != 0 || index != 0 }}"></wux-divider> --> |
||||
|
<purchase-item item="{{item}}"></purchase-item> |
||||
|
</view> |
||||
|
</view> |
||||
|
<!--加载更多的UI--> |
||||
|
<view wx:if="{{form.pageNum>1}}" style="padding:20rpx"> |
||||
|
<wux-divider> |
||||
|
<view class="loadmore"> |
||||
|
<text class="icon--refresher" wx:if="{{!finished}}"></text> |
||||
|
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
||||
|
</view> |
||||
|
</wux-divider> |
||||
|
</view> |
||||
|
</view> |
||||
|
</refresh-view> |
||||
@ -0,0 +1 @@ |
|||||
|
/* pages/goods/index/index.wxss */ |
||||
Write
Preview
Loading…
Cancel
Save