Browse Source

no message

featrue/v.4.0
xpz2018 5 years ago
parent
commit
52862a4970
23 changed files with 323 additions and 710 deletions
  1. 58
      app.js
  2. 2
      app.json
  3. 47
      colorui/components/cu-custom.js
  4. 8
      colorui/components/cu-custom.wxml
  5. 7
      pages/article/article-item/index.js
  6. 4
      pages/article/factory/index.js
  7. 146
      pages/article/hot-index/index.js
  8. 26
      pages/article/index/index.js
  9. 32
      pages/article/point-index/index.js
  10. 24
      pages/article/point-index/index.wxml
  11. 86
      pages/article/price-index/index.js
  12. 140
      pages/article/queue-index/index.js
  13. 41
      pages/home/index/index.js
  14. 58
      pages/home/index/index.wxml
  15. 1
      pages/home/qrcode/index.js
  16. 115
      pages/index/index.js
  17. 89
      pages/login/index.js
  18. 6
      pages/login/index.wxml
  19. 70
      pages/mall/index/index.js
  20. 24
      pages/mall/index/index.wxml
  21. 10
      pages/ztbvip/index.js
  22. 2
      utils/request.js
  23. 37
      utils/util.js

58
app.js

@ -1,5 +1,5 @@
//app.js
App({
App({
//----------------------------------------------globalData--------------------------------------
release: 0,
httpUrl: 'https://api.qniao.cn',
@ -8,7 +8,7 @@ App({
version: 152,
xAppId: '470236309865238528',
globalData: {
userInfo: {},
userInfo: null,
openId: null,
token: null,
isIPhoneX: false,
@ -18,49 +18,11 @@ App({
inited: false,
//-----------------------------------------onLaunch---------------------------------------------
onLaunch: function () {
if (this.release) {
this.httpUrl = 'https://api.qniao.cn'
} else {
this.httpUrl = 'http://47.113.118.47:9000'
// this.httpUrl = 'https://api-test.qniao.cn'
}
},
// 获取高度
onShow: function(){
wx.getSystemInfo({
success: e => {
this.globalData.isIPhoneX = this.checkIPhoneX(e)
this.globalData.isIos = this.checkIos(e)
this.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
this.globalData.Custom = custom
// 顶部操作栏高度
this.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (this.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let statusBarHeight = this.globalData.CustomBar * (750 / e.windowWidth)
// 状态栏高度
this.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
this.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
this.globalData.fragmentHeight = windowHeight - statusBarHeight
this.globalData.windowWidth = e.windowWidth
}
})
},
//-----------------------------------------checkIPhoneX---------------------------------------------
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
if (e.system.startsWith('iOS')) {
return true
}
return false
},
checkIPhoneX: function (e) {
var t = e.model,
o = e.platform;
return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && 'ios' === o
}
})
if (this.release) {
this.httpUrl = 'https://api.qniao.cn'
} else {
this.httpUrl = 'http://47.113.118.47:9000'
// this.httpUrl = 'https://api-test.qniao.cn'
}
}
})

2
app.json

@ -1,8 +1,8 @@
{
"pages": [
"pages/index/index",
"pages/login/index",
"pages/paper/index",
"pages/index/index",
"pages/home/about/index",
"pages/home/service/index",
"pages/home/mobile/index",

47
colorui/components/cu-custom.js

@ -1,3 +1,4 @@
const event = require('../../utils/event')
const app = getApp()
Component({
@ -15,7 +16,7 @@ Component({
bgColor: {
type: String,
default: ''
},
},
isCustom: {
type: [Boolean, String],
default: false
@ -24,6 +25,10 @@ Component({
type: [Boolean, String],
default: false
},
shadow: {
type: Boolean,
default: false
},
intercept: {
type: Boolean,
default: false
@ -44,30 +49,44 @@ Component({
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({
StatusBar: app.globalData.StatusBar || 40,
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60),
Custom: app.globalData.Custom
})
if(app.globalData.Custom){
this.setData({
StatusBar: app.globalData.StatusBar || 40,
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80),
Custom: app.globalData.Custom
})
} else {
event.on('InitMessage', this, this.onEvent)
}
},
detached: function(){
if(!app.globalData.Custom){
event.remove('InitMessage', this)
}
}
},
/**
* 组件的方法列表
*/
methods: {
backPage() {
if(this.data.intercept){
backspace() {
if (this.data.intercept) {
this.triggerEvent('customevent', null)
return
}
if(getCurrentPages().length == 1){
this.toHome()
} else {
wx.navigateBack()
wx.navigateBack()
},
onEvent: function(message){
if (message.what == 8) {
this.setData({
StatusBar: app.globalData.StatusBar || 40,
CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80),
Custom: app.globalData.Custom
})
}
},
toHome(){
if(app.globalData.userInfo.userId){
toHome() {
if (app.globalData.userInfo.userId) {
wx.redirectTo({ url: '/pages/index/index' })
} else {
wx.reLaunch({ url: '/pages/login/index' })

8
colorui/components/cu-custom.wxml

@ -1,11 +1,11 @@
<view class="cu-custom" style="height:{{CustomBar}}px">
<view class="cu-bar fixed {{bgColor}}" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}rpx">
<view class="action" bindtap="backPage" wx:if="{{isBack}}">
<view class="cu-custom" style="height:{{CustomBar}}px;z-index: 99;">
<view class="cu-bar fixed {{bgColor}}" style="height:{{CustomBar}}px;padding-top:{{StatusBar}}rpx;{{shadow?'box-shadow: none': ''}}">
<view class="action" bindtap="backspace" wx:if="{{isBack}}">
<text class="weui_goback"></text>
<slot name="backText"></slot>
</view>
<view class="action border-custom" wx:if="{{isCustom}}" style="width:{{Custom.width}}px;height:{{Custom.height}}px;margin-left:calc(750rpx - {{Custom.right}}px)">
<text class="cuIcon-back" bindtap="backPage"></text>
<text class="cuIcon-back" bindtap="backspace"></text>
<text class="cuIcon-homefill" bindtap="toHome"></text>
</view>
<view class="content" style="top:{{StatusBar}}rpx;color:black;font-size:36rpx">

7
pages/article/article-item/index.js

@ -1,6 +1,7 @@
// pages/stock/index.js
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
const app = getApp()
Component({
options: {
@ -19,9 +20,13 @@ Component({
wx.navigateTo({ url: '/pages/agent/factory/index?tabIndex=1&id=' + this.data.item.millPaperId })
},
lookItem: function(e){
wx.navigateTo({ url: '/pages/article/detail/index?id=' + this.data.item.id })
util.navigateTo('/pages/article/detail/index?id=' + this.data.item.id)
},
likeItem: function(e){
if(!app.globalData.userInfo){
wx.navigateTo({ url: '/pages/login/index' })
return
}
if(this.data.item.isLiked){
util.showToast('请勿重复点赞')
return

4
pages/article/factory/index.js

@ -24,7 +24,7 @@ Page({
this.data.type = Number(options.type)
}
wx.showLoading({ title: '加载中', mask: true })
if(this.data.type == 0){
if(this.data.type == 0 && app.globalData.userInfo){
this.data.recommendedString = storage.get('recommended' + app.globalData.userInfo.userId)
if(!util.isEmpty(this.data.recommendedString)){
this.data.recommendedList = JSON.parse(this.data.recommendedString)
@ -119,7 +119,7 @@ Page({
if(fList.length <= 4){
return
}
if(fString != this.data.recommendedString){
if(fString != this.data.recommendedString && app.globalData.userInfo){
storage.put('recommended' + app.globalData.userInfo.userId, fString)
event.emit('EventMessage', { what: 505, desc: 'RecommendedChange' })
}

146
pages/article/hot-index/index.js

@ -2,12 +2,8 @@
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
const storage = require('../../../utils/storage')
const math = require('../../../utils/math')
const event = require('../../../utils/event.js')
var wxCharts = require('../../../utils/wxcharts.js')
const app = getApp()
var lineChart = null
const colors = ['#FF4229', '#FFAD2A', '#297BFF', '#29FF46', '#AD29FF']
Component({
options: {
@ -37,7 +33,6 @@ Component({
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 190 })
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
@ -47,8 +42,7 @@ Component({
methods: {
onRestart: function () {
if (!this.data.firstShow) {
// this.fetchChartList()
this.setData({ height: app.globalData.safeFragmentHeight - 190 })
this.onRefreshList()
}
if(!this.data.noticeList.length && !this.data.status){
@ -57,22 +51,19 @@ Component({
this.data.firstShow = true
},
onEvent: function (message) {
if (message.what == 502) {
// this.fetchChartList()
} else if (message.what == 505) {
// 纸厂排队的纸厂选择
this.fetchFactoryList()
} else if (message.what == 570 || message.what == 571 || message.what == 572 || message.what == 573) {
if (message.what == 570 || message.what == 571 || message.what == 572 || message.what == 573) {
// 帖子发布刷新
this.onRefreshList()
}
},
//***********************************参与纸厂讨论*****************************************//
fetchFactoryList: function(){
var recommendedString = storage.get('recommended' + app.globalData.userInfo.userId)
if(!util.isEmpty(recommendedString)){
this.setData({ factoryList: JSON.parse(recommendedString) })
return
if(app.globalData.userInfo){
var recommendedString = storage.get('recommended' + app.globalData.userInfo.userId)
if(!util.isEmpty(recommendedString)){
this.setData({ factoryList: JSON.parse(recommendedString) })
return
}
}
// /recycle-service/get/paper-mill-list
request.get('/recycle-service/get/all-paper-mill').then(result => {
@ -90,108 +81,6 @@ Component({
toPaperList: function(){
wx.navigateTo({ url: '/pages/moment/paper/index' })
},
//***********************************fetchChartList*****************************************//
// fetchChartList: function(){
// var cateIds = storage.get('cateIdList' + app.globalData.userInfo.userId)
// if(!util.isEmpty(cateIds)){
// this.data.idList = cateIds
// }
// request.get('/information-center/getPaperCategoryPrice', {idList: this.data.idList}).then(result => {
// //成功回调
// if(result.data.length <= 0){
// return
// }
// var respList = result.data
// var categoriesList = []
// var serieList = []
// var min = Number.MAX_VALUE
// var max = 0
// for (let index = 0; index < respList.length; index++) {
// const element = respList[index]
// var dataList = []
// if(index == 0){
// element.list.forEach(item => {
// categoriesList.push(item.data.substring(5))
// var price = math.times(item.unitPrice, 1000)
// if(min > price){
// min = price
// }
// if(max < price){
// max = price
// }
// dataList.push(price)
// })
// } else {
// element.list.forEach(item => {
// var price = math.times(item.unitPrice, 1000)
// if(min > price){
// min = price
// }
// dataList.push(price)
// })
// }
// var series = {
// name: element.list[0].name,
// data: dataList,
// format: function (val, name) {
// return val + '元/吨'
// },
// color: colors[index]
// }
// serieList.push(series)
// }
// this.setData({ chartList: { categories: categoriesList, serieList: serieList } })
// // if(min < 50){
// // min = 50
// // }
// this.initChart(min - 50, max + 50)
// })
// },
// touchHandler: function (e) {
// if(lineChart){
// lineChart.scrollStart(e)
// }
// },
// moveHandler: function (e) {
// if(lineChart){
// lineChart.scroll(e)
// }
// },
// touchEndHandler: function (e) {
// if(lineChart){
// lineChart.scrollEnd(e)
// lineChart.showToolTip(e, {
// format: function (item, category) {
// return category + ' ' + item.name + ':' + item.data
// }
// })
// }
// },
// initChart: function (min, max) {
// lineChart = new wxCharts({
// canvasId: 'lineChart',
// type: 'line',
// categories: this.data.chartList.categories,
// animation: false,
// title: { name: '纸品单价 (元/吨)' },
// series: this.data.chartList.serieList,
// xAxis: { disableGrid: false },
// yAxis: {
// // title: '纸品单价 (元/吨)',
// format: function (val) {
// return val
// },
// min,
// max
// },
// width: 350,
// height: 200,
// dataLabel: false,
// dataPointShape: 'circle',
// enableScroll: true,
// extra: { lineStyle: 'curve' }
// }, this)
// },
//*************************************************momentList************************************************//
onRefreshList: function () {
this.setData({
@ -230,25 +119,6 @@ Component({
this.setData({ requesting: false })
})
},
lookItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id })
},
likeItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
if(item.isLiked){
util.showToast('请勿重复点赞')
return
}
request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => {
this.setData({
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity,
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1
})
}).catch(error => {
util.showToast(error)
})
},
//*************************************************noticeList************************************************//
fetchNoticeList: function(){
if (this.data.loopRequesting) {

26
pages/article/index/index.js

@ -16,13 +16,6 @@ Component({
tabList: [ '热门', '纸品价格', '车辆排队', '纸厂扣点' ],
tabIndex: 0
},
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 190 })
}
},
methods: {
onRestart: function () {
var fragment = this.selectComponent('#fragment' + this.data.tabIndex)
@ -30,16 +23,15 @@ Component({
fragment.onRestart()
}
if (!this.data.firstShow) {
this.setData({tabList: this.data.tabList})
// /article-category/get/article-category-list 查询所有文章分类
request.get('/information-center/article-category/get/article-category-list').then(result => {
for (let index = 0; index < result.data.length; index++) {
this.data.tabList[index + 1] = result.data[index].name
}
// this.setData({tabList: this.data.tabList})
}).catch(err => {
//异常回调
})
this.setData({ height: app.globalData.safeFragmentHeight - 190, tabList: this.data.tabList})
// request.get('/information-center/article-category/get/article-category-list').then(result => {
// for (let index = 0; index < result.data.length; index++) {
// this.data.tabList[index + 1] = result.data[index].name
// }
// // this.setData({tabList: this.data.tabList})
// }).catch(err => {
// //异常回调
// })
}
this.data.firstShow = true
},

32
pages/article/point-index/index.js

@ -1,7 +1,6 @@
// pages/stock/index.js
const request = require('../../../utils/request') //导入模块
const event = require('../../../utils/event.js')
const util = require('../../../utils/util')
const app = getApp()
Component({
@ -14,7 +13,7 @@ Component({
*/
data: {
height: app.globalData.safeFragmentHeight - 190,
vip: false,
userInfo: null,
momentList: [],
requesting: false,
finished: false,
@ -26,7 +25,6 @@ Component({
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 190, vip: app.globalData.userInfo.isVIP })
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
@ -35,7 +33,10 @@ Component({
},
methods: {
onRestart: function () {
if (!this.data.firstShow || this.data.momentList.length <= 0) {
if (!this.data.firstShow) {
this.setData({ height: app.globalData.safeFragmentHeight - 190, userInfo: app.globalData.userInfo })
}
if (this.data.momentList.length <= 0) {
this.onRefreshList()
}
this.data.firstShow = true
@ -46,7 +47,7 @@ Component({
this.onRefreshList()
} else if(message.what == 200){
// Vip的变化
this.setData({ vip: app.globalData.userInfo.isVIP })
this.setData({ userInfo: app.globalData.userInfo })
this.onRefreshList()
}
},
@ -85,26 +86,11 @@ Component({
this.setData({ requesting: false })
})
},
lookItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id })
},
likeItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
if(item.isLiked){
util.showToast('请勿重复点赞')
toVip: function(){
if(!app.globalData.userInfo){
wx.navigateTo({ url: '/pages/login/index' })
return
}
request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => {
this.setData({
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity,
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1
})
}).catch(error => {
util.showToast(error)
})
},
toVip: function(){
wx.navigateTo({ url: '/pages/ztbvip/index' })
}
}

24
pages/article/point-index/index.wxml

@ -2,18 +2,7 @@
<!-- <scroll-view scroll-y style="height: {{height}}rpx;" lower-threshold="200" bindscrolltolower="fetchMomentList"> -->
<refresh-view bind:refresh="onRefreshList" height="{{height}}" triggered="{{requesting}}" scrollTop="{{top}}" bind:scrolltolower="fetchMomentList">
<!----------------------------------------------------帖子列表---------------------------------------------------------------->
<view class="bg-white list-empty" style="height: {{height}}rpx;" wx:if="{{!vip}}">
<!-- <image class="img-empty" src="/assets/image/list_empty.png"></image> -->
<view class="flex" style="margin-bottom:48rpx">
<text class="cuIcon-info text-blue" style="font-size:42rpx;"></text>
<view style="width:540rpx;margin-left: 12rpx">
<view class="text-bold" style="font-size:32rpx;margin-bottom: 12rpx">需要开通会员才能查看纸厂扣点信息</view>
<text class="text-gray">限时优惠开通会员,获取更多货源、尊享会员权益,买卖更赚钱</text>
</view>
</view>
<wux-button type="positive" size="join" bind:click="toVip">立即开通</wux-button>
</view>
<view wx:else>
<view wx:if="{{userInfo && userInfo.isVIP}}">
<wux-skeleton active wx:if="{{!momentList.length}}">
<view class="cu-card dynamic no-card" wx:for="{{4}}" wx:key="index">
<view class="cu-item shadow" style="padding-left:30rpx">
@ -50,5 +39,16 @@
</view>
</view>
</view>
<view class="bg-white list-empty" style="height: {{height}}rpx;" wx:else>
<!-- <image class="img-empty" src="/assets/image/list_empty.png"></image> -->
<view class="flex" style="margin-bottom:48rpx">
<text class="cuIcon-info text-blue" style="font-size:42rpx;"></text>
<view style="width:540rpx;margin-left: 12rpx">
<view class="text-bold" style="font-size:32rpx;margin-bottom: 12rpx">需要开通会员才能查看纸厂扣点信息</view>
<text class="text-gray">限时优惠开通会员,获取更多货源、尊享会员权益,买卖更赚钱</text>
</view>
</view>
<wux-button type="positive" size="join" bind:click="toVip">立即开通</wux-button>
</view>
</refresh-view>
<!-- </scroll-view> -->

86
pages/article/price-index/index.js

@ -1,7 +1,5 @@
// pages/stock/index.js
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
const storage = require('../../../utils/storage')
const event = require('../../../utils/event.js')
const app = getApp()
@ -15,25 +13,18 @@ Component({
*/
data: {
height: app.globalData.safeFragmentHeight - 190,
chartList: null,
firstShow: false,
momentList: [],
requesting: false,
finished: false,
idList: '',
form: {
categoryId: 1,
pageNum: 1
},
factoryList: [],
priceId: null,
priceName: '',
priceList: []
}
},
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 190, kg: app.globalData.kg })
this.data.priceId = storage.get('priceId' + app.globalData.userInfo.userId)
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
@ -43,18 +34,13 @@ Component({
methods: {
onRestart: function () {
if (!this.data.firstShow) {
// this.fetchPriceList(this.data.priceId)
this.setData({ height: app.globalData.safeFragmentHeight - 190, kg: app.globalData.kg })
this.onRefreshList()
}
this.data.firstShow = true
},
onEvent: function (message) {
if (message.what == 555) {
// 纸厂价格的纸厂选择
this.data.priceId = message.obj.paperMillId
storage.put('priceId' + app.globalData.userInfo.userId, this.data.priceId)
// this.fetchPriceList(this.data.priceId)
} else if (message.what == 571) {
if (message.what == 571) {
// 帖子发布刷新
this.onRefreshList()
}
@ -93,68 +79,6 @@ Component({
//异常回调
this.setData({ requesting: false })
})
},
lookItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id })
},
likeItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
if(item.isLiked){
util.showToast('请勿重复点赞')
return
}
request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => {
this.setData({
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity,
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1
})
}).catch(error => {
util.showToast(error)
})
},
//*************************************************noticeList************************************************//
fetchNoticeList: function(){
if (this.data.loopRequesting) {
return
}
this.data.loopRequesting = true
request.get('/recycle-service/get/index-info-id').then(result => {
//成功回调
this.data.loopRequesting = false
this.data.noticeList = result.data
if(result.data && result.data.length){
this.data.noticeIndex = 0
this.data.loopIndex = 0
this.setData({ content: result.data[0].title})
}
}).catch(err => {
//异常回调
this.data.loopRequesting = false
})
},
onLoop: function(){
if(!this.data.noticeList.length){
this.data.loopIndex++
if(this.data.loopIndex >= 600){
this.fetchNoticeList()
}
return
}
this.data.noticeIndex++
if(this.data.noticeIndex >= this.data.noticeList.length){
this.data.loopIndex++
this.data.noticeIndex = 0
}
if(this.data.loopIndex >= 60){
this.fetchNoticeList()
}
this.setData({ content: this.data.noticeList[this.data.noticeIndex].title })
this.notice = this.notice || this.selectComponent('#wux-notice-bar')
this.notice.resetAnimation()
},
onClick: function(){
wx.navigateTo({ url: '/pages/html/notice/index?id=' + this.data.noticeList[this.data.noticeIndex].id })
}
}
}
})

140
pages/article/queue-index/index.js

@ -1,12 +1,7 @@
// pages/stock/index.js
const request = require('../../../utils/request') //导入模块
const util = require('../../../utils/util')
const storage = require('../../../utils/storage')
const event = require('../../../utils/event.js')
var wxCharts = require('../../../utils/wxcharts.js')
const event = require('../../../utils/event')
const app = getApp()
var queueChart = null
const colors = ['#FF4229', '#FFAD2A', '#297BFF', '#29FF46', '#AD29FF']
Component({
options: {
@ -18,21 +13,16 @@ Component({
*/
data: {
dev: app.globalData.dev,
firstShow: false,
height: app.globalData.safeFragmentHeight - 190,
momentList: [],
requesting: false,
finished: false,
form: { categoryId: 2, pageNum: 1 },
queueId: null,
queueName: '',
chartList: null,
form: { categoryId: 2, pageNum: 1 }
},
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ dev: app.globalData.dev, height: app.globalData.safeFragmentHeight - 190 })
this.data.queueId = storage.get('queueId' + app.globalData.userInfo.userId)
this.data.queueName = storage.get('queueName' + app.globalData.userInfo.userId)
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
@ -42,117 +32,17 @@ Component({
methods: {
onRestart: function () {
if (!this.data.firstShow) {
// this.fetchQueueList(this.data.queueId)
this.setData({ dev: app.globalData.dev, height: app.globalData.safeFragmentHeight - 190 })
this.onRefreshList()
}
this.data.firstShow = true
},
onEvent: function (message) {
if (message.what == 556) {
// 纸厂排队的纸厂选择
this.data.queueId = message.obj.paperMillId
this.data.queueName = message.obj.name
storage.put('queueId' + app.globalData.userInfo.userId, this.data.queueId)
storage.put('queueName' + app.globalData.userInfo.userId, this.data.queueName)
// this.fetchQueueList(this.data.queueId)
} else if (message.what == 572) {
if (message.what == 572) {
// 帖子发布刷新
this.onRefreshList()
}
},
//***********************************fetchChartList*****************************************//
// touchHandler: function (e) {
// if(queueChart){
// queueChart.scrollStart(e)
// }
// },
// moveHandler: function (e) {
// if(queueChart){
// queueChart.scroll(e)
// }
// },
// touchEndHandler: function (e) {
// if(queueChart){
// queueChart.scrollEnd(e)
// queueChart.showToolTip(e, {
// format: function (item, category) {
// return category + ' ' + item.name + ':' + item.data
// }
// })
// }
// },
// // 纸品价格>>>>选择纸厂
// selectFactory: function(event){
// wx.navigateTo({ url: '/pages/article/factory/index?type=2'})
// },
// fetchQueueList: function(millId){
// if(!millId){
// request.get('/recycle-service/get/paper-mill-list').then(result => {
// this.data.queueName = result.data.records[1].name
// this.fetchQueueList(result.data.records[1].paperMillId)
// })
// return
// }
// // recycle-service/get/paper-mill-received-weight-trend
// request.get('/recycle-service/get/paper-mill-received-weight-trend', {paperMillId: millId}).then(result => {
// //成功回调
// if(result.data.length <= 0){
// this.setData({chartList: [], queueName: this.data.queueName})
// return
// }
// var categoriesList = []
// var serieList = []
// var dataList = [[]]
// for (let index = 0; index < result.data.length; index++) {
// const element = result.data[index]
// categoriesList.push(element.time.substring(5))
// dataList[0].push(element.totalQuantity)
// // dataList[1].push(element.retainedQuantity)
// }
// var names = ['收货车辆总数', '排队车辆数']
// for (let index = 0; index < dataList.length; index++) {
// var series = {
// name: names[index],
// data: dataList[index],
// format: function (val, name) {
// return val + '辆'
// },
// color: colors[index]
// }
// serieList.push(series)
// }
// this.setData({ chartList: { categories: categoriesList, serieList: serieList }, queueName: this.data.queueName })
// this.initChart(0, 0)
// })
// },
// initChart: function (min, max) {
// queueChart = new wxCharts({
// canvasId: 'queueChart',
// type: 'line',
// legend: false,
// categories: this.data.chartList.categories,
// animation: false,
// series: this.data.chartList.serieList,
// xAxis: { disableGrid: false },
// yAxis: {
// // title: '纸品单价 (元/吨)',
// format: function (val) {
// return val;
// },
// min,
// max
// },
// width: 350,
// height: 200,
// dataLabel: false,
// dataPointShape: 'circle',
// enableScroll: true,
// extra: { lineStyle: 'curve' }
// }, this)
// },
// queueList: function(){
// wx.navigateTo({ url: '/pages/article/queue-detail/index' })
// },
//*************************************************momentList************************************************//
onRefreshList: function () {
this.setData({
@ -187,26 +77,6 @@ Component({
//异常回调
this.setData({ requesting: false })
})
},
lookItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.navigateTo({ url: '/pages/article/detail/index?id=' + item.id })
},
likeItem: function(e){
var item = this.data.momentList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
if(item.isLiked){
util.showToast('请勿重复点赞')
return
}
// /article/like-or-cancel/article-reply/{id} 点赞评论
request.post('/information-center/like-or-cancel/post', {postId: item.id}).then(result => {
this.setData({
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].likeQuantity']: result.data.likeQuantity,
['momentList[' + e.currentTarget.dataset.page + '][' + e.currentTarget.dataset.index + '].isLiked']: 1
})
}).catch(error => {
util.showToast(error)
})
}
}
})

41
pages/home/index/index.js

@ -1,8 +1,8 @@
// pages/stock/index.js
const request = require('../../../utils/request'); //导入模块
const util = require('../../../utils/util');
const event = require('../../../utils/event.js')
const math = require('../../../utils/math.js');
const util = require('../../../utils/util')
const event = require('../../../utils/event')
const math = require('../../../utils/math')
const app = getApp()
Component({
@ -25,8 +25,7 @@ Component({
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight, userInfo: app.globalData.userInfo })
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
event.on('EventMessage', this, this.onEvent)
},
detached: function () {
@ -36,8 +35,10 @@ Component({
methods: {
// resume的处理;
onRestart: function () {
if(!this.data.firstShow){
this.setData({ height: app.globalData.safeFragmentHeight, userInfo: app.globalData.userInfo })
}
this.fetchUserInfo()
// this.fetchMoney()
this.data.firstShow = true
},
onEvent: function (message) {
@ -47,7 +48,9 @@ Component({
}
},
fetchUserInfo: function () {
// /user/userInfo 获取用户信息
if(!app.globalData.token){
return
}
request.get('/recycle-service/user/get/base-info').then(result => {
app.globalData.userInfo = result.data
var nickname = ''
@ -71,8 +74,28 @@ Component({
this.setData({ messageNumber: result.data.messageNumber + result.data.notificationNumber })
})
},
toShop: function () {
wx.navigateTo({ url: '/pages/shop/index/index' })
toPage: function(e){
if(e.currentTarget.id == 'bidding'){
util.navigateTo('/pages/bidding/index/index')
} else if(e.currentTarget.id == 'shop'){
util.navigateTo('/pages/shop/index/index')
} else if(e.currentTarget.id == 'ordering'){
util.navigateTo('/pages/morder/index/index')
} else if(e.currentTarget.id == 'agent'){
util.navigateTo('/pages/agent/order/index')
} else if(e.currentTarget.id == 'message'){
util.navigateTo('/pages/message/index/index')
} else if(e.currentTarget.id == 'balance'){
util.navigateTo('/pages/withdrawal/balance/index')
} else if(e.currentTarget.id == 'integral'){
util.navigateTo('/pages/html/integral/index')
} else if(e.currentTarget.id == 'article'){
util.navigateTo('/pages/article/list/index')
} else if(e.currentTarget.id == 'adress'){
util.navigateTo('/pages/adress/list/index')
} else if(e.currentTarget.id == 'setting'){
util.navigateTo('/pages/home/setting/index')
}
},
checkout: function () {
wx.navigateTo({ url: '/pages/withdrawal/checkout/index' })

58
pages/home/index/index.wxml

@ -1,6 +1,6 @@
<wxs module="formate" src="../../../pages/formate.wxs"></wxs>
<cu-custom bgColor="bg-white" isBack="{{false}}">
<view slot="content" style="color:black;font-size:18px">我的</view>
<cu-custom bgColor="bg-blue" isBack="{{false}}">
<view slot="content" style="color:white;font-size:18px">我的</view>
</cu-custom>
<scroll-view scroll-y style="height: {{height}}rpx;">
@ -33,40 +33,6 @@
</view>
<text class="cuIcon-right text-gray" style="font-size:18px"></text>
</view>
<!-- <wux-grids col="4">
<wux-grid bind:click="toShop">
<view style="padding: 40rpx 0rpx">
<wux-badge count="{{0}}" top="-8" right="-8">
<image style="width:60rpx;height:60rpx;" src="/assets/image/menu/menu_shop.png"></image>
</wux-badge>
<view class="text-sm">{{userInfo.hasStore == 1 ? '我的店铺' : '申请开店'}}</view>
</view>
</wux-grid>
<wux-grid id="1" bind:click="clickGrid">
<view style="padding: 40rpx 0rpx">
<wux-badge count="{{0}}" top="-8" right="-8">
<image style="width:60rpx;height:60rpx;" src="/assets/image/menu/menu_biding.png"></image>
</wux-badge>
<view class="text-sm">我的竞价</view>
</view>
</wux-grid>
<wux-grid id="2" bind:click="clickGrid">
<view style="padding: 40rpx 0rpx">
<wux-badge count="{{0}}" top="-8" right="-8">
<image style="width:60rpx;height:60rpx;" src="/assets/image/menu/menu_form.png"></image>
</wux-badge>
<view class="text-sm">订单交易</view>
</view>
</wux-grid>
<wux-grid id="3" bind:click="clickGrid">
<view style="padding: 40rpx 0rpx">
<wux-badge count="{{messageNumber}}" top="-8" right="-8">
<image style="width:60rpx;height:60rpx;" src="/assets/image/menu/menu_message.png"></image>
</wux-badge>
<view class="text-sm">我的消息</view>
</view>
</wux-grid>
</wux-grids> -->
<view style="height:16rpx"></view>
<wux-cell-group>
@ -74,7 +40,7 @@
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_vip.png"></image>
</wux-cell>
<wux-cell title="{{userInfo.hasStore == 1 ? '我的店铺' : '我要开店'}}" is-link url="/pages/shop/index/index">
<wux-cell id="shop" title="{{userInfo.hasStore == 1 ? '我的店铺' : '我要开店'}}" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_shop.png"></image>
</wux-cell>
@ -82,19 +48,19 @@
<view style="height:16rpx"></view>
<wux-cell-group>
<wux-cell title="我的报价" is-link url="/pages/bidding/index/index">
<wux-cell id="bidding" title="我的报价" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_biding.png"></image>
</wux-cell>
<wux-cell title="交易订单" is-link url="/pages/morder/index/index">
<wux-cell id="ordering" title="交易订单" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_form.png"></image>
</wux-cell>
<wux-cell title="代卖订单" is-link url="/pages/agent/order/index">
<wux-cell id="agent" title="代卖订单" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_order.png"></image>
</wux-cell>
<wux-cell is-link url="/pages/message/index/index">
<wux-cell id="message" is-link bind:click="toPage">
<view slot="header" class="flex">
<image style="width:32rpx;height:32rpx;margin-right:12rpx" src="/assets/image/menu/menu_message.png"></image>
<wux-badge count="{{messageNumber}}" top="-16" right="-16">
@ -106,12 +72,12 @@
<view style="height:16rpx"></view>
<wux-cell-group>
<wux-cell title="我的余额" is-link url="/pages/withdrawal/balance/index">
<wux-cell id="balance" title="我的余额" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_balance.png"></image>
<text slot="footer" class="text-lg" style="padding-top:4px">{{formate.numberFormat2(accountMoney)}}</text>
</wux-cell>
<wux-cell title="我的积分" is-link url="/pages/html/integral/index">
<wux-cell id="integral" title="我的积分" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_jifen.png"></image>
<view slot="footer" class="flex flex-center">
@ -119,7 +85,7 @@
<text class="text-lg" style="margin-left:24rpx">{{userInfo.memberRewardPoint || 0}}</text>
</view>
</wux-cell>
<wux-cell title="我的帖子" is-link url="/pages/article/list/index">
<wux-cell id="article" title="我的帖子" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_article.png"></image>
</wux-cell>
@ -130,7 +96,7 @@
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_transform.png"></image>
</wux-cell>
<wux-cell title="收货地址" is-link url="/pages/adress/list/index">
<wux-cell id="adress" title="收货地址" is-link bind:click="toPage">
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_location.png"></image>
</wux-cell>
@ -138,7 +104,7 @@
<image slot="header" style="width:32rpx;height:32rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_service.png"></image>
</wux-cell>
<wux-cell title="设置" is-link url="/pages/home/setting/index">
<wux-cell id="setting" title="设置" is-link bind:click="toPage">
<image slot="header" style="width:36rpx;height:36rpx;margin:6rpx 12rpx 0rpx 0rpx"
src="/assets/image/menu/menu_setting.png"></image>
</wux-cell>

1
pages/home/qrcode/index.js

@ -8,7 +8,6 @@ Page({
* 页面的初始数据
*/
data: {
value: app.globalData.userInfo.userId,
fgColor: 'black',
userInfo: null,
avatarUrl: null,

115
pages/index/index.js

@ -11,11 +11,10 @@ Page({
{ index: 2, value: 'home', badge: 0, name: '我的' }
],
pageIndex: 1,
safeBottom: app.globalData.safeBottom
safeBottom: app.globalData.safeBottom,
inited: false
},
/**
* 生命周期函数--监听页面加载
*/
/************************************** 初始化流程 ********************************************/
onLoad: function (options) {
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
@ -26,48 +25,90 @@ Page({
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
})
if(app.inited){
this.setData({fragment: app.globalData.safeFragmentHeight + app.globalData.statusBarHeight - 100, safeBottom: app.globalData.safeBottom })
} else{
var devJson = storage.get('ztbdev')
if(devJson){
var devInfo = JSON.parse(devJson)
app.globalData.statusBarHeight =devInfo.statusBarHeight
app.globalData.safeBottom = devInfo.safeBottom
app.globalData.safeFragmentHeight = devInfo.safeFragmentHeight
app.globalData.fragmentHeight = devInfo.fragmentHeight
app.globalData.windowWidth = devInfo.windowWidth
app.globalData.isIPhoneX = devInfo.isIPhoneX
app.globalData.isIos = devInfo.isIos
app.globalData.dev = devInfo.dev
app.globalData.CustomBar = devInfo.CustomBar
app.globalData.Custom = devInfo.Custom
this.setData({fragment: app.globalData.safeFragmentHeight + app.globalData.statusBarHeight - 100, safeBottom: app.globalData.safeBottom })
},
onReady: function () {
wx.showLoading({ title: '获取中', mask: true })
wx.getSystemInfo({
success: e => {
app.globalData.isIPhoneX = this.checkIPhoneX(e)
app.globalData.isIos = this.checkIos(e)
app.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
app.globalData.Custom = custom
// 顶部操作栏高度
app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if(safeBottom > e.windowHeight){
safeBottom = 34
}
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
// 状态栏高度
app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth)
app.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
app.globalData.fragmentHeight = windowHeight - statusBarHeight
app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom
app.globalData.windowWidth = e.windowWidth
this.data.inited = true
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100
event.emit('InitMessage', { what: 8, desc: 'Logined' })
this.setData({fragment: fheght, safeBottom: app.globalData.safeBottom })
var authorization = app.globalData.token || storage.get('Authorization')
if(authorization){
app.globalData.token = authorization
this.fetchUserInfo()
} else {
wx.hideLoading()
this.onResume()
}
}
})
},
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
event.on('EventMessage', this, this.onEvent)
if(!app.globalData.userInfo.mobile){
request.get('/recycle-service/user/get/base-info').then(result => {
app.globalData.userInfo = result.data
})
if (e.system.startsWith('iOS')) {
return true
}
return false
},
//事件处理函数
onNavChange(e) {
// 处理用户的登录校验
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) })
checkIPhoneX: function (e) {
var t = e.model
return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && this.checkIos(e)
},
fetchUserInfo:function(){
request.get('/recycle-service/user/get/base-info').then(result => {
app.globalData.userInfo = result.data
wx.hideLoading()
this.onResume()
}).catch(err => {
wx.hideLoading()
})
},
onResume: function(){
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value)
if (pageView) {
if (pageView && this.data.inited) {
pageView.onRestart()
}
},
//事件处理函数
onNavChange: function(e) {
// 处理用户的登录校验
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) })
this.onResume()
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value)
if (pageView) {
pageView.onRestart()
if(this.data.inited){
this.onResume()
}
},
onEvent: function (message) {
@ -77,11 +118,5 @@ Page({
},
stopTouchMove: function(e){
return false
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
event.remove('EventMessage', this)
}
})

89
pages/login/index.js

@ -3,6 +3,7 @@ import { $wuxCountDown } from '../../components/index'
const storage = require('../../utils/storage')
const request = require('../../utils/request') //导入模块
const util = require('../../utils/util')
const event = require('../../utils/event')
const app = getApp()
Page({
@ -26,7 +27,6 @@ Page({
version15: false,
path: null
},
onLoad: function (options) {
if (options.mobile) {
this.setData({ ['form.mobile']: options.mobile })
@ -86,63 +86,6 @@ Page({
this.wxLogin()
}
},
onReady: function () {
wx.getSystemInfo({
success: e => {
app.globalData.isIPhoneX = this.checkIPhoneX(e)
app.globalData.isIos = this.checkIos(e)
app.globalData.dev = e.platform == 'devtools'
let custom = wx.getMenuButtonBoundingClientRect()
app.globalData.Custom = custom
// 顶部操作栏高度
app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0)
let windowHeight = e.windowHeight * (750 / e.windowWidth)
let safeBottom = e.windowHeight - e.safeArea.bottom
if(safeBottom > e.windowHeight){
safeBottom = 34
}
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth)
// 状态栏高度
app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth)
let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth)
app.globalData.statusBarHeight = statusBarHeight
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
app.globalData.fragmentHeight = windowHeight - statusBarHeight
app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom
app.globalData.windowWidth = e.windowWidth
this.saveDevInfo()
this.checkLogin()
app.inited = true
}
})
},
saveDevInfo: function(){
var devIno = { Custom: app.globalData.Custom, CustomBar: app.globalData.CustomBar }
devIno.statusBarHeight = app.globalData.statusBarHeight
devIno.fragmentHeight = app.globalData.fragmentHeight
devIno.safeFragmentHeight = app.globalData.safeFragmentHeight
devIno.safeBottom = app.globalData.safeBottom
devIno.windowWidth = app.globalData.windowWidth
devIno.isIPhoneX = app.globalData.isIPhoneX
devIno.isIos = app.globalData.isIos
devIno.dev = app.globalData.dev
storage.put('ztbdev', JSON.stringify(devIno))
},
checkIos: function (e) {
if ('ios' === e.platform) {
return true
}
if (e.system.startsWith('iOS')) {
return true
}
return false
},
checkIPhoneX: function (e) {
var t = e.model
return (/iPhone 11/.test(t) || /iPhone X/.test(t) || /iPhone 12/.test(t)) && this.checkIos(e)
},
changePwd: function () {
if (this.data.pwdType === 'password') {
this.setData({ pwdType: 'text' })
@ -150,7 +93,6 @@ Page({
this.setData({ pwdType: 'password' })
}
},
bindInput: function (e) {
this.data.form[e.target.id] = e.detail.value
if ('account' == e.target.id) {
@ -172,7 +114,6 @@ Page({
this.setData({ loginEnable: true })
}
},
loginForm: function () {
if (!(/^1\d{10}$/.test(this.data.form.account)) || this.data.form.account.length < 11) {
util.showToast('请输入11位手机号码')
@ -216,31 +157,9 @@ Page({
app.globalData.userToken = result.data.userToken
}
app.globalData.userInfo = result.data
if(this.data.path){
wx.redirectTo({ url: this.data.path })
} else if (this.data.version15 == 15) {
wx.hideLoading()
wx.redirectTo({ url: '/pages/paper/index' })
} else if(util.isEmpty(app.globalData.userToken)){
wx.hideLoading()
wx.redirectTo({ url: '/pages/index/index' })
} else {
// /receive/v150/get/OrderExists 判断该用户是否有订单存在 1存在 2不存在
request.get('/saas-trade/receive/v150/get/OrderExists').then(result => {
wx.hideLoading()
if (Number(result.data) != 1 || !app.release) {
wx.redirectTo({ url: '/pages/index/index' })
} else {
wx.redirectTo({ url: '/pages/paper/index' })
}
}).catch(err => {
//异常回调
wx.hideLoading()
wx.redirectTo({ url: '/pages/index/index' })
})
}
event.emit('EventMessage', { what: 888, desc: 'Logined' })
wx.navigateBack()
},
changeType: function () {
if (this.data.type == 1) {
this.setData({ type: 0, ['form.captcha']: null, loginEnable: true })
@ -248,7 +167,6 @@ Page({
this.setData({ type: 1, ['form.password']: null, loginEnable: true })
}
},
fetchCode: function (e) {
if (!(/^1\d{10}$/.test(this.data.form.account)) || this.data.form.account.length < 11) {
util.showToast('请输入11位手机号码')
@ -276,7 +194,6 @@ Page({
util.showToast(error)
})
},
onGotPhoneNumber: function (e) {
request.phoneWechat(e.detail).then(result => {
this.setData({ ['form.account']: result.data.phoneNumber, mobileEnable: true })

6
pages/login/index.wxml

@ -1,5 +1,9 @@
<!--pages/login/index.wxml-->
<view class="flex flex-center" style="width:100%;height:320rpx;margin-top:120rpx">
<cu-custom bgColor="bg-white" isBack="{{true}}">
<view slot="content" style="color:black;font-size:36rpx">登录</view>
</cu-custom>
<view class="flex flex-center" style="width:100%;height:320rpx;margin-top:60rpx">
<image style="width:192rpx;height:192rpx" src="/assets/image/icon_logo.png"></image>
</view>

70
pages/mall/index/index.js

@ -1,6 +1,7 @@
// pages/message/index.js
const request = require('../../../utils/request') //导入模块
const event = require('../../../utils/event')
const util = require('../../../utils/util')
const app = getApp()
Component({
@ -15,6 +16,7 @@ Component({
height: app.globalData.safeFragmentHeight - 100,
kg: app.globalData.kg,
stickyTop: app.globalData.CustomBar,
firstShow: false,
scrollTop: 0,
fixed: false,
toView: null,
@ -42,9 +44,7 @@ Component({
lifetimes: {
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
attached: function () {
this.setData({ height: app.globalData.safeFragmentHeight - 100, kg: app.globalData.kg, stickyTop: app.globalData.CustomBar })
event.on('EventMessage', this, this.onEvent)
this.onRefreshList()
},
detached: function () {
event.remove('EventMessage', this)
@ -52,6 +52,16 @@ Component({
},
methods: {
onRestart: function () {
if(!this.data.firstShow){
this.setData({
height: app.globalData.safeFragmentHeight - 100,
kg: app.globalData.kg,
stickyTop: app.globalData.CustomBar,
firstShow: true
})
this.onRefreshList()
}
this.data.firstShow = true
if(!this.data.noticeList.length){
this.fetchBannerList()
}
@ -81,72 +91,70 @@ Component({
tapBanner: function(e){
var item = this.data.bannerList[e.currentTarget.dataset.index]
if(item.redirectInfo.targetView == 'showH5'){
wx.navigateTo({ url: '/pages/html/html/index?link=' + item.redirectInfo.params.id + '?title=' + item.title})
util.navigateTo('/pages/html/html/index?link=' + item.redirectInfo.params.id + '?title=' + item.title)
} else if(item.redirectInfo.targetView == 'showImage'){
wx.navigateTo({ url: '/pages/html/banner/index?src=' + item.redirectInfo.params.id})
util.navigateTo('/pages/html/banner/index?src=' + item.redirectInfo.params.id)
}
if(item.redirectInfo.targetView == 'showBidList'){
wx.navigateTo({ url: '/pages/goods/ablility/index' })
util.navigateTo('/pages/goods/ablility/index')
} else if(item.redirectInfo.targetView == 'showProxyList'){
// wx.navigateTo({ url: '/pages/goods/ablility/index' })
} else if(item.redirectInfo.targetView == 'showQNPrice'){
wx.navigateTo({ url: '/pages/mall/price-index/index' })
util.navigateTo('/pages/mall/price-index/index')
} else if(item.redirectInfo.targetView == 'showFactoryPrice'){
wx.navigateTo({ url: '/pages/article/price-detail/index' })
} else if(item.redirectInfo.targetView == 'showFactoryQueue'){
wx.navigateTo({ url: '/pages/article/queue-detail/index' })
util.navigateTo('/pages/article/price-detail/index')
} else if(item.redirectInfo.targetView == 'showFactoryQueue'){
wx.navigateTo({ url: '/pages/article/queue-detail/index' })
util.navigateTo('/pages/article/queue-detail/index')
} else if(item.redirectInfo.targetView == 'showArticleHome'){
// 情报首页
event.emit('EventMessage', { what: 250, desc: 'page-article', index: 0 })
} else if(item.redirectInfo.targetView == 'myArticle'){
wx.navigateTo({ url: '/pages/article/list/index' })
util.navigateTo('/pages/article/list/index')
} else if(item.redirectInfo.targetView == 'myMessage'){
wx.navigateTo({ url: '/pages/message/index/index' })
util.navigateTo('/pages/message/index/index')
} else if(item.redirectInfo.targetView == 'member'){
wx.navigateTo({ url: '/pages/ztbvip/index' })
util.navigateTo('/pages/ztbvip/index')
} else if(item.redirectInfo.targetView == 'showPurchaseList'){
wx.navigateTo({ url: '/pages/purchase/ablility/index' })
util.navigateTo('/pages/purchase/ablility/index')
} else if(item.redirectInfo.targetView == 'showProductList'){
wx.navigateTo({ url: '/pages/goods/ablility/index?type=1' })
util.navigateTo('/pages/goods/ablility/index?type=1')
} else if(item.redirectInfo.targetView == 'logistics'){
wx.navigateTo({ url: '/pages/html/logistics/index' })
util.navigateTo('/pages/html/logistics/index')
} else if(item.redirectInfo.targetView == 'contract'){
wx.navigateTo({ url: '/pages/home/service/index' })
util.navigateTo('/pages/home/service/index')
} else if(item.redirectInfo.targetView == 'myAddress'){
wx.navigateTo({ url: '/pages/adress/list/index' })
util.navigateTo('/pages/adress/list/index')
} else if(item.redirectInfo.targetView == 'myBankCard'){
wx.navigateTo({ url: '/pages/bank/vindex/index' })
util.navigateTo('/pages/bank/vindex/index')
} else if(item.redirectInfo.targetView == 'personalBillDetail'){
wx.navigateTo({ url: '/pages/bank/bill/index' })
util.navigateTo('/pages/bank/bill/index')
} else if(item.redirectInfo.targetView == 'myScore'){
wx.navigateTo({ url: '/pages/html/integral/index' })
util.navigateTo('/pages/html/integral/index')
} else if(item.redirectInfo.targetView == 'myBalance'){
wx.navigateTo({ url: '/pages/withdrawal/balance/index' })
util.navigateTo('/pages/withdrawal/balance/index')
} else if(item.redirectInfo.targetView == 'myProxyList'){
wx.navigateTo({ url: '/pages/agent/order/index' })
util.navigateTo('/pages/agent/order/index')
} else if(item.redirectInfo.targetView == 'myBidList'){
wx.navigateTo({ url: '/pages/bidding/index/index' })
util.navigateTo('/pages/bidding/index/index')
} else if(item.redirectInfo.targetView == 'myShop'){
wx.navigateTo({ url: '/pages/shop/index/index' })
util.navigateTo('/pages/shop/index/index')
}
},
onGridTap: function(e){
var index = e.currentTarget.dataset.index
if (index === 0) {
wx.navigateTo({ url: '/pages/goods/ablility/index' })
util.navigateTo('/pages/goods/ablility/index')
} else if (index === 1) {
wx.navigateTo({ url: '/pages/purchase/ability/index' })
util.navigateTo('/pages/purchase/ability/index')
} else if (index === 2) {
wx.navigateTo({ url: '/pages/agent/index/index' })
util.navigateTo('/pages/agent/index/index')
} else if (index === 3) {
wx.navigateTo({ url: '/pages/mall/price-index/index' })
util.navigateTo('/pages/mall/price-index/index')
} else if (index === 4) {
wx.navigateTo({ url: '/pages/article/price-detail/index' })
util.navigateTo('/pages/article/price-detail/index')
} else if (index === 5) {
wx.navigateTo({ url: '/pages/article/queue-detail/index' })
util.navigateTo('/pages/article/queue-detail/index')
}
},
onTabChange: function({detail}){

24
pages/mall/index/index.wxml

@ -4,18 +4,18 @@
<view slot="content" style="color:black;font-size:36rpx">交易</view>
</cu-custom>
<scroll-view scroll-y style="height: {{height}}rpx;" bindscroll="onScroll" scroll-into-view="{{toView}}" bind:scrolltolower="fetchMoreList">
<swiper class="screen-swiper" style="height:270rpx;min-height: 270rpx" circular="{{true}}" indicator-dots="{{false}}" autoplay="true" interval="5000" duration="500">
<swiper-item wx:for="{{bannerList}}" wx:key="index">
<wux-image width="{{750}}" height="{{270}}" nuit="{{'rpx'}}" src="{{item.picUrl}}" mode="aspectFill" data-index="{{index}}" bind:click="tapBanner">
<view class="flex flex-center" slot="loading" style="height:270rpx;width:750rpx">
<text class="icon--refresher" wx:if="{{!finished[0]}}"></text>
</view>
</wux-image>
</swiper-item>
</swiper>
<scroll-view scroll-y style="height: {{height}}rpx;" bindscroll="onScroll" scroll-into-view="{{toView}}" bind:scrolltolower="fetchMoreList" wx:if="{{firstShow}}">
<view style="height:270rpx;min-height: 270rpx">
<swiper class="screen-swiper" circular="{{true}}" indicator-dots="{{false}}" autoplay="true" interval="5000" duration="500">
<swiper-item wx:for="{{bannerList}}" wx:key="index" >
<wux-image width="{{750}}" height="{{270}}" nuit="{{'rpx'}}" src="{{item.picUrl}}" mode="aspectFill" data-index="{{index}}" bind:click="tapBanner">
<view class="flex flex-center" slot="loading" style="height:270rpx;width:750rpx">
<text class="icon--refresher"></text>
</view>
</wux-image>
</swiper-item>
</swiper>
</view>
<view class="bg-white flex flex-center" style="height:60rpx;padding-right:16rpx;margin-top:16rpx">
<image style="width:200rpx;height:60rpx;" src="/assets/image/ico_notice.png"></image>
<!-- <text class="cuIcon-notification text-yellow" style="font-size:36rpx;margin:0rpx 16rpx;"></text> -->

10
pages/ztbvip/index.js

@ -28,15 +28,13 @@ Page({
})
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.fetchUserInfo()
},
fetchUserInfo: function () {
if(!app.globalData.userInfo){
return
}
wx.showLoading({ title: '处理中', mask: true })
// /user/userInfo 获取用户信息
request.get('/recycle-service/user/get/base-info').then(result => {
@ -59,7 +57,7 @@ Page({
},
toAuthor: function(){
if(!this.data.userInfo.isAuth){
wx.navigateTo({ url: '/pages/home/idcard/index' })
util.navigateTo('/pages/home/idcard/index')
}
},
/**

2
utils/request.js

@ -58,7 +58,7 @@ function fun(url, method, data, header) {
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.reLaunch({ url: '/pages/login/index' })
wx.navigateTo({ url: '/pages/login/index' })
}
},
complete: function(){

37
utils/util.js

@ -1,3 +1,5 @@
const app = getApp()
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
@ -167,6 +169,38 @@ function checkId(id) {
}
}
const tokenList = [
'pages/mall/price-index/index',
'/pages/article/price-detail/index',
'/pages/article/queue-detail/index',
'/pages/article/detail/index',
'/pages/shop/index/index',
'/pages/bidding/index/index',
'/pages/morder/index/index',
'/pages/message/index/index',
'/pages/home/setting/index',
'/pages/adress/list/index',
'/pages/article/list/index',
'/pages/html/integral/index',
'/pages/withdrawal/balance/index',
'/pages/agent/order/index',
'/pages/home/idcard/index'
]
function navigateTo(url){
var white = false
for (let index = 0; index < tokenList.length; index++) {
if(url.indexOf(tokenList[index]) != -1){
white = true
break
}
}
if(white && !app.globalData.userInfo){
wx.navigateTo({ url: '/pages/login/index' })
return
}
wx.navigateTo({ url })
}
module.exports = {
isEmpty: isEmpty,
@ -180,5 +214,6 @@ module.exports = {
playDing: playDing,
showBackToast: showBackToast,
checkPhone: checkPhone,
checkId: checkId
checkId: checkId,
navigateTo: navigateTo
}
Loading…
Cancel
Save