Commit 53694284 by 施宇

11

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