Commit 5b6e385d by 施宇

11

parent b386e4bc
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
width: 68rpx; width: 68rpx;
height: 68rpx; height: 68rpx;
/* margin-left:24rpx; */ /* margin-left:24rpx; */
border-radius: 8rpx; border-radius: 50% 50%;
float: left; float: left;
margin: 0 24rpx 0 0; margin: 0 24rpx 0 0;
} }
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
import { import {
getData, getData,
changeTime, changeTime,
judgeToken judgeToken,
tips
} from '../../../utils/util.js'; } from '../../../utils/util.js';
import { import {
apis apis
...@@ -22,7 +23,7 @@ Page({ ...@@ -22,7 +23,7 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function (options) {
let me = this; let me = this;
this.setData({ this.setData({
goodId: options.goodId || '', goodId: options.goodId || '',
...@@ -34,7 +35,7 @@ Page({ ...@@ -34,7 +35,7 @@ Page({
me.getData(true) me.getData(true)
}) })
}, },
getData: function(bool) { getData: function (bool) {
let me = this; let me = this;
let token = wx.getStorageSync('access_token'); let token = wx.getStorageSync('access_token');
let goodId = me.data.goodId; let goodId = me.data.goodId;
...@@ -42,7 +43,7 @@ Page({ ...@@ -42,7 +43,7 @@ Page({
getData(apis.goodsSearch, 'get', { getData(apis.goodsSearch, 'get', {
"goods_id/eq": goodId, "goods_id/eq": goodId,
"token": token, "token": token,
}, function(res) { }, function (res) {
if (res.errcode == 0) { if (res.errcode == 0) {
if (res.total == 0) { if (res.total == 0) {
me.setData({ me.setData({
...@@ -85,7 +86,7 @@ Page({ ...@@ -85,7 +86,7 @@ Page({
} }
}, true) }, true)
}, },
editGood: function() { editGood: function () {
if (!judgeToken(true) && this.data.type == 3) { if (!judgeToken(true) && this.data.type == 3) {
return return
} }
...@@ -93,7 +94,7 @@ Page({ ...@@ -93,7 +94,7 @@ Page({
url: "/pages/form/good/index?goodId=" + this.data.goodId, url: "/pages/form/good/index?goodId=" + this.data.goodId,
}) })
}, },
sendTemplate: function() { sendTemplate: function () {
if (!judgeToken(true) && this.data.type == 3) { if (!judgeToken(true) && this.data.type == 3) {
return return
} }
...@@ -135,57 +136,57 @@ Page({ ...@@ -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"); let userId = wx.getStorageSync("user_id");
if (this.data.info.user_id == userId){ if (this.data.info.user_id == userId) {
wx.navigateTo({ wx.navigateTo({
url: "/pages/person/company/index?type=1" url: "/pages/person/company/index?type=1"
}) })
}else{ } else {
wx.navigateTo({ wx.navigateTo({
url: "/pages/person/company/index?type=2&userId=" + this.data.info.user_id url: "/pages/person/company/index?type=2&userId=" + this.data.info.user_id
}) })
} }
}, },
onShareAppMessage: function(res) { onShareAppMessage: function (res) {
let me = this; let me = this;
wx.reportAnalytics('share_good', { wx.reportAnalytics('share_good', {
good_name: me.data.info.goods_name, good_name: me.data.info.goods_name,
...@@ -197,7 +198,7 @@ Page({ ...@@ -197,7 +198,7 @@ Page({
path: "/pages/detail/good/index?type=3&goodId=" + me.data.goodId path: "/pages/detail/good/index?type=3&goodId=" + me.data.goodId
} }
}, },
previewImage: function() { previewImage: function () {
let img = this.data.info.goods_images; let img = this.data.info.goods_images;
if (img) { if (img) {
wx.previewImage({ wx.previewImage({
...@@ -207,8 +208,19 @@ Page({ ...@@ -207,8 +208,19 @@ Page({
return return
} }
}, },
refreshGood:function(){ refreshGood: function () {
let me = this;
console.log(this.data.goodId) 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 @@ ...@@ -2,10 +2,10 @@
<view class="head boxsiz row verCenter bothSide"> <view class="head boxsiz row verCenter bothSide">
<view class="row"> <view class="row">
<view class="pic"> <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>
<view class="txt"> <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="row">
<view class="company-txt" wx:if="{{userInfo.auth_type!=''&&userInfo.auth_type!=undefined }}"> <view class="company-txt" wx:if="{{userInfo.auth_type!=''&&userInfo.auth_type!=undefined }}">
<text class="icon iconfont iconiconxiantiaoshouji24"></text> <text class="icon iconfont iconiconxiantiaoshouji24"></text>
......
...@@ -88,6 +88,8 @@ Page({ ...@@ -88,6 +88,8 @@ Page({
wx.removeStorageSync('access_token'); wx.removeStorageSync('access_token');
wx.removeStorageSync('user_id'); wx.removeStorageSync('user_id');
wx.removeStorageSync('company_name');
wx.removeStorageSync('avatar');
wx.removeStorageSync('myUsername'); wx.removeStorageSync('myUsername');
wx.removeStorageSync('myPassword'); wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth'); wx.removeStorageSync('auth');
......
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 welfare_url = 'https://welfareapi.icsales.com' // const welfare_url = 'https://welfareapi.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 welfare_url = 'http://welfareapi.icsales.cc'; const welfare_url = 'http://welfareapi.icsales.cc';
const apis = { const apis = {
......
...@@ -39,24 +39,24 @@ const onMessageError = (err) => { ...@@ -39,24 +39,24 @@ const onMessageError = (err) => {
const getImUser = () => { const getImUser = () => {
let token = wx.getStorageSync('access_token') || ''; let token = wx.getStorageSync('access_token') || '';
let imName = wx.getStorageSync('myUsername') || ''; // let imName = wx.getStorageSync('myUsername') || '';
let imPassword = wx.getStorageSync('myPassword') || ''; // let imPassword = wx.getStorageSync('myPassword') || '';
if (imName && imPassword) { // if (imName && imPassword) {
conn.open({ // conn.open({
apiUrl: WebIM.config.apiURL, // apiUrl: WebIM.config.apiURL,
user: imName, // user: imName,
pwd: imPassword, // pwd: imPassword,
appKey: WebIM.config.appkey // appKey: WebIM.config.appkey
}); // });
return; // return;
} // }
getData(apis.authme, 'get', { getData(apis.userInfo, 'get', {
"token": token, "token": token,
}, function(res) { }, function(res) {
if (res.errcode == 0) { if (res.errcode == 0) {
wx.setStorageSync('user_id', res.data.user_id + ''); wx.setStorageSync('user_id', res.data.user_id + '');
wx.setStorageSync('avatar', res.data.avatar); wx.setStorageSync('avatar', res.data.avatar || res.data.wechat_oauth.oauth_head);
wx.setStorageSync('company_name', res.data.company_name); wx.setStorageSync('company_name', res.data.company_name || res.data.wechat_oauth.oauth_nickname);
wx.setStorageSync("myUsername", res.data.im_username); wx.setStorageSync("myUsername", res.data.im_username);
wx.setStorageSync("myPassword", res.data.im_password); wx.setStorageSync("myPassword", res.data.im_password);
conn.open({ conn.open({
......
...@@ -3,7 +3,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => { ...@@ -3,7 +3,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
wx.showNavigationBarLoading(); wx.showNavigationBarLoading();
var token, header; var token, header, tokenInvalid;
//获取token //获取token
token = wx.getStorageSync('access_token'); token = wx.getStorageSync('access_token');
...@@ -51,21 +51,35 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => { ...@@ -51,21 +51,35 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
//处理token失效的情况 //处理token失效的情况
if (res.data.hasOwnProperty('data')) { if (res.data.hasOwnProperty('data')) {
if (res.data.errcode == 501 || res.data.errcode == 501) { if (res.data.errcode == 501 || res.data.errcode == 501) {
wx.redirectTo({ tokenInvalid = true
url: '/pages/person/login/index' // wx.redirectTo({
}); // url: '/pages/person/login/index'
// });
} else { } else {
typeof callBack == "function" && callBack(res.data, ""); typeof callBack == "function" && callBack(res.data, "");
} }
} else { } else {
if (res.data.errcode == 501 || res.data.errcode == 501) { if (res.data.errcode == 501 || res.data.errcode == 501) {
wx.redirectTo({ tokenInvalid = true
url: '/pages/person/login/index' // wx.redirectTo({
}); // url: '/pages/person/login/index'
// });
} else { } else {
typeof callBack == "function" && callBack(res.data, ""); 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) => { 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