27 changed files with 180 additions and 770 deletions
Unified View
Diff Options
-
1app.json
-
2pages/api/request.js
-
17pages/enterprise/index/index.js
-
5pages/enterprise/index/index.json
-
16pages/enterprise/index/index.wxml
-
1pages/enterprise/index/index.wxss
-
28pages/formate.wxs
-
0pages/home/employee/index.js
-
0pages/home/employee/index.json
-
0pages/home/employee/index.wxml
-
0pages/home/employee/index.wxss
-
2pages/index/index.js
-
2pages/index/index.json
-
2pages/index/index.wxml
-
106pages/mall/index.wxs
-
126pages/mall/index/index.js
-
14pages/mall/index/index.json
-
40pages/mall/index/index.wxml
-
4pages/mall/index/index.wxss
-
136pages/mall/search-list/index.js
-
7pages/mall/search-list/index.json
-
41pages/mall/search-list/index.wxml
-
1pages/mall/search-list/index.wxss
-
272pages/message/index/index.js
-
10pages/message/index/index.json
-
107pages/message/index/index.wxml
-
10pages/message/index/index.wxss
@ -1,17 +0,0 @@ |
|||||
// pages/enterprise/index/index.js
|
|
||||
const app = getApp() |
|
||||
|
|
||||
Page({ |
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
userInfo: null, |
|
||||
}, |
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad: function (options) { |
|
||||
this.setData({ userInfo: app.accountInfo }) |
|
||||
} |
|
||||
}) |
|
||||
@ -1,5 +0,0 @@ |
|||||
{ |
|
||||
"usingComponents": { |
|
||||
"van-cell": "/components/cell/index" |
|
||||
} |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
<!--pages/enterprise/index/index.wxml--> |
|
||||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
|
||||
<view slot="content" style="color:black;font-size:36rpx">我的企业</view> |
|
||||
</cu-custom> |
|
||||
|
|
||||
<view class="bg-white" style="padding:60rpx 30rpx 40rpx 30rpx"> |
|
||||
<view class="flex flex-justify"> |
|
||||
<text style="color:black;font-size:40rpx;">{{userInfo.realName}}</text> |
|
||||
<van-tag plain round type="primary" wx:if="{{userInfo.position == 'ADMINISTRATOR'}}">管理员</van-tag> |
|
||||
</view> |
|
||||
<view style="color:black;font-size:30rpx;margin-top:16rpx">{{userInfo.enterpriseName}}</view> |
|
||||
</view> |
|
||||
<view style="height:24rpx"></view> |
|
||||
<van-cell title="企业员工" is-link url="/pages/enterprise/employee/index" /> |
|
||||
<!-- <van-cell title="企业设备" is-link url="/pages/enterprise/device/index" /> --> |
|
||||
<van-cell title="地址管理" is-link url="/pages/enterprise/address/index" /> |
|
||||
@ -1 +0,0 @@ |
|||||
/* pages/enterprise/index/index.wxss */ |
|
||||
@ -1,106 +0,0 @@ |
|||||
function formatePrice(price) { |
|
||||
return Number(price).toFixed(2) |
|
||||
} |
|
||||
|
|
||||
function formateNumber(price, fixed) { |
|
||||
if(price == null || price == undefined){ |
|
||||
price = 0 |
|
||||
} |
|
||||
return Number(price).toFixed(fixed) |
|
||||
} |
|
||||
|
|
||||
function isEmpty(val) { |
|
||||
return typeof val === 'undefined' || val === '' || val === null |
|
||||
} |
|
||||
|
|
||||
function formateDate(datetime) { |
|
||||
if (isEmpty(datetime)) { |
|
||||
return '' |
|
||||
} |
|
||||
var date = getDate(datetime.trim()) |
|
||||
var today = getDate() |
|
||||
var dayCode = 24 * 60 * 60 * 1000 |
|
||||
var week = '' |
|
||||
if (date.getTime() === today.getTime()) { |
|
||||
week = '(今天)' |
|
||||
} else if (date.getTime() === today.getTime() + dayCode) { |
|
||||
week = '(明天)' |
|
||||
} else if (date.getTime() === today.getTime() - dayCode) { |
|
||||
week = '(昨天)' |
|
||||
} else if (date.getTime() === today.getTime() + dayCode * 2) { |
|
||||
week = '(后天)' |
|
||||
} else { |
|
||||
week = ['(周日)', '(周一)', '(周二)', '(周三)', '(周四)', '(周五)', '(周六)'][date.getDay()] |
|
||||
} |
|
||||
if (isEmpty(week)) { |
|
||||
week = '' |
|
||||
} |
|
||||
return datetime + week |
|
||||
} |
|
||||
|
|
||||
function formateText(text, length) { |
|
||||
if (!text) { |
|
||||
return '' |
|
||||
} |
|
||||
if (text.length <= length) { |
|
||||
return text |
|
||||
} |
|
||||
return text.substring(0, length) + '...' |
|
||||
} |
|
||||
|
|
||||
function isVideoUrl(url){ |
|
||||
if(url && url.indexOf('.mp4') >= 0){ |
|
||||
return true |
|
||||
} |
|
||||
return false |
|
||||
} |
|
||||
|
|
||||
function minNumber(order, num){ |
|
||||
if(order && parseInt(order.minBuyNum) > 0){ |
|
||||
return Number(order.minBuyNum) |
|
||||
} |
|
||||
return num |
|
||||
} |
|
||||
|
|
||||
function getOrderInfo(item) { |
|
||||
var attributes = '' |
|
||||
for (var i = 0; i < item.attributesJSONArray.length; i++) { |
|
||||
var element = item.attributesJSONArray[i] |
|
||||
if(i == 0){ |
|
||||
attributes = element.arriName + ':' + element.arriVal |
|
||||
} else { |
|
||||
attributes += ';' + element.arriName + ':' + element.arriVal |
|
||||
} |
|
||||
} |
|
||||
return attributes |
|
||||
} |
|
||||
|
|
||||
function orderStatus(status){ |
|
||||
if(status == 1 || status == 2){ |
|
||||
return '取消订单' |
|
||||
} else if(status == 3){ |
|
||||
return '确认收货' |
|
||||
} |
|
||||
return '' |
|
||||
} |
|
||||
|
|
||||
function submitPrice(price){ |
|
||||
return Number(price) * 100 |
|
||||
} |
|
||||
|
|
||||
function formateAmount(amount) { |
|
||||
return Number(amount).toFixed(2) |
|
||||
} |
|
||||
|
|
||||
module.exports = { |
|
||||
formatePrice: formatePrice, |
|
||||
formateDate: formateDate, |
|
||||
formateText: formateText, |
|
||||
isVideoUrl: isVideoUrl, |
|
||||
minNumber: minNumber, |
|
||||
orderStatus: orderStatus, |
|
||||
getOrderInfo: getOrderInfo, |
|
||||
submitPrice: submitPrice, |
|
||||
formateAmount: formateAmount, |
|
||||
formateNumber: formateNumber |
|
||||
} |
|
||||
@ -1,126 +0,0 @@ |
|||||
// pages/process/supply/index.js
|
|
||||
// import { getCategoryList, getProductList } from "../../api/mall"
|
|
||||
const event = require('../../../utils/event') |
|
||||
const util = require('../../../utils/util') |
|
||||
const app = getApp() |
|
||||
|
|
||||
Component({ |
|
||||
options: { |
|
||||
addGlobalClass: true, |
|
||||
multipleSlots: true |
|
||||
}, |
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
height: app.globalData.safeFragmentHeight - 190, |
|
||||
CustomBar: app.globalData.CustomBar, |
|
||||
userInfo: null, |
|
||||
firstShow: false, |
|
||||
tabIndex: 0, |
|
||||
tabList: [], |
|
||||
loading: true, |
|
||||
requesting: false, |
|
||||
finished: false, |
|
||||
top: 0, |
|
||||
orderList: [], |
|
||||
form: { categoryId: '', pageNum: 1, pageSize: 10 } |
|
||||
}, |
|
||||
lifetimes: { |
|
||||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
||||
attached: function () { |
|
||||
event.on('EventMessage', this, this.onEvent) |
|
||||
}, |
|
||||
detached: function () { |
|
||||
event.remove('EventMessage', this) |
|
||||
} |
|
||||
}, |
|
||||
methods: { |
|
||||
onRestart: function () { |
|
||||
if (this.data.firstShow) { |
|
||||
return |
|
||||
} |
|
||||
this.setData({ height: app.globalData.safeFragmentHeight - 190, CustomBar: app.globalData.CustomBar, userInfo: app.accountInfo }) |
|
||||
this.fetchCategoryList() |
|
||||
this.fetchOrderList() |
|
||||
this.data.firstShow = true |
|
||||
}, |
|
||||
onEvent: function (message) { |
|
||||
if (message.what == 888) { |
|
||||
this.setData({ userInfo: app.accountInfo }) |
|
||||
} |
|
||||
}, |
|
||||
fetchCategoryList: function(){ |
|
||||
getCategoryList().then(result => { |
|
||||
this.setData({ tabList: [{id: '', name: '全部'}].concat(result.data) }) |
|
||||
}) |
|
||||
}, |
|
||||
onTabChange: function ({detail}) { |
|
||||
if (this.data.tabIndex == Number(detail.index)) { |
|
||||
return |
|
||||
} |
|
||||
this.setData({ tabIndex: detail.index}) |
|
||||
this.data.form.categoryId = this.data.tabList[this.data.tabIndex].id |
|
||||
this.onRefreshList() |
|
||||
}, |
|
||||
onRefreshList: function () { |
|
||||
this.setData({ |
|
||||
orderList: [], |
|
||||
['form.pageNum']: 1, |
|
||||
loading: true, |
|
||||
finished: false |
|
||||
}) |
|
||||
this.fetchOrderList() |
|
||||
}, |
|
||||
fetchOrderList: 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 = this.data.form.pageNum |
|
||||
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|
||||
if(this.data.form.pageNum == 1){ |
|
||||
this.setData({ |
|
||||
[nowList]: respList, |
|
||||
['form.pageNum']: (num + 1), |
|
||||
top: 0, |
|
||||
finished, |
|
||||
requesting: false, |
|
||||
loading: false |
|
||||
}) |
|
||||
} else { |
|
||||
this.setData({ |
|
||||
[nowList]: respList, |
|
||||
['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 }) |
|
||||
util.showToast(err) |
|
||||
}) |
|
||||
}, |
|
||||
lookItem: function (e) { |
|
||||
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
||||
wx.navigateTo({ url: '/pages/process/purchase-detail/index?id=' + item.id }) |
|
||||
}, |
|
||||
searchList: function(){ |
|
||||
wx.navigateTo({ url: '/pages/mall/search-list/index' }) |
|
||||
} |
|
||||
} |
|
||||
}) |
|
||||
@ -1,14 +0,0 @@ |
|||||
{ |
|
||||
"component": true, |
|
||||
"usingComponents": { |
|
||||
"van-search": "/components/search/index", |
|
||||
"refresh-view": "/components/refresher/index", |
|
||||
"van-tabs": "/components/tabs/index", |
|
||||
"van-tab": "/components/tab/index", |
|
||||
"van-divider": "/components/divider/index", |
|
||||
"van-loading": "/components/loading/index", |
|
||||
"skeleton": "/components/skeleton/index", |
|
||||
"skeleton-avatar": "/components/skeleton-avatar/index", |
|
||||
"skeleton-paragraph": "/components/skeleton-paragraph/index" |
|
||||
} |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
<!--pages/mall/index/index.wxml--> |
|
||||
<cu-custom bgColor="bg-white"> |
|
||||
<view slot="right" class="text-cut text-black text-xl margin-l" wx:if="{{userInfo.enterpriseName}}">{{userInfo.enterpriseName}}</view> |
|
||||
<view slot="content" style="color:black;font-size:36rpx" wx:else>原纸商场</view> |
|
||||
</cu-custom> |
|
||||
|
|
||||
<view class="bg-white" style="height:90rpx;" wx:if="{{tabList.length}}"> |
|
||||
<van-tabs sticky active="{{tabIndex}}" color="#008AFF" bind:change="onTabChange" line-height="2px" swipe-threshold="6"> |
|
||||
<van-tab wx:for="{{tabList}}" wx:key="index" title="{{item.name}}" title-style="color:{{tabIndex==index?'#008AFF':'#333333'}}"></van-tab> |
|
||||
</van-tabs> |
|
||||
</view> |
|
||||
<view wx:else class="bg-white" style="height:90rpx;padding: 10rpx 32rpx"> |
|
||||
<skeleton active> |
|
||||
<skeleton-avatar shape="rounded" size="tab" /> |
|
||||
</skeleton> |
|
||||
</view> |
|
||||
|
|
||||
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchOrderList"> |
|
||||
<van-search disabled shape="round" placeholder="请输入要搜索的商品" bindtap="searchList"/> |
|
||||
<view class="list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}"> |
|
||||
<view style="margin-bottom:24px" wx:if="{{loading}}"> |
|
||||
<van-loading type="spinner" size="32" /> |
|
||||
</view> |
|
||||
<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 class="bg-white" style="padding:0rpx 32rpx" wx:if="{{pageIndex>0}}"> |
|
||||
<view style="height:2rpx;background-color:#f3f3f3"></view> |
|
||||
</view> |
|
||||
<good-item dataList="{{pageItem}}"></good-item> |
|
||||
</view> |
|
||||
<!--加载更多的UI--> |
|
||||
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx"> |
|
||||
<van-loading type="spinner" size="16" wx:if="{{!finished}}" /> |
|
||||
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
|
||||
</van-divider> |
|
||||
</view> |
|
||||
</refresh-view> |
|
||||
@ -1,4 +0,0 @@ |
|||||
/* pages/mall/index/index.wxss */ |
|
||||
.margin-l{ |
|
||||
margin-left: 32rpx; |
|
||||
} |
|
||||
@ -1,136 +0,0 @@ |
|||||
// pages/mall/search-list/index.js
|
|
||||
const util = require('../../../utils/util') |
|
||||
const app = getApp() |
|
||||
|
|
||||
Page({ |
|
||||
/** |
|
||||
* 页面的初始数据 |
|
||||
*/ |
|
||||
data: { |
|
||||
height: app.globalData.fragmentHeight - 100, |
|
||||
loading: false, |
|
||||
finished: false, |
|
||||
requesting: false, |
|
||||
top: 0, |
|
||||
rearchStringList: [], |
|
||||
taskList: [], |
|
||||
form: { |
|
||||
name: '', |
|
||||
pageSize: 10, |
|
||||
pageNum: 1 |
|
||||
}, |
|
||||
focus: true |
|
||||
}, |
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad: function (options) { |
|
||||
this.setData({ height: app.globalData.fragmentHeight - 100, CustomBar: app.globalData.CustomBar }) |
|
||||
var that = this |
|
||||
wx.getStorage({ key: 'mall-search', success (res) { |
|
||||
that.setData({ rearchStringList: res.data.split(',') }) |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
onChange(e) { |
|
||||
this.setData({ ['form.name']: e.detail }) |
|
||||
}, |
|
||||
/** |
|
||||
* 生命周期函数--监听页面显示 |
|
||||
*/ |
|
||||
onSearch: function (e) { |
|
||||
if(util.isEmpty(this.data.form.name)){ |
|
||||
util.showToast('请输入要搜索的关键字') |
|
||||
return |
|
||||
} |
|
||||
this.setData({ taskList: [], ['form.pageNum']: 1, finished: false }) |
|
||||
this.fetchTaskList() |
|
||||
}, |
|
||||
fetchTaskList: function () { |
|
||||
if (this.data.requesting || this.data.finished) { |
|
||||
return |
|
||||
} |
|
||||
if (this.data.form.pageNum == 1 && this.data.taskList.length == 0) { |
|
||||
this.setData({ loading: true }) |
|
||||
} |
|
||||
this.data.requesting = true |
|
||||
// /product/list产品列表
|
|
||||
searchProductList(this.data.form).then(result => { |
|
||||
//成功回调
|
|
||||
this.data.requesting = false |
|
||||
if(this.data.form.pageNum == 1){ |
|
||||
this.setData({ focus: false, top: 0 }) |
|
||||
} else { |
|
||||
this.setData({ focus: false }) |
|
||||
} |
|
||||
if (result.data.records.length) { |
|
||||
var respList = result.data.records |
|
||||
let nowList = `taskList[${this.data.taskList.length}]` |
|
||||
var num = this.data.form.pageNum |
|
||||
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
|
||||
var strList = this.data.rearchStringList |
|
||||
if(!util.isEmpty(this.data.form.name) && strList.indexOf(this.data.form.name) < 0){ |
|
||||
strList.splice(0, 0, this.data.form.name) |
|
||||
} |
|
||||
this.setData({ |
|
||||
rearchStringList: strList, |
|
||||
[nowList]: respList, |
|
||||
['form.pageNum']: (num + 1), |
|
||||
finished, |
|
||||
loading: false |
|
||||
}) |
|
||||
} else { |
|
||||
var strList = this.data.rearchStringList |
|
||||
if(!util.isEmpty(this.data.form.name) && strList.indexOf(this.data.form.name) < 0){ |
|
||||
strList.splice(0, 0, this.data.form.name) |
|
||||
} |
|
||||
this.setData({ |
|
||||
rearchStringList: strList, |
|
||||
focus: false, |
|
||||
finished: true, |
|
||||
loading: false |
|
||||
}) |
|
||||
} |
|
||||
// wx.hideLoading()
|
|
||||
}).catch(err => { |
|
||||
//异常回调
|
|
||||
// wx.hideLoading()
|
|
||||
this.setData({ loading: false }) |
|
||||
this.data.requesting = false |
|
||||
var strList = this.data.rearchStringList |
|
||||
if(strList.indexOf(this.data.form.name) < 0){ |
|
||||
strList.splice(0, 0, this.data.form.name) |
|
||||
} |
|
||||
this.setData({ |
|
||||
rearchStringList: strList, |
|
||||
focus: false |
|
||||
}) |
|
||||
util.showToast(err) |
|
||||
}); |
|
||||
}, |
|
||||
clearHistory: function (e) { |
|
||||
var that = this |
|
||||
wx.removeStorage({ |
|
||||
key: 'mall-search', |
|
||||
success (res) { |
|
||||
that.setData({ |
|
||||
rearchStringList: [] |
|
||||
}) |
|
||||
} |
|
||||
}) |
|
||||
}, |
|
||||
tagClick: function(e){ |
|
||||
this.setData({ ['form.name']: this.data.rearchStringList[e.currentTarget.dataset.index] }) |
|
||||
this.onSearch(null) |
|
||||
}, |
|
||||
onUnload() { |
|
||||
if(this.data.rearchStringList.length){ |
|
||||
try { |
|
||||
wx.setStorageSync('mall-search', this.data.rearchStringList.toString()) |
|
||||
} catch (e) { |
|
||||
|
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
}) |
|
||||
@ -1,7 +0,0 @@ |
|||||
{ |
|
||||
"usingComponents": { |
|
||||
"van-search": "/components/search/index", |
|
||||
"van-divider": "/components/divider/index", |
|
||||
"van-loading": "/components/loading/index" |
|
||||
} |
|
||||
} |
|
||||
@ -1,41 +0,0 @@ |
|||||
<!--pages/mall/search-list/index.wxml--> |
|
||||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
|
||||
<view slot="content" style="color:black;font-size:18px">原纸商城</view> |
|
||||
</cu-custom> |
|
||||
|
|
||||
<van-search value="{{ form.name }}" shape="round" placeholder="请输入搜索关键词" use-action-slot bind:change="onChange"> |
|
||||
<view slot="action" bind:tap="onSearch" style="padding: 0rpx 8rpx">搜索</view> |
|
||||
</van-search> |
|
||||
|
|
||||
<view class="bg-white" wx:if="{{focus}}"> |
|
||||
<view class="cu-form-group" style="min-height:80rpx" wx:if="{{rearchStringList.length}}"> |
|
||||
<view class="action" style="color:black">搜索历史</view> |
|
||||
<text class="cuIcon-delete" style="font-size: 17px" bindtap="clearHistory"></text> |
|
||||
</view> |
|
||||
<view class="flex flex-wrap" style="padding: 0rpx 20rpx 30rpx 20rpx" wx:if="{{rearchStringList.length}}"> |
|
||||
<view class="padding-xs" wx:for-item="item" wx:for="{{rearchStringList}}" wx:key="index"> |
|
||||
<view class="cu-tag round" style="padding:18rpx 24rpx" data-index="{{index}}" bindtap="tagClick">{{item}}</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
<view class="flex flex-column flex-center" wx:elif="{{loading}}" style="height:{{height}}rpx"> |
|
||||
<view class="load-spinner text-gray" /> |
|
||||
<view class="text-empty" style="margin-top:48rpx">加载中...</view> |
|
||||
</view> |
|
||||
<view class="list-empty" wx:elif="{{!taskList.length}}" style="height:{{height}}rpx"> |
|
||||
<image class="img-empty" src="/assets/image/icon_empty.svg"></image> |
|
||||
<view class="text-empty">暂无数据</view> |
|
||||
</view> |
|
||||
<scroll-view scroll-y scroll-top="{{top}}" style="height:{{height}}rpx;" wx:else bindscrolltolower="fetchTaskList"> |
|
||||
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{taskList}}" wx:key="pageIndex"> |
|
||||
<view class="bg-white" style="padding:0rpx 32rpx" wx:if="{{pageIndex>0}}"> |
|
||||
<view style="height:2rpx;background-color:#f3f3f3"></view> |
|
||||
</view> |
|
||||
<page-list dataList="{{pageItem}}"></page-list> |
|
||||
</view> |
|
||||
<!--加载更多的UI--> |
|
||||
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx"> |
|
||||
<van-loading type="spinner" size="16" wx:if="{{!finished}}" /> |
|
||||
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
|
||||
</van-divider> |
|
||||
</scroll-view> |
|
||||
@ -1 +0,0 @@ |
|||||
/* pages/mall/search-list/index.wxss */ |
|
||||
@ -1,190 +1,126 @@ |
|||||
// pages/bidding/index/index.js
|
|
||||
|
// pages/process/supply/index.js
|
||||
|
// import { getCategoryList, getProductList } from "../../api/mall"
|
||||
|
const event = require('../../../utils/event') |
||||
const util = require('../../../utils/util') |
const util = require('../../../utils/util') |
||||
const event = require('../../../utils/event.js') |
|
||||
const app = getApp() |
const app = getApp() |
||||
const urlList = ['/message-center/message/get/message-list', '/message-center/message/get/notification-list'] |
|
||||
|
|
||||
Page({ |
|
||||
|
Component({ |
||||
|
options: { |
||||
|
addGlobalClass: true, |
||||
|
multipleSlots: true |
||||
|
}, |
||||
/** |
/** |
||||
* 页面的初始数据 |
* 页面的初始数据 |
||||
*/ |
*/ |
||||
data: { |
data: { |
||||
height: app.globalData.fragmentHeight, |
|
||||
|
height: app.globalData.safeFragmentHeight - 190, |
||||
|
CustomBar: app.globalData.CustomBar, |
||||
|
userInfo: null, |
||||
|
firstShow: false, |
||||
|
tabIndex: 0, |
||||
|
tabList: [], |
||||
loading: true, |
loading: true, |
||||
requesting: false, |
requesting: false, |
||||
finished: false, |
finished: false, |
||||
tabList: [ |
|
||||
{id: 0, name: '订单', badge: 12}, |
|
||||
{id: 1, name: '系统', badge: 0} |
|
||||
], |
|
||||
tabIndex: 0, |
|
||||
top: 0, |
top: 0, |
||||
messageList: [], |
|
||||
form: { |
|
||||
pageNum: 1 |
|
||||
} |
|
||||
}, |
|
||||
/** |
|
||||
* 生命周期函数--监听页面加载 |
|
||||
*/ |
|
||||
onLoad: function (options) { |
|
||||
this.setData({ |
|
||||
height: app.globalData.fragmentHeight - 90, |
|
||||
CustomBar: app.globalData.CustomBar |
|
||||
}) |
|
||||
event.on('EventMessage', this, this.onEvent) |
|
||||
// this.fetchMessageNumber()
|
|
||||
// this.fetchMessageList()
|
|
||||
|
orderList: [], |
||||
|
form: { categoryId: '', pageNum: 1, pageSize: 10 } |
||||
}, |
}, |
||||
onEvent: function (message) { |
|
||||
if (message.what == 320) { |
|
||||
this.onRefreshList() |
|
||||
|
lifetimes: { |
||||
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||||
|
attached: function () { |
||||
|
event.on('EventMessage', this, this.onEvent) |
||||
|
}, |
||||
|
detached: function () { |
||||
|
event.remove('EventMessage', this) |
||||
} |
} |
||||
}, |
}, |
||||
onRefreshList: function () { |
|
||||
this.setData({ |
|
||||
messageList: [], |
|
||||
tabIndex: this.data.tabIndex, |
|
||||
['form.pageNum']: 1, |
|
||||
loading: true, |
|
||||
finished: false |
|
||||
}) |
|
||||
this.fetchMessageNumber() |
|
||||
this.fetchMessageList() |
|
||||
}, |
|
||||
fetchMessageNumber: function () { |
|
||||
// request.get('/message-center/message/get/unread-number').then(result => {
|
|
||||
// this.setData({ ['tabList[0].badge']: result.data.messageNumber, ['tabList[1].badge']: result.data.notificationNumber })
|
|
||||
// })
|
|
||||
}, |
|
||||
fetchMessageList: function () { |
|
||||
if (this.data.requesting || this.data.finished) { |
|
||||
return |
|
||||
} |
|
||||
if (this.data.loading) { |
|
||||
this.data.requesting = true |
|
||||
} else { |
|
||||
this.setData({ requesting: true }) |
|
||||
} |
|
||||
// /product/cheapList特价产品列表
|
|
||||
request.get(urlList[this.data.tabIndex], this.data.form).then(result => { |
|
||||
//成功回调
|
|
||||
if (result.data.records.length) { |
|
||||
var respList = result.data.records |
|
||||
let nowList = `messageList[${this.data.messageList.length}]` |
|
||||
var num = this.data.form.pageNum |
|
||||
var finished = this.data.form.pageNum >= 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 |
|
||||
}) |
|
||||
|
methods: { |
||||
|
onRestart: function () { |
||||
|
if (this.data.firstShow) { |
||||
|
return |
||||
} |
} |
||||
}).catch(err => { |
|
||||
//异常回调
|
|
||||
|
this.setData({ height: app.globalData.safeFragmentHeight - 190, CustomBar: app.globalData.CustomBar, userInfo: app.accountInfo }) |
||||
|
this.fetchCategoryList() |
||||
|
this.fetchOrderList() |
||||
|
this.data.firstShow = true |
||||
|
}, |
||||
|
onEvent: function (message) { |
||||
|
if (message.what == 888) { |
||||
|
this.setData({ userInfo: app.accountInfo }) |
||||
|
} |
||||
|
}, |
||||
|
fetchCategoryList: function(){ |
||||
|
getCategoryList().then(result => { |
||||
|
this.setData({ tabList: [{id: '', name: '全部'}].concat(result.data) }) |
||||
|
}) |
||||
|
}, |
||||
|
onTabChange: function ({detail}) { |
||||
|
if (this.data.tabIndex == Number(detail.index)) { |
||||
|
return |
||||
|
} |
||||
|
this.setData({ tabIndex: detail.index}) |
||||
|
this.data.form.categoryId = this.data.tabList[this.data.tabIndex].id |
||||
|
this.onRefreshList() |
||||
|
}, |
||||
|
onRefreshList: function () { |
||||
this.setData({ |
this.setData({ |
||||
requesting: false, |
|
||||
loading: false |
|
||||
|
orderList: [], |
||||
|
['form.pageNum']: 1, |
||||
|
loading: true, |
||||
|
finished: false |
||||
}) |
}) |
||||
util.showToast(err) |
|
||||
}) |
|
||||
}, |
|
||||
lookItem: function (e) { |
|
||||
var item = this.data.messageList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
|
||||
if(item.status == 0){ |
|
||||
request.post('/message-center/message/read', { idList: [item.id] }).then(result => { |
|
||||
|
this.fetchOrderList() |
||||
|
}, |
||||
|
fetchOrderList: 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 => { |
||||
//成功回调
|
//成功回调
|
||||
this.setData({ |
|
||||
['tabList[' + this.data.tabIndex + '].badge']: this.data.tabList[this.data.tabIndex].badge - 1, |
|
||||
['messageList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].status']: 1 |
|
||||
}) |
|
||||
this.redirectInfo(item.redirectInfo) |
|
||||
}) |
|
||||
} else { |
|
||||
this.redirectInfo(item.redirectInfo) |
|
||||
} |
|
||||
}, |
|
||||
redirectInfo: function(redirect){ |
|
||||
if(!redirect){ |
|
||||
return |
|
||||
} |
|
||||
if(redirect.targetView == 'biddingDetail'){ |
|
||||
// 买家竞价的详情页
|
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/bidding/detail/index?id=' + redirect.params.id |
|
||||
}) |
|
||||
} else if(redirect.targetView == 'buyerOrderDetail'){ |
|
||||
// 买家订单的详情页
|
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/morder/detail/index?orderId=' + redirect.params.id |
|
||||
}) |
|
||||
} else if(redirect.targetView == 'sellerOrderDetail'){ |
|
||||
// 卖家订单的详情页 sellerOrderDetail
|
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/morder/detail/index?type=1&orderId=' + redirect.params.id |
|
||||
}) |
|
||||
} else if(redirect.targetView == 'storeIndex'){ |
|
||||
// 店铺首页 storeIndex
|
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/shop/detail/index?storeId=' + redirect.params.id |
|
||||
}) |
|
||||
} else if(redirect.targetView == 'personalBillDetail'){ |
|
||||
// 账单详情页 personalBillDetail
|
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/bank/bill-detail/index?id=' + redirect.params.id |
|
||||
}) |
|
||||
} else if(redirect.targetView == 'member'){ |
|
||||
// 会员页 member
|
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/ztbvip/index' |
|
||||
}) |
|
||||
} else { |
|
||||
wx.navigateTo({ |
|
||||
url: '/pages/message/detail/index?id=' + redirect.params.id |
|
||||
|
if (result.data.records.length) { |
||||
|
var respList = result.data.records |
||||
|
let nowList = `orderList[${this.data.orderList.length}]` |
||||
|
var num = this.data.form.pageNum |
||||
|
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total |
||||
|
if(this.data.form.pageNum == 1){ |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
['form.pageNum']: (num + 1), |
||||
|
top: 0, |
||||
|
finished, |
||||
|
requesting: false, |
||||
|
loading: false |
||||
|
}) |
||||
|
} else { |
||||
|
this.setData({ |
||||
|
[nowList]: respList, |
||||
|
['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 }) |
||||
|
util.showToast(err) |
||||
}) |
}) |
||||
|
}, |
||||
|
lookItem: function (e) { |
||||
|
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index] |
||||
|
wx.navigateTo({ url: '/pages/process/purchase-detail/index?id=' + item.id }) |
||||
|
}, |
||||
|
searchList: function(){ |
||||
|
wx.navigateTo({ url: '/pages/mall/search-list/index' }) |
||||
} |
} |
||||
}, |
|
||||
onTabChange: function (e) { |
|
||||
if (this.data.tabIndex == Number(e.detail.index)) { |
|
||||
return |
|
||||
} |
|
||||
this.data.tabIndex = Number(e.detail.index) |
|
||||
this.onRefreshList() |
|
||||
}, |
|
||||
readMessage: function(){ |
|
||||
wx.showLoading({ title: '加载中', mask: true }) |
|
||||
request.post('/message-center/message/read').then(result => { |
|
||||
//成功回调
|
|
||||
this.setData({ ['tabList[0].badge']: 0, ['tabList[1].badge']: 0 }) |
|
||||
wx.hideLoading() |
|
||||
}).catch(err => { |
|
||||
//异常回调
|
|
||||
wx.hideLoading() |
|
||||
util.showToast(err) |
|
||||
}) |
|
||||
}, |
|
||||
onUnload: function(){ |
|
||||
event.remove('EventMessage', this) |
|
||||
} |
} |
||||
}) |
}) |
||||
@ -1,12 +1,14 @@ |
|||||
{ |
{ |
||||
|
"component": true, |
||||
"usingComponents": { |
"usingComponents": { |
||||
|
"van-search": "/components/search/index", |
||||
"refresh-view": "/components/refresher/index", |
"refresh-view": "/components/refresher/index", |
||||
"van-tabs": "/components/tabs/index", |
"van-tabs": "/components/tabs/index", |
||||
"van-tab": "/components/tab/index", |
"van-tab": "/components/tab/index", |
||||
"van-button": "/components/button/index", |
|
||||
"van-cell": "/components/cell/index", |
|
||||
"van-info": "/components/info/index", |
|
||||
"van-divider": "/components/divider/index", |
"van-divider": "/components/divider/index", |
||||
"van-loading": "/components/loading/index" |
|
||||
|
"van-loading": "/components/loading/index", |
||||
|
"skeleton": "/components/skeleton/index", |
||||
|
"skeleton-avatar": "/components/skeleton-avatar/index", |
||||
|
"skeleton-paragraph": "/components/skeleton-paragraph/index" |
||||
} |
} |
||||
} |
} |
||||
@ -1,77 +1,40 @@ |
|||||
<!--pages/message/index/index.wxml--> |
|
||||
<cu-custom bgColor="bg-white" isBack="{{true}}"> |
|
||||
<view slot="content" style="color:black;font-size:18px">消息</view> |
|
||||
|
<!--pages/mall/index/index.wxml--> |
||||
|
<cu-custom bgColor="bg-white"> |
||||
|
<view slot="right" class="text-cut text-black text-xl margin-l" wx:if="{{userInfo.enterpriseName}}">{{userInfo.enterpriseName}}</view> |
||||
|
<view slot="content" style="color:black;font-size:36rpx" wx:else>原纸商场</view> |
||||
</cu-custom> |
</cu-custom> |
||||
|
|
||||
<view class="nav bg-white fixed flex flex-justify" style="top:{{CustomBar}}px;padding-right:24rpx"> |
|
||||
<view style="width:160px"> |
|
||||
<van-tabs active="{{ tabIndex }}" color="#008AFF" bind:change="onTabChange" line-height="2px"> |
|
||||
<van-tab wx:for="{{tabList}}" wx:key="index" title="{{item.name}}" info="{{item.badge || ''}}" |
|
||||
title-style="color:{{tabIndex==index?'#008AFF':'#333333'}}"></van-tab> |
|
||||
</van-tabs> |
|
||||
</view> |
|
||||
<van-button type="info" plain size="small" bind:click="readMessage">全部标识已读</van-button> |
|
||||
|
<view class="bg-white" style="height:90rpx;" wx:if="{{tabList.length}}"> |
||||
|
<van-tabs sticky active="{{tabIndex}}" color="#008AFF" bind:change="onTabChange" line-height="2px" swipe-threshold="6"> |
||||
|
<van-tab wx:for="{{tabList}}" wx:key="index" title="{{item.name}}" title-style="color:{{tabIndex==index?'#008AFF':'#333333'}}"></van-tab> |
||||
|
</van-tabs> |
||||
|
</view> |
||||
|
<view wx:else class="bg-white" style="height:90rpx;padding: 10rpx 32rpx"> |
||||
|
<skeleton active> |
||||
|
<skeleton-avatar shape="rounded" size="tab" /> |
||||
|
</skeleton> |
||||
</view> |
</view> |
||||
<view style="height:90rpx;width:100%"></view> |
|
||||
|
|
||||
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchMessageList"> |
|
||||
<view wx:if="{{!messageList.length}}"> |
|
||||
<view class="list-empty" style="height:{{height}}rpx"> |
|
||||
<view style="margin-bottom:24px" wx:if="{{loading}}"> |
|
||||
<van-loading type="spinner" size="32" /> |
|
||||
</view> |
|
||||
<image class="img-empty" src="/assets/image/list_empty.png" wx:else></image> |
|
||||
<view class="text-empty">{{loading? '正在加载' : '暂无数据'}}</view> |
|
||||
</view> |
|
||||
</view> |
|
||||
<view wx:else> |
|
||||
<view wx:for-item="pageItem" wx:for-index="pageIndex" wx:for="{{messageList}}" wx:key="pageIndex"> |
|
||||
<van-cell clickable wx:for="{{pageItem}}" wx:key="index" data-page="{{pageIndex}}" data-index="{{index}}" bindtap="lookItem"> |
|
||||
<view slot="title" style="position: relative"> |
|
||||
<view class="flex flex-justify"> |
|
||||
<view class="text-sg text-bold">[{{item.categoryName}}]</view> |
|
||||
<view class="text-sm text-gray">{{util.formateDate(item.createTime)}}</view> |
|
||||
</view> |
|
||||
<view class="text-df" style="margin-top:18rpx">{{item.content}}</view> |
|
||||
<van-info dot custom-class="van-icon__info" wx:if="{{item.status == 0}}" /> |
|
||||
</view> |
|
||||
</van-cell> |
|
||||
</view> |
|
||||
<!--加载更多的UI--> |
|
||||
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}"> |
|
||||
<van-loading type="spinner" size="16" wx:if="{{!finished}}" /> |
|
||||
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
|
||||
</van-divider> |
|
||||
</view> |
|
||||
|
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchOrderList"> |
||||
|
<van-search disabled shape="round" placeholder="请输入要搜索的商品" bindtap="searchList"/> |
||||
|
<view class="list-empty" style="height:{{height}}rpx" wx:if="{{!orderList.length}}"> |
||||
|
<view style="margin-bottom:24px" wx:if="{{loading}}"> |
||||
|
<van-loading type="spinner" size="32" /> |
||||
|
</view> |
||||
|
<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 class="bg-white" style="padding:0rpx 32rpx" wx:if="{{pageIndex>0}}"> |
||||
|
<view style="height:2rpx;background-color:#f3f3f3"></view> |
||||
|
</view> |
||||
|
<good-item dataList="{{pageItem}}"></good-item> |
||||
|
</view> |
||||
|
<!--加载更多的UI--> |
||||
|
<van-divider content-position="center" wx:if="{{ form.pageNum > 1}}" custom-style="padding:0rpx 120rpx"> |
||||
|
<van-loading type="spinner" size="16" wx:if="{{!finished}}" /> |
||||
|
<text class="text-sm" style="margin-left:8rpx">{{finished?'到底啦~':'加载中...'}}</text> |
||||
|
</van-divider> |
||||
|
</view> |
||||
</refresh-view> |
</refresh-view> |
||||
|
|
||||
<wxs module="util"> |
|
||||
function isEmpty(val) { |
|
||||
return typeof val === 'undefined' || val === '' || val === null |
|
||||
} |
|
||||
function formateDate(datetime) { |
|
||||
if (isEmpty(datetime)) { |
|
||||
return '' |
|
||||
} |
|
||||
var dayCode = 24 * 60 * 60 * 1000 |
|
||||
datetime = datetime.replace(getRegExp('/\s/g', 'g'), '') |
|
||||
var date = getDate(datetime.trim()) |
|
||||
var today = getDate() |
|
||||
var yestoday = getDate(getDate().getTime() - dayCode) |
|
||||
var week = '' |
|
||||
if (date.getFullYear() === today.getFullYear() && date.getMonth() === today.getMonth() && date.getDate() === |
|
||||
today.getDate()) { |
|
||||
week = '今天 ' + datetime.substring(10) |
|
||||
} else if (date.getFullYear() === yestoday.getFullYear() && date.getMonth() === yestoday.getMonth() && date.getDate() |
|
||||
=== yestoday.getDate()) { |
|
||||
week = '昨天 ' + datetime.substring(10) |
|
||||
} |
|
||||
if (isEmpty(week)) { |
|
||||
return datetime |
|
||||
} |
|
||||
return week |
|
||||
} |
|
||||
module.exports = { |
|
||||
formateDate: formateDate |
|
||||
} |
|
||||
</wxs> |
|
||||
@ -1,8 +1,4 @@ |
|||||
/* pages/message/index/index.wxss */ |
|
||||
.tab__badge { |
|
||||
width: 100rpx; |
|
||||
height: 80rpx; |
|
||||
line-height: 80rpx; |
|
||||
text-align: center; |
|
||||
font-size: 30rpx; |
|
||||
|
/* pages/mall/index/index.wxss */ |
||||
|
.margin-l{ |
||||
|
margin-left: 32rpx; |
||||
} |
} |
||||
Write
Preview
Loading…
Cancel
Save