Commit 95dba4d9 by 梁建民

Merge branch 'master' of http://119.23.72.7/shiyu/icsalesProgram

parents 459f530b 1d4bac63
......@@ -56,7 +56,7 @@
width: 68rpx;
height: 68rpx;
/* margin-left:24rpx; */
border-radius: 8rpx;
border-radius: 50% 50%;
float: left;
margin: 0 24rpx 0 0;
}
......
......@@ -2,7 +2,8 @@
import {
getData,
changeTime,
judgeToken
judgeToken,
tips
} from '../../../utils/util.js';
import {
apis
......@@ -22,7 +23,7 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
onLoad: function (options) {
let me = this;
this.setData({
goodId: options.goodId || '',
......@@ -34,7 +35,7 @@ Page({
me.getData(true)
})
},
getData: function(bool) {
getData: function (bool) {
let me = this;
let token = wx.getStorageSync('access_token');
let goodId = me.data.goodId;
......@@ -42,7 +43,7 @@ Page({
getData(apis.goodsSearch, 'get', {
"goods_id/eq": goodId,
"token": token,
}, function(res) {
}, function (res) {
if (res.errcode == 0) {
if (res.total == 0) {
me.setData({
......@@ -85,7 +86,7 @@ Page({
}
}, true)
},
editGood: function() {
editGood: function () {
if (!judgeToken(true) && this.data.type == 3) {
return
}
......@@ -93,7 +94,7 @@ Page({
url: "/pages/form/good/index?goodId=" + this.data.goodId,
})
},
sendTemplate: function() {
sendTemplate: function () {
if (!judgeToken(true) && this.data.type == 3) {
return
}
......@@ -135,57 +136,57 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
onReachBottom: function () {
},
companyHome:function(){//跳转到公司首页
companyHome: function () {//跳转到公司首页
let userId = wx.getStorageSync("user_id");
if (this.data.info.user_id == userId){
if (this.data.info.user_id == userId) {
wx.navigateTo({
url: "/pages/person/company/index?type=1"
})
}else{
} else {
wx.navigateTo({
url: "/pages/person/company/index?type=2&userId=" + this.data.info.user_id
})
}
},
onShareAppMessage: function(res) {
onShareAppMessage: function (res) {
let me = this;
wx.reportAnalytics('share_good', {
good_name: me.data.info.goods_name,
......@@ -197,7 +198,7 @@ Page({
path: "/pages/detail/good/index?type=3&goodId=" + me.data.goodId
}
},
previewImage: function() {
previewImage: function () {
let img = this.data.info.goods_images;
if (img) {
wx.previewImage({
......@@ -207,8 +208,19 @@ Page({
return
}
},
refreshGood:function(){
console.log(this.data.goodId)
refreshGood: function () {
let me = this;
console.log(this.data.goodId)
getData(apis.goodsSave, 'get', {
token: wx.getStorageSync('access_token') || '',
goods_id: me.data.goodId
}, function (res) {
if (res.errcode == 0) {
tips('操作成功')
} else {
tips(res.errmsg)
}
}, true)
}
})
\ No newline at end of file
......@@ -2,10 +2,10 @@
<view class="head boxsiz row verCenter bothSide">
<view class="row">
<view class="pic">
<cover-image class="im" src="{{userInfo.avatar||'/res/images/imgs/heads.png'}}"></cover-image>
<cover-image class="im" src="{{userInfo.avatar||userInfo.wechat_oauth.oauth_head||'/res/images/imgs/heads.png'}}"></cover-image>
</view>
<view class="txt">
<text class="t1">{{userInfo.company_name||'--'}}</text>
<text class="t1">{{userInfo.company_name||userInfo.wechat_oauth.oauth_nickname||'--'}}</text>
<view class="row">
<view class="company-txt" wx:if="{{userInfo.auth_type!=''&&userInfo.auth_type!=undefined }}">
<text class="icon iconfont iconiconxiantiaoshouji24"></text>
......@@ -33,7 +33,7 @@
<text class="edit">编辑</text>
</view>
</view>
<view class="tab row rowCenter verCenter" bindtap="toCompanyData">
<view class="tab row rowCenter verCenter" bindtap="toCompanyData">
<view class="v">
<text class="t1">{{business.goods}}</text>
<text class="t2">商品</text>
......
......@@ -88,6 +88,8 @@ Page({
wx.removeStorageSync('access_token');
wx.removeStorageSync('user_id');
wx.removeStorageSync('company_name');
wx.removeStorageSync('avatar');
wx.removeStorageSync('myUsername');
wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth');
......
......@@ -39,24 +39,24 @@ const onMessageError = (err) => {
const getImUser = () => {
let token = wx.getStorageSync('access_token') || '';
let imName = wx.getStorageSync('myUsername') || '';
let imPassword = wx.getStorageSync('myPassword') || '';
if (imName && imPassword) {
conn.open({
apiUrl: WebIM.config.apiURL,
user: imName,
pwd: imPassword,
appKey: WebIM.config.appkey
});
return;
}
getData(apis.authme, 'get', {
// let imName = wx.getStorageSync('myUsername') || '';
// let imPassword = wx.getStorageSync('myPassword') || '';
// if (imName && imPassword) {
// conn.open({
// apiUrl: WebIM.config.apiURL,
// user: imName,
// pwd: imPassword,
// appKey: WebIM.config.appkey
// });
// return;
// }
getData(apis.userInfo, 'get', {
"token": token,
}, function(res) {
if (res.errcode == 0) {
wx.setStorageSync('user_id', res.data.user_id + '');
wx.setStorageSync('avatar', res.data.avatar);
wx.setStorageSync('company_name', res.data.company_name);
wx.setStorageSync('avatar', res.data.avatar || res.data.wechat_oauth.oauth_head);
wx.setStorageSync('company_name', res.data.company_name || res.data.wechat_oauth.oauth_nickname);
wx.setStorageSync("myUsername", res.data.im_username);
wx.setStorageSync("myPassword", res.data.im_password);
conn.open({
......
......@@ -3,7 +3,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
wx.showNavigationBarLoading();
var token, header;
var token, header, tokenInvalid;
//获取token
token = wx.getStorageSync('access_token');
......@@ -51,21 +51,35 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
//处理token失效的情况
if (res.data.hasOwnProperty('data')) {
if (res.data.errcode == 501 || res.data.errcode == 501) {
wx.redirectTo({
url: '/pages/person/login/index'
});
tokenInvalid = true
// wx.redirectTo({
// url: '/pages/person/login/index'
// });
} else {
typeof callBack == "function" && callBack(res.data, "");
}
} else {
if (res.data.errcode == 501 || res.data.errcode == 501) {
wx.redirectTo({
url: '/pages/person/login/index'
});
tokenInvalid = true
// wx.redirectTo({
// url: '/pages/person/login/index'
// });
} else {
typeof callBack == "function" && callBack(res.data, "");
}
}
if (tokenInvalid){
wx.removeStorageSync('access_token');
wx.removeStorageSync('user_id');
wx.removeStorageSync('company_name');
wx.removeStorageSync('avatar');
wx.removeStorageSync('myUsername');
wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth');
wx.reLaunch({
url: '/pages/person/auth/index',
});
}
},
fail: (err) => {
......
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