Commit 53694284 by 施宇

11

parent d211da47
...@@ -16,34 +16,29 @@ Page({ ...@@ -16,34 +16,29 @@ Page({
info: null, info: null,
editOrShow: -1, //1编辑 2在线沟通 editOrShow: -1, //1编辑 2在线沟通
goodId: "", goodId: "",
type: "", type: ""
isShowImg: false,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function(options) {
let me = this;
this.setData({ this.setData({
goodId: options.goodId || '', goodId: options.goodId || '',
type: options.type || '' type: options.type || ''
});
this.getData(false)
getApp().globalData.bus.off('editGood');
getApp().globalData.bus.on('editGood', () => {
me.getData(true)
}) })
console.log(options)
}, },
getData: function() { getData: function(bool) {
let me = this; let me = this;
let token = wx.getStorageSync('access_token'); let token = wx.getStorageSync('access_token');
let url = "";
let goodId = me.data.goodId; let goodId = me.data.goodId;
let type = me.data.type; let type = me.data.type;
// if (type == 1) {
// url = apis.goodsInfo;
// } else if (type == 2 || type == 3) {
// url = apis.goodsSearch;
// } else {
// return;
// }
getData(apis.goodsSearch, 'get', { getData(apis.goodsSearch, 'get', {
"goods_id/eq": goodId, "goods_id/eq": goodId,
"token": token, "token": token,
...@@ -59,12 +54,18 @@ Page({ ...@@ -59,12 +54,18 @@ Page({
if (type == 1) { if (type == 1) {
me.setData({ me.setData({
editOrShow: 1 editOrShow: 1
}) });
if (bool) {
getApp().globalData.bus.emit('editGoodSuccess', res.goods_list[goodId]);
}
} else if (type == 2 || type == 3) { } else if (type == 2 || type == 3) {
if (userId == targetId) { if (userId == targetId) {
me.setData({ me.setData({
editOrShow: 1 editOrShow: 1
}) });
if (bool) {
getApp().globalData.bus.emit('editGoodSuccess', res.goods_list[goodId]);
}
} else { } else {
me.setData({ me.setData({
editOrShow: 2 editOrShow: 2
...@@ -142,13 +143,7 @@ Page({ ...@@ -142,13 +143,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function() { onShow: function() {
if (this.data.isShowImg) {
this.setData({
isShowImg: false
})
} else {
this.getData()
}
}, },
/** /**
...@@ -193,9 +188,6 @@ Page({ ...@@ -193,9 +188,6 @@ Page({
previewImage: function() { previewImage: function() {
let img = this.data.info.goods_images; let img = this.data.info.goods_images;
if (img) { if (img) {
this.setData({
isShowImg: true
})
wx.previewImage({ wx.previewImage({
urls: [img] urls: [img]
}) })
......
...@@ -92,7 +92,11 @@ Page({ ...@@ -92,7 +92,11 @@ Page({
isClick: true isClick: true
}); });
setTimeout(() => { setTimeout(() => {
wx.navigateBack() wx.navigateBack();
getApp().globalData.bus.emit('addBj');
if (me.data.type == 1){
getApp().globalData.bus.emit('addFirstBj', me.data.inquiryItemsId);
}
}, 1000) }, 1000)
} else { } else {
......
...@@ -49,8 +49,7 @@ Page({ ...@@ -49,8 +49,7 @@ Page({
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '新增商品' title: '新增商品'
}) })
} };
}, },
getGoodData: function() { getGoodData: function() {
let me = this; let me = this;
......
...@@ -25,6 +25,7 @@ Page({ ...@@ -25,6 +25,7 @@ Page({
onLoad: function(options) { onLoad: function(options) {
let me = this; let me = this;
this.getData(); this.getData();
getApp().globalData.bus.off('addXj');
getApp().globalData.bus.on('addXj', () => { getApp().globalData.bus.on('addXj', () => {
me.setData({ me.setData({
priceList: null, priceList: null,
...@@ -33,6 +34,18 @@ Page({ ...@@ -33,6 +34,18 @@ Page({
isShowBottom: false, isShowBottom: false,
}); });
me.getData(); me.getData();
});
getApp().globalData.bus.off('addFirstBj');
getApp().globalData.bus.on('addFirstBj', (id) => {
let index = me.data.priceList.findIndex((value, index, arr) => {
return value.inquiry_items_id == id
});
if (index !== -1) {
me.data.priceList[index].offer_num+=1;
me.setData({
priceList: me.data.priceList
})
}
}) })
}, },
getData: function() { getData: function() {
......
...@@ -21,7 +21,7 @@ Page({ ...@@ -21,7 +21,7 @@ Page({
type: 0, //1 看别人的询价 2给别人报价 3分享进来的 type: 0, //1 看别人的询价 2给别人报价 3分享进来的
inquiryItemsId: "", inquiryItemsId: "",
offerId: "", offerId: "",
isShowImg: false, // isShowImg: false,
isShareType: 0, //分享后点进来的页面 1代表自己的询价 2代表别人的询价 isShareType: 0, //分享后点进来的页面 1代表自己的询价 2代表别人的询价
}, },
...@@ -29,16 +29,26 @@ Page({ ...@@ -29,16 +29,26 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function(options) {
let me = this;
this.setData({ this.setData({
inquiryItemsId: options.inquiryItemsId || '', inquiryItemsId: options.inquiryItemsId || '',
type: options.type || '', type: options.type || '',
offerId: options.offerId || '' offerId: options.offerId || ''
}); });
console.log(options)
this.getTopInfo(); this.getTopInfo();
if (this.data.type == 1) { if (this.data.type == 1) {
this.getOthertBj(); this.getOthertBj();
} else if (this.data.type == 2) {
this.getSelfBj();
} }
getApp().globalData.bus.off('addBj');
getApp().globalData.bus.on('addBj', function() {
me.setData({
priceList: null,
total: 0,
});
me.getSelfBj();
});
}, },
getTopInfo: function() { getTopInfo: function() {
let me = this; let me = this;
...@@ -156,19 +166,19 @@ Page({ ...@@ -156,19 +166,19 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function() { onShow: function() {
if (this.data.type == 2 || this.data.isShareType == 2) { // if (this.data.type == 2 || this.data.isShareType == 2) {
if (this.data.isShowImg) { // if (this.data.isShowImg) {
this.setData({ // this.setData({
isShowImg: false // isShowImg: false
}) // })
} else { // } else {
this.setData({ // this.setData({
priceList: null, // priceList: null,
total: 0, // total: 0,
}); // });
this.getSelfBj() // this.getSelfBj()
} // }
} // }
}, },
...@@ -249,11 +259,11 @@ Page({ ...@@ -249,11 +259,11 @@ Page({
previewImage: function() { previewImage: function() {
let img = this.data.topInfo.goods_images; let img = this.data.topInfo.goods_images;
if (img) { if (img) {
if (this.data.type == 2) { // if (this.data.type == 2) {
this.setData({ // this.setData({
isShowImg: true // isShowImg: true
}) // })
} // }
wx.previewImage({ wx.previewImage({
urls: [img] urls: [img]
}) })
......
...@@ -30,6 +30,7 @@ Page({ ...@@ -30,6 +30,7 @@ Page({
onLoad: function(options) { onLoad: function(options) {
let key = options.key; let key = options.key;
let me = this;
this.setData({ this.setData({
key: key, key: key,
confirmKey: key, confirmKey: key,
...@@ -37,6 +38,7 @@ Page({ ...@@ -37,6 +38,7 @@ Page({
}); });
this.storageKey(key) this.storageKey(key)
this.getData(); this.getData();
getApp().globalData.bus.off('addXj');
getApp().globalData.bus.on('addXj', () => { getApp().globalData.bus.on('addXj', () => {
if (me.data.tabIndex == 2) { if (me.data.tabIndex == 2) {
me.setData({ me.setData({
...@@ -48,6 +50,7 @@ Page({ ...@@ -48,6 +50,7 @@ Page({
me.getData(); me.getData();
} }
}); });
getApp().globalData.bus.off('addGood');
getApp().globalData.bus.on('addGood', () => { getApp().globalData.bus.on('addGood', () => {
if (me.data.tabIndex == 1) { if (me.data.tabIndex == 1) {
me.setData({ me.setData({
...@@ -58,10 +61,29 @@ Page({ ...@@ -58,10 +61,29 @@ Page({
}); });
me.getData(); me.getData();
} }
}) });
getApp().globalData.bus.on('editGood', () => { getApp().globalData.bus.off('editGoodSuccess');
if (me.data.tabIndex == 1) { getApp().globalData.bus.on('editGoodSuccess', (params) => {
console.log('编辑商品') let index = me.data.priceList.findIndex((value, index, arr) => {
return value.goods_id == params.goods_id
});
if (index !== -1) {
me.data.priceList[index] = params;
me.setData({
priceList: me.data.priceList
})
}
});
getApp().globalData.bus.off('addFirstBj');
getApp().globalData.bus.on('addFirstBj', (id) => {
let index = me.data.priceList.findIndex((value, index, arr) => {
return value.inquiry_items_id == id
});
if (index !== -1) {
me.data.priceList[index].offer_num += 1;
me.setData({
priceList: me.data.priceList
})
} }
}) })
}, },
......
// pages/tab/good/good.js // pages/tab/good/good.js
import { getData, judgeToken } from '../../../utils/util.js'; import {
import { apis } from '../../../utils/api.js'; getData,
judgeToken
} from '../../../utils/util.js';
import {
apis
} from '../../../utils/api.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
priceList: null,//商品数据 priceList: null, //商品数据
limit: 10,//每页的条数 limit: 10, //每页的条数
p: 1,//当前页面 p: 1, //当前页面
total: 0, total: 0,
time: "", time: "",
key: "", key: "",
confirmKey: "", confirmKey: "",
isShowBottom:false, isShowBottom: false,
isFixed:false, isFixed: false,
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function(options) {
let me = this; let me = this;
if (judgeToken(true)) { if (judgeToken(true)) {
this.getData(); this.getData();
...@@ -34,17 +39,25 @@ Page({ ...@@ -34,17 +39,25 @@ Page({
isShowBottom: false, isShowBottom: false,
}); });
me.getData(); me.getData();
}) });
getApp().globalData.bus.on('editGood', () => { getApp().globalData.bus.on('editGoodSuccess', (params) => {
console.log('编辑商品') let index = me.data.priceList.findIndex((value, index, arr) => {
return value.goods_id == params.goods_id
});
if (index !== -1) {
me.data.priceList[index] = params;
me.setData({
priceList: me.data.priceList
})
}
}) })
}, },
bindKeyInput: function (e) { bindKeyInput: function(e) {
this.setData({ this.setData({
key: e.detail.value key: e.detail.value
}) })
}, },
bindKeyConfirm: function () { bindKeyConfirm: function() {
let key = this.data.key; let key = this.data.key;
this.setData({ this.setData({
confirmKey: key, confirmKey: key,
...@@ -52,17 +65,20 @@ Page({ ...@@ -52,17 +65,20 @@ Page({
p: 1, p: 1,
total: 0, total: 0,
time: "", time: "",
isShowBottom:false isShowBottom: false
}); });
this.getData(); this.getData();
}, },
getData: function (isRefresh) { getData: function(isRefresh) {
let me = this; let me = this;
let token = wx.getStorageSync('access_token') let token = wx.getStorageSync('access_token')
getData(apis.goodsInfo,'get', { getData(apis.goodsInfo, 'get', {
offset: me.data.limit, p: me.data.p, token: token, 'goods_name/like': me.data.confirmKey offset: me.data.limit,
}, function (res) { p: me.data.p,
token: token,
'goods_name/like': me.data.confirmKey
}, function(res) {
if (res.errcode === 0) { if (res.errcode === 0) {
let newArr = []; let newArr = [];
if (me.data.p > 1) { if (me.data.p > 1) {
...@@ -80,7 +96,7 @@ Page({ ...@@ -80,7 +96,7 @@ Page({
priceList: newArr, priceList: newArr,
total: res.total, total: res.total,
}); });
if (isRefresh){ if (isRefresh) {
wx.stopPullDownRefresh() wx.stopPullDownRefresh()
} }
} else if (res.errcode === 110001 || res.errcode === 103001) { } else if (res.errcode === 110001 || res.errcode === 103001) {
...@@ -94,21 +110,21 @@ Page({ ...@@ -94,21 +110,21 @@ Page({
} }
} }
}, isRefresh?false:true) }, isRefresh ? false : true)
}, },
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function () { onReady: function() {
}, },
onPageScroll:function(e){ onPageScroll: function(e) {
if(e.scrollTop>90){ if (e.scrollTop > 90) {
this.setData({ this.setData({
isFixed:true isFixed: true
}) })
}else{ } else {
this.setData({ this.setData({
isFixed: false isFixed: false
}) })
...@@ -117,44 +133,44 @@ Page({ ...@@ -117,44 +133,44 @@ Page({
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function() {
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function() {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function() {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { onPullDownRefresh: function() {
this.setData({ this.setData({
p: 1, p: 1,
isShowBottom: false isShowBottom: false
}); });
this.getData(true); this.getData(true);
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function() {
let allPage = Math.ceil(this.data.total / this.data.limit); let allPage = Math.ceil(this.data.total / this.data.limit);
let p = this.data.p; let p = this.data.p;
if (p == allPage) { if (p == allPage) {
this.setData({ this.setData({
isShowBottom:true isShowBottom: true
}); });
return return
} else { } else {
...@@ -164,7 +180,7 @@ Page({ ...@@ -164,7 +180,7 @@ Page({
this.getData(); this.getData();
} }
}, },
fbGood: function () { fbGood: function() {
wx.navigateTo({ wx.navigateTo({
url: "/pages/form/good/index", url: "/pages/form/good/index",
}) })
......
...@@ -27,7 +27,7 @@ Page({ ...@@ -27,7 +27,7 @@ Page({
onLoad: function (options) { onLoad: function (options) {
let me = this; let me = this;
wx.removeStorageSync('homeToken') wx.removeStorageSync('homeToken')
this.getData(false); this.getData();
if (!judgeToken()) { if (!judgeToken()) {
wx.setStorageSync('homeToken', 1) wx.setStorageSync('homeToken', 1)
}; };
...@@ -83,9 +83,9 @@ Page({ ...@@ -83,9 +83,9 @@ Page({
}) })
} }
}, true) }, false)
}, },
getData: function (bool) { getData: function () {
let me = this; let me = this;
let url, token = wx.getStorageSync('access_token') let url, token = wx.getStorageSync('access_token')
if (!token) { if (!token) {
...@@ -121,7 +121,7 @@ Page({ ...@@ -121,7 +121,7 @@ Page({
priceList: [] priceList: []
}) })
} }
}, bool) }, true)
} }
}, },
/** /**
...@@ -138,7 +138,7 @@ Page({ ...@@ -138,7 +138,7 @@ Page({
this.getTopData(); this.getTopData();
if (judgeToken()) { if (judgeToken()) {
if (wx.getStorageSync('homeToken')) { if (wx.getStorageSync('homeToken')) {
this.getData(false); this.getData();
wx.removeStorageSync('homeToken') wx.removeStorageSync('homeToken')
} }
......
...@@ -23,7 +23,7 @@ Page({ ...@@ -23,7 +23,7 @@ Page({
let me = this; let me = this;
if (judgeToken(true)) { if (judgeToken(true)) {
this.getData(); this.getData();
} };
getApp().globalData.bus.on('addXj', () => { getApp().globalData.bus.on('addXj', () => {
if (me.data.tabIndex == 1) { if (me.data.tabIndex == 1) {
me.setData({ me.setData({
......
// const auth_url = 'https://authapi.icsales.com'; const auth_url = 'https://authapi.icsales.com';
// const so_url = 'https://soapi.icsales.com'; const so_url = 'https://soapi.icsales.com';
// const offer_url = "https://offerapi.icsales.com"; const offer_url = "https://offerapi.icsales.com";
// const user_url = 'https://userapi.icsales.com'; const user_url = 'https://userapi.icsales.com';
// const goods_url = 'https://goodsapi.icsales.com'; const goods_url = 'https://goodsapi.icsales.com';
// const home_url = 'https://home.icsales.com'; const home_url = 'https://home.icsales.com';
const auth_url = 'http://authapi.icsales.cc'; // const auth_url = 'http://authapi.icsales.cc';
const so_url = 'http://soapi.icsales.cc'; // const so_url = 'http://soapi.icsales.cc';
const offer_url = "http://offerapi.icsales.cc"; // const offer_url = "http://offerapi.icsales.cc";
const user_url = 'http://userapi.icsales.cc'; // const user_url = 'http://userapi.icsales.cc';
const goods_url = 'http://goodsapi.icsales.cc'; // const goods_url = 'http://goodsapi.icsales.cc';
const home_url = 'http://home.icsales.cc'; // const home_url = 'http://home.icsales.cc';
const apis = { const apis = {
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment