Browse Source

ui调整

featrue/v4.5
xpz2018 4 years ago
parent
commit
44d5bcbf3f
36 changed files with 2738 additions and 421 deletions
  1. 1
      app.js
  2. 5
      app.wxss
  3. 13
      components/city-change/README.md
  4. 190
      components/city-change/index.js
  5. 47
      components/city-change/index.wxml
  6. 125
      components/city-change/index.wxss
  7. 161
      components/free-input/index.js
  8. 4
      components/free-input/index.json
  9. 32
      components/free-input/index.wxml
  10. 78
      components/free-input/index.wxss
  11. 24
      pages/agent/fragment/index.js
  12. 4
      pages/agent/index/index.json
  13. 4
      pages/agent/index/index.wxml
  14. 31
      pages/article/fragment/index.js
  15. 8
      pages/article/fragment/index.wxml
  16. 143
      pages/goods/fragment/index.js
  17. 15
      pages/goods/fragment/index.json
  18. 41
      pages/goods/fragment/index.wxml
  19. 1
      pages/goods/fragment/index.wxss
  20. 1535
      pages/home/city-select/city.js
  21. 90
      pages/home/city-select/index.js
  22. 2
      pages/home/city-select/index.json
  23. 51
      pages/home/city-select/index.wxml
  24. 70
      pages/home/city-select/index.wxss
  25. 109
      pages/index/index.js
  26. 3
      pages/index/index.json
  27. 8
      pages/index/index.wxml
  28. 130
      pages/moment/fragment/index.js
  29. 6
      pages/moment/fragment/index.json
  30. 31
      pages/moment/fragment/index.wxml
  31. 34
      pages/moment/fragment/index.wxss
  32. 118
      pages/purchase/fragment/index.js
  33. 11
      pages/purchase/fragment/index.json
  34. 30
      pages/purchase/fragment/index.wxml
  35. 1
      pages/purchase/fragment/index.wxss
  36. 3
      pages/purchase/index/index.wxml

1
app.js

@ -6,6 +6,7 @@ App({
agentMsgIds: ['kG8DErWDpyzBHCFaLlSKYMF7xVy8UpgogCwV_WSNt10', 'lOQ8Gvyy_dTk68bYGpRVnVA0M7DsYYrV81Gd39GUPBA'], agentMsgIds: ['kG8DErWDpyzBHCFaLlSKYMF7xVy8UpgogCwV_WSNt10', 'lOQ8Gvyy_dTk68bYGpRVnVA0M7DsYYrV81Gd39GUPBA'],
version: 152, version: 152,
xAppId: '470236309865238528', xAppId: '470236309865238528',
nowLocation: null,
globalData: { globalData: {
userInfo: null, userInfo: null,
openId: null, openId: null,

5
app.wxss

@ -41,4 +41,7 @@
opacity: .5 opacity: .5
} }
.solid-bottom,
.solid-bottom::after {
border-bottom: 1rpx solid #f3f3ff;
}

13
components/city-change/README.md

@ -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();
},

190
components/city-change/index.js

@ -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
})
}
},
})

47
components/city-change/index.wxml

@ -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>

125
components/city-change/index.wxss

@ -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%;
}

161
components/free-input/index.js

@ -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: ''
})
}
}
})

components/city-change/index.json → components/free-input/index.json

@ -1,6 +1,6 @@
{ {
"component": true, "component": true,
"usingComponents": { "usingComponents": {
"wux-dialog": "/components/dialog/index"
} }
}
}

32
components/free-input/index.wxml

@ -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>

78
components/free-input/index.wxss

@ -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;
}

24
pages/agent/fragment/index.js

@ -1,5 +1,7 @@
// pages/agent/index/index.js // pages/agent/index/index.js
import util from "../../../utils/util"
import { getFactoryPrice, getFactoryCity, hasActivity } from "../../api/ztb" import { getFactoryPrice, getFactoryCity, hasActivity } from "../../api/ztb"
const event = require('../../../utils/event')
const app = getApp() const app = getApp()
Component({ Component({
@ -37,12 +39,15 @@ Component({
lifetimes: { lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名 // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () { attached: function () {
event.on('EventMessage', this, this.onEvent)
if(app.globalData.userInfo){ if(app.globalData.userInfo){
hasActivity().then(result => { hasActivity().then(result => {
this.setData({ hasActivity: result.data }) this.setData({ hasActivity: result.data })
}) })
} }
},
detached: function () {
event.remove('EventMessage', this)
} }
}, },
methods: { methods: {
@ -54,8 +59,20 @@ Component({
} }
this.data.firstShow = true this.data.firstShow = true
}, },
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: [], tabIndex: this.data.tabIndex, ['form.pageNum']: 1, loading: true, finished: false })
this.fetchPapersList()
}
},
toAbility: function(){ toAbility: function(){
wx.navigateTo({ url: '/pages/agent/ability/index' })
util.navigateTo('/pages/agent/ability/index')
}, },
fetchRegionList: function () { fetchRegionList: function () {
getFactoryCity().then(result => { getFactoryCity().then(result => {
@ -126,9 +143,6 @@ Component({
//异常回调 //异常回调
this.setData({ requesting: false, finished: true, loading: false, }) this.setData({ requesting: false, finished: true, loading: false, })
}) })
},
goattentionIndex: function () {
wx.navigateTo({ url: '/pages/home/attentionPaperList/index' })
} }
} }

4
pages/agent/index/index.json

@ -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"
} }
} }

4
pages/agent/index/index.wxml

@ -9,10 +9,10 @@
</view> </view>
<view class="flex" style="top:{{StatusBar}}rpx;color:black;font-size:36rpx;width:340rpx;height:80rpx"> <view class="flex" style="top:{{StatusBar}}rpx;color:black;font-size:36rpx;width:340rpx;height:80rpx">
<view data-index="0" class="flex flex-center flex-column" style="flex:1;" catchtap="onTabChangeTop"> <view data-index="0" class="flex flex-center flex-column" style="flex:1;" catchtap="onTabChangeTop">
<view class="text-sg text-bold" style="color:{{pageIndex == 0 ? '#008AFF' : '#333'}}">关注</view>
<view class="text-sg text-bold" style="color:{{pageIndex == 0 ? '#008AFF' : '#333'}}">求购</view>
</view> </view>
<view data-index="1" class="flex flex-center flex-column" style="flex:1;" catchtap="onTabChangeTop"> <view data-index="1" class="flex flex-center flex-column" style="flex:1;" catchtap="onTabChangeTop">
<view class="text-sg text-bold" style="color:{{pageIndex == 1 ? '#008AFF' : '#333'}}">全部</view>
<view class="text-sg text-bold" style="color:{{pageIndex == 1 ? '#008AFF' : '#333'}}">供应</view>
</view> </view>
</view> </view>
</view> </view>

31
pages/article/fragment/index.js

