From c832fea9dd4c6f85892381ee8683091747eca232 Mon Sep 17 00:00:00 2001 From: xpz2018 <107107461@qq.com> Date: Wed, 13 Jan 2021 10:41:13 +0800 Subject: [PATCH] no message --- pages/api/ztb.js | 28 ++++++++++++- pages/bidding/detail/index.js | 70 ++++++++------------------------- pages/bidding/detail/index.wxml | 2 +- pages/bidding/index/index.js | 10 ++--- pages/html/integral/index.js | 20 ++++------ pages/html/notice/index.js | 11 ++---- pages/mall/detail/index.js | 49 ++++------------------- 7 files changed, 66 insertions(+), 124 deletions(-) diff --git a/pages/api/ztb.js b/pages/api/ztb.js index 246f0c5..5ddb0f0 100644 --- a/pages/api/ztb.js +++ b/pages/api/ztb.js @@ -22,6 +22,7 @@ const getFactoryPriceDetail = (id) => mGet(`/recycle-service/get/paper-mill-pape const getFactoryCity = () => mGet(`/recycle-service/get/paper-mill-city`, null, zconfig) // /get/index-info-id 首页获取公告id接口 const getIndexInfoId = () => mGet(`/recycle-service/get/index-info-id`, null, zconfig) +const getIndexInfo = (id) => mGet(`/recycle-service/get/index-info/${id}`, null, zconfig) // /get/paper-mill-list 获取纸厂列表 const getFactoryList = () => mGet(`/recycle-service/get/paper-mill-list`, null, zconfig) // /get/paper-mill-received-weight-list/on-today 获取纸厂今日收货量(排队)列表 @@ -66,6 +67,18 @@ const getGoodProductList = (params) => mGet(`/recycle-service/get/product-list`, // /recycle-service/update/product-status const statusProductInfo = (params) => mPost(`/recycle-service/update/product-status`, params, zconfig) const deleteProduct = (params) => mPost(`/recycle-service/delete/product`, params, zconfig) +const getTaskList = () => mGet(`/recycle-service/point-task/get/potn-task/list`, null, zconfig) +const getPointList = () => mGet(`/recycle-service/point-product/get/point-product-list`, null, zconfig) +const getPointProduct = (id) => mGet(`/recycle-service/point-product/buy/point-product/${id}`, null, zconfig) +const getBiddingActivity = (id) => mGet(`/recycle-service/get/bidding-activity-detail/${id}`, null, zconfig) +const getBiddingDetail = (id) => mGet(`/recycle-service/get/bidding-detail/${id}`, null, zconfig) +const biddingActivity = (id, params) => mPost(`/recycle-service/bid/${id}`, params, zconfig) +const getMyBiddingList = (params) => mGet(`/recycle-service/get/bidding-list`, params, zconfig) +const getBiddingList = (id) => mGet(`/recycle-service/get/bidding-list/${id}`, null, zconfig) +const getUserProduct = (id) => mGet(`/recycle-service/get/user-product/${id}`, null, zconfig) +const confirmBidding = (params) => mPost(`/recycle-service/confirm/bidding`, params, zconfig) +const cancelBidding = (id) => mPost(`/recycle-service/cancel/bidding-activity/${id}`, null, zconfig) +const getMyBidding = (id) => mGet(`/recycle-service/get/my-bidding/${id}`, null, zconfig) export { zconfig, @@ -75,6 +88,7 @@ export { getFactoryPrice, getFactoryCity, getIndexInfoId, + getIndexInfo, getFactoryList, getFactoryTodayList, getVehicleList, @@ -107,5 +121,17 @@ export { getBiddingInterval, getGoodProductList, statusProductInfo, - deleteProduct + deleteProduct, + getTaskList, + getPointList, + getPointProduct, + getBiddingActivity, + getBiddingDetail, + biddingActivity, + getMyBiddingList, + getBiddingList, + getUserProduct, + confirmBidding, + cancelBidding, + getMyBidding } \ No newline at end of file diff --git a/pages/bidding/detail/index.js b/pages/bidding/detail/index.js index 4853582..ee8b8d4 100644 --- a/pages/bidding/detail/index.js +++ b/pages/bidding/detail/index.js @@ -1,5 +1,5 @@ // pages/bidding/detail/index.js -const request = require('../../../utils/request') //导入模块 +import { getBiddingDetail, getBiddingActivity, getBiddingList, biddingActivity, confirmBidding, cancelBidding, getMyBidding } from "../../api/ztb" const util = require('../../../utils/util') const math = require('../../../utils/math') const event = require('../../../utils/event.js') @@ -7,7 +7,6 @@ import { $wuxCountDown } from '../../../components/index' const app = getApp() Page({ - /** * 页面的初始数据 */ @@ -45,9 +44,7 @@ Page({ fetchInfo: function(id){ if (this.data.type == 1) { wx.showLoading({ title: '加载中', mask: true }) - // recycle-service/get/bidding-activity-detail/{biddingActivityId} - request.get('/recycle-service/get/bidding-activity-detail/' + id).then(result => { - //成功回调 + getBiddingActivity(id).then(result => { this.setData({ type: this.data.type, biddingInfo: result.data, @@ -66,9 +63,7 @@ Page({ } else { this.biddingDialog = this.biddingDialog || this.selectComponent('#bidding-good') wx.showLoading({ title: '加载中', mask: true }) - // recycle-service/get/bidding-detail/{biddingId} - request.get('/recycle-service/get/bidding-detail/' + id).then(result => { - //成功回调 + getBiddingDetail(id).then(result => { if(result.data.status == 0 && this.data.frist){ this.expiredTime(result.data.biddingActivity.expiredTime, id) } else if(result.data.status == 1 && this.data.frist){ @@ -107,19 +102,13 @@ Page({ } }) }, - fetchBiddingInfo: function (biddingActivityId) { - request.get('/recycle-service/get/my-bidding/' + biddingActivityId).then(result => { - //成功回调 - this.setData({ - recordInfo: result.data - }) + getMyBidding(biddingActivityId).then(result => { + this.setData({ recordInfo: result.data }) }) }, - fetchBiddingList: function (biddingActivityId) { - request.get('/recycle-service/get/bidding-list/' + biddingActivityId).then(result => { - //成功回调 + getBiddingList(biddingActivityId).then(result => { var record = null if(this.data.biddingInfo.winBiddingId){ for (let index = 0; index < result.data.records.length; index++) { @@ -130,10 +119,7 @@ Page({ } } } - this.setData({ - recordList: result.data.records, - recordInfo: record - }) + this.setData({ recordList: result.data.records, recordInfo: record }) }) }, toShopInfo: function () { @@ -156,7 +142,7 @@ Page({ } return 0 }, - biddingActicity: function () { + showBiddingDialog: function () { var that = this this.wuxDialog.prompt({ offer: true, @@ -186,17 +172,12 @@ Page({ title: '加载中', mask: true }) - // /recycle-service/bid/{biddingActivityId} 参与报价 - request.post('/recycle-service/bid/' + this.data.biddingInfo.biddingActivity.id, { biddingUnitPrice: price }).then(result => { - //成功回调 + biddingActivity(this.data.biddingInfo.biddingActivity.id, { biddingUnitPrice: price }).then(result => { wx.hideLoading() util.showToast('报价成功') - this.setData({ - ['biddingInfo.unitPrice']: price - }) + this.setData({ ['biddingInfo.unitPrice']: price }) this.fetchBiddingList(this.data.biddingInfo.biddingActivity.id) }).catch(err => { - //异常回调 wx.hideLoading() util.showToast(err) }) @@ -221,13 +202,8 @@ Page({ }, cancelActivity: function(){ - wx.showLoading({ - title: '处理中', - mask: true - }) - // /recycle-service/bid/{biddingActivityId} 参与报价 - request.post('/recycle-service/cancel/bidding-activity/' + this.data.biddingInfo.id).then(result => { - //成功回调 + wx.showLoading({ title: '处理中', mask: true }) + cancelBidding(this.data.biddingInfo.id).then(result => { wx.hideLoading() util.showToast('竞价取消成功') event.emit('EventMessage', { what: 301, desc: 'bidding-cancel' }) @@ -238,26 +214,19 @@ Page({ util.showToast(err) }) }, - checkRecord: function(e){ if(this.data.biddingInfo.status == 0){ this.setData({recordIndex: e.currentTarget.dataset.index}) } }, - biddingConfrim: function(){ if(this.data.recordIndex < 0){ util.showToast('请选择一个报价') return } - wx.showLoading({ - title: '处理中', - mask: true - }) - // /recycle-service/bid/{biddingActivityId} 参与报价 + wx.showLoading({ title: '处理中', mask: true }) var biddingId = this.data.recordList[this.data.recordIndex].id - request.post('/recycle-service/confirm/bidding', { biddingId }).then(result => { - //成功回调 + confirmBidding({ biddingId }).then(result => { wx.hideLoading() util.showToast('确认报价成功') if (this.countDown) { @@ -276,20 +245,13 @@ Page({ util.showToast(err) }) }, - offerOrder: function(){ var productId = this.data.biddingInfo.biddingActivity.productId - wx.navigateTo({ - url: '/pages/morder/create/index?productId=' + productId + '&price=' + this.data.biddingInfo.unitPrice - }) + wx.navigateTo({ url: '/pages/morder/create/index?productId=' + productId + '&price=' + this.data.biddingInfo.unitPrice }) }, - restartActivity: function(){ - wx.redirectTo({ - url: '/pages/goods/create/index?id=' + this.data.biddingInfo.productId - }) + wx.redirectTo({ url: '/pages/goods/create/index?id=' + this.data.biddingInfo.productId }) }, - onUnload: function () { if (this.countDown) { this.countDown.stop() diff --git a/pages/bidding/detail/index.wxml b/pages/bidding/detail/index.wxml index 4cb6c5f..260e844 100644 --- a/pages/bidding/detail/index.wxml +++ b/pages/bidding/detail/index.wxml @@ -92,7 +92,7 @@ 店铺 - 修改报价 + 修改报价 立即下单 diff --git a/pages/bidding/index/index.js b/pages/bidding/index/index.js index 40ca19f..b1c3c7f 100644 --- a/pages/bidding/index/index.js +++ b/pages/bidding/index/index.js @@ -1,5 +1,5 @@ // pages/morder/index/index.js -const request = require('../../../utils/request') //导入模块 +import { getMyBiddingList } from "../../api/ztb" const util = require('../../../utils/util') const event = require('../../../utils/event.js') const app = getApp() @@ -60,13 +60,9 @@ Page({ if (this.data.loading) { this.data.requesting = true } else { - this.setData({ - requesting: true - }) + this.setData({ requesting: true }) } - // /product/cheapList特价产品列表 - request.get('/recycle-service/get/bidding-list', this.data.form).then(result => { - //成功回调 + getMyBiddingList(this.data.form).then(result => { if (result.data.records.length) { var respList = result.data.records let nowList = `orderList[${this.data.orderList.length}]` diff --git a/pages/html/integral/index.js b/pages/html/integral/index.js index bed6bce..87dfb81 100644 --- a/pages/html/integral/index.js +++ b/pages/html/integral/index.js @@ -1,8 +1,8 @@ // pages/ztbvip/index.js -const request = require('../../../utils/request') //导入模块 +import { getBaseInfo, getTaskList, getPointProduct } from "../../api/ztb" const util = require('../../../utils/util') -const events = require('../../../utils/event.js') -import WxCountUp from '../../../utils/countup.js' +const events = require('../../../utils/event') +import WxCountUp from '../../../utils/countup' const app = getApp() Page({ @@ -29,13 +29,11 @@ Page({ }, fetchUserInfo: function () { wx.showLoading({ title: '处理中', mask: true }) - // /user/userInfo 获取用户信息 - request.get('/recycle-service/user/get/base-info').then(result => { + getBaseInfo().then(result => { app.globalData.userInfo = result.data this.countUp.update(app.globalData.userInfo.memberRewardPoint) }) - //point-task/get/potn-task/list查询所有积分任务 - request.get('/recycle-service/point-task/get/potn-task/list').then(result => { + getTaskList().then(result => { var shareIndex = -1 for (let index = 0; index < result.data.length; index++) { const element = result.data[index] @@ -49,8 +47,7 @@ Page({ } this.setData({ taskList: result.data }) }) - // /point-product/get/point-product-list 查询所有积分产品 - request.get('/recycle-service/point-product/get/point-product-list').then(result => { + getPointList().then(result => { this.setData({ pointList: result.data }) wx.hideLoading() }).catch(error => { @@ -106,12 +103,11 @@ Page({ return } wx.showLoading({ title: '处理中', mask: true }) - // /point-product/buy/point-product/{id} 购买积分产品 - request.get('/recycle-service/point-product/buy/point-product/' + item.id).then(res => { + getPointProduct(item.id).then(res => { util.showToast('兑换成功') app.globalData.userInfo.isVIP = 1 events.emit('EventMessage', { what: 200, desc: 'Vip' }) - request.get('/recycle-service/point-product/get/point-product-list').then(result => { + getPointList().then(result => { this.setData({ pointList: result.data }) wx.hideLoading() app.globalData.userInfo.memberRewardPoint -= parseInt(item.price) diff --git a/pages/html/notice/index.js b/pages/html/notice/index.js index a3db67e..14f24b9 100644 --- a/pages/html/notice/index.js +++ b/pages/html/notice/index.js @@ -1,26 +1,21 @@ // pages/html/notice/index.js -const request = require('../../../utils/request') //导入模块 +import { getIndexInfo } from "../../api/ztb" const util = require('../../../utils/util') Page({ - /** * 页面的初始数据 */ data: { noticeInfo: null }, - /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if(!util.isEmpty(options.id)){ - wx.showLoading({ - title: '加载中', - mask: true - }) - request.get('/recycle-service/get/index-info/' + options.id).then(result => { + wx.showLoading({ title: '加载中', mask: true }) + getIndexInfo(options.id).then(result => { wx.hideLoading() this.setData({ noticeInfo: result.data }) }).catch(err => { diff --git a/pages/mall/detail/index.js b/pages/mall/detail/index.js index dd578ca..eb471a7 100644 --- a/pages/mall/detail/index.js +++ b/pages/mall/detail/index.js @@ -1,6 +1,6 @@ // pages/order/order-info/index.js +import { biddingActivity, getBiddingList, getUserProduct } from "../../api/ztb" import { $wuxCountDown } from '../../../components/index' -const request = require('../../../utils/request') //导入模块 const util = require('../../../utils/util') const math = require('../../../utils/math') const event = require('../../../utils/event.js') @@ -51,9 +51,7 @@ Page({ } }, fetchInfo: function (id) { - // /product/{id}产品详情 - request.get('/recycle-service/get/user-product/' + id).then(result => { - //成功回调 + getUserProduct(id).then(result => { wx.hideLoading() if (Number(result.data.minBuyNum) > 1) { this.data.form.number = parseInt(result.data.minBuyNum) @@ -88,15 +86,7 @@ Page({ }] }) } else if (result.data.bidType == 2 && (result.data.biddingActivityStatus != 0)) { - // this.wuxDialog.open({ - // maskClosable: false, - // title: '温馨提示', - // content: '该商品的竞价已经结束,无法报价', - // buttons: [{ - // text: '确定', - // type: 'primary' - // }] - // }) + } else if (result.data.bidType == 2 && result.data.biddingActivityStatus == 0) { this.fetchBiddingList(result.data.biddingActivityId) if(this.data.frist){ @@ -104,7 +94,6 @@ Page({ } } }).catch(err => { - //异常回调 wx.hideLoading() util.showToast(err) }) @@ -134,8 +123,7 @@ Page({ this.setData({ current: e.detail.current + 1 }) }, fetchBiddingList: function (biddingActivityId) { - request.get('/recycle-service/get/bidding-list/' + biddingActivityId).then(result => { - //成功回调 + getBiddingList(biddingActivityId).then(result => { for (let index = 0; index < result.data.records.length; index++) { const element = result.data.records[index] if(element.isMine && app.globalData.userInfo){ @@ -154,7 +142,6 @@ Page({ }, // 事件处理 onEvent: function (message) { - console.log('mall>>order>>onEvent', message) if (message.what == 1) { } else if (message.what == 10) { @@ -179,9 +166,7 @@ Page({ }, bindended: function () { this.videoContext.exitFullScreen() - this.setData({ - visible: false - }) + this.setData({ visible: false }) }, // 图片查看 viewImage: function (e) { @@ -195,10 +180,7 @@ Page({ } imgList.push(this.data.imgList[index]) } - wx.previewImage({ - urls: imgList, - current: e.currentTarget.dataset.url - }); + wx.previewImage({ urls: imgList, current: e.currentTarget.dataset.url }) }, // 进入支付流程 offerProject: function (e) { @@ -268,12 +250,6 @@ Page({ } return 0 }, - // 就行登录流程;然后进入下一步的支付操作 - onGotPhoneNumber: function (e) { - request.loginWechat(e.detail).then(data => { - this.offerProject() - }) - }, onShareAppMessage: function () { var title = this.data.orderInfo.locProvinceName + this.data.orderInfo.locCityName if(this.data.orderInfo.bidType == 2){ @@ -323,17 +299,8 @@ Page({ util.showToast('请输入合理的报价') return } - // if(Number(price) < Number(this.data.orderInfo.unitPrice)){ - // util.showToast('您输入单价低于最低报价,请重新输入') - // return - // } - wx.showLoading({ - title: '加载中', - mask: true - }) - // /recycle-service/bid/{biddingActivityId} 参与报价 - request.post('/recycle-service/bid/' + this.data.orderInfo.biddingActivityId, { biddingUnitPrice: price }).then(result => { - //成功回调 + wx.showLoading({ title: '加载中', mask: true }) + biddingActivity(this.data.orderInfo.biddingActivityId, { biddingUnitPrice: price }).then(result => { wx.hideLoading() this.fetchBiddingList(this.data.orderInfo.biddingActivityId) util.showToast('报价成功')