@ -1,5 +1,5 @@
// pages/message/index.js // pages/message/index.js
import { getFactoryPrice, getProductList, getMiniProxyList, getBannerList, getSuccessNotices } from "../../api/ztb"
import { getFactoryPrice, getBannerList, getSuccessNotices } from "../../api/ztb"
const event = require('../../../utils/event') const event = require('../../../utils/event')
const util = require('../../../utils/util') const util = require('../../../utils/util')
const app = getApp() const app = getApp()
@ -9,6 +9,12 @@ Component({
addGlobalClass: true, addGlobalClass: true,
multipleSlots: true multipleSlots: true
}, },
properties:{
cityName: { //这个是可以自定义最外层的view的样式
type: String,
value: ''
}
},
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
@ -80,25 +86,28 @@ Component({
} else if(message.what == 888){ } else if(message.what == 888){
this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false }) this.setData({ orderList: [], ['form.pageNum']: 1, loading: true, finished: false })
this.fetchAgentList() 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(){ chooseCity: function(){
var that = this
console.log('chooseCity>>>')
wx.navigateTo({
url: `/pages/home/city-select/index?type=1`,
events: {
onCallback: (data) => {
}
}
})
wx.navigateTo({url: `/pages/home/city-select/index?type=1` })
}, },
searchList: function(){ searchList: function(){
}, },
postList: function(){ postList: function(){
},
gridTap: function(e){
if(e.currentTarget.id == 'agent'){
this.triggerEvent("click", { what: 1 })
} else if(e.currentTarget.id == 'trans'){
util.navigateTo('/pages/agent/index/index')
} else if(e.currentTarget.id == 'action'){
util.navigateTo(`/pages/agent/ability/index`)
}
}, },
tapBanner: function(e){ tapBanner: function(e){
var item = this.data.bannerList[e.currentTarget.dataset.index] var item = this.data.bannerList[e.currentTarget.dataset.index]

8
pages/article/fragment/index.wxml

@ -4,7 +4,7 @@
<view class="cu-bar fixed " style="height:{{customHeight}}rpx;padding-top:{{StatusBar}}rpx;border-bottom:none"> <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" style="margin-left: 32rpx;width: 100%;">
<view class="flex flex-center" catchtap="chooseCity"> <view class="flex flex-center" catchtap="chooseCity">
<text class="text-white text-lg">广州</text>
<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> <text class="cuIcon-unfold text-white" style="font-size:16px;padding-top: 8rpx;margin-left: 8rpx;"></text>
</view> </view>
<view class="bg-white flex flex-center" style="margin-left:24rpx;flex: 1;border-radius: 16rpx;height: 60rpx;" catchtap="searchList"> <view class="bg-white flex flex-center" style="margin-left:24rpx;flex: 1;border-radius: 16rpx;height: 60rpx;" catchtap="searchList">
@ -29,11 +29,11 @@
</view> </view>
<view class="flex" style="margin-top:16rpx"> <view class="flex" style="margin-top:16rpx">
<wux-image width="{{294}}" height="{{180}}" wux-class="banner" nuit="{{'rpx'}}" src="{{bannerList[0].picUrl}}" mode="aspectFill" bind:click="tapBanner">
<wux-image id="agent" width="{{294}}" height="{{180}}" wux-class="banner" nuit="{{'rpx'}}" src="{{bannerList[0].picUrl}}" mode="aspectFill" bind:click="gridTap">
</wux-image> </wux-image>
<wux-image width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="{{bannerList[0].picUrl}}" mode="aspectFill" bind:click="tapBanner">
<wux-image id="trans" width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="{{bannerList[0].picUrl}}" mode="aspectFill" bind:click="gridTap">
</wux-image> </wux-image>
<wux-image width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="{{bannerList[0].picUrl}}" mode="aspectFill" bind:click="tapBanner">
<wux-image id="action" width="{{180}}" height="{{180}}" wux-class="banner-left" nuit="{{'rpx'}}" src="{{bannerList[0].picUrl}}" mode="aspectFill" bind:click="gridTap">
</wux-image> </wux-image>
</view> </view>

143
pages/goods/fragment/index.js

@ -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 })
}
}
})

15
pages/goods/fragment/index.json

@ -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"
}
}

41
pages/goods/fragment/index.wxml

@ -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>

1
pages/goods/fragment/index.wxss

@ -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

90
pages/home/city-select/index.js

@ -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()
} }
}) })

2
pages/home/city-select/index.json

@ -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"
} }
} }

51
pages/home/city-select/index.wxml

@ -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>

70
pages/home/city-select/index.wxss

@ -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;
}

109
pages/index/index.js

@ -3,14 +3,20 @@ import { zconfig, loginToken, getBaseInfo, getPopupInfo } from "../api/ztb"
import { pconfig } from "../api/payment" import { pconfig } from "../api/payment"
import { mconfig } from "../api/moment" import { mconfig } from "../api/moment"
const util = require('../../utils/util') const util = require('../../utils/util')
const wxqqmap = require('../../utils/qqmap-wx-jssdk.min')
const event = require('../../utils/event') const event = require('../../utils/event')
const storage = require('../../utils/storage') const storage = require('../../utils/storage')
const app = getApp() const app = getApp()
const qqwxmap = new wxqqmap({
key: 'GAMBZ-CBGCK-GB6J3-A6PJX-F6ZHH-IWFUD' // 必填,这里最好填自己申请的的
// key: 'NGOBZ-UL7ED-WJ34D-PMWW7-LBDI2-J5FYK'
})
Page({ Page({
data: { data: {
cityName: '',
TabList: [ TabList: [
{ index: 0, value: 'article', badge: 0, name: '情报' },
{ index: 0, value: 'article', badge: 0, name: '首页' },
{ index: 1, value: 'mall', badge: 0, name: '行情' }, { index: 1, value: 'mall', badge: 0, name: '行情' },
{ index: 2, value: 'agent', badge: 0, name: '交易' }, { index: 2, value: 'agent', badge: 0, name: '交易' },
{ index: 3, value: 'home', badge: 0, name: '我的' } { index: 3, value: 'home', badge: 0, name: '我的' }
@ -48,7 +54,22 @@ Page({
this.toIndex() this.toIndex()
} }
}, },
alertMessage: function(content){
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
content,
buttons: [{
text: '确定',
type: 'primary',
onTap(e) {
}
}]
})
},
defaultIndex: function () { defaultIndex: function () {
this.locationing()
this.onResume() this.onResume()
if (this.data.path) { if (this.data.path) {
wx.navigateTo({ url: this.data.path }) wx.navigateTo({ url: this.data.path })
@ -59,6 +80,82 @@ Page({
} }
}) })
}, },
locationing: function() {
var that = this
wx.getLocation({
type: 'gcj02',
success (res) {
app.nowLocation = res
qqwxmap.reverseGeocoder({
location: res,
success: function (res) {
app.nowLocation.cityName = res.result.address_component.city.replace('市', '')
app.nowLocation.cityCode = res.result.ad_info.city_code
that.setData({ cityName: app.nowLocation.cityName })
that.locate = true
},
fail: function (res) {
that.locate = true
}
})
},
fail (e){
that.locate = true
if (e && (e.errCode == 2 || e.errCode == 404)) {
that.alertMessage('位置信息获取失败,请检查手机“位置信息”是否未开启')
} else if (e && ((e.errMsg.indexOf('getLocation:fail auth deny') != -1) || (e.errMsg.indexOf('system permission denied') != -1))) {
wx.getSetting({
success(res){
if(res && (res.authSetting["scope.userLocation"] !== undefined && res.authSetting["scope.userLocation"] !==true)){
that.detectSettings()
} else {
that.alertMessage('位置信息获取失败,请检查微信是否有定位权限')
}
}
})
} else if (e && e.errMsg.indexOf('getLocation:fail connect ETIMEDOUT') != -1) {
that.alertMessage('位置信息获取失败,请检查网络是否连接')
}
}
})
},
detectSettings: function(){
var that = this
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
content: '小程序没有定位权限,无法进行送餐服务,请前往设置微信小程序的定位权限。',
buttons: [{
text: '前往设置',
type: 'primary',
onTap(e) {
wx.openSetting({
success(result){
if(result && (result.authSetting["scope.userLocation"] !== undefined && result.authSetting["scope.userLocation"] ===true)){
// 成功设置
that.locationing()
} else {
that.detectSettings()
}
}
})
}
}]
})
Dialog.alert({ title: '温馨提示', message: '小程序没有定位权限,无法进行送餐服务,请前往设置微信小程序的定位权限。', confirmButtonText: '前往设置' }).then(() => {
wx.openSetting({
success(result){
if(result && (result.authSetting["scope.userLocation"] !== undefined && result.authSetting["scope.userLocation"] ===true)){
// 成功设置
that.locationing()
} else {
that.detectSettings()
}
}
})
})
},
toIndex: function () { toIndex: function () {
if (!app.globalData.token) { if (!app.globalData.token) {
wx.hideLoading() wx.hideLoading()
@ -97,12 +194,22 @@ Page({
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) }) this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) })
this.onResume() this.onResume()
}, },
onAgentClick: function({detail}){
if(detail.what == 1) {
this.setData({ pageIndex: 2 })
this.onResume()
}
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
if (this.data.inited) { if (this.data.inited) {
this.onResume() this.onResume()
}
// 如果定位完成,但是还是没有获取城市信息,那么就要进行城市选择
if(this.locate && util.isEmpty(this.data.cityName)){
} }
if(app.globalData.userInfo && !app.globalData.userInfo.identityTag){ if(app.globalData.userInfo && !app.globalData.userInfo.identityTag){
wx.navigateTo({ url: '/pages/home/tab1/index' }) wx.navigateTo({ url: '/pages/home/tab1/index' })

3
pages/index/index.json

@ -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"
} }
} }

8
pages/index/index.wxml

@ -2,10 +2,10 @@
<swiper current="{{pageIndex}}" duration="0" style="height:{{fragment}}rpx"> <swiper current="{{pageIndex}}" duration="0" style="height:{{fragment}}rpx">
<swiper-item catchtouchmove="stopTouchMove"> <swiper-item catchtouchmove="stopTouchMove">
<article id="{{TabList[0].value}}" />
<article id="{{TabList[0].value}}" city-name="{{cityName}}" bind:click="onAgentClick"/>
</swiper-item> </swiper-item>
<swiper-item catchtouchmove="stopTouchMove"> <swiper-item catchtouchmove="stopTouchMove">
<mall id="{{TabList[1].value}}" />
<mall id="{{TabList[1].value}}" city-name="{{cityName}}"/>
</swiper-item> </swiper-item>
<swiper-item catchtouchmove="stopTouchMove"> <swiper-item catchtouchmove="stopTouchMove">
<agent id="{{TabList[2].value}}" /> <agent id="{{TabList[2].value}}" />
@ -41,4 +41,6 @@
<text style="color:#FFEF93;padding:12rpx 24rpx;" catchtap="toRule">活动规则</text> <text style="color:#FFEF93;padding:12rpx 24rpx;" catchtap="toRule">活动规则</text>
</view> </view>
</view> </view>
</wux-popup>
</wux-popup>
<wux-dialog id="wux-dialog" />

130
pages/moment/fragment/index.js

@ -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 })
})
}
}
})

6
pages/moment/fragment/index.json

@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"wux-tabi": "/components/tabi/index"
}
}

31
pages/moment/fragment/index.wxml

@ -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>

34
pages/moment/fragment/index.wxss

@ -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;
}

118
pages/purchase/fragment/index.js

@ -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 })
}
}
})

11
pages/purchase/fragment/index.json

@ -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"
}
}

30
pages/purchase/fragment/index.wxml

@ -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>

1
pages/purchase/fragment/index.wxss

@ -0,0 +1 @@
/* pages/goods/index/index.wxss */

3
pages/purchase/index/index.wxml

@ -4,10 +4,9 @@
<view slot="content">采购管理</view> <view slot="content">采购管理</view>
</cu-custom> </cu-custom>
<view class="nav bg-white fixed" style="top:{{CustomBar}}px;">
<view class="bg-white" style="top:{{CustomBar}}px;height:90rpx">
<wux-tabi scroll="{{cateScroll}}" tab-data="{{tabiList}}" tab-index="{{pageIndex}}" bind:change="onCategoryChange"></wux-tabi> <wux-tabi scroll="{{cateScroll}}" tab-data="{{tabiList}}" tab-index="{{pageIndex}}" bind:change="onCategoryChange"></wux-tabi>
</view> </view>
<view style="height:90rpx;width:100%"></view>
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchGoodsList"> <refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchGoodsList">
<view wx:if="{{!orderList.length}}"> <view wx:if="{{!orderList.length}}">

Loading…
Cancel
Save